From 3ac7f4755c532bb8f54aae33aee9f5a75ab2903b Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Mon, 28 Jul 2008 14:38:34 +0000 Subject: [PATCH] 2008-07-28 Dan Williams Patch from Fabrice Bellet * src/NetworkManagerSystem.c - (route_in_same_subnet): mask addresses and compare them so that the function actually does what it says it's going to do (rh #456685) git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3868 4912f4e0-d625-0410-9fb7-b9a5a253dbdc --- ChangeLog | 8 ++++++++ src/NetworkManagerSystem.c | 13 +++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 67f88d14c0..85d41b54da 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-07-28 Dan Williams + + Patch from Fabrice Bellet + + * src/NetworkManagerSystem.c + - (route_in_same_subnet): mask addresses and compare them so that the + function actually does what it says it's going to do (rh #456685) + 2008-07-27 Dan Williams * libnm-util/nm-setting-ip6-config.c diff --git a/src/NetworkManagerSystem.c b/src/NetworkManagerSystem.c index 3763b84988..8aa885c0f2 100644 --- a/src/NetworkManagerSystem.c +++ b/src/NetworkManagerSystem.c @@ -62,7 +62,7 @@ #include static gboolean -route_in_same_subnet (NMIP4Config *config, guint32 prefix) +route_in_same_subnet (NMIP4Config *config, guint32 dest, guint32 prefix) { int num; int i; @@ -72,8 +72,13 @@ route_in_same_subnet (NMIP4Config *config, guint32 prefix) const NMSettingIP4Address *addr; addr = nm_ip4_config_get_address (config, i); - if (prefix == addr->prefix) - return TRUE; + if (prefix == addr->prefix) { + guint32 masked_addr = addr->address >> (32 - addr->prefix); + guint32 masked_dest = dest >> (32 - prefix); + + if (masked_addr == masked_dest) + return TRUE; + } } return FALSE; @@ -110,7 +115,7 @@ nm_system_device_set_ip4_route (const char *iface, struct nl_addr *gw_addr = NULL; int err, iface_idx; - if (iface_config && route_in_same_subnet (iface_config, ip4_prefix)) + if (iface_config && route_in_same_subnet (iface_config, ip4_dest, ip4_prefix)) return; nlh = nm_netlink_get_default_handle ();