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: 2f68a50041
This commit is contained in:
Beniamino Galvani 2017-02-08 14:47:14 +01:00
parent 0a0893280b
commit a347962831

View file

@ -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;
}