Skip to content

Commit 754f1e6

Browse files
borkmanndavem330
authored andcommitted
sched, bpf: make skb->priority writable
{cls,act}_bpf can now set the skb->priority from an eBPF program based on various critera, so that for example classful qdiscs like multiq can update the skb's priority during enqueue time and further push it down into subsequent qdiscs. Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Alexei Starovoitov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c46646d commit 754f1e6

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

net/core/filter.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1721,6 +1721,7 @@ static bool tc_cls_act_is_valid_access(int off, int size,
17211721
switch (off) {
17221722
case offsetof(struct __sk_buff, mark):
17231723
case offsetof(struct __sk_buff, tc_index):
1724+
case offsetof(struct __sk_buff, priority):
17241725
case offsetof(struct __sk_buff, cb[0]) ...
17251726
offsetof(struct __sk_buff, cb[4]):
17261727
break;
@@ -1762,8 +1763,12 @@ static u32 bpf_net_convert_ctx_access(enum bpf_access_type type, int dst_reg,
17621763
case offsetof(struct __sk_buff, priority):
17631764
BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, priority) != 4);
17641765

1765-
*insn++ = BPF_LDX_MEM(BPF_W, dst_reg, src_reg,
1766-
offsetof(struct sk_buff, priority));
1766+
if (type == BPF_WRITE)
1767+
*insn++ = BPF_STX_MEM(BPF_W, dst_reg, src_reg,
1768+
offsetof(struct sk_buff, priority));
1769+
else
1770+
*insn++ = BPF_LDX_MEM(BPF_W, dst_reg, src_reg,
1771+
offsetof(struct sk_buff, priority));
17671772
break;
17681773

17691774
case offsetof(struct __sk_buff, ingress_ifindex):

0 commit comments

Comments
 (0)