From: Jakub Kicinski <kuba@kernel.org>
To: bpf@vger.kernel.org
Cc: davem@davemloft.net, netdev@vger.kernel.org, edumazet@google.com,
pabeni@redhat.com, Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH bpf-next 2/3] net: skbuff: reorder bytes 2 and 3 of the bitfield
Date: Tue, 7 Mar 2023 16:31:58 -0800 [thread overview]
Message-ID: <20230308003159.441580-3-kuba@kernel.org> (raw)
In-Reply-To: <20230308003159.441580-1-kuba@kernel.org>
BPF needs to know the offsets of fields it tries to access.
Zero-length fields are added to make offsetof() work.
This unfortunately partitions the bitfield (fields across
the zero-length members can't be coalesced).
Reorder bytes 2 and 3, BPF needs to know the offset of fields
previously in byte 3 and some fields in byte 2 should really
be optional.
The two bytes are always in the same cacheline so it should
not matter.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
include/linux/skbuff.h | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 004009b3930f..c4122797d465 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -945,16 +945,6 @@ struct sk_buff {
__u8 ip_summed:2;
__u8 ooo_okay:1;
- __u8 l4_hash:1;
- __u8 sw_hash:1;
- __u8 wifi_acked_valid:1;
- __u8 wifi_acked:1;
- __u8 no_fcs:1;
- /* Indicates the inner headers are valid in the skbuff. */
- __u8 encapsulation:1;
- __u8 encap_hdr_csum:1;
- __u8 csum_valid:1;
-
/* private: */
__u8 __mono_tc_offset[0];
/* public: */
@@ -967,6 +957,16 @@ struct sk_buff {
__u8 tc_skip_classify:1;
__u8 tc_at_ingress:1; /* See TC_AT_INGRESS_MASK */
#endif
+
+ __u8 l4_hash:1;
+ __u8 sw_hash:1;
+ __u8 wifi_acked_valid:1;
+ __u8 wifi_acked:1;
+ __u8 no_fcs:1;
+ /* Indicates the inner headers are valid in the skbuff. */
+ __u8 encapsulation:1;
+ __u8 encap_hdr_csum:1;
+ __u8 csum_valid:1;
#ifdef CONFIG_IPV6_NDISC_NODETYPE
__u8 ndisc_nodetype:2;
#endif
--
2.39.2
next prev parent reply other threads:[~2023-03-08 0:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-08 0:31 [PATCH bpf-next 0/3] net: skbuff: skb bitfield compaction - bpf Jakub Kicinski
2023-03-08 0:31 ` [PATCH bpf-next 1/3] net: skbuff: rename __pkt_vlan_present_offset to __mono_tc_offset Jakub Kicinski
2023-03-09 1:16 ` Martin KaFai Lau
2023-03-08 0:31 ` Jakub Kicinski [this message]
2023-03-08 0:31 ` [PATCH bpf-next 3/3] net: skbuff: move the fields BPF cares about directly next to the offset marker Jakub Kicinski
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=20230308003159.441580-3-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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