[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 3 Mar 2015 16:51:56 +0200
From: Eyal Birger <eyal.birger@...il.com>
To: David Laight <David.Laight@...lab.com>
Cc: Daniel Borkmann <daniel@...earbox.net>,
Florian Westphal <fw@...len.de>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: Re: [PATCH v2] net: bridge: add compile-time assert for cb struct size
On Tue, Mar 3, 2015 at 4:44 PM, David Laight <David.Laight@...lab.com> wrote:
> From: Daniel Borkmann
>> On 03/03/2015 02:50 PM, David Laight wrote:
>> ...
>> >> + BUILD_BUG_ON(sizeof(struct br_input_skb_cb) > FIELD_SIZEOF(struct sk_buff, cb));
>> >> +
>> >
>> > What about using something based on:
>> > #define GET_CB(skb, type) ((type *)((skb)->cb + (sizeof (char[(sizeof (type) <= sizeof (skb->cb)) ? 1 : -1] - 1)))
>> > to access skb->sb?
>>
>> That would require to change all skb->cb[] call-sites everywhere.
>
> Well, only once for each type.
Note that there are cases where skb->cb[] used size is greater than
the associated
type.
For example, in packet_rcv() a full hw address is stored in skb->cb[], exceeding
the packet_skb_cb struct size. This is also true for can/raw.c (in
raw_flags()), though
in that specific case the skb->cb[] use could have been wrapped in a struct.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists