* [PATCH] ipv6: handle Redirect ICMP Message with no Redirected Header option
@ 2013-08-19 10:54 Duan Jiong
2013-08-19 11:55 ` Hannes Frederic Sowa
2013-08-19 19:00 ` Sergei Shtylyov
0 siblings, 2 replies; 5+ messages in thread
From: Duan Jiong @ 2013-08-19 10:54 UTC (permalink / raw)
To: davem; +Cc: netdev
From: Duan Jiong <duanj.fnst@cn.fujitsu.com>
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 <duanj.fnst@cn.fujitsu.com>
---
include/net/ip6_route.h | 1 +
net/ipv6/ndisc.c | 4 +++-
net/ipv6/route.c | 21 +++++++++++++++++++++
3 files changed, 25 insertions(+), 1 deletions(-)
diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
index 260f83f..7966f54 100644
--- a/include/net/ip6_route.h
+++ b/include/net/ip6_route.h
@@ -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;
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 79aa965..04d31c2 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -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;
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index b70f897..9934b87 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -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);
--
1.7.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] ipv6: handle Redirect ICMP Message with no Redirected Header option
2013-08-19 10:54 [PATCH] ipv6: handle Redirect ICMP Message with no Redirected Header option Duan Jiong
@ 2013-08-19 11:55 ` Hannes Frederic Sowa
2013-08-20 1:56 ` Duan Jiong
2013-08-19 19:00 ` Sergei Shtylyov
1 sibling, 1 reply; 5+ messages in thread
From: Hannes Frederic Sowa @ 2013-08-19 11:55 UTC (permalink / raw)
To: Duan Jiong; +Cc: davem, netdev
On Mon, Aug 19, 2013 at 06:54:51PM +0800, Duan Jiong wrote:
> From: Duan Jiong <duanj.fnst@cn.fujitsu.com>
>
> 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 <duanj.fnst@cn.fujitsu.com>
> ---
> include/net/ip6_route.h | 1 +
> net/ipv6/ndisc.c | 4 +++-
> net/ipv6/route.c | 21 +++++++++++++++++++++
> 3 files changed, 25 insertions(+), 1 deletions(-)
>
> diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
> index 260f83f..7966f54 100644
> --- a/include/net/ip6_route.h
> +++ b/include/net/ip6_route.h
> @@ -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;
> diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
> index 79aa965..04d31c2 100644
> --- a/net/ipv6/ndisc.c
> +++ b/net/ipv6/ndisc.c
> @@ -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?
>
> hdr = (u8 *)ndopts.nd_opts_rh;
> hdr += 8;
> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index b70f897..9934b87 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ipv6: handle Redirect ICMP Message with no Redirected Header option
2013-08-19 10:54 [PATCH] ipv6: handle Redirect ICMP Message with no Redirected Header option Duan Jiong
2013-08-19 11:55 ` Hannes Frederic Sowa
@ 2013-08-19 19:00 ` Sergei Shtylyov
2013-08-20 2:00 ` Duan Jiong
1 sibling, 1 reply; 5+ messages in thread
From: Sergei Shtylyov @ 2013-08-19 19:00 UTC (permalink / raw)
To: Duan Jiong; +Cc: davem, netdev
Hello.
On 08/19/2013 02:54 PM, Duan Jiong wrote:
> From: Duan Jiong <duanj.fnst@cn.fujitsu.com>
> 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 <duanj.fnst@cn.fujitsu.com>
[...]
> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index b70f897..9934b87 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -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.
> + struct dst_entry *dst;
> + struct flowi6 fl6;
WBR, Sergei
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ipv6: handle Redirect ICMP Message with no Redirected Header option
2013-08-19 11:55 ` Hannes Frederic Sowa
@ 2013-08-20 1:56 ` Duan Jiong
0 siblings, 0 replies; 5+ messages in thread
From: Duan Jiong @ 2013-08-20 1:56 UTC (permalink / raw)
To: hannes; +Cc: davem, netdev
于 2013年08月19日 19:55, Hannes Frederic Sowa 写道:
> On Mon, Aug 19, 2013 at 06:54:51PM +0800, Duan Jiong wrote:
>> From: Duan Jiong <duanj.fnst@cn.fujitsu.com>
>>
>> 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 <duanj.fnst@cn.fujitsu.com>
>> ---
>> include/net/ip6_route.h | 1 +
>> net/ipv6/ndisc.c | 4 +++-
>> net/ipv6/route.c | 21 +++++++++++++++++++++
>> 3 files changed, 25 insertions(+), 1 deletions(-)
>>
>> diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
>> index 260f83f..7966f54 100644
>> --- a/include/net/ip6_route.h
>> +++ b/include/net/ip6_route.h
>> @@ -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;
>> diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
>> index 79aa965..04d31c2 100644
>> --- a/net/ipv6/ndisc.c
>> +++ b/net/ipv6/ndisc.c
>> @@ -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?
>
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.
>>
>> hdr = (u8 *)ndopts.nd_opts_rh;
>> hdr += 8;
>> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
>> index b70f897..9934b87 100644
>> --- a/net/ipv6/route.c
>> +++ b/net/ipv6/route.c
>> @@ -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 for you help, i will apply it in next version.
Thanks,
Duan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ipv6: handle Redirect ICMP Message with no Redirected Header option
2013-08-19 19:00 ` Sergei Shtylyov
@ 2013-08-20 2:00 ` Duan Jiong
0 siblings, 0 replies; 5+ messages in thread
From: Duan Jiong @ 2013-08-20 2:00 UTC (permalink / raw)
To: Sergei Shtylyov; +Cc: davem, netdev
于 2013年08月20日 03:00, Sergei Shtylyov 写道:
> Hello.
>
> On 08/19/2013 02:54 PM, Duan Jiong wrote:
>
>> From: Duan Jiong <duanj.fnst@cn.fujitsu.com>
>
>> 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 <duanj.fnst@cn.fujitsu.com>
> [...]
>
>> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
>> index b70f897..9934b87 100644
>> --- a/net/ipv6/route.c
>> +++ b/net/ipv6/route.c
>> @@ -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.
>
Thanks for you help, i will apply it in next version.
Thanks,
Duan
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-08-20 2:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-19 10:54 [PATCH] ipv6: handle Redirect ICMP Message with no Redirected Header option Duan Jiong
2013-08-19 11:55 ` Hannes Frederic Sowa
2013-08-20 1:56 ` Duan Jiong
2013-08-19 19:00 ` Sergei Shtylyov
2013-08-20 2:00 ` Duan Jiong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).