[patch] check for a gateway of zero.



Hi Ho!

"nm_system_device_set_ip4_route_with_iface()" will fail if "ip4_gateway"
is zero.  Zero is not a legal gateway and the ioctl will return EINVAL.

The problem is, the zeroconf IP stuff (and possibly other places) set
the gateway to zero to mean "no gateway".  But
"nm_system_device_set_from_ip4_config()" and other places sets the
gateway to the value in NMIP4Config.

Attached patch checks for and simply returns if "ip4_gateway" is zero.
This is fine--indeed, the expecting behavior.  We just need to make sure
we flush the routes first (we do).

Without this, autoip causes an error on assignment.

Alternative fixes would check for zero at a different level, but we
might as well do it where it matters.

May I apply?

	Robert Love

 src/NetworkManagerSystem.c |    8 ++++++++
 1 files changed, 8 insertions(+)

diff -u -u -p -r1.20 NetworkManagerSystem.c
--- src/NetworkManagerSystem.c	1 Jul 2005 18:41:17 -0000	1.20
+++ src/NetworkManagerSystem.c	1 Jul 2005 19:36:23 -0000
@@ -732,6 +732,14 @@ static gboolean nm_system_device_set_ip4
 
 	g_return_val_if_fail (iface != NULL, FALSE);
 
+	/*
+	 * Zero is not a legal gateway and the ioctl will fail.  But zero is a
+	 * way of saying "no route" so we just return here.  Hopefully the
+	 * caller flushed the routes, first.
+	 */
+	if (ip4_gateway == 0)
+		return TRUE;
+
 	if ((sk = nm_dev_sock_open (dev, NETWORK_CONTROL, __FUNCTION__, NULL)) == NULL)
 		return FALSE;
 


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