NetworkManager r3597 - in trunk: . src src/backends
- From: dcbw svn gnome org
- To: svn-commits-list gnome org
- Subject: NetworkManager r3597 - in trunk: . src src/backends
- Date: Fri, 25 Apr 2008 20:30:05 +0100 (BST)
Author: dcbw
Date: Fri Apr 25 19:30:05 2008
New Revision: 3597
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=3597&view=rev
Log:
2008-04-25 Dan Williams <dcbw redhat com>
Patch from Benoit Boissinot <bboissin+networkmanager gmail com>
* src/NetworkManagerSystem.c
- (nm_system_device_replace_default_ip4_route): new function; a libnl
implementation of nm_system_device_replace_default_route()
* src/NetworkManagerPolicy.c
- (update_default_route): use nm_system_device_replace_default_ip4_route()
* src/backends/NetworkManagerArch.c
src/backends/NetworkManagerDebian.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerGeneric.c
src/backends/NetworkManagerGeneric.h
src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerMandriva.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerSuSE.c
- (nm_system_device_replace_default_route): remove
Modified:
trunk/ChangeLog
trunk/src/NetworkManagerPolicy.c
trunk/src/NetworkManagerSystem.c
trunk/src/NetworkManagerSystem.h
trunk/src/backends/NetworkManagerArch.c
trunk/src/backends/NetworkManagerDebian.c
trunk/src/backends/NetworkManagerFrugalware.c
trunk/src/backends/NetworkManagerGeneric.c
trunk/src/backends/NetworkManagerGeneric.h
trunk/src/backends/NetworkManagerGentoo.c
trunk/src/backends/NetworkManagerMandriva.c
trunk/src/backends/NetworkManagerPaldo.c
trunk/src/backends/NetworkManagerRedHat.c
trunk/src/backends/NetworkManagerSlackware.c
trunk/src/backends/NetworkManagerSuSE.c
Modified: trunk/src/NetworkManagerPolicy.c
==============================================================================
--- trunk/src/NetworkManagerPolicy.c (original)
+++ trunk/src/NetworkManagerPolicy.c Fri Apr 25 19:30:05 2008
@@ -83,12 +83,12 @@
a serial device with ppp interface, so route all the traffic to it. */
ip_iface = nm_device_get_ip_iface (new);
if (strcmp (ip_iface, nm_device_get_iface (new))) {
- nm_system_device_replace_default_route (ip_iface, 0, 0);
+ nm_system_device_replace_default_ip4_route (ip_iface, 0, 0);
} else {
NMIP4Config *config;
config = nm_device_get_ip4_config (new);
- nm_system_device_replace_default_route (ip_iface, nm_ip4_config_get_gateway (config),
+ nm_system_device_replace_default_ip4_route (ip_iface, nm_ip4_config_get_gateway (config),
nm_ip4_config_get_mss (config));
}
}
Modified: trunk/src/NetworkManagerSystem.c
==============================================================================
--- trunk/src/NetworkManagerSystem.c (original)
+++ trunk/src/NetworkManagerSystem.c Fri Apr 25 19:30:05 2008
@@ -347,7 +347,7 @@
nm_system_device_flush_ip4_routes_with_iface (iface);
if (g_slist_length (routes) == 0) {
- nm_system_device_replace_default_route (iface, 0, 0);
+ nm_system_device_replace_default_ip4_route (iface, 0, 0);
} else {
GSList *iter;
@@ -496,8 +496,61 @@
nl_addr_put (dst);
err = rtnl_route_add (nlh, route, 0);
- if (err)
- nm_warning ("rtnl_route_add() returned error %s (%d)", strerror (err), err);
+ if (err) {
+ nm_warning ("rtnl_route_add() returned error %s (%d)\n%s",
+ strerror (err), err, nl_geterror());
+ }
+
+out:
+ rtnl_route_put (route);
+}
+
+/*
+ * nm_system_replace_default_ip4_route
+ *
+ * Replace default IPv4 route with one via the current device
+ *
+ */
+void
+nm_system_device_replace_default_ip4_route (const char *iface, guint32 gw, guint32 mss)
+{
+ struct rtnl_route * route;
+ struct nl_handle * nlh;
+ struct nl_addr * gw_addr;
+ int iface_idx, err;
+
+ nlh = nm_netlink_get_default_handle ();
+ g_return_if_fail (nlh != NULL);
+
+ route = rtnl_route_alloc();
+ g_return_if_fail (route != NULL);
+
+ rtnl_route_set_scope (route, RT_SCOPE_UNIVERSE);
+
+ iface_idx = nm_netlink_iface_to_index (iface);
+ if (iface_idx < 0)
+ goto out;
+ rtnl_route_set_oif (route, iface_idx);
+
+ /* Build up gateway address; a gateway of 0 (used in e.g. PPP links) means
+ * that all packets should be sent to the gateway since it's a point-to-point
+ * link and has no broadcast segment really.
+ */
+ if (!(gw_addr = nl_addr_build (AF_INET, &gw, sizeof (gw))))
+ goto out;
+ 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)
+ goto out;
+ }
+
+ err = rtnl_route_add (nlh, route, NLM_F_REPLACE);
+ if (err) {
+ nm_warning ("rtnl_route_add() returned error %s (%d)\n%s",
+ strerror (err), err, nl_geterror());
+ }
out:
rtnl_route_put (route);
Modified: trunk/src/NetworkManagerSystem.h
==============================================================================
--- trunk/src/NetworkManagerSystem.h (original)
+++ trunk/src/NetworkManagerSystem.h Fri Apr 25 19:30:05 2008
@@ -38,7 +38,7 @@
void nm_system_device_flush_ip4_routes (NMDevice *dev);
void nm_system_device_flush_ip4_routes_with_iface (const char *iface);
-void nm_system_device_replace_default_route (const char *iface,
+void nm_system_device_replace_default_ip4_route (const char *iface,
guint32 gw,
guint32 mss);
Modified: trunk/src/backends/NetworkManagerArch.c
==============================================================================
--- trunk/src/backends/NetworkManagerArch.c (original)
+++ trunk/src/backends/NetworkManagerArch.c Fri Apr 25 19:30:05 2008
@@ -68,20 +68,6 @@
}
/*
- * nm_system_device_replace_default_route
- *
- * Add default route to the given device
- *
- */
-void
-nm_system_device_replace_default_route (const char *iface,
- guint32 gw,
- guint32 mss)
-{
- nm_generic_device_replace_default_route (iface, gw, mss);
-}
-
-/*
* nm_system_device_flush_ip4_addresses
*
* Flush all network addresses associated with a network device
Modified: trunk/src/backends/NetworkManagerDebian.c
==============================================================================
--- trunk/src/backends/NetworkManagerDebian.c (original)
+++ trunk/src/backends/NetworkManagerDebian.c Fri Apr 25 19:30:05 2008
@@ -57,20 +57,6 @@
}
/*
- * nm_system_device_replace_default_route
- *
- * Add default route to the given device
- *
- */
-void
-nm_system_device_replace_default_route (const char *iface,
- guint32 gw,
- guint32 mss)
-{
- nm_generic_device_replace_default_route (iface, gw, mss);
-}
-
-/*
* nm_system_device_flush_ip4_addresses
*
* Flush all network addresses associated with a network device
Modified: trunk/src/backends/NetworkManagerFrugalware.c
==============================================================================
--- trunk/src/backends/NetworkManagerFrugalware.c (original)
+++ trunk/src/backends/NetworkManagerFrugalware.c Fri Apr 25 19:30:05 2008
@@ -179,21 +179,6 @@
}
/*
- * nm_system_device_replace_default_route
- *
- * Add default route to the given device
- *
- */
-void
-nm_system_device_replace_default_route (const char *iface,
- guint32 gw,
- guint32 mss)
-{
- nm_generic_device_replace_default_route (iface, gw, mss);
-}
-
-
-/*
* nm_system_flush_loopback_routes
*
* Flush all routes associated with the loopback device, because it
Modified: trunk/src/backends/NetworkManagerGeneric.c
==============================================================================
--- trunk/src/backends/NetworkManagerGeneric.c (original)
+++ trunk/src/backends/NetworkManagerGeneric.c Fri Apr 25 19:30:05 2008
@@ -52,39 +52,6 @@
}
/*
- * nm_generic_replace_default_route
- *
- * Replace default route with one via the current device
- *
- */
-void
-nm_generic_device_replace_default_route (const char *iface, guint32 gw, guint32 mss)
-{
- char *buf, *addr_str = NULL, *mss_str = NULL;
-
- g_return_if_fail (iface != NULL);
-
- if (gw > 0) {
- struct in_addr addr = { .s_addr = gw };
- char buf2[INET_ADDRSTRLEN + 1];
-
- memset (buf2, 0, sizeof (buf2));
- inet_ntop (AF_INET, &addr, buf2, INET_ADDRSTRLEN);
- addr_str = g_strdup_printf ("via %s", buf2);
- }
-
- if (mss > 0)
- mss_str = g_strdup_printf ("advmss %d", mss);
-
- buf = g_strdup_printf (IP_BINARY_PATH" route replace default %s %s dev %s",
- addr_str ? addr_str : "",
- mss_str ? mss_str : "",
- iface);
- nm_spawn_process (buf);
- g_free (buf);
-}
-
-/*
* nm_generic_device_flush_ip4_addresses
*
* Flush all network addresses associated with a network device
Modified: trunk/src/backends/NetworkManagerGeneric.h
==============================================================================
--- trunk/src/backends/NetworkManagerGeneric.h (original)
+++ trunk/src/backends/NetworkManagerGeneric.h Fri Apr 25 19:30:05 2008
@@ -39,8 +39,6 @@
void nm_generic_device_flush_ip4_routes (NMDevice *dev);
void nm_generic_device_flush_ip4_routes_with_iface (const char *iface);
-void nm_generic_device_replace_default_route (const char *iface, guint32 gw, guint32 mss);
-
void nm_generic_device_flush_ip4_addresses (NMDevice *dev);
void nm_generic_device_flush_ip4_addresses_with_iface (const char *iface);
Modified: trunk/src/backends/NetworkManagerGentoo.c
==============================================================================
--- trunk/src/backends/NetworkManagerGentoo.c (original)
+++ trunk/src/backends/NetworkManagerGentoo.c Fri Apr 25 19:30:05 2008
@@ -220,20 +220,6 @@
}
/*
- * nm_system_device_replace_default_route
- *
- * Add default route to the given device
- *
- */
-void
-nm_system_device_replace_default_route (const char *iface,
- guint32 gw,
- guint32 mss)
-{
- nm_generic_device_replace_default_route (iface, gw, mss);
-}
-
-/*
* nm_system_activate_nis
*
* set up the nis domain and write a yp.conf
Modified: trunk/src/backends/NetworkManagerMandriva.c
==============================================================================
--- trunk/src/backends/NetworkManagerMandriva.c (original)
+++ trunk/src/backends/NetworkManagerMandriva.c Fri Apr 25 19:30:05 2008
@@ -76,21 +76,6 @@
nm_generic_device_flush_ip4_routes_with_iface (iface);
}
-
-/*
- * nm_system_device_replace_default_route
- *
- * Add default route to the given device
- *
- */
-void
-nm_system_device_replace_default_route (const char *iface,
- guint32 gw,
- guint32 mss)
-{
- nm_generic_device_replace_default_route (iface, gw, mss);
-}
-
/*
* nm_system_device_has_active_routes
*
Modified: trunk/src/backends/NetworkManagerPaldo.c
==============================================================================
--- trunk/src/backends/NetworkManagerPaldo.c (original)
+++ trunk/src/backends/NetworkManagerPaldo.c Fri Apr 25 19:30:05 2008
@@ -77,21 +77,6 @@
nm_generic_device_flush_ip4_routes_with_iface (iface);
}
-
-/*
- * nm_system_device_replace_default_route
- *
- * Add default route to the given device
- *
- */
-void
-nm_system_device_replace_default_route (const char *iface,
- guint32 gw,
- guint32 mss)
-{
- nm_generic_device_replace_default_route (iface, gw, mss);
-}
-
/*
* nm_system_device_has_active_routes
*
Modified: trunk/src/backends/NetworkManagerRedHat.c
==============================================================================
--- trunk/src/backends/NetworkManagerRedHat.c (original)
+++ trunk/src/backends/NetworkManagerRedHat.c Fri Apr 25 19:30:05 2008
@@ -74,21 +74,6 @@
nm_generic_device_flush_ip4_routes_with_iface (iface);
}
-
-/*
- * nm_system_device_replace_default_route
- *
- * Add default route to the given device
- *
- */
-void
-nm_system_device_replace_default_route (const char *iface,
- guint32 gw,
- guint32 mss)
-{
- nm_generic_device_replace_default_route (iface, gw, mss);
-}
-
/*
* nm_system_device_has_active_routes
*
Modified: trunk/src/backends/NetworkManagerSlackware.c
==============================================================================
--- trunk/src/backends/NetworkManagerSlackware.c (original)
+++ trunk/src/backends/NetworkManagerSlackware.c Fri Apr 25 19:30:05 2008
@@ -158,22 +158,6 @@
{
}
-
-/*
- * nm_system_device_replace_default_route
- *
- * Add default route to the given device
- *
- */
-void
-nm_system_device_replace_default_route (const char *iface,
- guint32 gw,
- guint32 mss)
-{
- nm_generic_device_replace_default_route (iface, gw, mss);
-}
-
-
/*
* nm_system_flush_loopback_routes
*
Modified: trunk/src/backends/NetworkManagerSuSE.c
==============================================================================
--- trunk/src/backends/NetworkManagerSuSE.c (original)
+++ trunk/src/backends/NetworkManagerSuSE.c Fri Apr 25 19:30:05 2008
@@ -83,21 +83,6 @@
nm_generic_device_flush_ip4_routes_with_iface (iface);
}
-
-/*
- * nm_system_device_replace_default_route
- *
- * Add default route to the given device
- *
- */
-void
-nm_system_device_replace_default_route (const char *iface,
- guint32 gw,
- guint32 mss)
-{
- nm_generic_device_replace_default_route (iface, gw, mss);
-}
-
/*
* nm_system_device_has_active_routes
*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]