[PATCH] two system eth, chooses one w/o a gateway, makes up gateway



On Wed, Jan 07, 2009 at 09:32:29PM -0500, Chuck Anderson wrote:
> So perhaps we should just NULL out tmp each time before we call 
> get_one_ip4_addr.  I'll work up a patch.

I built and tested tested this patch against 
NetworkManager-0.7.0-1.git20090102.fc10 and it fixes the problem for 
me.

The patch also initializes netmask to zero before calling 
get_one_ip4_addr in that case, even though it isn't strictly necessary 
since there is no other call to get_one_ip4_addr with the netmask 
variable yet.  However, if in the future another call was added, one 
would need to make sure to reinitialize netmask to zero before making 
the call.  It is just safer to never assume and always initialize in 
case someone comes along later and copies/pastes the call.

get_one_ip4_addr is only used within 
system-settings/plugins/ifcfg-rh/reader.c AFAICT, so there should be 
no other lingering instances of this particular bug.
diff -up NetworkManager-0.7.0/system-settings/plugins/ifcfg-rh/reader.c.gwfix NetworkManager-0.7.0/system-settings/plugins/ifcfg-rh/reader.c
--- NetworkManager-0.7.0/system-settings/plugins/ifcfg-rh/reader.c.gwfix	2008-12-15 09:07:03.000000000 -0500
+++ NetworkManager-0.7.0/system-settings/plugins/ifcfg-rh/reader.c	2009-01-07 21:42:52.000000000 -0500
@@ -222,11 +222,13 @@ make_ip4_setting (shvarFile *ifcfg, GErr
 	if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL)) {
 		addr = nm_ip4_address_new ();
 
+		tmp = 0;
 		get_one_ip4_addr (ifcfg, "IPADDR", &tmp, error);
 		if (*error)
 			goto error;
 		nm_ip4_address_set_address (addr, tmp);
 
+		tmp = 0;
 		get_one_ip4_addr (ifcfg, "GATEWAY", &tmp, error);
 		if (*error)
 			goto error;
@@ -236,6 +238,7 @@ make_ip4_setting (shvarFile *ifcfg, GErr
 		if (!nm_ip4_address_get_gateway (addr)) {
 			network_ifcfg = svNewFile (SYSCONFDIR "/sysconfig/network");
 			if (network_ifcfg) {
+				tmp = 0;
 				get_one_ip4_addr (network_ifcfg, "GATEWAY", &tmp, error);
 				svCloseFile (network_ifcfg);
 				if (*error)
@@ -262,6 +265,7 @@ make_ip4_setting (shvarFile *ifcfg, GErr
 
 		/* Fall back to NETMASK if no PREFIX was specified */
 		if (!nm_ip4_address_get_prefix (addr)) {
+			netmask = 0;
 			get_one_ip4_addr (ifcfg, "NETMASK", &netmask, error);
 			if (*error)
 				goto error;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]