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

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/bpf/prog_tests/signal_pending.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 <test_progs.h>
  3 #include <network_helpers.h>
  4 
  5 static void sigalrm_handler(int s) {}
  6 static struct sigaction sigalrm_action = {
  7         .sa_handler = sigalrm_handler,
  8 };
  9 
 10 static void test_signal_pending_by_type(enum bpf_prog_type prog_type)
 11 {
 12         struct bpf_insn prog[4096];
 13         struct itimerval timeo = {
 14                 .it_value.tv_usec = 100000, /* 100ms */
 15         };
 16         int prog_fd;
 17         int err;
 18         int i;
 19         LIBBPF_OPTS(bpf_test_run_opts, topts,
 20                 .data_in = &pkt_v4,
 21                 .data_size_in = sizeof(pkt_v4),
 22                 .repeat = 0xffffffff,
 23         );
 24 
 25         for (i = 0; i < ARRAY_SIZE(prog); i++)
 26                 prog[i] = BPF_ALU64_IMM(BPF_MOV, BPF_REG_0, 0);
 27         prog[ARRAY_SIZE(prog) - 1] = BPF_EXIT_INSN();
 28 
 29         prog_fd = bpf_test_load_program(prog_type, prog, ARRAY_SIZE(prog),
 30                                    "GPL", 0, NULL, 0);
 31         ASSERT_GE(prog_fd, 0, "test-run load");
 32 
 33         err = sigaction(SIGALRM, &sigalrm_action, NULL);
 34         ASSERT_OK(err, "test-run-signal-sigaction");
 35 
 36         err = setitimer(ITIMER_REAL, &timeo, NULL);
 37         ASSERT_OK(err, "test-run-signal-timer");
 38 
 39         err = bpf_prog_test_run_opts(prog_fd, &topts);
 40         ASSERT_LE(topts.duration, 500000000 /* 500ms */,
 41                   "test-run-signal-duration");
 42 
 43         signal(SIGALRM, SIG_DFL);
 44 }
 45 
 46 void test_signal_pending(void)
 47 {
 48         test_signal_pending_by_type(BPF_PROG_TYPE_SOCKET_FILTER);
 49         test_signal_pending_by_type(BPF_PROG_TYPE_FLOW_DISSECTOR);
 50 }
 51 

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