Re: Using pinned maps within a network namespace

John McDowall <[email protected]>
Newsgroups org.kernel.vger.xdp-newbies
Message-ID <CAHQoOTYi7Pfyoaxpz1a7hkPA7fEC6gPhdRgWz=6BOLuFHB4zVg@mail.gmail.com>
Song,

I think it is something to do with the namespace, when I run the same
code on the host os (not in a network namespace) it works fine and
creates the map and writes to it.

The error coming back from bpf_pin_obj is errno: No such file or directory

I can see /sys/fs/bpf in the namespace after I do.

$ mount --make-shared /sys/fs/bpf

but just cannot access it.

Thanks for the help

Regards

John

On Tue, Sep 15, 2020 at 10:12 PM Y Song <[email protected]> wrote:
>
> On Tue, Sep 15, 2020 at 11:46 AM John McDowall
> <[email protected]> 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
>
> Similar commands `mount --bind /sys/fs/bpf /sys/fs/bpf1` in the same namespace
> works fine.
>
> Maybe there are restrictions related to namespace? Maybe it becomes readonly?
> Could you print out the error code below?
>
> >
> > 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);
> >             pin_fd = bpf_obj_get(CONFIG_MAP_PATH);
> >             if (pin_fd < 0){
> >              jed_error(jed_logfile,"Access to %s map failed with
> > obj_get ", CONFIG_MAP_PATH);
> >             }
> >         }
> >
> > Is this possible, and if so what am I missing?
> >
> > Regards
> >
> > John
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.