linux/tools/testing/selftests/bpf/progs/test_core_reloc_ints.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_ints {
  17        uint8_t         u8_field;
  18        int8_t          s8_field;
  19        uint16_t        u16_field;
  20        int16_t         s16_field;
  21        uint32_t        u32_field;
  22        int32_t         s32_field;
  23        uint64_t        u64_field;
  24        int64_t         s64_field;
  25};
  26
  27#define CORE_READ(dst, src) bpf_core_read(dst, sizeof(*(dst)), src)
  28
  29SEC("raw_tracepoint/sys_enter")
  30int test_core_ints(void *ctx)
  31{
  32        struct core_reloc_ints *in = (void *)&data.in;
  33        struct core_reloc_ints *out = (void *)&data.out;
  34
  35        if (CORE_READ(&out->u8_field, &in->u8_field) ||
  36            CORE_READ(&out->s8_field, &in->s8_field) ||
  37            CORE_READ(&out->u16_field, &in->u16_field) ||
  38            CORE_READ(&out->s16_field, &in->s16_field) ||
  39            CORE_READ(&out->u32_field, &in->u32_field) ||
  40            CORE_READ(&out->s32_field, &in->s32_field) ||
  41            CORE_READ(&out->u64_field, &in->u64_field) ||
  42            CORE_READ(&out->s64_field, &in->s64_field))
  43                return 1;
  44
  45        return 0;
  46}
  47
  48
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.