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 BPF_PROG_ARRAY(jmp_tc, JMP_MAP_ID, PIN_OBJECT_NS, 1); 10 11 __section_tail(JMP_MAP_ID, 0) 12 int cls_loop(struct __sk_buff *skb) 13 { 14 char fmt[] = "cb: %u\n"; 15 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; 21 } 22 23 __section_cls_entry 24 int cls_entry(struct __sk_buff *skb) 25 { 26 tail_call(skb, &jmp_tc, 0); 27 return TC_ACT_SHOT; 28 } 29 30 BPF_LICENSE("GPL"); 31