[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 3 Mar 2015 14:44:29 +0000
From: David Laight <David.Laight@...LAB.COM>
To: '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
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.
As opposed to adding an open coded check at all of them.
Clearly if the majority of sites have been changed then the 'cb' field member can
be renamed to pick up the stragglers. I wouldn't suggest doing that immediately.
> Besides that, this macro is also buggy, my totally untrained lisp-eye tells
> me that you got your brackets wrong.
I did say 'based on'....
It is also probably possible to get the name of the type into the error message.
Although that might require it always be a 'struct'.
David
--
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