Commit c0ba8611 authored by Jakub Kicinski's avatar Jakub Kicinski Committed by Martin KaFai Lau

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: default avatarJakub Kicinski <kuba@kernel.org>
Link: https://lore.kernel.org/r/20230321014115.997841-4-kuba@kernel.orgSigned-off-by: default avatarMartin KaFai Lau <martin.lau@kernel.org>
parent b94e032b
...@@ -947,15 +947,15 @@ struct sk_buff { ...@@ -947,15 +947,15 @@ struct sk_buff {
/* private: */ /* private: */
__u8 __mono_tc_offset[0]; __u8 __mono_tc_offset[0];
/* public: */ /* public: */
__u8 remcsum_offload:1;
__u8 csum_complete_sw:1;
__u8 csum_level:2;
__u8 dst_pending_confirm:1;
__u8 mono_delivery_time:1; /* See SKB_MONO_DELIVERY_TIME_MASK */ __u8 mono_delivery_time:1; /* See SKB_MONO_DELIVERY_TIME_MASK */
#ifdef CONFIG_NET_CLS_ACT #ifdef CONFIG_NET_CLS_ACT
__u8 tc_skip_classify:1;
__u8 tc_at_ingress:1; /* See TC_AT_INGRESS_MASK */ __u8 tc_at_ingress:1; /* See TC_AT_INGRESS_MASK */
__u8 tc_skip_classify:1;
#endif #endif
__u8 remcsum_offload:1;
__u8 csum_complete_sw:1;
__u8 csum_level:2;
__u8 dst_pending_confirm:1;
__u8 l4_hash:1; __u8 l4_hash:1;
__u8 sw_hash:1; __u8 sw_hash:1;
...@@ -1072,11 +1072,11 @@ struct sk_buff { ...@@ -1072,11 +1072,11 @@ struct sk_buff {
* around, you also must adapt these constants. * around, you also must adapt these constants.
*/ */
#ifdef __BIG_ENDIAN_BITFIELD #ifdef __BIG_ENDIAN_BITFIELD
#define TC_AT_INGRESS_MASK (1 << 0) #define SKB_MONO_DELIVERY_TIME_MASK (1 << 7)
#define SKB_MONO_DELIVERY_TIME_MASK (1 << 2) #define TC_AT_INGRESS_MASK (1 << 6)
#else #else
#define TC_AT_INGRESS_MASK (1 << 7) #define SKB_MONO_DELIVERY_TIME_MASK (1 << 0)
#define SKB_MONO_DELIVERY_TIME_MASK (1 << 5) #define TC_AT_INGRESS_MASK (1 << 1)
#endif #endif
#define SKB_BF_MONO_TC_OFFSET offsetof(struct sk_buff, __mono_tc_offset) #define SKB_BF_MONO_TC_OFFSET offsetof(struct sk_buff, __mono_tc_offset)
......
...@@ -69,15 +69,15 @@ static struct test_case test_cases[] = { ...@@ -69,15 +69,15 @@ static struct test_case test_cases[] = {
{ {
N(SCHED_CLS, struct __sk_buff, tstamp), N(SCHED_CLS, struct __sk_buff, tstamp),
.read = "r11 = *(u8 *)($ctx + sk_buff::__mono_tc_offset);" .read = "r11 = *(u8 *)($ctx + sk_buff::__mono_tc_offset);"
"w11 &= 160;" "w11 &= 3;"
"if w11 != 0xa0 goto pc+2;" "if w11 != 0x3 goto pc+2;"
"$dst = 0;" "$dst = 0;"
"goto pc+1;" "goto pc+1;"
"$dst = *(u64 *)($ctx + sk_buff::tstamp);", "$dst = *(u64 *)($ctx + sk_buff::tstamp);",
.write = "r11 = *(u8 *)($ctx + sk_buff::__mono_tc_offset);" .write = "r11 = *(u8 *)($ctx + sk_buff::__mono_tc_offset);"
"if w11 & 0x80 goto pc+1;" "if w11 & 0x2 goto pc+1;"
"goto pc+2;" "goto pc+2;"
"w11 &= -33;" "w11 &= -2;"
"*(u8 *)($ctx + sk_buff::__mono_tc_offset) = r11;" "*(u8 *)($ctx + sk_buff::__mono_tc_offset) = r11;"
"*(u64 *)($ctx + sk_buff::tstamp) = $src;", "*(u64 *)($ctx + sk_buff::tstamp) = $src;",
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment