Skip to content

Commit c0ba861

Browse files
kuba-mooMartin KaFai Lau
authored andcommitted
net: skbuff: move the fields BPF cares about directly next to the offset marker
To avoid more possible BPF dependencies with moving bitfields around keep the fields BPF cares about right next to the offset marker. Signed-off-by: Jakub Kicinski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin KaFai Lau <[email protected]>
1 parent b94e032 commit c0ba861

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

include/linux/skbuff.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -947,15 +947,15 @@ struct sk_buff {
947947
/* private: */
948948
__u8 __mono_tc_offset[0];
949949
/* public: */
950-
__u8 remcsum_offload:1;
951-
__u8 csum_complete_sw:1;
952-
__u8 csum_level:2;
953-
__u8 dst_pending_confirm:1;
954950
__u8 mono_delivery_time:1; /* See SKB_MONO_DELIVERY_TIME_MASK */
955951
#ifdef CONFIG_NET_CLS_ACT
956-
__u8 tc_skip_classify:1;
957952
__u8 tc_at_ingress:1; /* See TC_AT_INGRESS_MASK */
953+
__u8 tc_skip_classify:1;
958954
#endif
955+
__u8 remcsum_offload:1;
956+
__u8 csum_complete_sw:1;
957+
__u8 csum_level:2;
958+
__u8 dst_pending_confirm:1;
959959

960960
__u8 l4_hash:1;
961961
__u8 sw_hash:1;
@@ -1072,11 +1072,11 @@ struct sk_buff {
10721072
* around, you also must adapt these constants.
10731073
*/
10741074
#ifdef __BIG_ENDIAN_BITFIELD
1075-
#define TC_AT_INGRESS_MASK (1 << 0)
1076-
#define SKB_MONO_DELIVERY_TIME_MASK (1 << 2)
1075+
#define SKB_MONO_DELIVERY_TIME_MASK (1 << 7)
1076+
#define TC_AT_INGRESS_MASK (1 << 6)
10771077
#else
1078-
#define TC_AT_INGRESS_MASK (1 << 7)
1079-
#define SKB_MONO_DELIVERY_TIME_MASK (1 << 5)
1078+
#define SKB_MONO_DELIVERY_TIME_MASK (1 << 0)
1079+
#define TC_AT_INGRESS_MASK (1 << 1)
10801080
#endif
10811081
#define SKB_BF_MONO_TC_OFFSET offsetof(struct sk_buff, __mono_tc_offset)
10821082

tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ static struct test_case test_cases[] = {
6969
{
7070
N(SCHED_CLS, struct __sk_buff, tstamp),
7171
.read = "r11 = *(u8 *)($ctx + sk_buff::__mono_tc_offset);"
72-
"w11 &= 160;"
73-
"if w11 != 0xa0 goto pc+2;"
72+
"w11 &= 3;"
73+
"if w11 != 0x3 goto pc+2;"
7474
"$dst = 0;"
7575
"goto pc+1;"
7676
"$dst = *(u64 *)($ctx + sk_buff::tstamp);",
7777
.write = "r11 = *(u8 *)($ctx + sk_buff::__mono_tc_offset);"
78-
"if w11 & 0x80 goto pc+1;"
78+
"if w11 & 0x2 goto pc+1;"
7979
"goto pc+2;"
80-
"w11 &= -33;"
80+
"w11 &= -2;"
8181
"*(u8 *)($ctx + sk_buff::__mono_tc_offset) = r11;"
8282
"*(u64 *)($ctx + sk_buff::tstamp) = $src;",
8383
},

0 commit comments

Comments
 (0)