summaryrefslogtreecommitdiff
path: root/net/core
diff options
context:
space:
mode:
authorDaniel Borkmann <daniel@iogearbox.net>2015-09-29 23:41:52 (GMT)
committerDavid S. Miller <davem@davemloft.net>2015-10-03 12:02:41 (GMT)
commit754f1e6a36c9b42525de223ee1ba628dcafbad41 (patch)
tree4e7003c31ee7623c1119a4fd21fac007766e9259 /net/core
parentc46646d0484f5d08e2bede9b45034ba5b8b489cc (diff)
downloadlinux-754f1e6a36c9b42525de223ee1ba628dcafbad41.tar.xz
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 <daniel@iogearbox.net> Acked-by: Alexei Starovoitov <ast@plumgrid.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/filter.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/net/core/filter.c b/net/core/filter.c
index 45c69ce..53a5036 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -1721,6 +1721,7 @@ static bool tc_cls_act_is_valid_access(int off, int size,
switch (off) {
case offsetof(struct __sk_buff, mark):
case offsetof(struct __sk_buff, tc_index):
+ case offsetof(struct __sk_buff, priority):
case offsetof(struct __sk_buff, cb[0]) ...
offsetof(struct __sk_buff, cb[4]):
break;
@@ -1762,8 +1763,12 @@ static u32 bpf_net_convert_ctx_access(enum bpf_access_type type, int dst_reg,
case offsetof(struct __sk_buff, priority):
BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, priority) != 4);
- *insn++ = BPF_LDX_MEM(BPF_W, dst_reg, src_reg,
- offsetof(struct sk_buff, priority));
+ if (type == BPF_WRITE)
+ *insn++ = BPF_STX_MEM(BPF_W, dst_reg, src_reg,
+ offsetof(struct sk_buff, priority));
+ else
+ *insn++ = BPF_LDX_MEM(BPF_W, dst_reg, src_reg,
+ offsetof(struct sk_buff, priority));
break;
case offsetof(struct __sk_buff, ingress_ifindex):