netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hannes Frederic Sowa <hannes@stressinduktion.org>
To: Werner Almesberger <werner@almesberger.net>
Cc: netdev@vger.kernel.org
Subject: Re: minimum ICMPv6 message size vs. RPL's DIS
Date: Thu, 25 Jul 2013 08:17:31 +0200	[thread overview]
Message-ID: <20130725061731.GA12365@order.stressinduktion.org> (raw)
In-Reply-To: <20130724232852.GA29572@ws>

On Wed, Jul 24, 2013 at 08:28:52PM -0300, Werner Almesberger wrote:
> The kernel assumes that any valid ICMPv6 message is at least eight
> bytes long, for example in net/ipv6/raw.c:icmpv6_filter
> 
> The DIS message of RPL (RFC 6550 section 6.2, from the 6LoWPAN
> world), has a minimum length of six bytes, and is thus blocked by
> icmpv6_filter.
> 
> Contiki OS sends this sort of messages and is thus ignored by an
> user-space RPL application on Linux (in my case simpleRPL). Nodes
> will eventually join the network regardless, but this can take
> hours instead of seconds.
>  
> RFC 4443 seems to allow even a zero-sized body, making the minimum
> allowable size four bytes.
> 
> A similar restriction exists in net/ipv6/icmp.c:icmpv6_rcv but
> causes no harm there since all potential recipients at that point
> expect a larger payload.
> 
> Now, while this is easy enough to fix on the Linux side (see
> below), I wonder if it is really a Linux bug or if I (and the
> authors of RPL in Contiki) may have missed some minimum size
> requirement for ICMPv6 messages stated elsewhere.
> 
> Opinions ?

Browsing the RFCs, I do think you are correct. Did you check what IPv4 does?
(what a strange errata to RFC 4443...)

> diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
> index c45f7a5..539534c 100644
> --- a/net/ipv6/raw.c
> +++ b/net/ipv6/raw.c
> @@ -112,7 +112,7 @@ static int icmpv6_filter(const struct sock *sk, const struct sk_buff *skb)
>  	const struct icmp6hdr *hdr;
>  
>  	hdr = skb_header_pointer(skb, skb_transport_offset(skb),
> -				 sizeof(_hdr), &_hdr);
> +				 4, &_hdr);
>  	if (hdr) {
>  		const __u32 *data = &raw6_sk(sk)->filter.data[0];
>  		unsigned int type = hdr->icmp6_type;

Hmm, maybe we should update the icmp header to something like

struct icmp6hdr {
	struct icmp6hdr_head {
		__u8 icmp6_type;
		...;
	} icmpv6_head;
#define icmp6_type icmpv6_head.icmp6_type

and just change the type in icmpv6_filter to icmp6hdr_head.

Hmm, there is a bug in this function, _hdr must not be a pointer.

Greetings,

  Hannes

  reply	other threads:[~2013-07-25  6:17 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-24 23:28 minimum ICMPv6 message size vs. RPL's DIS Werner Almesberger
2013-07-25  6:17 ` Hannes Frederic Sowa [this message]
2013-07-25 10:30   ` Werner Almesberger
2013-07-25 13:03     ` Hannes Frederic Sowa
2013-07-25 13:58     ` Hannes Frederic Sowa
2013-07-25 14:32       ` Werner Almesberger
2013-07-25 18:40         ` Hannes Frederic Sowa
2013-07-25 21:47           ` Werner Almesberger
2013-07-25 23:31             ` Hannes Frederic Sowa
2013-08-01  5:48     ` Hannes Frederic Sowa
2013-08-02  1:10       ` David Miller
2013-08-02  4:51         ` Werner Almesberger

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=20130725061731.GA12365@order.stressinduktion.org \
    --to=hannes@stressinduktion.org \
    --cc=netdev@vger.kernel.org \
    --cc=werner@almesberger.net \
    /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 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).