• Michal Kubeček's avatar
    ipv6: fix ECMP route replacement · 27596472
    Michal Kubeček authored
    When replacing an IPv6 multipath route with "ip route replace", i.e.
    NLM_F_CREATE | NLM_F_REPLACE, fib6_add_rt2node() replaces only first
    matching route without fixing its siblings, resulting in corrupted
    siblings linked list; removing one of the siblings can then end in an
    infinite loop.
    
    IPv6 ECMP implementation is a bit different from IPv4 so that route
    replacement cannot work in exactly the same way. This should be a
    reasonable approximation:
    
    1. If the new route is ECMP-able and there is a matching ECMP-able one
    already, replace it and all its siblings (if any).
    
    2. If the new route is ECMP-able and no matching ECMP-able route exists,
    replace first matching non-ECMP-able (if any) or just add the new one.
    
    3. If the new route is not ECMP-able, replace first matching
    non-ECMP-able route (if any) or add the new route.
    
    We also need to remove the NLM_F_REPLACE flag after replacing old
    route(s) by first nexthop of an ECMP route so that each subsequent
    nexthop does not replace previous one.
    
    Fixes: 51ebd318 ("ipv6: add support of equal cost multipath (ECMP)")
    Signed-off-by: default avatarMichal Kubecek <mkubecek@suse.cz>
    Acked-by: default avatarNicolas Dichtel <nicolas.dichtel@6wind.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    27596472
route.c 79.1 KB