Skip to content

Commit 093d04d

Browse files
duanjiongdavem330
authored andcommitted
ipv6: Change skb->data before using icmpv6_notify() to propagate redirect
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>
1 parent 1e9f954 commit 093d04d

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

‎include/net/ndisc.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ struct ra_msg {
7878
__be32 retrans_timer;
7979
};
8080

81+
struct rd_msg {
82+
struct icmp6hdr icmph;
83+
struct in6_addr target;
84+
struct in6_addr dest;
85+
__u8 opt[0];
86+
};
87+
8188
struct nd_opt_hdr {
8289
__u8 nd_opt_type;
8390
__u8 nd_opt_len;

‎net/ipv6/ndisc.c‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,6 +1314,12 @@ static void ndisc_router_discovery(struct sk_buff *skb)
13141314

13151315
static void ndisc_redirect_rcv(struct sk_buff *skb)
13161316
{
1317+
u8 *hdr;
1318+
struct ndisc_options ndopts;
1319+
struct rd_msg *msg = (struct rd_msg *)skb_transport_header(skb);
1320+
u32 ndoptlen = skb->tail - (skb->transport_header +
1321+
offsetof(struct rd_msg, opt));
1322+
13171323
#ifdef CONFIG_IPV6_NDISC_NODETYPE
13181324
switch (skb->ndisc_nodetype) {
13191325
case NDISC_NODETYPE_HOST:
@@ -1330,6 +1336,17 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
13301336
return;
13311337
}
13321338

1339+
if (!ndisc_parse_options(msg->opt, ndoptlen, &ndopts))
1340+
return;
1341+
1342+
if (!ndopts.nd_opts_rh)
1343+
return;
1344+
1345+
hdr = (u8 *)ndopts.nd_opts_rh;
1346+
hdr += 8;
1347+
if (!pskb_pull(skb, hdr - skb_transport_header(skb)))
1348+
return;
1349+
13331350
icmpv6_notify(skb, NDISC_REDIRECT, 0, 0);
13341351
}
13351352

0 commit comments

Comments
 (0)