linux/tools/testing/selftests/bpf/progs/test_core_reloc_ptr_as_arr.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_ptr_as_arr {
  17        int a;
  18};
  19
  20#define CORE_READ(dst, src) bpf_core_read(dst, sizeof(*(dst)), src)
  21
  22SEC("raw_tracepoint/sys_enter")
  23int test_core_ptr_as_arr(void *ctx)
  24{
  25        struct core_reloc_ptr_as_arr *in = (void *)&data.in;
  26        struct core_reloc_ptr_as_arr *out = (void *)&data.out;
  27
  28        if (CORE_READ(&out->a, &in[2].a))
  29                return 1;
  30
  31        return 0;
  32}
  33
  34
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.