• Ido Schimmel's avatar
    ipv4: nexthop: Correctly update nexthop group when replacing a nexthop · 885a3b15
    Ido Schimmel authored
    Each nexthop group contains an indication if it has IPv4 nexthops
    ('has_v4'). Its purpose is to prevent IPv6 routes from using groups with
    IPv4 nexthops.
    
    However, the indication is not updated when a nexthop is replaced. This
    results in the kernel wrongly rejecting IPv6 routes from pointing to
    groups that only contain IPv6 nexthops. Example:
    
    # ip nexthop replace id 1 via 192.0.2.2 dev dummy10
    # ip nexthop replace id 10 group 1
    # ip nexthop replace id 1 via 2001:db8:1::2 dev dummy10
    # ip route replace 2001:db8:10::/64 nhid 10
    Error: IPv6 routes can not use an IPv4 nexthop.
    
    Solve this by iterating over all the nexthop groups that the replaced
    nexthop is a member of and potentially update their IPv4 indication
    according to the new set of member nexthops.
    
    Avoid wasting cycles by only performing the update in case an IPv4
    nexthop is replaced by an IPv6 nexthop.
    Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
    Reviewed-by: default avatarDavid Ahern <dsahern@gmail.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    885a3b15
nexthop.c 44.8 KB