linux/tools/testing/selftests/bpf/progs/test_core_reloc_nesting.c
<<
>>
Prefs
   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/bpf_helpers.h>
   7#include <bpf/bpf_core_read.h>
   8
   9char _license[] SEC("license") = "GPL";
  10
  11struct {
  12        char in[256];
  13        char out[256];
  14} data = {};
  15
  16struct core_reloc_nesting_substruct {
  17        int a;
  18};
  19
  20union core_reloc_nesting_subunion {
  21        int b;
  22};
  23
  24/* int a.a.a and b.b.b accesses */
  25struct core_reloc_nesting {
  26        union {
  27                struct core_reloc_nesting_substruct a;
  28        } a;
  29        struct {
  30                union core_reloc_nesting_subunion b;
  31        } b;
  32};
  33
  34#define CORE_READ(dst, src) bpf_core_read(dst, sizeof(*(dst)), src)
  35
  36SEC("raw_tracepoint/sys_enter")
  37int test_core_nesting(void *ctx)
  38{
  39        struct core_reloc_nesting *in = (void *)&data.in;
  40        struct core_reloc_nesting *out = (void *)&data.out;
  41
  42        if (CORE_READ(&out->a.a.a, &in->a.a.a))
  43                return 1;
  44        if (CORE_READ(&out->b.b.b, &in->b.b.b))
  45                return 1;
  46
  47        return 0;
  48}
  49
  50
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.