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

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/bpf/prog_tests/fexit_stress.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 /* Copyright (c) 2019 Facebook */
  3 #include <test_progs.h>
  4 
  5 void serial_test_fexit_stress(void)
  6 {
  7         int bpf_max_tramp_links, err, i;
  8         int *fd, *fexit_fd, *link_fd;
  9 
 10         bpf_max_tramp_links = get_bpf_max_tramp_links();
 11         if (!ASSERT_GE(bpf_max_tramp_links, 1, "bpf_max_tramp_links"))
 12                 return;
 13         fd = calloc(bpf_max_tramp_links * 2, sizeof(*fd));
 14         if (!ASSERT_OK_PTR(fd, "fd"))
 15                 return;
 16         fexit_fd = fd;
 17         link_fd = fd + bpf_max_tramp_links;
 18 
 19         const struct bpf_insn trace_program[] = {
 20                 BPF_MOV64_IMM(BPF_REG_0, 0),
 21                 BPF_EXIT_INSN(),
 22         };
 23 
 24         LIBBPF_OPTS(bpf_prog_load_opts, trace_opts,
 25                 .expected_attach_type = BPF_TRACE_FEXIT,
 26         );
 27 
 28         LIBBPF_OPTS(bpf_test_run_opts, topts);
 29 
 30         err = libbpf_find_vmlinux_btf_id("bpf_fentry_test1",
 31                                          trace_opts.expected_attach_type);
 32         if (!ASSERT_GT(err, 0, "find_vmlinux_btf_id"))
 33                 goto out;
 34         trace_opts.attach_btf_id = err;
 35 
 36         for (i = 0; i < bpf_max_tramp_links; i++) {
 37                 fexit_fd[i] = bpf_prog_load(BPF_PROG_TYPE_TRACING, NULL, "GPL",
 38                                             trace_program,
 39                                             sizeof(trace_program) / sizeof(struct bpf_insn),
 40                                             &trace_opts);
 41                 if (!ASSERT_GE(fexit_fd[i], 0, "fexit load"))
 42                         goto out;
 43                 link_fd[i] = bpf_link_create(fexit_fd[i], 0, BPF_TRACE_FEXIT, NULL);
 44                 if (!ASSERT_GE(link_fd[i], 0, "fexit attach"))
 45                         goto out;
 46         }
 47 
 48         err = bpf_prog_test_run_opts(fexit_fd[0], &topts);
 49         ASSERT_OK(err, "bpf_prog_test_run_opts");
 50 
 51 out:
 52         for (i = 0; i < bpf_max_tramp_links; i++) {
 53                 if (link_fd[i] > 0)
 54                         close(link_fd[i]);
 55                 if (fexit_fd[i] > 0)
 56                         close(fexit_fd[i]);
 57         }
 58         free(fd);
 59 }
 60 

~ [ 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