This source file includes following definitions.
- SEC
1
2
3
4
5
6
7 #include <linux/skbuff.h>
8 #include <linux/netdevice.h>
9 #include <uapi/linux/bpf.h>
10 #include <linux/version.h>
11 #include "bpf_helpers.h"
12
13 #define _(P) ({typeof(P) val = 0; bpf_probe_read(&val, sizeof(val), &P); val;})
14
15
16
17
18
19
20 SEC("kprobe/__netif_receive_skb_core")
21 int bpf_prog1(struct pt_regs *ctx)
22 {
23
24
25
26 char devname[IFNAMSIZ];
27 struct net_device *dev;
28 struct sk_buff *skb;
29 int len;
30
31
32 skb = (struct sk_buff *) PT_REGS_PARM1(ctx);
33 dev = _(skb->dev);
34 len = _(skb->len);
35
36 bpf_probe_read(devname, sizeof(devname), dev->name);
37
38 if (devname[0] == 'l' && devname[1] == 'o') {
39 char fmt[] = "skb %p len %d\n";
40
41 bpf_trace_printk(fmt, sizeof(fmt), skb, len);
42 }
43
44 return 0;
45 }
46
47 char _license[] SEC("license") = "GPL";
48 u32 _version SEC("version") = LINUX_VERSION_CODE;