Skip to content

Commit bcad571

Browse files
borkmanndavem330
authored andcommitted
ebpf: add skb->priority to offset map for usage in {cls, act}_bpf
This adds the ability to read out the skb->priority from an eBPF program, so that it can be taken into account from a tc filter or action for the use-case where the priority is not being used to directly override the filter classification in a qdisc, but to tag traffic otherwise for the classifier; the priority can be assigned from various places incl. user space, in future we may also mangle it from an eBPF program. Signed-off-by: Daniel Borkmann <[email protected]> Cc: Alexei Starovoitov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2e7056c commit bcad571

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

include/uapi/linux/bpf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ struct __sk_buff {
184184
__u32 vlan_present;
185185
__u32 vlan_tci;
186186
__u32 vlan_proto;
187+
__u32 priority;
187188
};
188189

189190
#endif /* _UAPI__LINUX_BPF_H__ */

net/core/filter.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,6 +1304,13 @@ static u32 sk_filter_convert_ctx_access(int dst_reg, int src_reg, int ctx_off,
13041304
offsetof(struct sk_buff, vlan_proto));
13051305
break;
13061306

1307+
case offsetof(struct __sk_buff, priority):
1308+
BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, priority) != 4);
1309+
1310+
*insn++ = BPF_LDX_MEM(BPF_W, dst_reg, src_reg,
1311+
offsetof(struct sk_buff, priority));
1312+
break;
1313+
13071314
case offsetof(struct __sk_buff, mark):
13081315
return convert_skb_access(SKF_AD_MARK, dst_reg, src_reg, insn);
13091316

0 commit comments

Comments
 (0)