Open dave-tucker opened 2 years ago
hello, is there any progress on BPF_MAP_TYPE_SK_STORAGE
?
I am trying to use sk_storage map in aya, but I can't load the ebpf program, no matter I use bpf_map_def
to define the map or use BTF-defined maps
#[repr(C)]
pub struct SkStore {
type_: *const [c_int; BPF_MAP_TYPE_SK_STORAGE as _],
map_flags: *const [c_int; BPF_F_NO_PREALLOC as _],
key: *const c_int,
value: *const u32,
max_entries: *const [c_int; 0],
}
unsafe impl Sync for SkStore {}
#[map]
pub static mut SRC_ADDR_STORE: SkStore = SkStore {
type_: ptr::null(),
map_flags: ptr::null(),
key: ptr::null(),
value: ptr::null(),
max_entries: ptr::null(),
};
it always report EINVAL
I found a way to use sk_storage
#[repr(C)]
pub struct SkStore {
r#type: *const [c_int; BPF_MAP_TYPE_SK_STORAGE as _],
map_flags: *const [c_int; BPF_F_NO_PREALLOC as _],
key: *const c_int,
value: *const u32,
// max_entries: *const [c_int; 0],
}
unsafe impl Sync for SkStore {}
// #[map]
#[link_section = ".maps"]
#[export_name = "SRC_ADDR_STORE"]
pub static mut SRC_ADDR_STORE: SkStore = SkStore {
r#type: ptr::null(),
map_flags: ptr::null(),
key: ptr::null(),
value: ptr::null(),
// max_entries: ptr::null(),
};
that
#[link_section = ".maps"]
#[export_name = "SRC_ADDR_STORE"]
can make sure use .maps
section, not legacy maps
then change rustflags rustflags = ["-C", "debuginfo=2", "-C", "link-arg=--btf"]
to let bpf-linker add BTF section into bpf elf
aya BpfLoader::allow_unsupported_maps
should be used
Howdy! Would there be any issues if I took a stab at this?