Re: [PATCH net-next 7/7] net: move skb->dropcount to skb->cb[]
From: Eyal Birger <hidden>
Date: 2015-02-26 18:52:31
On Thu, Feb 26, 2015 at 5:32 PM, Shmulik Ladkani [off-list ref] wrote:
On Thu, 26 Feb 2015 12:48:14 +0200 Eyal Birger [off-list ref] wrote:quoted
After giving it some additional thought and research, I don't think this is necessary. The sizeof operator on struct sock_skb_cb would give a padded result which would take care of the structure alignment. This is under the assumption that skb->cb[] size is of a proper multiple (which I think is rather safe).Yes, you are correct. With the assumption that skb->cb and 'cb' size are properly aligned and sized (compile time asserted, btw?), you can simply: struct your_thing { // name it u32 dropcount; }; struct sock_skb_cb { /* protocol families specifc CBs */ u8 pf_reserved[PAD]; struct your_thing sock_cb; }; where: #define PAD (FIELD_SIZEOF(struct sk_buff, cb) - sizeof(struct your_thing))
struct sock_skb_cb as I see it represents the sock generic metadata required in the skb->cb[] and its placement at the end of skb->cb[] is an implementation detail - so it, in my view, is what you referred to as "struct your_thing". Coding-wise I would rather avoid the additional enclosing struct and stick with the proposed implementation. Eyal.