Subject: Re: [PATCH net-next 7/7] net: move skb->dropcount to skb->cb[]

From: Shmulik Ladkani <[email-masked]>
Date: Thu, 26 Feb 2015 17:32:18 +0200

On Thu, 26 Feb 2015 12:48:14 +0200 Eyal Birger <[email-masked]> wrote:
> 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))