[NetworkManager/f16] Fix IPv6 connectivity problems (rh #785772)

Dan Winship danw at fedoraproject.org
Fri Apr 20 18:05:40 UTC 2012


commit cca1e0a6489c53e988e6a1f32b050477a1c036d9
Author: Dan Winship <danw at gnome.org>
Date:   Thu Apr 19 17:29:21 2012 -0400

    Fix IPv6 connectivity problems (rh #785772)

 NetworkManager.spec        |    7 ++-
 nm-ip6-default-route.patch |  126 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 132 insertions(+), 1 deletions(-)
---
diff --git a/NetworkManager.spec b/NetworkManager.spec
index 459ba0a..aaf5efa 100644
--- a/NetworkManager.spec
+++ b/NetworkManager.spec
@@ -30,6 +30,7 @@ Patch4: nm-polkit-permissive.patch
 Patch5: nm-applet-wifi-dialog-ui-fixes.patch
 Patch6: nss-error.patch
 Patch7: applet-ignore-deprecated.patch
+Patch8: nm-ip6-default-route.patch
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
 Requires(post): chkconfig
@@ -198,6 +199,7 @@ tar -xjf %{SOURCE1}
 %patch5 -p1 -b .applet-wifi-ui
 %patch6 -p1 -b .nss-error
 %patch7 -p1 -b .no-deprecated
+%patch8 -p1 -b .ip6-default-route
 
 %build
 
@@ -464,8 +466,11 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
 %{_libdir}/libnm-gtk.so
 
 %changelog
+* Thu Apr 19 2012 Dan Winship <danw at redhat.com> - 0.9.4-5.git20120403
+- Fix IPv6 connectivity problems (rh #785772)
+
 * Wed Mar 28 2012 Jiří Klimeš <jklimes at redhat.com> - 0.9.4-2.git20120403
--libnm-glib: initialize GError, else NMRemoteSettings crash can occur (rh #809123)
+- libnm-glib: initialize GError, else NMRemoteSettings crash can occur (rh #809123)
 
 * Wed Mar 28 2012 Jiří Klimeš <jklimes at redhat.com> - 0.9.4.0-1.git20120328
 - Update to 0.9.4
diff --git a/nm-ip6-default-route.patch b/nm-ip6-default-route.patch
new file mode 100644
index 0000000..f1bc3bb
--- /dev/null
+++ b/nm-ip6-default-route.patch
@@ -0,0 +1,126 @@
+From 77de91e5a8b1c1993ae65c54b37e0411e78e6fe6 Mon Sep 17 00:00:00 2001
+From: Dan Winship <danw at gnome.org>
+Date: Thu, 19 Apr 2012 14:27:12 -0400
+Subject: [PATCH] core: don't fight with the kernel over the default IPv6
+ route
+
+The kernel wants there to be a default route over every RA-ed IPv6
+interface, and it gets confused and annoyed if we remove that default
+route and replace it with our own (causing it to effectively drop all
+further RAs on the floor, which is particularly bad if some of the
+information in the earlier RA had an expiration time).
+
+So, rather than replacing the kernel's default route(s), just add an
+additional one of our own, with a lower (ie, higher priority) metric.
+
+https://bugzilla.redhat.com/show_bug.cgi?id=785772
+---
+ src/nm-system.c |   57 +++++++++++++++++++++++++++++++++++++++++++++----------
+ 1 file changed, 47 insertions(+), 10 deletions(-)
+
+diff --git a/src/nm-system.c b/src/nm-system.c
+index 91153ec..4cebb13 100644
+--- a/src/nm-system.c
++++ b/src/nm-system.c
+@@ -1023,7 +1023,7 @@ add_ip6_route_to_gateway (int ifindex, const struct in6_addr *gw)
+ }
+ 
+ static int
+-replace_default_ip6_route (int ifindex, const struct in6_addr *gw)
++add_default_ip6_route (int ifindex, const struct in6_addr *gw)
+ {
+ 	struct rtnl_route *route = NULL;
+ 	struct nl_sock *nlh;
+@@ -1037,22 +1037,36 @@ replace_default_ip6_route (int ifindex, const struct in6_addr *gw)
+ 	route = nm_netlink_route_new (ifindex, AF_INET6, 0,
+ 	                              NMNL_PROP_SCOPE, RT_SCOPE_UNIVERSE,
+ 	                              NMNL_PROP_TABLE, RT_TABLE_MAIN,
++	                              NMNL_PROP_PRIO, 1,
+ 	                              NULL);
+ 	g_return_val_if_fail (route != NULL, -ENOMEM);
+ 
+ 	/* Add the new default route */
+-	err = nm_netlink_route6_add (route, &in6addr_any, 0, gw, NLM_F_REPLACE);
+-	if (err == -NLE_EXIST) {
+-		/* FIXME: even though we use NLM_F_REPLACE the kernel won't replace
+-		 * the route if it's the same.  Suppress the pointless error.
+-		 */
++	err = nm_netlink_route6_add (route, &in6addr_any, 0, gw, NLM_F_CREATE);
++	if (err == -NLE_EXIST)
+ 		err = 0;
+-	}
+ 
+ 	rtnl_route_put (route);
+ 	return err;
+ }
+ 
++static struct rtnl_route *
++find_static_default_routes (struct rtnl_route *route,
++                            struct nl_addr *dst,
++                            const char *iface,
++                            gpointer user_data)
++{
++	GList **def_routes = user_data;
++
++	if (   nl_addr_get_prefixlen (dst) == 0
++	    && rtnl_route_get_protocol (route) == RTPROT_STATIC) {
++		rtnl_route_get (route);
++		*def_routes = g_list_prepend (*def_routes, route);
++	}
++
++	return NULL;
++}
++
+ /*
+  * nm_system_replace_default_ip6_route
+  *
+@@ -1062,12 +1076,35 @@ replace_default_ip6_route (int ifindex, const struct in6_addr *gw)
+ gboolean
+ nm_system_replace_default_ip6_route (int ifindex, const struct in6_addr *gw)
+ {
+-	struct rtnl_route *gw_route = NULL;
++	GList *def_routes, *iter;
++	struct rtnl_route *route, *gw_route = NULL;
+ 	gboolean success = FALSE;
+ 	char *iface;
+ 	int err;
+ 
+-	err = replace_default_ip6_route (ifindex, gw);
++	/* We can't just use NLM_F_REPLACE here like in the IPv4 case, because
++	 * the kernel doesn't like it if we replace the default routes it
++	 * creates. (See rh#785772.) So we delete any non-kernel default routes,
++	 * and then add a new default route of our own with a lower metric than
++	 * the kernel ones.
++	 */
++	def_routes = NULL;
++	nm_netlink_foreach_route (ifindex, AF_INET6, RT_SCOPE_UNIVERSE, TRUE,
++	                          find_static_default_routes, &def_routes);
++	for (iter = def_routes; iter; iter = iter->next) {
++		route = iter->data;
++		if (!nm_netlink_route_delete (route)) {
++			iface = nm_netlink_index_to_iface (ifindex);
++			nm_log_err (LOGD_DEVICE | LOGD_IP6,
++			            "(%s): failed to delete existing IPv6 default route",
++			            iface);
++			g_free (iface);
++		}
++		rtnl_route_put (route);
++	}
++	g_list_free (def_routes);
++
++	err = add_default_ip6_route (ifindex, gw);
+ 	if (err == 0)
+ 		return TRUE;
+ 
+@@ -1091,7 +1128,7 @@ nm_system_replace_default_ip6_route (int ifindex, const struct in6_addr *gw)
+ 		goto out;
+ 
+ 	/* Try adding the original route again */
+-	err = replace_default_ip6_route (ifindex, gw);
++	err = add_default_ip6_route (ifindex, gw);
+ 	if (err != 0) {
+ 		nm_netlink_route_delete (gw_route);
+ 		nm_log_err (LOGD_DEVICE | LOGD_IP6,
+-- 
+1.7.9.3
+


More information about the scm-commits mailing list