aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Borkmann <daniel@iogearbox.net>2015-04-03 14:52:24 -0400
committerDavid S. Miller <davem@davemloft.net>2015-04-03 14:59:15 -0400
commitbcad57182425426dd4aa14deb27f97acb329f3cd (patch)
treed534fef01490769c56a9246f9cf07dd681f0ecbe
parent2e7056c433216f406b90a003aa0ba42e19d3bdcf (diff)
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>
-rw-r--r--include/uapi/linux/bpf.h1
-rw-r--r--net/core/filter.c7
2 files changed, 8 insertions, 0 deletions
diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
index 74aab6e0d964..0db8580f3cca 100644
--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -184,6 +184,7 @@ struct __sk_buff {
184 __u32 vlan_present; 184 __u32 vlan_present;
185 __u32 vlan_tci; 185 __u32 vlan_tci;
186 __u32 vlan_proto; 186 __u32 vlan_proto;
187 __u32 priority;
187}; 188};
188 189
189#endif /* _UAPI__LINUX_BPF_H__ */ 190#endif /* _UAPI__LINUX_BPF_H__ */
diff --git a/net/core/filter.c b/net/core/filter.c
index 444a07e4f68d..955a7d77decd 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -1304,6 +1304,13 @@ static u32 sk_filter_convert_ctx_access(int dst_reg, int src_reg, int ctx_off,
1304 offsetof(struct sk_buff, vlan_proto)); 1304 offsetof(struct sk_buff, vlan_proto));
1305 break; 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 case offsetof(struct __sk_buff, mark): 1314 case offsetof(struct __sk_buff, mark):
1308 return convert_skb_access(SKF_AD_MARK, dst_reg, src_reg, insn); 1315 return convert_skb_access(SKF_AD_MARK, dst_reg, src_reg, insn);
1309 1316