bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Rafael David Tinoco <rafaeldtinoco@ubuntu.com>
Cc: John Fastabend <john.fastabend@gmail.com>, bpf <bpf@vger.kernel.org>
Subject: Re: [PATCH v3 bpf-next] libbpf: add bpf object kern_version attribute setter
Date: Thu, 25 Mar 2021 13:39:09 -0700	[thread overview]
Message-ID: <CAEf4BzYjyppFCS02n-+VyNbj8-FHMyFMtV7-+_ttkroceEjLbg@mail.gmail.com> (raw)
In-Reply-To: <a286bddf-8217-57e3-30bf-a09f3de2592e@ubuntu.com>

On Thu, Mar 25, 2021 at 1:01 PM Rafael David Tinoco
<rafaeldtinoco@ubuntu.com> wrote:
>
> >> Unfortunately some distros don't have their kernel version defined
> >> accurately in <linux/version.h> due to different long term support
> >> reasons.
> >>
> >> It is important to have a way to override the bpf kern_version
> >> attribute during runtime: some old kernels might still check for
> >> kern_version attribute during bpf_prog_load().
> >>
> >> Signed-off-by: Rafael David Tinoco <rafaeldtinoco@ubuntu.com>
> >> ---
> >>   tools/lib/bpf/libbpf.c   | 10 ++++++++++
> >>   tools/lib/bpf/libbpf.h   |  1 +
> >>   tools/lib/bpf/libbpf.map |  1 +
> >>   3 files changed, 12 insertions(+)
> >>
> >
> > Hi Andrii and Rafael,
> >
> > Did you consider making kernel version an attribute of the load
> > API, bpf_prog_load_xattr()? This feels slightly more natural
> > to me, to tell the API the kernel you need at load time.
>
> Hi John,
>
> This is how I'm using:
> https://github.com/rafaeldtinoco/portablebpf/blob/master/mine.c#L285
>
> > Although, I don't use the skeleton pieces so maybe it would be
> > awkward for that usage.
>
> having a xxx_bpf object:
>
> xxx_bpf__open_and_load() -> xxx_bpf__load() ->
> bpf_object__load_skeleton() -> bpf_object_load() -> bpf_object__loadxattr()
>
> We would have to add kern_version to 'bpf_object_skeleton' struct, to be
> passed to 'bpf_object__load_skeleton()' to have it passed on.
>
> I'll let Andrii to see what he prefers.

See my reply to John. What he asked for already exists. Having a test
would be nice, but selftests/bpf don't have an infrastructure to even
perform this test, so I don't think it's worth it.

So in summary, LGTM. I'll apply it once bpf-next is ready to accept new patches.

Acked-by: Andrii Nakryiko <andrii@kernel.org>

>
> Note:
>
> Reason for all this (including the legacy kprobe logic, in other commit)
> is to continue the
> https://github.com/rafaeldtinoco/conntracker/tree/poc-cmd project,
> making sure it supports 4.x kernels. Still adding bpf support to it
> (identify task/pid per flow) and will replace the libnf* usage with bpf
> after that.
>
> Thanks
> -rafaeldtinoco

  reply	other threads:[~2021-03-25 20:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-23  4:09 [PATCH v3 bpf-next] libbpf: add bpf object kern_version attribute setter Rafael David Tinoco
2021-03-23  5:31 ` John Fastabend
2021-03-25 20:01   ` Rafael David Tinoco
2021-03-25 20:39     ` Andrii Nakryiko [this message]
2021-03-25 20:35   ` Andrii Nakryiko
2021-03-26  0:56     ` John Fastabend
2021-03-26  3:00       ` Andrii Nakryiko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAEf4BzYjyppFCS02n-+VyNbj8-FHMyFMtV7-+_ttkroceEjLbg@mail.gmail.com \
    --to=andrii.nakryiko@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=john.fastabend@gmail.com \
    --cc=rafaeldtinoco@ubuntu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).