Skip to content

Panic when export C struct to skel #1155

Closed as duplicate of#1151
Closed as duplicate of#1151
@3Xpl0it3r

Description

@3Xpl0it3r

After I export c struct to skel, prog panic when load bpf code
panic message:
thread 'main' panicked at /Users/l0calh0st/Git/Rust/netdig/src/bpf/netdig.skel.rs:129:26: BPF mapbssmmap pointer is NULL note: run withRUST_BACKTRACE=1environment variable to display a backtrace
example code as blow

`struct {
__uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY);
__uint(key_size, sizeof(u32));
__uint(value_size, sizeof(u32));
__uint(max_entries, 1024);
} events SEC(".maps");

struct skb_tuple_t {
u16 sport;
};

struct skb_tuple_t _event = {}; // This code cause panic

SEC("kprobe/ip_rcv") // SEC("kprobe/ip_rcv_core")
int kprobe_ip_rcv_core(struct pt_regs *ctx) {
u16 pid = 10;
struct skb_tuple_t tupple = {};
tupple.sport = pid;
bpf_perf_event_output(ctx, &events, 0, &tupple, sizeof(tupple));
return BPF_OK;
}

char _license[] SEC("license") = "GPL";
`

osversion: Linux lima-ubuntu20 5.4.0-212-generic 2025 x86_64 x86_64 x86_64 GNU/Linux

libbpf-rs version: 0.24.8
libbpf-cargo version: master

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions