Skip to content

Commit 04aae21

Browse files
kuba-mooMartin KaFai Lau
authored andcommitted
net: skbuff: rename __pkt_vlan_present_offset to __mono_tc_offset
vlan_present is gone since commit 354259f ("net: remove skb->vlan_present") rename the offset field to what BPF is currently looking for in this byte - mono_delivery_time and tc_at_ingress. 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 01dc26c commit 04aae21

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

include/linux/skbuff.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ struct sk_buff {
955955
__u8 csum_valid:1;
956956

957957
/* private: */
958-
__u8 __pkt_vlan_present_offset[0];
958+
__u8 __mono_tc_offset[0];
959959
/* public: */
960960
__u8 remcsum_offload:1;
961961
__u8 csum_complete_sw:1;
@@ -1078,7 +1078,7 @@ struct sk_buff {
10781078
#define TC_AT_INGRESS_MASK (1 << 7)
10791079
#define SKB_MONO_DELIVERY_TIME_MASK (1 << 5)
10801080
#endif
1081-
#define PKT_VLAN_PRESENT_OFFSET offsetof(struct sk_buff, __pkt_vlan_present_offset)
1081+
#define SKB_BF_MONO_TC_OFFSET offsetof(struct sk_buff, __mono_tc_offset)
10821082

10831083
#ifdef __KERNEL__
10841084
/*

net/core/filter.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9185,7 +9185,7 @@ static struct bpf_insn *bpf_convert_tstamp_type_read(const struct bpf_insn *si,
91859185
__u8 tmp_reg = BPF_REG_AX;
91869186

91879187
*insn++ = BPF_LDX_MEM(BPF_B, tmp_reg, skb_reg,
9188-
PKT_VLAN_PRESENT_OFFSET);
9188+
SKB_BF_MONO_TC_OFFSET);
91899189
*insn++ = BPF_JMP32_IMM(BPF_JSET, tmp_reg,
91909190
SKB_MONO_DELIVERY_TIME_MASK, 2);
91919191
*insn++ = BPF_MOV32_IMM(value_reg, BPF_SKB_TSTAMP_UNSPEC);
@@ -9232,7 +9232,7 @@ static struct bpf_insn *bpf_convert_tstamp_read(const struct bpf_prog *prog,
92329232
/* AX is needed because src_reg and dst_reg could be the same */
92339233
__u8 tmp_reg = BPF_REG_AX;
92349234

9235-
*insn++ = BPF_LDX_MEM(BPF_B, tmp_reg, skb_reg, PKT_VLAN_PRESENT_OFFSET);
9235+
*insn++ = BPF_LDX_MEM(BPF_B, tmp_reg, skb_reg, SKB_BF_MONO_TC_OFFSET);
92369236
*insn++ = BPF_ALU32_IMM(BPF_AND, tmp_reg,
92379237
TC_AT_INGRESS_MASK | SKB_MONO_DELIVERY_TIME_MASK);
92389238
*insn++ = BPF_JMP32_IMM(BPF_JNE, tmp_reg,
@@ -9267,14 +9267,14 @@ static struct bpf_insn *bpf_convert_tstamp_write(const struct bpf_prog *prog,
92679267
if (!prog->tstamp_type_access) {
92689268
__u8 tmp_reg = BPF_REG_AX;
92699269

9270-
*insn++ = BPF_LDX_MEM(BPF_B, tmp_reg, skb_reg, PKT_VLAN_PRESENT_OFFSET);
9270+
*insn++ = BPF_LDX_MEM(BPF_B, tmp_reg, skb_reg, SKB_BF_MONO_TC_OFFSET);
92719271
/* Writing __sk_buff->tstamp as ingress, goto <clear> */
92729272
*insn++ = BPF_JMP32_IMM(BPF_JSET, tmp_reg, TC_AT_INGRESS_MASK, 1);
92739273
/* goto <store> */
92749274
*insn++ = BPF_JMP_A(2);
92759275
/* <clear>: mono_delivery_time */
92769276
*insn++ = BPF_ALU32_IMM(BPF_AND, tmp_reg, ~SKB_MONO_DELIVERY_TIME_MASK);
9277-
*insn++ = BPF_STX_MEM(BPF_B, skb_reg, tmp_reg, PKT_VLAN_PRESENT_OFFSET);
9277+
*insn++ = BPF_STX_MEM(BPF_B, skb_reg, tmp_reg, SKB_BF_MONO_TC_OFFSET);
92789278
}
92799279
#endif
92809280

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,17 @@ static struct test_case test_cases[] = {
6868
#if defined(__x86_64__) || defined(__aarch64__)
6969
{
7070
N(SCHED_CLS, struct __sk_buff, tstamp),
71-
.read = "r11 = *(u8 *)($ctx + sk_buff::__pkt_vlan_present_offset);"
71+
.read = "r11 = *(u8 *)($ctx + sk_buff::__mono_tc_offset);"
7272
"w11 &= 160;"
7373
"if w11 != 0xa0 goto pc+2;"
7474
"$dst = 0;"
7575
"goto pc+1;"
7676
"$dst = *(u64 *)($ctx + sk_buff::tstamp);",
77-
.write = "r11 = *(u8 *)($ctx + sk_buff::__pkt_vlan_present_offset);"
77+
.write = "r11 = *(u8 *)($ctx + sk_buff::__mono_tc_offset);"
7878
"if w11 & 0x80 goto pc+1;"
7979
"goto pc+2;"
8080
"w11 &= -33;"
81-
"*(u8 *)($ctx + sk_buff::__pkt_vlan_present_offset) = r11;"
81+
"*(u8 *)($ctx + sk_buff::__mono_tc_offset) = r11;"
8282
"*(u64 *)($ctx + sk_buff::tstamp) = $src;",
8383
},
8484
#endif

0 commit comments

Comments
 (0)