diff options
author | Michal Kubeček <mkubecek@suse.cz> | 2015-05-18 14:54:00 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-05-20 12:02:26 -0400 |
commit | 27596472473a02cfef2908a6bcda7e55264ba6b7 (patch) | |
tree | 2151136cf03e0dadcff04de695f10f91633acf4f /net/ipv6/route.c | |
parent | 35f1b4e96b9258a3668872b1139c51e5a23eb876 (diff) |
ipv6: fix ECMP route replacement
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: 51ebd3181572 ("ipv6: add support of equal cost multipath (ECMP)")
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/route.c')
-rw-r--r-- | net/ipv6/route.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 3821a3517478..c73ae5039e46 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c | |||
@@ -2541,11 +2541,14 @@ beginning: | |||
2541 | } | 2541 | } |
2542 | } | 2542 | } |
2543 | /* Because each route is added like a single route we remove | 2543 | /* Because each route is added like a single route we remove |
2544 | * this flag after the first nexthop (if there is a collision, | 2544 | * these flags after the first nexthop: if there is a collision, |
2545 | * we have already fail to add the first nexthop: | 2545 | * we have already failed to add the first nexthop: |
2546 | * fib6_add_rt2node() has reject it). | 2546 | * fib6_add_rt2node() has rejected it; when replacing, old |
2547 | * nexthops have been replaced by first new, the rest should | ||
2548 | * be added to it. | ||
2547 | */ | 2549 | */ |
2548 | cfg->fc_nlinfo.nlh->nlmsg_flags &= ~NLM_F_EXCL; | 2550 | cfg->fc_nlinfo.nlh->nlmsg_flags &= ~(NLM_F_EXCL | |
2551 | NLM_F_REPLACE); | ||
2549 | rtnh = rtnh_next(rtnh, &remaining); | 2552 | rtnh = rtnh_next(rtnh, &remaining); |
2550 | } | 2553 | } |
2551 | 2554 | ||