summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Suryaputra Lin <stephen.suryaputra.lin@gmail.com>2016-11-10 11:16:15 -0500
committerWilly Tarreau <w@1wt.eu>2017-02-10 11:03:55 +0100
commit3816ef445e2b4762c6242b672b5bf72ec2bed7a9 (patch)
treed1cd580c0e6b8e49825ff6cc6436c59c98e79b06
parent4d4c1fc6258af913f0a9a9595f2385e58f9f1d9a (diff)
downloadlinux-stable-3816ef445e2b4762c6242b672b5bf72ec2bed7a9.tar.gz
linux-stable-3816ef445e2b4762c6242b672b5bf72ec2bed7a9.tar.bz2
linux-stable-3816ef445e2b4762c6242b672b5bf72ec2bed7a9.zip
ipv4: use new_gw for redirect neigh lookup
commit 969447f226b451c453ddc83cac6144eaeac6f2e3 upstream. In v2.6, ip_rt_redirect() calls arp_bind_neighbour() which returns 0 and then the state of the neigh for the new_gw is checked. If the state isn't valid then the redirected route is deleted. This behavior is maintained up to v3.5.7 by check_peer_redirect() because rt->rt_gateway is assigned to peer->redirect_learned.a4 before calling ipv4_neigh_lookup(). After commit 5943634fc559 ("ipv4: Maintain redirect and PMTU info in struct rtable again."), ipv4_neigh_lookup() is performed without the rt_gateway assigned to the new_gw. In the case when rt_gateway (old_gw) isn't zero, the function uses it as the key. The neigh is most likely valid since the old_gw is the one that sends the ICMP redirect message. Then the new_gw is assigned to fib_nh_exception. The problem is: the new_gw ARP may never gets resolved and the traffic is blackholed. So, use the new_gw for neigh lookup. Changes from v1: - use __ipv4_neigh_lookup instead (per Eric Dumazet). Fixes: 5943634fc559 ("ipv4: Maintain redirect and PMTU info in struct rtable again.") Signed-off-by: Stephen Suryaputra Lin <ssurya@ieee.org> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Willy Tarreau <w@1wt.eu>
-rw-r--r--net/ipv4/route.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index cbad9b896c75..e59d6332458b 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -713,7 +713,9 @@ static void __ip_do_redirect(struct rtable *rt, struct sk_buff *skb, struct flow
goto reject_redirect;
}
- n = ipv4_neigh_lookup(&rt->dst, NULL, &new_gw);
+ n = __ipv4_neigh_lookup(rt->dst.dev, new_gw);
+ if (!n)
+ n = neigh_create(&arp_tbl, &new_gw, rt->dst.dev);
if (!IS_ERR(n)) {
if (!(n->nud_state & NUD_VALID)) {
neigh_event_send(n, NULL);