Skip to contentSkip to conversation

ipv6:introduce function to find route for redirect

PATCH Superseded Duan Jiong 2 participants 2 messages Aug 30, 2013

Subsystems (4)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Duan Jiong

author
#0 lore raw

PATCH v2 1/1 ipv6:introduce function to find route for redirect

RFC 4861 says that the IP source address of the Redirect is the same as the current first-hop router for the specified ICMP Destination Address, so the gateway should be taken into consideration when we find the route for redirect.

---
 net/ipv6/ah6.c     |  2 +-
 net/ipv6/esp6.c    |  2 +-
 net/ipv6/icmp.c    |  2 +-
 net/ipv6/ipcomp6.c |  2 +-
 net/ipv6/ndisc.c   |  2 +-
 net/ipv6/route.c   | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++----
 6 files changed, 80 insertions(+), 11 deletions(-)
net/ipv6/ah6.c +1 -1
index bb02e17..73784c3 100644
@@ -628,7 +628,7 @@ static void ah6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
 		return;
 
 	if (type == NDISC_REDIRECT)
-		ip6_redirect(skb, net, 0, 0);
+		ip6_redirect(skb, net, skb->dev->ifindex, 0);
 	else
 		ip6_update_pmtu(skb, net, info, 0, 0);
 	xfrm_state_put(x);
net/ipv6/esp6.c +1 -1
index aeac0dc..d3618a7 100644
@@ -447,7 +447,7 @@ static void esp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
 		return;
 
 	if (type == NDISC_REDIRECT)
-		ip6_redirect(skb, net, 0, 0);
+		ip6_redirect(skb, net, skb->dev->ifindex, 0);
 	else
 		ip6_update_pmtu(skb, net, info, 0, 0);
 	xfrm_state_put(x);
net/ipv6/icmp.c +1 -1
index 7cfc8d2..73681c2 100644
@@ -92,7 +92,7 @@ static void icmpv6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
 	if (type == ICMPV6_PKT_TOOBIG)
 		ip6_update_pmtu(skb, net, info, 0, 0);
 	else if (type == NDISC_REDIRECT)
-		ip6_redirect(skb, net, 0, 0);
+		ip6_redirect(skb, net, skb->dev->ifindex, 0);
 
 	if (!(type & ICMPV6_INFOMSG_MASK))
 		if (icmp6->icmp6_type == ICMPV6_ECHO_REQUEST)
net/ipv6/ipcomp6.c +1 -1
index 7af5aee..5636a91 100644
@@ -76,7 +76,7 @@ static void ipcomp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
 		return;
 
 	if (type == NDISC_REDIRECT)
-		ip6_redirect(skb, net, 0, 0);
+		ip6_redirect(skb, net, skb->dev->ifindex, 0);
 	else
 		ip6_update_pmtu(skb, net, info, 0, 0);
 	xfrm_state_put(x);
net/ipv6/ndisc.c +1 -1
index 04d31c2..604b718 100644
@@ -1370,7 +1370,7 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
 		return;
 
 	if (!ndopts.nd_opts_rh) {
-		ip6_redirect_no_header(skb, dev_net(skb->dev), 0, 0);
+		ip6_redirect_no_header(skb, dev_net(skb->dev), skb->dev->ifindex, 0);
 		return;
 	}
 
net/ipv6/route.c +75 -6

99 lines not on this page · raw message

Signature · 1 line
1.8.3.1
maintainer
#1 lore raw

From: Duan Jiong <[email protected]>
Date: Fri, 30 Aug 2013 15:23:34 +0800

net/ipv6/route.c void ip6_sk_update_pmtu(struct sk_buff *skb, struct sock *sk, __be32 mtu) · line 1186

Quoted 10 lines
net/ipv6/route.c +10 -0
+	/*
+	 * Get the "current" route for this destination and
+	 * check if the redirect has come from approriate router.
+	 *
+	 * RFC 4861 specifies that redirects should only be
+	 * accepted if they come from the nexthop to the target.
+	 * Due to the way the routes are chosen, this notion
+	 * is a bit fuzzy and one might need to check all possible
+	 * routes.
+	 */

Comments in the networking code should be formatted:

	/* Like
	 * this.
	 */