Skip to content
  • Beniamino Galvani's avatar
    platform: fix the order of addition of primary and secondary IPv4 addresses · 2f68a500
    Beniamino Galvani authored
    
    
    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
    
    Co-Authored-By: default avatarThomas Haller <thaller@redhat.com>
    2f68a500