1 // SPDX-License-Identifier: GPL-2.0
3 #include <bpf/bpf_tracing.h>
4 #include <bpf/bpf_helpers.h>
6 char _license[] SEC("license") = "GPL";
9 /* Structure does not need to contain all entries,
10 * as "preserve_access_index" will use BTF to fix this...
13 } __attribute__((preserve_access_index));
16 /* Structure does not need to contain all entries,
17 * as "preserve_access_index" will use BTF to fix this...
19 struct net_device *dev;
21 } __attribute__((preserve_access_index));
27 void *data_hard_start;
29 struct xdp_rxq_info *rxq;
30 } __attribute__((preserve_access_index));
38 __uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY);
41 } perf_buf_map SEC(".maps");
43 __u64 test_result_fentry = 0;
45 int BPF_PROG(trace_on_entry, struct xdp_buff *xdp)
49 meta.ifindex = xdp->rxq->dev->ifindex;
50 meta.pkt_len = bpf_xdp_get_buff_len((struct xdp_md *)xdp);
51 bpf_xdp_output(xdp, &perf_buf_map,
52 ((__u64) meta.pkt_len << 32) |
56 test_result_fentry = xdp->rxq->dev->ifindex;
60 __u64 test_result_fexit = 0;
62 int BPF_PROG(trace_on_exit, struct xdp_buff *xdp, int ret)
64 test_result_fexit = ret;