mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-25 03:40:07 +01:00
core: sort addresses in captured IPv4 configuration
When IPv4 addresses are synchronized to platform, the order of IPv4 addresses matters because the first address is considered the primary one. Thus, nm_ip4_config_capture() should put the primary address as first, otherwise during synchronization addresses will be removed and added back with a different primary/secondary role. https://bugzilla.redhat.com/show_bug.cgi?id=1459813
This commit is contained in:
parent
4ca3002b86
commit
b6fa87a4c0
1 changed files with 12 additions and 0 deletions
|
|
@ -248,6 +248,16 @@ notify_addresses (NMIP4Config *self)
|
|||
_notify (self, PROP_ADDRESSES);
|
||||
}
|
||||
|
||||
static gint
|
||||
sort_captured_addresses (gconstpointer a, gconstpointer b)
|
||||
{
|
||||
const NMPlatformIP4Address *addr_a = a, *addr_b = b;
|
||||
|
||||
/* Primary addresses first */
|
||||
return NM_FLAGS_HAS (addr_a->n_ifa_flags, IFA_F_SECONDARY) -
|
||||
NM_FLAGS_HAS (addr_b->n_ifa_flags, IFA_F_SECONDARY);
|
||||
}
|
||||
|
||||
NMIP4Config *
|
||||
nm_ip4_config_capture (NMPlatform *platform, int ifindex, gboolean capture_resolv_conf)
|
||||
{
|
||||
|
|
@ -269,6 +279,8 @@ nm_ip4_config_capture (NMPlatform *platform, int ifindex, gboolean capture_resol
|
|||
g_array_unref (priv->routes);
|
||||
|
||||
priv->addresses = nm_platform_ip4_address_get_all (platform, ifindex);
|
||||
g_array_sort (priv->addresses, sort_captured_addresses);
|
||||
|
||||
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);
|
||||
|
||||
/* Extract gateway from default route */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue