Re: Using pinned maps within a network namespace

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <ys114321@xxxxxxxxx> wrote:
>
> On Tue, Sep 15, 2020 at 11:46 AM John McDowall
> <jmcdowall@xxxxxxxxxxxxxxxxxxxx> 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



[Index of Archives]     [Linux Networking Development]     [Fedora Linux Users]     [Linux SCTP]     [DCCP]     [Gimp]     [Yosemite Campsites]

  Powered by Linux