Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Hangbin Liu <haliu@redhat.com>
Cc: Martynas Pumputis <m@lambda.lt>,
	Networking <netdev@vger.kernel.org>,
	Stephen Hemminger <stephen@networkplumber.org>,
	David Ahern <dsahern@gmail.com>,
	Daniel Borkmann <daniel@iogearbox.net>
Subject: Re: [PATCH iproute2] libbpf: fix attach of prog with multiple sections
Date: Fri, 23 Jul 2021 09:09:01 -0700	[thread overview]
Message-ID: <CAEf4BzYayFVz4SVw3RpmTd-9w01bkA58NQ_QH4S8gLDDUsVPHA@mail.gmail.com> (raw)
In-Reply-To: <YPp17yOht8W+Kaqy@Laptop-X1>

On Fri, Jul 23, 2021 at 12:55 AM Hangbin Liu <haliu@redhat.com> wrote:
>
> On Thu, Jul 22, 2021 at 09:51:50PM -0700, Andrii Nakryiko wrote:
> > > > > This is still problematic, because one section can have multiple BPF
> > > > > programs. I.e., it's possible two define two or more XDP BPF programs
> > > > > all with SEC("xdp") and libbpf works just fine with that. I suggest
> > > > > moving users to specify the program name (i.e., C function name
> > > > > representing the BPF program). All the xdp_mycustom_suffix namings are
>
> I just propose an implementation as you suggested.
>
> > > > > a hack and will be rejected by libbpf 1.0, so it would be great to get
> > > > > a head start on fixing this early on.
> > > >
> > > > Thanks for bringing this up. Currently, there is no way to specify a
> > > > function name with "tc exec bpf" (only a section name via the "sec" arg). So
> > > > probably, we should just add another arg to specify the function name.
> > >
> > > How about add a "prog" arg to load specified program name and mark
> > > "sec" as not recommended? To keep backwards compatibility we just load the
> > > first program in the section.
> >
> > Why not error out if there is more than one program with the same
> > section name? if there is just one (and thus section name is still
> > unique) -- then proceed. It seems much less confusing, IMO.
>
> If you and others think it's OK to only support one program each section.
> I do no object.
>

I'm not sure we are on the same page. I'll try to summarize what I
understood and you guys can decide for yourself what you want to do.

So I like your idea of introducing "prog" arg that will expect BPF
program name (i.e., C function name). In that case the name is always
unique. For existing "sec" arg, for backwards compatibility, I'd keep
it working, but when "sec" is used I'd check that the match is unique
(i.e., there is only one BPF program within the specified section). If
not and there are more than one matching BPF programs, that's a hard
error, because otherwise you essentially randomly pick one BPF program
out of a few.

> Thanks
> Hangbin
>

  reply	other threads:[~2021-07-23 16:09 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-05 12:43 Martynas Pumputis
2021-07-06  2:44 ` Hangbin Liu
2021-07-20 20:27 ` Andrii Nakryiko
2021-07-21 14:47   ` Martynas Pumputis
2021-07-21 14:59     ` David Ahern
2021-07-21 15:27       ` Martynas Pumputis
2021-07-23  4:01         ` Andrii Nakryiko
2021-07-23  4:41     ` Hangbin Liu
2021-07-23  4:51       ` Andrii Nakryiko
2021-07-23  7:55         ` Hangbin Liu
2021-07-23 16:09           ` Andrii Nakryiko [this message]
2021-07-24  8:12             ` Hangbin Liu
2021-07-24  0:12         ` David Ahern
2021-07-24  0:25           ` Andrii Nakryiko
2021-07-26 13:58             ` David Ahern
2021-07-26 15:13               ` Andrii Nakryiko
2021-07-27  2:51                 ` David Ahern
2021-07-27 19:05                   ` 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=CAEf4BzYayFVz4SVw3RpmTd-9w01bkA58NQ_QH4S8gLDDUsVPHA@mail.gmail.com \
    --to=andrii.nakryiko@gmail.com \
    --cc=daniel@iogearbox.net \
    --cc=dsahern@gmail.com \
    --cc=haliu@redhat.com \
    --cc=m@lambda.lt \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    --subject='Re: [PATCH iproute2] libbpf: fix attach of prog with multiple sections' \
    /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

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).