[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1409836154.26422.101.camel@edumazet-glaptop2.roam.corp.google.com>
Date: Thu, 04 Sep 2014 06:09:14 -0700
From: Eric Dumazet <eric.dumazet@...il.com>
To: Hannes Frederic Sowa <hannes@...essinduktion.org>
Cc: Denis Kirjanov <kirjanov@...il.com>,
Alexei Starovoitov <alexei.starovoitov@...il.com>,
Daniel Borkmann <dborkman@...hat.com>,
Eric Dumazet <edumazet@...gle.com>,
Denis Kirjanov <kda@...ux-powerpc.org>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
Markos Chandras <markos.chandras@...tec.com>,
Martin Schwidefsky <schwidefsky@...ibm.com>
Subject: Re: [PATCH v2 net-next] net: filter: export pkt_type_offset() helper
On Thu, 2014-09-04 at 13:50 +0200, Hannes Frederic Sowa wrote:
>
> Denis, I thought about something like this, you can incorperate this in
> your patch if you can give it a test and check for other architectures,
> thanks!
>
> diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
> index 02529fc..87b86aa 100644
> --- a/include/linux/skbuff.h
> +++ b/include/linux/skbuff.h
> @@ -548,6 +548,10 @@ struct sk_buff {
> ip_summed:2,
> nohdr:1,
> nfctinfo:3;
> + /* __pkt_type_offset marks the offset of the bitfield pkt_type
> + * contains, so bpf can relatively address it
> + */
> + int __pkt_type_offset[0];
Why is it 'int', while the following uses __u8 ?
This means pkt_type has to stay at this bit offset, and nothing will
detect at compile time or execution time if someone did a reorg or added
a new field (it seems to be the trend lately)
__u8 bar:4,
pkt_type:3,
...
> __u8 pkt_type:3,
> fclone:2,
> ipvs_property:1,
> @@ -647,6 +651,17 @@ struct sk_buff {
> #define SKB_ALLOC_FCLONE 0x01
> #define SKB_ALLOC_RX 0x02
>
> +#ifdef __BIG_ENDIAN_BITFIELD
> +#define PKT_TYPE_MAX (7 << 5)
> +#else
> +#define PKT_TYPE_MAX 7
> +#endif
It had a sense right before static int pkt_type_offset(void), but here,
a casual reader might be lost.
I am saying this because a reorder of the bit fields is probably needed
to speedup __copy_skb_header() : Grouping together bit fields could
allow optimized word copies instead of bit field manipulations.
--
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