iproute2: ip addr flush fail on many secondary addresses
Subsystems (2)
Hi!
ip addr flush dev eth0
Returns:
Failed to send flush request: Cannot assign requested address when I have many (> 62) secondary addresses.
Deletion is handled by ipaddr_flush sending two filters (secondary/primary) to rtnl_dump_filter_l.
With a lot of addresses rtnl_dump_filter_l calls recvmsg more than once. However, all filters are traversed for each recv call, so the primary address will be deleted before all the secondary addresses have been removed.
Running with stat the primary address is not the last. ip -stat -stat addr flush dev eth0
Flushing secondary/primary addresses has been addressed before:b49240ec7eab91418d2f090536bf8cd2205988d6 3bc1c4f29777171b484d36abf673667e3729202b
As mentioned there, trying to remove the remaining secondary addresses will cause an error as they were auto removed when deleting the primary.
Workaround:
sysctl -w net.ipv4.conf.all.promote_secondaries=1
Regards, vopatek