linux/tools/testing/selftests/bpf/progs/test_skeleton.c
<<
>>
Prefs
   1// SPDX-License-Identifier: GPL-2.0
   2/* Copyright (c) 2019 Facebook */
   3
   4#include <stdbool.h>
   5#include <linux/bpf.h>
   6#include <bpf/bpf_helpers.h>
   7
   8struct s {
   9        int a;
  10        long long b;
  11} __attribute__((packed));
  12
  13/* .data section */
  14int in1 = -1;
  15long long in2 = -1;
  16
  17/* .bss section */
  18char in3 = '\0';
  19long long in4 __attribute__((aligned(64))) = 0;
  20struct s in5 = {};
  21
  22/* .rodata section */
  23const volatile struct {
  24        const int in6;
  25} in = {};
  26
  27/* .data section */
  28int out1 = -1;
  29long long out2 = -1;
  30
  31/* .bss section */
  32char out3 = 0;
  33long long out4 = 0;
  34int out6 = 0;
  35
  36extern bool CONFIG_BPF_SYSCALL __kconfig;
  37extern int LINUX_KERNEL_VERSION __kconfig;
  38bool bpf_syscall = 0;
  39int kern_ver = 0;
  40
  41SEC("raw_tp/sys_enter")
  42int handler(const void *ctx)
  43{
  44        static volatile struct s out5;
  45
  46        out1 = in1;
  47        out2 = in2;
  48        out3 = in3;
  49        out4 = in4;
  50        out5 = in5;
  51        out6 = in.in6;
  52
  53        bpf_syscall = CONFIG_BPF_SYSCALL;
  54        kern_ver = LINUX_KERNEL_VERSION;
  55
  56        return 0;
  57}
  58
  59char _license[] SEC("license") = "GPL";
  60