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

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/bpf/prog_tests/reference_tracking.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ 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 <test_progs.h>
  3 
  4 void test_reference_tracking(void)
  5 {
  6         const char *file = "test_sk_lookup_kern.bpf.o";
  7         const char *obj_name = "ref_track";
  8         DECLARE_LIBBPF_OPTS(bpf_object_open_opts, open_opts,
  9                 .object_name = obj_name,
 10                 .relaxed_maps = true,
 11         );
 12         struct bpf_object *obj_iter, *obj = NULL;
 13         struct bpf_program *prog;
 14         __u32 duration = 0;
 15         int err = 0;
 16 
 17         obj_iter = bpf_object__open_file(file, &open_opts);
 18         if (!ASSERT_OK_PTR(obj_iter, "obj_iter_open_file"))
 19                 return;
 20 
 21         if (CHECK(strcmp(bpf_object__name(obj_iter), obj_name), "obj_name",
 22                   "wrong obj name '%s', expected '%s'\n",
 23                   bpf_object__name(obj_iter), obj_name))
 24                 goto cleanup;
 25 
 26         bpf_object__for_each_program(prog, obj_iter) {
 27                 struct bpf_program *p;
 28                 const char *name;
 29 
 30                 name = bpf_program__name(prog);
 31                 if (!test__start_subtest(name))
 32                         continue;
 33 
 34                 obj = bpf_object__open_file(file, &open_opts);
 35                 if (!ASSERT_OK_PTR(obj, "obj_open_file"))
 36                         goto cleanup;
 37 
 38                 /* all programs are not loaded by default, so just set
 39                  * autoload to true for the single prog under test
 40                  */
 41                 p = bpf_object__find_program_by_name(obj, name);
 42                 bpf_program__set_autoload(p, true);
 43 
 44                 /* Expect verifier failure if test name has 'err' */
 45                 if (strncmp(name, "err_", sizeof("err_") - 1) == 0) {
 46                         libbpf_print_fn_t old_print_fn;
 47 
 48                         old_print_fn = libbpf_set_print(NULL);
 49                         err = !bpf_object__load(obj);
 50                         libbpf_set_print(old_print_fn);
 51                 } else {
 52                         err = bpf_object__load(obj);
 53                 }
 54                 ASSERT_OK(err, name);
 55 
 56                 bpf_object__close(obj);
 57                 obj = NULL;
 58         }
 59 
 60 cleanup:
 61         bpf_object__close(obj);
 62         bpf_object__close(obj_iter);
 63 }
 64 

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