~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/bpf/progs/test_xdp_bpf2bpf.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 #include <linux/bpf.h>
  3 #include <bpf/bpf_tracing.h>
  4 #include <bpf/bpf_helpers.h>
  5 
  6 char _license[] SEC("license") = "GPL";
  7 
  8 struct net_device {
  9         /* Structure does not need to contain all entries,
 10          * as "preserve_access_index" will use BTF to fix this...
 11          */
 12         int ifindex;
 13 } __attribute__((preserve_access_index));
 14 
 15 struct xdp_rxq_info {
 16         /* Structure does not need to contain all entries,
 17          * as "preserve_access_index" will use BTF to fix this...
 18          */
 19         struct net_device *dev;
 20         __u32 queue_index;
 21 } __attribute__((preserve_access_index));
 22 
 23 struct xdp_buff {
 24         void *data;
 25         void *data_end;
 26         void *data_meta;
 27         void *data_hard_start;
 28         unsigned long handle;
 29         struct xdp_rxq_info *rxq;
 30 } __attribute__((preserve_access_index));
 31 
 32 struct meta {
 33         int ifindex;
 34         int pkt_len;
 35 };
 36 
 37 struct {
 38         __uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY);
 39         __type(key, int);
 40         __type(value, int);
 41 } perf_buf_map SEC(".maps");
 42 
 43 __u64 test_result_fentry = 0;
 44 SEC("fentry/FUNC")
 45 int BPF_PROG(trace_on_entry, struct xdp_buff *xdp)
 46 {
 47         struct meta meta;
 48 
 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) |
 53                        BPF_F_CURRENT_CPU,
 54                        &meta, sizeof(meta));
 55 
 56         test_result_fentry = xdp->rxq->dev->ifindex;
 57         return 0;
 58 }
 59 
 60 __u64 test_result_fexit = 0;
 61 SEC("fexit/FUNC")
 62 int BPF_PROG(trace_on_exit, struct xdp_buff *xdp, int ret)
 63 {
 64         test_result_fexit = ret;
 65         return 0;
 66 }
 67 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php