root/tools/testing/selftests/bpf/progs/test_core_reloc_arrays.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 struct core_reloc_arrays_output {
  16         int a2;
  17         char b123;
  18         int c1c;
  19         int d00d;
  20 };
  21 
  22 struct core_reloc_arrays_substruct {
  23         int c;
  24         int d;
  25 };
  26 
  27 struct core_reloc_arrays {
  28         int a[5];
  29         char b[2][3][4];
  30         struct core_reloc_arrays_substruct c[3];
  31         struct core_reloc_arrays_substruct d[1][2];
  32 };
  33 
  34 SEC("raw_tracepoint/sys_enter")
  35 int test_core_arrays(void *ctx)
  36 {
  37         struct core_reloc_arrays *in = (void *)&data.in;
  38         struct core_reloc_arrays_output *out = (void *)&data.out;
  39 
  40         /* in->a[2] */
  41         if (BPF_CORE_READ(&out->a2, &in->a[2]))
  42                 return 1;
  43         /* in->b[1][2][3] */
  44         if (BPF_CORE_READ(&out->b123, &in->b[1][2][3]))
  45                 return 1;
  46         /* in->c[1].c */
  47         if (BPF_CORE_READ(&out->c1c, &in->c[1].c))
  48                 return 1;
  49         /* in->d[0][0].d */
  50         if (BPF_CORE_READ(&out->d00d, &in->d[0][0].d))
  51                 return 1;
  52 
  53         return 0;
  54 }
  55 

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