Skip to content

Commit

Permalink
ipv6: Change skb->data before using icmpv6_notify() to propagate redi…
Browse files Browse the repository at this point in the history
…rect

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>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Duan Jiong authored and David S. Miller committed Dec 14, 2012
1 parent 1e9f954 commit 093d04d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/net/ndisc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 17 additions & 0 deletions net/ipv6/ndisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1314,6 +1314,12 @@ static void ndisc_router_discovery(struct sk_buff *skb)

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:
Expand All @@ -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);
}

Expand Down

0 comments on commit 093d04d

Please sign in to comment.