1 #include "../../include/bpf_api.h"
2
3 /* Cyclic dependency example to test the kernel's runtime upper
4 * bound on loops. Also demonstrates on how to use direct-actions,
5 * loaded as: tc filter add [...] bpf da obj [...]
6 */
7 #define JMP_MAP_ID 0xabccba
8
9 struct bpf_elf_map __section_maps jmp_tc = {
10 .type = BPF_MAP_TYPE_PROG_ARRAY,
11 .id = JMP_MAP_ID,
12 .size_key = sizeof(uint32_t),
13 .size_value = sizeof(uint32_t),
14 .pinning = PIN_OBJECT_NS,
15 .max_elem = 1,
16 };
17
18 __section_tail(JMP_MAP_ID, 0)
cls_loop(struct __sk_buff * skb)19 int cls_loop(struct __sk_buff *skb)
20 {
21 printt("cb: %u\n", skb->cb[0]++);
22 tail_call(skb, &jmp_tc, 0);
23
24 skb->tc_classid = TC_H_MAKE(1, 42);
25 return TC_ACT_OK;
26 }
27
28 __section_cls_entry
cls_entry(struct __sk_buff * skb)29 int cls_entry(struct __sk_buff *skb)
30 {
31 tail_call(skb, &jmp_tc, 0);
32 return TC_ACT_SHOT;
33 }
34
35 BPF_LICENSE("GPL");
36