Re: libbpf expected backward compatibility

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

 



On Mon, Aug 12, 2019 at 10:52 PM Y Song <ys114321@xxxxxxxxx> wrote:
>
> On Mon, Aug 12, 2019 at 11:13 AM Rafael Vargas <vargas@xxxxxxxxx> wrote:
> >
> > Hi,
> > Reading the tools/lib/bpf/README.rst file, I could find what should be
> > the expected backward compatibility of the library with older kernels.
>
> Now, libbpf tries to maintain backward compatibility with itself.
> That is, APIs introduced in older versions are expected to work
> in new versions.
>
> This has nothing to do with old or new kernels.
>
> >
> > Should I be able to use a libbpf compiled from a kernel newer than the
> > one I will be running or vice-versa?
>
> On the other hand, when libbpf is able to able to load a program or map,
> it tries to reload by resetting some debug/info fields. But depending on
> which API you are using, you may not be able to retry successfully
> on old kernels.
>
> >
> > I've noticed that the following diff (part of
> > 421ecf02c8e73e1d95e16e5e12aa19146561edba) makes the xsk_socket__create
> > function return errno 95 'Operation not supported' on older kernels
> > (5.1.0 in this particular case).
> >
> >
> > diff --git a/src/xsk.c b/src/xsk.c
> > index 7ef6293..bf15a80 100644
> > @@ -597,6 +599,16 @@ int xsk_socket__create(struct xsk_socket
> > **xsk_ptr, const char *ifname,
> >         }
> >
> >         xsk->prog_fd = -1;
> > +
> > +       optlen = sizeof(opts);
> > +       err = getsockopt(xsk->fd, SOL_XDP, XDP_OPTIONS, &opts, &optlen);
> > +       if (err) {
> > +               err = -errno;
> > +               goto out_mmap_tx;
> > +       }
> > +
> > +       xsk->zc = opts.flags & XDP_OPTIONS_ZEROCOPY;
> >
> > Should this really return Operation not supported or should it handle
> > this particular error and set the zc flag as false?
>
> maybe xdp expert can commit on this.
> From my understanding of the code, XDP_OPTIONS_ZEROCOPY
> does not involve any user parameters, so it is totally okay
> to test whether kernel has XDP_OPTIONS or not.
> If not, xdk->zc = 0. Also seems xdk->zc is not really used?

Thanks for spotting this. We should remove the zc field from the
struct as it is not used anymore. Not good to have dead code in there.
Who wants to produce a patch?

/Magnus

> >
> > --
> > Rafael Vargas



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

  Powered by Linux