小编Fer*_*rar的帖子

eBPF:“bpf_map_update()”返回“从堆栈中间接读取无效”错误

我有一个带有以下映射定义的 eBPF 程序:

struct bpf_map_def SEC("maps") servers = {
    .type = BPF_MAP_TYPE_HASH,
    .key_size = sizeof(struct ip_key),
    .value_size = sizeof(struct dest_info),
    .max_entries = MAX_SERVERS,
};

struct bpf_map_def SEC("maps") client_addrs = {
    .type = BPF_MAP_TYPE_HASH,
    .key_size = sizeof(struct port_key),
    .value_size = sizeof(struct client_port_addr),
    .max_entries = MAX_CLIENTS,
};
Run Code Online (Sandbox Code Playgroud)

其中结构体定义如下:

struct port_key {
    __u16 port;
    __u16 pad[3];
};

struct ip_key {
    __u32 key;
    __u32 pad;
};

struct dest_info {
    __u32 saddr;
    __u32 daddr;
    __u64 bytes;
    __u64 pkts;
    __u8 dmac[6];
    __u16 pad;
};

struct client_port_addr …
Run Code Online (Sandbox Code Playgroud)

bpf ebpf xdp-bpf

3
推荐指数
1
解决办法
1496
查看次数

标签 统计

bpf ×1

ebpf ×1

xdp-bpf ×1