ipv6: handle Redirect ICMP Message with no Redirected Header option
Subsystems (3)
PATCH 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.
--- include/net/ip6_route.h | 1 + net/ipv6/ndisc.c | 4 +++- net/ipv6/route.c | 21 +++++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletions(-)
include/net/ip6_route.h +1 -0
@@ -135,6 +135,7 @@ 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
@@ -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 +21 -0
@@ -1178,6 +1178,27 @@ 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 = (struct ipv6hdr *)skb_network_header (skb); +struct rd_msg *msg = (struct rd_msg *)skb_transport_header (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
Quoted 32 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.Signed-off-by Duan Jiong <[email protected]>--- include/net/ip6_route.h | 1 + net/ipv6/ndisc.c | 4 +++- net/ipv6/route.c | 21 +++++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletions(-)include/net/ip6_route.h +1
-0@@ -135,6 +135,7 @@ 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 +0
-0
net/ipv6/ndisc.c static void ndisc_redirect_rcv(struct sk_buff *skb) · line 1375
Quoted 8 lines
net/ipv6/ndisc.c +3
-1@@ -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 ; + }
Can't we just jump down to icmpv6_notify without introducing ip6_redirect_no_header?
Quoted 8 lines
net/ipv6/ndisc.c +0
-0hdr = (u8 *)ndopts.nd_opts_rh; hdr +=8 ;net/ipv6/route.c +0
-0
net/ipv6/route.c void ip6_redirect(struct sk_buff *skb, struct net *net, int oif, u32 mark) · line 1183
Quoted 6 lines
net/ipv6/route.c +3
-0@@ -1178,6 +1178,27 @@ 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 = (struct ipv6hdr *)skb_network_header (skb);
const struct ipv6hdr *iph = ipv6_hdr(skb);
Thanks,
Hannes
Quoted 36 lines · Hannes Frederic Sowa
Quoted 35 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.Signed-off-by Duan Jiong <[email protected]>--- include/net/ip6_route.h | 1 + net/ipv6/ndisc.c | 4 +++- net/ipv6/route.c | 21 +++++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletions(-)include/net/ip6_route.h +1
-0@@ -135,6 +135,7 @@ 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 +0
-0@@ -1369,8 +1369,10 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)if (!ndisc_parse_options (msg->opt, ndoptlen, &ndopts))return ;
Quoted 9 lines
net/ipv6/ndisc.c static void ndisc_redirect_rcv(struct sk_buff *skb) · line 1375
Quoted 5 lines
net/ipv6/ndisc.c +3
-1-if (!ndopts.nd_opts_rh) +if (!ndopts.nd_opts_rh) { +ip6_redirect_no_header (skb,dev_net (skb->dev),0 ,0 );return ; + }Can't we just jump down to
icmpv6_notifywithout introducingip6_redirect_no_header?
No, the function icmpv6_notify need the skb->data point the inner IP packet that triggered the sending of the ICMP Message, so when the Redirect Message has no Redirected Header option, it should not be handled in icmpv6_notify.
Quoted 11 lines
Quoted 11 lines
net/ipv6/ndisc.c +0
-0hdr = (u8 *)ndopts.nd_opts_rh; hdr +=8 ;net/ipv6/route.c +0
-0@@ -1178,6 +1178,27 @@ void ip6_redirect(struct sk_buff *skb, struct net *net, int oif, u32 mark) }EXPORT_SYMBOL_GPL (ip6_redirect);
Quoted 6 lines
net/ipv6/route.c void ip6_redirect(struct sk_buff *skb, struct net *net, int oif, u32 mark) · line 1183
Quoted 3 lines
net/ipv6/route.c +3
-0+void ip6_redirect_no_header (struct sk_buff *skb,struct net *net,int oif,u32 mark) +{ +const struct ipv6hdr *iph = (struct ipv6hdr *)skb_network_header (skb);const struct ipv6hdr *iph =
ipv6_hdr(skb);
Thanks for you help, i will apply it in next version.
Thanks,
Duan
Hello.
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.Signed-off-by Duan Jiong <[email protected]>
[...]
net/ipv6/route.c void ip6_redirect(struct sk_buff *skb, struct net *net, int oif, u32 mark) · line 1184
Quoted 12 lines
net/ipv6/route.c +4
-0@@ -1178,6 +1178,27 @@ 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 = (struct ipv6hdr *)skb_network_header (skb); +struct rd_msg *msg = (struct rd_msg *)skb_transport_header (skb);
Be consistent please: either put space after a typecast or not.
net/ipv6/route.c void ip6_redirect(struct sk_buff *skb, struct net *net, int oif, u32 mark) · line 1186
Quoted 2 lines
net/ipv6/route.c +2
-0+struct dst_entry *dst; +struct flowi6 fl6;
WBR, Sergei
Quoted 23 lines · Sergei Shtylyov
Hello.
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.Signed-off-by Duan Jiong <[email protected]>[...]
Quoted 8 lines
net/ipv6/route.c +0
-0@@ -1178,6 +1178,27 @@ void ip6_redirect(struct sk_buff *skb, struct net *net, int oif, u32 mark) }EXPORT_SYMBOL_GPL (ip6_redirect);
Quoted 7 lines
net/ipv6/route.c void ip6_redirect(struct sk_buff *skb, struct net *net, int oif, u32 mark) · line 1184
Quoted 4 lines
net/ipv6/route.c +4
-0+void ip6_redirect_no_header (struct sk_buff *skb,struct net *net,int oif,u32 mark) +{ +const struct ipv6hdr *iph = (struct ipv6hdr *)skb_network_header (skb); +struct rd_msg *msg = (struct rd_msg *)skb_transport_header (skb);Be consistent please: either put space after a typecast or not.
Thanks for you help, i will apply it in next version.
Thanks,
Duan