From a347962831ed127338a13b7a0939302d42bcfe60 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Wed, 8 Feb 2017 14:47:14 +0100 Subject: [PATCH] platform: fix detection of primary/secondary addresses ip4_addr_subnets_is_secondary() should fill the list of addresses in the same subnet also when returning FALSE, because nm_platform_ip4_address_sync() uses it. Fixes: 2f68a5004153cea9878999bf3a442ecda263e5f7 --- src/platform/nm-platform.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index 8b22ced2d8..a9014b36b9 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -2864,6 +2864,18 @@ ip4_addr_subnets_build_index (const GArray *addresses, gboolean consider_flags) return subnets; } +/** + * ip4_addr_subnets_is_secondary: + * @address: an address + * @subnets: the hash table mapping subnets to addresses + * @addresses: array of addresses in the hash table + * @out_addr_list: array of addresses belonging to the same subnet + * + * Checks whether @address is secondary and returns in @out_addr_list the list of addresses + * belonging to the same subnet, if it contains other elements. + * + * Returns: %TRUE if the address is secondary, %FALSE otherwise + */ static gboolean ip4_addr_subnets_is_secondary (const NMPlatformIP4Address *address, GHashTable *subnets, const GArray *addresses, GPtrArray **out_addr_list) { @@ -2876,13 +2888,13 @@ ip4_addr_subnets_is_secondary (const NMPlatformIP4Address *address, GHashTable * nm_assert (p); if (!_ptr_inside_ip4_addr_array (addresses, p)) { addr_list = p; - if (addr_list->pdata[0] != address) { - NM_SET_OUT (out_addr_list, addr_list); + NM_SET_OUT (out_addr_list, addr_list); + if (addr_list->pdata[0] != address) return TRUE; - } - } else + } else { nm_assert ((gconstpointer) address == p); - NM_SET_OUT (out_addr_list, NULL); + NM_SET_OUT (out_addr_list, NULL); + } return FALSE; }