NetworkManager r4290 - in trunk: . src
- From: dcbw svn gnome org
- To: svn-commits-list gnome org
- Subject: NetworkManager r4290 - in trunk: . src
- Date: Fri, 14 Nov 2008 20:42:38 +0000 (UTC)
Author: dcbw
Date: Fri Nov 14 20:42:38 2008
New Revision: 4290
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=4290&view=rev
Log:
2008-11-14 Dan Williams <dcbw redhat com>
Handle gateways on different subnets
* src/NetworkManagerSystem.c
- (add_ip4_route_to_gateway): gateway route should be link scope and
a host route
- (replace_default_ip4_route): use a destination address too; gateway
address should be /0; don't leak the gateway route object
Modified:
trunk/ChangeLog
trunk/src/NetworkManagerSystem.c
Modified: trunk/src/NetworkManagerSystem.c
==============================================================================
--- trunk/src/NetworkManagerSystem.c (original)
+++ trunk/src/NetworkManagerSystem.c Fri Nov 14 20:42:38 2008
@@ -525,12 +525,15 @@
if (route == NULL)
return NULL;
+ rtnl_route_set_family (route, AF_INET);
+ rtnl_route_set_table (route, RT_TABLE_MAIN);
rtnl_route_set_oif (route, iface_idx);
- rtnl_route_set_scope (route, RT_SCOPE_UNIVERSE);
+ rtnl_route_set_scope (route, RT_SCOPE_LINK);
gw_addr = nl_addr_build (AF_INET, &gw, sizeof (gw));
if (!gw_addr)
goto error;
+ nl_addr_set_prefixlen (gw_addr, 32);
rtnl_route_set_dst (route, gw_addr);
nl_addr_put (gw_addr);
@@ -542,8 +545,7 @@
/* Add direct route to the gateway */
err = rtnl_route_add (nlh, route, 0);
if (err) {
- nm_warning ("Failed to add IPv4 default route on '%s': (%d) %s",
- iface, err, nl_geterror ());
+ nm_warning ("(%s): failed to add IPv4 route to gateway (%d)", iface, err);
goto error;
}
@@ -559,6 +561,8 @@
{
struct rtnl_route *route = NULL;
struct nl_handle *nlh;
+ struct nl_addr *dst_addr = NULL;
+ guint32 dst = 0;
struct nl_addr *gw_addr = NULL;
int iface_idx, err = -1;
@@ -574,15 +578,28 @@
route = rtnl_route_alloc();
g_return_val_if_fail (route != NULL, -1);
+ rtnl_route_set_family (route, AF_INET);
+ rtnl_route_set_table (route, RT_TABLE_MAIN);
rtnl_route_set_scope (route, RT_SCOPE_UNIVERSE);
rtnl_route_set_oif (route, iface_idx);
+ /* Build up the destination address */
+ dst_addr = nl_addr_build (AF_INET, &dst, sizeof (dst));
+ if (!dst_addr) {
+ err = -1;
+ goto out;
+ }
+ nl_addr_set_prefixlen (dst_addr, 0);
+ rtnl_route_set_dst (route, dst_addr);
+
/* Build up the gateway address */
gw_addr = nl_addr_build (AF_INET, &gw, sizeof (gw));
- if (!gw_addr)
+ if (!gw_addr) {
+ err = -1;
goto out;
+ }
+ nl_addr_set_prefixlen (gw_addr, 0);
rtnl_route_set_gateway (route, gw_addr);
- nl_addr_put (gw_addr);
if (mss > 0) {
if (rtnl_route_set_metric (route, RTAX_ADVMSS, mss) < 0)
@@ -593,6 +610,10 @@
err = rtnl_route_add (nlh, route, NLM_F_REPLACE);
out:
+ if (dst_addr)
+ nl_addr_put (dst_addr);
+ if (gw_addr)
+ nl_addr_put (gw_addr);
rtnl_route_put (route);
return err;
}
@@ -623,8 +644,7 @@
if (err == 0) {
return TRUE;
} else if (err != -ESRCH) {
- nm_warning ("replace_default_ip4_route() returned error %s (%d)",
- strerror (err), err);
+ nm_warning ("(%s): failed to set IPv4 default route (%d)", iface, err);
return FALSE;
}
@@ -637,7 +657,7 @@
err = replace_default_ip4_route (iface, int_gw, mss);
if (err != 0) {
rtnl_route_del (nlh, gw_route, 0);
- nm_warning ("Failed to set IPv4 default route on '%s': %s", iface, nl_geterror ());
+ nm_warning ("(%s): failed to set IPv4 default route (%d)", iface, err);
} else
success = TRUE;
@@ -680,7 +700,7 @@
err = replace_default_ip4_route (iface, gw, mss);
if (err != 0) {
rtnl_route_del (nlh, gw_route, 0);
- nm_warning ("Failed to set IPv4 default route on '%s': %s", iface, nl_geterror ());
+ nm_warning ("Failed to set IPv4 default route on '%s': %d", iface, err);
} else
success = TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]