root/tools/testing/selftests/bpf/progs/test_core_reloc_nesting.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_nesting_substruct {
  16         int a;
  17 };
  18 
  19 union core_reloc_nesting_subunion {
  20         int b;
  21 };
  22 
  23 /* int a.a.a and b.b.b accesses */
  24 struct core_reloc_nesting {
  25         union {
  26                 struct core_reloc_nesting_substruct a;
  27         } a;
  28         struct {
  29                 union core_reloc_nesting_subunion b;
  30         } b;
  31 };
  32 
  33 SEC("raw_tracepoint/sys_enter")
  34 int test_core_nesting(void *ctx)
  35 {
  36         struct core_reloc_nesting *in = (void *)&data.in;
  37         struct core_reloc_nesting *out = (void *)&data.out;
  38 
  39         if (BPF_CORE_READ(&out->a.a.a, &in->a.a.a))
  40                 return 1;
  41         if (BPF_CORE_READ(&out->b.b.b, &in->b.b.b))
  42                 return 1;
  43 
  44         return 0;
  45 }
  46 

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