1 #include "vmlinux.h" 2 #include <bpf/bpf_helpers.h> 3 4 #define NF_ACCEPT 1 5 6 struct { 7 __uint(type, BPF_MAP_TYPE_RINGBUF); 8 __uint(max_entries, 4096 /* one page */); 9 } ringbuf SEC(".maps"); 10 11 SEC("netfilter") handle_netfilter(struct bpf_nf_ctx * ctx)12int handle_netfilter(struct bpf_nf_ctx *ctx) { 13 14 int *value; 15 16 value = bpf_ringbuf_reserve(&ringbuf, sizeof(int), 0); 17 if (!value) { 18 bpf_printk("handle_netfilter: failed to reserve ring buffer space"); 19 return 1; 20 } 21 22 *value = 1; 23 bpf_ringbuf_submit(value, 0); 24 25 bpf_printk("handle_netfilter: submitted ringbuf value"); 26 return NF_ACCEPT; 27 } 28 29 char LICENSE[] SEC("license") = "GPL"; 30