]>
Commit | Line | Data |
---|---|---|
41d6e33f | 1 | #include "../../include/bpf_api.h" |
0b7e3fc8 DB |
2 | |
3 | /* Cyclic dependency example to test the kernel's runtime upper | |
41d6e33f DB |
4 | * bound on loops. Also demonstrates on how to use direct-actions, |
5 | * loaded as: tc filter add [...] bpf da obj [...] | |
0b7e3fc8 | 6 | */ |
41d6e33f DB |
7 | #define JMP_MAP_ID 0xabccba |
8 | ||
9 | BPF_PROG_ARRAY(jmp_tc, JMP_MAP_ID, PIN_OBJECT_NS, 1); | |
0b7e3fc8 | 10 | |
41d6e33f DB |
11 | __section_tail(JMP_MAP_ID, 0) |
12 | int cls_loop(struct __sk_buff *skb) | |
0b7e3fc8 DB |
13 | { |
14 | char fmt[] = "cb: %u\n"; | |
15 | ||
41d6e33f DB |
16 | trace_printk(fmt, sizeof(fmt), skb->cb[0]++); |
17 | tail_call(skb, &jmp_tc, 0); | |
18 | ||
19 | skb->tc_classid = TC_H_MAKE(1, 42); | |
20 | return TC_ACT_OK; | |
0b7e3fc8 DB |
21 | } |
22 | ||
41d6e33f DB |
23 | __section_cls_entry |
24 | int cls_entry(struct __sk_buff *skb) | |
0b7e3fc8 | 25 | { |
41d6e33f DB |
26 | tail_call(skb, &jmp_tc, 0); |
27 | return TC_ACT_SHOT; | |
0b7e3fc8 DB |
28 | } |
29 | ||
41d6e33f | 30 | BPF_LICENSE("GPL"); |