Blame SOURCES/0031-don-t-remove-ext-ipv4-addresses-rh1459813.patch

fc9aca
From 59aa2a26b4a712131b38e155d3c1d70a74183636 Mon Sep 17 00:00:00 2001
fc9aca
From: Beniamino Galvani <bgalvani@redhat.com>
fc9aca
Date: Tue, 13 Jun 2017 14:44:22 +0200
fc9aca
Subject: [PATCH] core: sort addresses in captured IPv4 configuration
fc9aca
fc9aca
When IPv4 addresses are synchronized to platform, the order of IPv4
fc9aca
addresses matters because the first address is considered the primary
fc9aca
one. Thus, nm_ip4_config_capture() should put the primary address as
fc9aca
first, otherwise during synchronization addresses will be removed and
fc9aca
added back with a different primary/secondary role.
fc9aca
fc9aca
https://bugzilla.redhat.com/show_bug.cgi?id=1459813
fc9aca
(cherry picked from commit b6fa87a4c07c968614d123750be47a74de62f04d)
fc9aca
(cherry picked from commit 9819ffe7d42f08bb082ae2d9e125a7dd3bfe6420)
fc9aca
---
fc9aca
 src/nm-ip4-config.c | 12 ++++++++++++
fc9aca
 1 file changed, 12 insertions(+)
fc9aca
fc9aca
diff --git a/src/nm-ip4-config.c b/src/nm-ip4-config.c
fc9aca
index 20532e8..ae6af9c 100644
fc9aca
--- a/src/nm-ip4-config.c
fc9aca
+++ b/src/nm-ip4-config.c
fc9aca
@@ -248,6 +248,16 @@ notify_addresses (NMIP4Config *self)
fc9aca
 	_notify (self, PROP_ADDRESSES);
fc9aca
 }
fc9aca
 
fc9aca
+static gint
fc9aca
+sort_captured_addresses (gconstpointer a, gconstpointer b)
fc9aca
+{
fc9aca
+	const NMPlatformIP4Address *addr_a = a, *addr_b = b;
fc9aca
+
fc9aca
+	/* Primary addresses first */
fc9aca
+	return NM_FLAGS_HAS (addr_a->n_ifa_flags, IFA_F_SECONDARY) -
fc9aca
+	       NM_FLAGS_HAS (addr_b->n_ifa_flags, IFA_F_SECONDARY);
fc9aca
+}
fc9aca
+
fc9aca
 NMIP4Config *
fc9aca
 nm_ip4_config_capture (NMPlatform *platform, int ifindex, gboolean capture_resolv_conf)
fc9aca
 {
fc9aca
@@ -269,6 +279,8 @@ nm_ip4_config_capture (NMPlatform *platform, int ifindex, gboolean capture_resol
fc9aca
 	g_array_unref (priv->routes);
fc9aca
 
fc9aca
 	priv->addresses = nm_platform_ip4_address_get_all (platform, ifindex);
fc9aca
+	g_array_sort (priv->addresses, sort_captured_addresses);
fc9aca
+
fc9aca
 	priv->routes = nm_platform_ip4_route_get_all (platform, ifindex, NM_PLATFORM_GET_ROUTE_FLAGS_WITH_DEFAULT | NM_PLATFORM_GET_ROUTE_FLAGS_WITH_NON_DEFAULT);
fc9aca
 
fc9aca
 	/* Extract gateway from default route */
fc9aca
-- 
fc9aca
2.9.3
fc9aca