99Linux
99Linux

Reputation: 186

How to initialize eBPF tail call program array map statically

this is a clone repo I had https://github.com/vincentmli/XDPeriments/blob/master/Cookies/xdp_dns_cookies_kern.c and i am trying to initialize the tail call program array map statically instead of running user space eBPF loader to populate the program array map like https://github.com/vincentmli/XDPeriments/blob/master/Cookies/xdp_dns_cookies_user.c

here is the program array map I modified as below

https://github.com/vincentmli/XDPeriments/blob/master/Cookies/xdp_dns_cookies_kern.c#L659-L671

struct {
        __uint(type, BPF_MAP_TYPE_PROG_ARRAY);
        __uint(max_entries, 3);
        __uint(key_size, sizeof(uint32_t));
        __uint(value_size, sizeof(uint64_t));
        __array(values, int (void *));
} jmp_rate_table SEC(".maps") = {
        .values = {
                [DO_RATE_LIMIT_IPV6] = (void *)&xdp_do_rate_limit_ipv6,
                [DO_RATE_LIMIT_IPV4] = (void *)&xdp_do_rate_limit_ipv4,
        },
};

Note I had to use gcc to compile the xdp_dns_cookies_user to load the program https://github.com/NLnetLabs/XDPeriments/issues/6

root@vincent-pc2:/home/vincent/go/src/github.com/vincentmli/XDPeriments/Cookies# ./xdp_dns_cookies_user 
libbpf: map 'jmp_rate_table': should be map-in-map.
ERROR: opening BPF object file failed
(null) successfully loaded and running on interface lo.
Press Ctrl-C to stop and unload.
^C

you can see libbpf indicates that the jmp_rate_table should be map-in-map table, am I initializing the map wrong?

Upvotes: 0

Views: 378

Answers (1)

99Linux
99Linux

Reputation: 186

it turned out I need to use clang to compile the https://github.com/vincentmli/XDPeriments/blob/master/Cookies/xdp_dns_cookies_user.c instead of gcc. answered here https://github.com/libbpf/libbpf/issues/690#issuecomment-1550548336

Upvotes: 0

Related Questions