root/tools/testing/selftests/bpf/progs/test_core_reloc_primitives.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. SEC

   1 // SPDX-License-Identifier: GPL-2.0
   2 // Copyright (c) 2019 Facebook
   3 
   4 #include <linux/bpf.h>
   5 #include <stdint.h>
   6 #include "bpf_helpers.h"
   7 
   8 char _license[] SEC("license") = "GPL";
   9 
  10 static volatile struct data {
  11         char in[256];
  12         char out[256];
  13 } data;
  14 
  15 enum core_reloc_primitives_enum {
  16         A = 0,
  17         B = 1,
  18 };
  19 
  20 struct core_reloc_primitives {
  21         char a;
  22         int b;
  23         enum core_reloc_primitives_enum c;
  24         void *d;
  25         int (*f)(const char *);
  26 };
  27 
  28 SEC("raw_tracepoint/sys_enter")
  29 int test_core_primitives(void *ctx)
  30 {
  31         struct core_reloc_primitives *in = (void *)&data.in;
  32         struct core_reloc_primitives *out = (void *)&data.out;
  33 
  34         if (BPF_CORE_READ(&out->a, &in->a) ||
  35             BPF_CORE_READ(&out->b, &in->b) ||
  36             BPF_CORE_READ(&out->c, &in->c) ||
  37             BPF_CORE_READ(&out->d, &in->d) ||
  38             BPF_CORE_READ(&out->f, &in->f))
  39                 return 1;
  40 
  41         return 0;
  42 }
  43 

/* [<][>][^][v][top][bottom][index][help] */