History

cls_bpf: introduce integrated actions

Often cls_bpf classifier is used with single action drop attached. Optimize this use case and let cls_bpf return both classid and action. For backwards compatibility reasons enable this feature under TCA_BPF_FLAG_ACT_DIRECT flag. Then more interesting programs like the following are easier to write: int cls_bpf_prog(struct __sk_buff *skb) { /* classify arp, ip, ipv6 into different traffic classes * and drop all other packets */ switch (skb->protocol) { case htons(ETH_P_ARP): skb->tc_classid = 1; break; case htons(ETH_P_IP): skb->tc_classid = 2; break; case htons(ETH_P_IPV6): skb->tc_classid = 3; break; default: return TC_ACT_SHOT; } return TC_ACT_OK; } Joint work with Daniel Borkmann.

Daniel Borkmann committed 11 years ago

Commit 045efa81 parent f6c53335 files · +68 −12Browse files

Showing the changes to include/uapi (2 of 5 files). Show all

Unified · Split

2 files
  1. include/uapi/linux/bpf.h +1 −0
  2. include/uapi/linux/pkt_cls.h +3 −0
include/uapi/linux/bpf.h+1−0
@@ -293,6 +293,7 @@ struct __sk_buff { · 292 unmodified lines
293293 __u32 tc_index;
294294 __u32 cb[5];
295295 __u32 hash;
296+ __u32 tc_classid;
296297 };
297298
298299 struct bpf_tunnel_key {
include/uapi/linux/pkt_cls.h+3−0
@@ -373,6 +373,8 @@ enum { · 372 unmodified lines
373373
374374 /* BPF classifier */
375375
376+#define TCA_BPF_FLAG_ACT_DIRECT (1 << 0)
377+
376378 enum {
377379 TCA_BPF_UNSPEC,
378380 TCA_BPF_ACT,
@@ -382,6 +384,7 @@ enum { · 3 unmodified lines
382384 TCA_BPF_OPS,
383385 TCA_BPF_FD,
384386 TCA_BPF_NAME,
387+ TCA_BPF_FLAGS,
385388 __TCA_BPF_MAX,
386389 };
387390

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t