From: Shmulik Ladkani <shmulik.ladkani@gmail.com>
To: Eyal Birger <eyal.birger@gmail.com>
Cc: davem@davemloft.net, willemb@google.com, edumazet@google.com,
marcel@holtmann.org, netdev@vger.kernel.org
Subject: Re: [PATCH net-next 7/7] net: move skb->dropcount to skb->cb[]
Date: Thu, 26 Feb 2015 10:49:09 +0200 [thread overview]
Message-ID: <20150226104909.1f2c882d@halley> (raw)
In-Reply-To: <1424916612-744-8-git-send-email-eyal.birger@gmail.com>
On Thu, 26 Feb 2015 04:10:12 +0200 Eyal Birger <eyal.birger@gmail.com> wrote:
> diff --git a/include/net/sock.h b/include/net/sock.h
> index d462f5e..8807586 100644
> --- a/include/net/sock.h
> +++ b/include/net/sock.h
> @@ -2078,12 +2078,26 @@ static inline int sock_intr_errno(long timeo)
> return timeo == MAX_SCHEDULE_TIMEOUT ? -ERESTARTSYS : -EINTR;
> }
>
> +struct sock_skb_cb {
> + u32 dropcount;
> +};
> +
> +/* Store sock_skb_cb at the end of skb->cb[] so protocol families
> + * using skb->cb[] would keep using it directly and utilize its
> + * alignement guarantee.
> + */
> +#define SOCK_SKB_CB_OFFSET ((FIELD_SIZEOF(struct sk_buff, cb) - \
> + sizeof(struct sock_skb_cb)))
> +
> +#define SOCK_SKB_CB(__skb) ((struct sock_skb_cb *)((__skb)->cb + \
> + SOCK_SKB_CB_OFFSET))
> +
> #define sock_skb_cb_check_size(size) \
> - BUILD_BUG_ON((size) > FIELD_SIZEOF(struct sk_buff, cb))
> + BUILD_BUG_ON((size) > SOCK_SKB_CB_OFFSET)
>
You didn't take care of aligning the 'sock_skb_cb'.
(Althogh in practive, dropcount is 4 and cb[] is 48 so you're golden).
How about:
struct sock_skb_cb {
/* protocol families specifc CBs */
u8 reserved[__SOCK_SKB_CB_OFFSET];
struct __sock_skb_cb x; // name me better!
};
Where '__SOCK_SKB_CB_OFFSET' and '__sock_skb_cb' are as follows:
struct __sock_skb_cb { // name me better!
u32 dropcount;
};
#define __SOCK_SKB_CB_OFFSET_UNALIGNED \
(FIELD_SIZEOF(struct sk_buff, cb) - sizeof(struct __sock_skb_cb))
#define __SOCK_SKB_CB_OFFSET \
(__SOCK_SKB_CB_OFFSET_UNALIGNED - \
(__SOCK_SKB_CB_OFFSET_UNALIGNED % __alignof__(struct __sock_skb_cb)))
This also takes care for alignement of '__sock_skb_cb x' within the CB.
Then,
#define sock_skb_cb_check_size(size) \
BUILD_BUG_ON((size) > FIELD_SIZEOF(struct sock_skb_cb, reserved))
Regards,
Shmulik
next prev parent reply other threads:[~2015-02-26 8:49 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-26 2:10 [PATCH net-next 0/7] net: move skb->dropcount to skb->cb[] Eyal Birger
2015-02-26 2:10 ` [PATCH net-next 1/7] net: bluetooth: compact struct bt_skb_cb by inlining struct hci_req_ctrl Eyal Birger
2015-02-26 7:02 ` Shmulik Ladkani
2015-02-26 16:15 ` Marcel Holtmann
2015-02-26 21:22 ` Eyal Birger
2015-02-26 2:10 ` [PATCH net-next 2/7] net: bluetooth: compact struct bt_skb_cb by converting boolean fields to bit fields Eyal Birger
2015-02-26 7:30 ` Shmulik Ladkani
2015-02-26 13:22 ` Eyal Birger
2015-02-26 11:31 ` David Laight
2015-02-26 13:21 ` Eyal Birger
2015-02-26 2:10 ` [PATCH net-next 3/7] net: rxrpc: change call to sock_recv_ts_and_drops() on rxrpc recvmsg to sock_recv_timestamp() Eyal Birger
2015-02-26 4:40 ` Eric Dumazet
2015-02-26 7:30 ` Eyal Birger
2015-02-26 14:31 ` Eric Dumazet
2015-02-26 14:55 ` Eyal Birger
2015-02-26 2:10 ` [PATCH net-next 4/7] net: packet: use skb->dev as storage for skb orig len instead of skb->cb[] Eyal Birger
2015-02-26 4:03 ` Eyal Birger
2015-02-26 17:26 ` Willem de Bruijn
2015-02-26 18:38 ` Eyal Birger
2015-02-26 18:51 ` Willem de Bruijn
2015-02-26 18:55 ` Eyal Birger
2015-02-26 2:10 ` [PATCH net-next 5/7] net: use common macro for assering skb->cb[] available size in protocol families Eyal Birger
2015-02-26 2:10 ` [PATCH net-next 6/7] net: add common accessor for setting dropcount on packets Eyal Birger
2015-02-26 4:43 ` Eric Dumazet
2015-02-26 2:10 ` [PATCH net-next 7/7] net: move skb->dropcount to skb->cb[] Eyal Birger
2015-02-26 8:49 ` Shmulik Ladkani [this message]
2015-02-26 10:17 ` Eyal Birger
2015-02-26 10:48 ` Eyal Birger
2015-02-26 15:32 ` Shmulik Ladkani
2015-02-26 18:52 ` Eyal Birger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150226104909.1f2c882d@halley \
--to=shmulik.ladkani@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eyal.birger@gmail.com \
--cc=marcel@holtmann.org \
--cc=netdev@vger.kernel.org \
--cc=willemb@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).