Skip to contentSkip to conversation

ipv6: handle Redirect ICMP Message with no Redirected Header option

PATCH Superseded Duan Jiong 3 participants 4 messages Aug 21, 2013 – Aug 22, 2013

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Duan Jiong

author
#0 lore raw

PATCH v3 1/1 ipv6: handle Redirect ICMP Message with no Redirected Header option

From: Duan Jiong <[email protected]>

rfc 4861 says the Redirected Header option is optional, so the kernel should not drop the Redirect Message that has no Redirected Header option. In this patch, the function ip6_redirect_no_header() is introduced to deal with that condition.

---
Changes for v3:
1: replace skb_network_header() with ipv6_hdr() 2: replace skb_transport_header() with icmp6_hdr()

 include/net/ip6_route.h |    2 ++
 net/ipv6/ndisc.c        |    4 +++-
 net/ipv6/route.c        |   22 ++++++++++++++++++++++
 3 files changed, 27 insertions(+), 1 deletions(-)
include/net/ip6_route.h +2 -0
index 260f83f..f667248 100644
@@ -135,6 +135,8 @@ extern void ip6_update_pmtu(struct sk_buff *skb, struct net *net, __be32 mtu,
 extern void ip6_sk_update_pmtu(struct sk_buff *skb, struct sock *sk,
 			       __be32 mtu);
 extern void ip6_redirect(struct sk_buff *skb, struct net *net, int oif, u32 mark);
+extern void ip6_redirect_no_header(struct sk_buff *skb, struct net *net, int oif,
+				   u32 mark);
 extern void ip6_sk_redirect(struct sk_buff *skb, struct sock *sk);
 
 struct netlink_callback;
net/ipv6/ndisc.c +3 -1
index 79aa965..04d31c2 100644
@@ -1369,8 +1369,10 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
 	if (!ndisc_parse_options(msg->opt, ndoptlen, &ndopts))
 		return;
 
-	if (!ndopts.nd_opts_rh)
+	if (!ndopts.nd_opts_rh) {
+		ip6_redirect_no_header(skb, dev_net(skb->dev), 0, 0);
 		return;
+	}
 
 	hdr = (u8 *)ndopts.nd_opts_rh;
 	hdr += 8;
net/ipv6/route.c +22 -0
index b70f897..846f9b1 100644
@@ -1178,6 +1178,28 @@ void ip6_redirect(struct sk_buff *skb, struct net *net, int oif, u32 mark)
 }
 EXPORT_SYMBOL_GPL(ip6_redirect);
 
+void ip6_redirect_no_header(struct sk_buff *skb, struct net *net, int oif,
+			    u32 mark)
+{
+	const struct ipv6hdr *iph = ipv6_hdr(skb);
+	const struct rd_msg *msg = (struct rd_msg *)icmp6_hdr(skb);
+	struct dst_entry *dst;
+	struct flowi6 fl6;
+
+	memset(&fl6, 0, sizeof(fl6));
+	fl6.flowi6_oif = oif;
+	fl6.flowi6_mark = mark;
+	fl6.flowi6_flags = 0;
+	fl6.daddr = msg->dest;
+	fl6.saddr = iph->daddr;
+
+	dst = ip6_route_output(net, NULL, &fl6);
+	if (!dst->error)
+		rt6_do_redirect(dst, NULL, skb);
+	dst_release(dst);
+}
+EXPORT_SYMBOL_GPL(ip6_redirect_no_header);
+
 void ip6_sk_redirect(struct sk_buff *skb, struct sock *sk)
 {
 	ip6_redirect(skb, sock_net(sk), sk->sk_bound_dev_if, sk->sk_mark);
Signature · 1 line
1.7.3.1
Acked-by on v3 1/1
#1 lore raw
Quoted 9 lines · Duan Jiong

From: Duan Jiong <[email protected]>

rfc 4861 says the Redirected Header option is optional, so the kernel should not drop the Redirect Message that has no Redirected Header option. In this patch, the function ip6_redirect_no_header() is introduced to deal with that condition.

Sorry for being so picky about local socket delivery before. You were right all along.

I just tested and reviewed this patch and everything is fine:

Just out of curiosity, can you tell because of which devices you did this patch?

Thanks,

Hannes

author
#2 lore raw
Quoted 14 lines · Hannes Frederic Sowa
Quoted 9 lines · Duan Jiong

From: Duan Jiong <[email protected]>

rfc 4861 says the Redirected Header option is optional, so the kernel should not drop the Redirect Message that has no Redirected Header option. In this patch, the function ip6_redirect_no_header() is introduced to deal with that condition.

Sorry for being so picky about local socket delivery before. You were right all along.

Quoted 6 lines

I just tested and reviewed this patch and everything is fine:

Just out of curiosity, can you tell because of which devices you did this patch?

In fact, i did this patch just because i want to learn more about the ipv6 implemention.

maintainer
#3 lore raw
In reply to Duan Jiong

From: Duan Jiong <[email protected]>
Date: Wed, 21 Aug 2013 15:14:12 +0800

Quoted 2 lines
net/ipv6/route.c +2 -0
+void ip6_redirect_no_header(struct sk_buff *skb, struct net *net, int oif,
+			    u32 mark)

...

Quoted 1 line

+EXPORT_SYMBOL_GPL(ip6_redirect_no_header);

I don't think you need to export this to modules, this is in route.c and the only user is in ndisc.c, both of which are linked together.

Please resubmit this with the symbol export removed, thanks.