• Sabrina Dubroca's avatar
    ipv6: dad: don't remove dynamic addresses if link is down · 5f1b07b4
    Sabrina Dubroca authored
    [ Upstream commit ec8add2a ]
    
    Currently, when the link for $DEV is down, this command succeeds but the
    address is removed immediately by DAD (1):
    
        ip addr add 1111::12/64 dev $DEV valid_lft 3600 preferred_lft 1800
    
    In the same situation, this will succeed and not remove the address (2):
    
        ip addr add 1111::12/64 dev $DEV
        ip addr change 1111::12/64 dev $DEV valid_lft 3600 preferred_lft 1800
    
    The comment in addrconf_dad_begin() when !IF_READY makes it look like
    this is the intended behavior, but doesn't explain why:
    
         * If the device is not ready:
         * - keep it tentative if it is a permanent address.
         * - otherwise, kill it.
    
    We clearly cannot prevent userspace from doing (2), but we can make (1)
    work consistently with (2).
    
    addrconf_dad_stop() is only called in two cases: if DAD failed, or to
    skip DAD when the link is down. In that second case, the fix is to avoid
    deleting the address, like we already do for permanent addresses.
    
    Fixes: 3c21edbd ("[IPV6]: Defer IPv6 device initialization until the link becomes ready.")
    Signed-off-by: default avatarSabrina Dubroca <sd@queasysnail.net>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    Signed-off-by: default avatarSasha Levin <alexander.levin@verizon.com>
    5f1b07b4
addrconf.c 141 KB