From patchwork Thu Jul 25 10:30:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Werner Almesberger X-Patchwork-Id: 261665 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 38FA42C00C3 for ; Thu, 25 Jul 2013 20:32:24 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755299Ab3GYKcV (ORCPT ); Thu, 25 Jul 2013 06:32:21 -0400 Received: from hydra.openmoko.org ([144.76.72.4]:60737 "EHLO hydra.openmoko.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753394Ab3GYKcT (ORCPT ); Thu, 25 Jul 2013 06:32:19 -0400 Received: from 201-160-231-201.fibertel.com.ar ([201.231.160.201] helo=ws) by hydra.openmoko.org with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1V2IqF-0006tL-Un for netdev@vger.kernel.org; Thu, 25 Jul 2013 12:32:17 +0200 Received: by ws (sSMTP sendmail emulation); Thu, 25 Jul 2013 07:30:49 -0300 Date: Thu, 25 Jul 2013 07:30:49 -0300 From: Werner Almesberger To: netdev@vger.kernel.org Subject: Re: minimum ICMPv6 message size vs. RPL's DIS Message-ID: <20130725103048.GB29572@ws> References: <20130724232852.GA29572@ws> <20130725061731.GA12365@order.stressinduktion.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20130725061731.GA12365@order.stressinduktion.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Hannes Frederic Sowa wrote: > Hmm, maybe we should update the icmp header to something like That would be quite clean. Is it okay to introduce new names like that in a uapi/ header (uapi/linux/icmpv6.h) ? > Hmm, there is a bug in this function, _hdr must not be a pointer. Oh, I didn't even notice that. Very good catch ! So on 32 bit system, it would actually work even with "short" ICMPv6 messages. Two wrongs sometimes do make a right :-) I've attached a revised patch that, according to quick testing, still works and doesn't break anything else. Thanks, - Werner ---------------------------------- cut here ----------------------------------- --- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/uapi/linux/icmpv6.h b/include/uapi/linux/icmpv6.h index e0133c7..11eb5ff 100644 --- a/include/uapi/linux/icmpv6.h +++ b/include/uapi/linux/icmpv6.h @@ -5,11 +5,15 @@ #include struct icmp6hdr { - - __u8 icmp6_type; - __u8 icmp6_code; - __sum16 icmp6_cksum; - + struct icmp6hdr_head { + __u8 type; + __u8 code; + __sum16 cksum; + } icmpv6_head; + +#define icmp6_type icmpv6_head.type +#define icmp6_code icmpv6_head.code +#define icmp6_cksum icmpv6_head.cksum union { __be32 un_data32[1]; diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c index c45f7a5..99ab06f 100644 --- a/net/ipv6/raw.c +++ b/net/ipv6/raw.c @@ -108,14 +108,14 @@ found: */ static int icmpv6_filter(const struct sock *sk, const struct sk_buff *skb) { - struct icmp6hdr *_hdr; - const struct icmp6hdr *hdr; + struct icmp6hdr_head _head; + const struct icmp6hdr_head *head; - hdr = skb_header_pointer(skb, skb_transport_offset(skb), - sizeof(_hdr), &_hdr); - if (hdr) { + head = skb_header_pointer(skb, skb_transport_offset(skb), + sizeof(_head), &_head); + if (head) { const __u32 *data = &raw6_sk(sk)->filter.data[0]; - unsigned int type = hdr->icmp6_type; + unsigned int type = head->type; return (data[type >> 5] & (1U << (type & 31))) != 0; }