Re: Using pinned maps within a network namespace
Quentin Monnet <[email protected]>
| Newsgroups | org.kernel.vger.xdp-newbies |
|---|---|
| Message-ID | <[email protected]> |
On 15/09/2020 18:00, John McDowall wrote:
> Hi everyone,
>
> This may be a dumb question, I have set up a simple test environment
> with multiple network namespaces running on a ubuntu 20.04 vagrant
> box, with the latest github libbpf.
>
> I want to use a pinned map, I can make /sys/fs/bpf shared by:
>
> $ mount mount --make-shared /sys/fs/bpf
> $ mount --bind /sys/fs/bpf /sys/fs/bpf
>
> but when I try access the maps from a C program running in a namespace
> using bpf I get
>
> Access to /sys/fs/bpf/lwtconfig map failed obj_pin errno: No such
> file or directory
>
> The code snippet is:
>
> mapfd = bpf_obj_pin(pin_fd,CONFIG_MAP_PATH);
> if (mapfd < 0) {
> jed_info(jed_logfile,"Access to %s map failed obj_pin ",
> CONFIG_MAP_PATH);
Hi, from your log message ("obj_pin") it looks like the error occurs
when you try to pin the map, not when you try to access it. The way you
try to pin it:
mapfd = bpf_obj_pin(pin_fd,CONFIG_MAP_PATH);
looks suspicious. If I remember correctly, bpf_obj_pin() returns 0 on
success, it does not return a fd. It does use a file descriptor to the
map as a first argument, can you double check that this is what "pin_fd"
contains? How did you retrieve this fd? It looks to me like "pin_fd"
does not point to an existing map, and that the kernel fails to find the
map to pin.
Good luck,
Quentin