platform: fix the order of addition of primary and secondary IPv4 addresses

System Internals / NetworkManager - Beniamino Galvani [redhat.com] - 5 December 2016 03:56 UTC

nm_platform_ip4_address_sync() tries to apply the new configuration with the minimum effort and doesn't delete addresses if they are already present on the interface. This can break the ordering, as an existing address would be promoted by kernel to primary, even if it was last in our configuration.

Add some logic to ensure the correct order of addresses is always enforced. This fixes situations like:

# nmcli connection add type ethernet ifname eth0 con-name t \ ipv4.method manual \ ipv4.addresses "1.1.1.1/24,1.1.1.2/24,1.1.1.5/24" # nmcli connection up t

=> addresses are applied in the right order: inet 1.1.1.1/24 brd 1.1.1.255 scope global eth0 inet 1.1.1.2/24 brd 1.1.1.255 scope global secondary eth0 inet 1.1.1.5/24 brd 1.1.1.255 scope global secondary eth0

# nmcli connection mod t ipv4.addresses "1.1.1.5/24,1.1.1.2/24,1.1.1.1/24" # nmcli device reapply eth0

=> order is wrong: inet 1.1.1.2/24 brd 1.1.1.255 scope global eth0 inet 1.1.1.5/24 brd 1.1.1.255 scope global secondary eth0 inet 1.1.1.1/24 brd 1.1.1.255 scope global secondary eth0

2f68a50 platform: fix the order of addition of primary and secondary IPv4 addresses
src/platform/nm-platform.c | 161 +++++++++++++++++++++++++++++++++++++++++---
1 file changed, 151 insertions(+), 10 deletions(-)

Upstream: cgit.freedesktop.org


  • Share