Blame SOURCES/rh1031763-0003-core-don-t-leave-additional-default-routes-in-captur.patch

2186fd
From 05a82a948877c62fb624c3b681fa95c9f26c26e4 Mon Sep 17 00:00:00 2001
2186fd
From: Dan Williams <dcbw@redhat.com>
2186fd
Date: Tue, 19 Nov 2013 22:51:29 -0600
2186fd
Subject: [PATCH 3/3] core: don't leave additional default routes in captured
2186fd
 IP config
2186fd
2186fd
There can be multiple defualt routes for an interface with different
2186fd
metrics.  Only accept the first one, otherwise the rest get left in
2186fd
the IPv4 config and could be applied at random times.
2186fd
---
2186fd
 src/nm-ip4-config.c | 4 ++--
2186fd
 src/nm-ip6-config.c | 4 ++--
2186fd
 2 files changed, 4 insertions(+), 4 deletions(-)
2186fd
2186fd
diff --git a/src/nm-ip4-config.c b/src/nm-ip4-config.c
2186fd
index e27a557..aa4bfd5 100644
2186fd
--- a/src/nm-ip4-config.c
2186fd
+++ b/src/nm-ip4-config.c
2186fd
@@ -147,21 +147,21 @@ nm_ip4_config_capture (int ifindex, gboolean capture_resolv_conf)
2186fd
 	priv->routes = nm_platform_ip4_route_get_all (ifindex, TRUE);
2186fd
 
2186fd
 	/* Extract gateway from default route */
2186fd
 	for (i = 0; i < priv->routes->len; i++) {
2186fd
 		const NMPlatformIP4Route *route = &g_array_index (priv->routes, NMPlatformIP4Route, i);
2186fd
 
2186fd
 		if (route->network == 0) {
2186fd
-			if (priv->gateway != route->gateway) {
2186fd
+			if (!gateway_changed && (priv->gateway != route->gateway)) {
2186fd
 				priv->gateway = route->gateway;
2186fd
 				gateway_changed = TRUE;
2186fd
 			}
2186fd
 			/* Remove the default route from the list */
2186fd
 			g_array_remove_index (priv->routes, i);
2186fd
-			break;
2186fd
+			i--;
2186fd
 		}
2186fd
 	}
2186fd
 
2186fd
 	/* If the interface has the default route, and has IPv4 addresses, capture
2186fd
 	 * nameservers from /etc/resolv.conf.
2186fd
 	 */
2186fd
 	if (priv->addresses->len && priv->gateway && capture_resolv_conf) {
2186fd
diff --git a/src/nm-ip6-config.c b/src/nm-ip6-config.c
2186fd
index 726e658..08ac43a 100644
2186fd
--- a/src/nm-ip6-config.c
2186fd
+++ b/src/nm-ip6-config.c
2186fd
@@ -147,21 +147,21 @@ nm_ip6_config_capture (int ifindex, gboolean capture_resolv_conf)
2186fd
 	priv->routes = nm_platform_ip6_route_get_all (ifindex, TRUE);
2186fd
 
2186fd
 	/* Extract gateway from default route */
2186fd
 	for (i = 0; i < priv->routes->len; i++) {
2186fd
 		const NMPlatformIP6Route *route = &g_array_index (priv->routes, NMPlatformIP6Route, i);
2186fd
 
2186fd
 		if (IN6_IS_ADDR_UNSPECIFIED (&route->network)) {
2186fd
-			if (!IN6_ARE_ADDR_EQUAL (&priv->gateway, &route->gateway)) {
2186fd
+			if (!gateway_changed && !IN6_ARE_ADDR_EQUAL (&priv->gateway, &route->gateway)) {
2186fd
 				priv->gateway = route->gateway;
2186fd
 				gateway_changed = TRUE;
2186fd
 			}
2186fd
 			/* Remove the default route from the list */
2186fd
 			g_array_remove_index (priv->routes, i);
2186fd
-			break;
2186fd
+			i--;
2186fd
 		}
2186fd
 	}
2186fd
 
2186fd
 	/* If the interface has the default route, and has IPv4 addresses, capture
2186fd
 	 * nameservers from /etc/resolv.conf.
2186fd
 	 */
2186fd
 	if (priv->addresses->len && !IN6_IS_ADDR_UNSPECIFIED (&priv->gateway) && capture_resolv_conf) {
2186fd
-- 
2186fd
1.8.3.1
2186fd