All of lore.kernel.org
 help / color / mirror / Atom feed
From: Duan Jiong <djduanjiong@gmail.com>
To: Steffen Klassert <steffen.klassert@secunet.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: Re: [PATCH] ipv6: fix the bug when propagating Redirect Message
Date: Wed, 12 Dec 2012 19:09:51 +0800	[thread overview]
Message-ID: <50C865FF.7030209@gmail.com> (raw)
In-Reply-To: <20121211134514.GE18940@secunet.com>

于 2012/12/11 21:45, Steffen Klassert 写道:
> On Tue, Dec 11, 2012 at 08:58:20PM +0800, Duan Jiong wrote:
>>
>> Just like you said, i try to use ndisc_parse_options() to instead
>> of the loop, but i find the skb->data can't be changed in function
>> ndisc_parse_options() due to lack of  arguments. So i think it is
>> better to continue to use the loop. How do you think this?
>>
> 
> You can change the data pointer after ndisc_parse_options().
> Something like the (untested) patch below should do it.
> 
>  include/net/ndisc.h |    7 +++++++
>  net/ipv6/ndisc.c    |   20 ++++++++++++++++++++
>  2 files changed, 27 insertions(+)
> 
> diff --git a/include/net/ndisc.h b/include/net/ndisc.h
> index 980d263..c17bccd 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..9afd23f 100644
> --- a/net/ipv6/ndisc.c
> +++ b/net/ipv6/ndisc.c
> @@ -1333,6 +1333,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:
> @@ -1349,6 +1355,20 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
>  		return;
>  	}
>  
> +	if (!ndisc_parse_options(msg->opt, ndoptlen, &ndopts)) {
> +		ND_PRINTK(2, warn, "Redirect: invalid ND options\n");
> +		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);
>  }
>  
> 
Thanks for you help. I will test it.

      reply	other threads:[~2012-12-12 11:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-23 15:26 [PATCH] ipv6: fix the bug when propagating Redirect Message Duan Jiong
2012-10-24  4:54 ` Steffen Klassert
2012-11-09  8:54   ` Steffen Klassert
2012-12-11 12:58   ` Duan Jiong
2012-12-11 13:45     ` Steffen Klassert
2012-12-12 11:09       ` Duan Jiong [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50C865FF.7030209@gmail.com \
    --to=djduanjiong@gmail.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=steffen.klassert@secunet.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.