ebpf/
maps.rs

1// Copyright 2024 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5use bitflags::bitflags;
6use linux_uapi::bpf_map_type;
7
8bitflags! {
9    #[derive(Debug, Clone, Copy, PartialEq, Eq)]
10    pub struct MapFlags: u32 {
11        const NoPrealloc = linux_uapi::BPF_F_NO_PREALLOC;
12        const NoCommonLru = linux_uapi::BPF_F_NO_COMMON_LRU;
13        const NumaNode = linux_uapi::BPF_F_NUMA_NODE;
14        const SyscallReadOnly = linux_uapi::BPF_F_RDONLY;
15        const SyscallWriteOnly = linux_uapi::BPF_F_WRONLY;
16        const StackBuildId = linux_uapi::BPF_F_STACK_BUILD_ID;
17        const ZeroSeed = linux_uapi::BPF_F_ZERO_SEED;
18        const ProgReadOnly = linux_uapi::BPF_F_RDONLY_PROG;
19        const ProgWriteOnly = linux_uapi::BPF_F_WRONLY_PROG;
20        const Clone = linux_uapi::BPF_F_CLONE;
21        const Mmapable = linux_uapi::BPF_F_MMAPABLE;
22        const PreserveElems = linux_uapi::BPF_F_PRESERVE_ELEMS;
23        const InnerMap = linux_uapi::BPF_F_INNER_MAP;
24        const Link = linux_uapi::BPF_F_LINK;
25        const PathFd = linux_uapi::BPF_F_PATH_FD;
26        const VtypeBtfObjFd = linux_uapi::BPF_F_VTYPE_BTF_OBJ_FD;
27        const TokenFd = linux_uapi::BPF_F_TOKEN_FD;
28        const SegvOnFault = linux_uapi::BPF_F_SEGV_ON_FAULT;
29        const NoUserConv = linux_uapi::BPF_F_NO_USER_CONV;
30    }
31}
32
33#[derive(Debug, Clone, Copy, PartialEq)]
34pub struct MapSchema {
35    pub map_type: bpf_map_type,
36    pub key_size: u32,
37    pub value_size: u32,
38    pub max_entries: u32,
39    pub flags: MapFlags,
40}