* [PATCH v3] ipv6: Change skb->data before using icmpv6_notify() to propagate redirect
@ 2012-12-14 12:59 Duan Jiong
2012-12-14 18:16 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Duan Jiong @ 2012-12-14 12:59 UTC (permalink / raw)
To: davem; +Cc: Steffen Klassert, netdev
In function ndisc_redirect_rcv(), the skb->data points to the transport
header, but function icmpv6_notify() need the skb->data points to the
inner IP packet. So before using icmpv6_notify() to propagate redirect,
change skb->data to point the inner IP packet that triggered the sending
of the Redirect, and introduce struct rd_msg to make it easy.
Signed-off-by: Duan Jiong <djduanjiong@gmail.com>
---
include/net/ndisc.h | 7 +++++++
net/ipv6/ndisc.c | 17 +++++++++++++++++
2 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/include/net/ndisc.h b/include/net/ndisc.h
index 980d263..6b305d7 100644
--- a/include/net/ndisc.h
+++ b/include/net/ndisc.h
@@ -78,6 +78,13 @@ struct ra_msg {
__be32 retrans_timer;
};
+struct rd_msg {
+ struct icmp6hdr icmph;
+ struct in6_addr target;
+ struct in6_addr dest;
+ __u8 opt[0];
+};
+
struct nd_opt_hdr {
__u8 nd_opt_type;
__u8 nd_opt_len;
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 2edce30..89dab79 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1314,6 +1314,12 @@ out:
static void ndisc_redirect_rcv(struct sk_buff *skb)
{
+ u8 *hdr;
+ struct ndisc_options ndopts;
+ struct rd_msg *msg = (struct rd_msg *)skb_transport_header(skb);
+ u32 ndoptlen = skb->tail - (skb->transport_header +
+ offsetof(struct rd_msg, opt));
+
#ifdef CONFIG_IPV6_NDISC_NODETYPE
switch (skb->ndisc_nodetype) {
case NDISC_NODETYPE_HOST:
@@ -1330,6 +1336,17 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
return;
}
+ if (!ndisc_parse_options(msg->opt, ndoptlen, &ndopts))
+ return;
+
+ if (!ndopts.nd_opts_rh)
+ return;
+
+ hdr = (u8 *)ndopts.nd_opts_rh;
+ hdr += 8;
+ if (!pskb_pull(skb, hdr - skb_transport_header(skb)))
+ return;
+
icmpv6_notify(skb, NDISC_REDIRECT, 0, 0);
}
--
1.7.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v3] ipv6: Change skb->data before using icmpv6_notify() to propagate redirect
2012-12-14 12:59 [PATCH v3] ipv6: Change skb->data before using icmpv6_notify() to propagate redirect Duan Jiong
@ 2012-12-14 18:16 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2012-12-14 18:16 UTC (permalink / raw)
To: djduanjiong; +Cc: steffen.klassert, netdev
From: Duan Jiong <djduanjiong@gmail.com>
Date: Fri, 14 Dec 2012 20:59:59 +0800
>
> In function ndisc_redirect_rcv(), the skb->data points to the transport
> header, but function icmpv6_notify() need the skb->data points to the
> inner IP packet. So before using icmpv6_notify() to propagate redirect,
> change skb->data to point the inner IP packet that triggered the sending
> of the Redirect, and introduce struct rd_msg to make it easy.
>
> Signed-off-by: Duan Jiong <djduanjiong@gmail.com>
Applied and queued up for -stable.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-12-14 18:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-14 12:59 [PATCH v3] ipv6: Change skb->data before using icmpv6_notify() to propagate redirect Duan Jiong
2012-12-14 18:16 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.