Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <daniel@iogearbox.net>
Cc: Alexei Starovoitov <ast@plumgrid.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Daniel Borkmann and committed by
David S. Miller
bcad5718 2e7056c4

+8
+1
include/uapi/linux/bpf.h
··· 184 184 __u32 vlan_present; 185 185 __u32 vlan_tci; 186 186 __u32 vlan_proto; 187 + __u32 priority; 187 188 }; 188 189 189 190 #endif /* _UAPI__LINUX_BPF_H__ */
+7
net/core/filter.c
··· 1304 1304 offsetof(struct sk_buff, vlan_proto)); 1305 1305 break; 1306 1306 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 + 1307 1314 case offsetof(struct __sk_buff, mark): 1308 1315 return convert_skb_access(SKF_AD_MARK, dst_reg, src_reg, insn); 1309 1316