bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Toke Høiland-Jørgensen" <toke@redhat.com>
To: Jakub Kicinski <kuba@kernel.org>,
	Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Networking <netdev@vger.kernel.org>, bpf <bpf@vger.kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
	Yonghong Song <yhs@fb.com>, Andrii Nakryiko <andriin@fb.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jesper Dangaard Brouer <brouer@redhat.com>,
	John Fastabend <john.fastabend@gmail.com>,
	Lorenz Bauer <lmb@cloudflare.com>, Andrey Ignatov <rdna@fb.com>
Subject: Re: [PATCH bpf-next v3 1/4] xdp: Support specifying expected existing program when attaching XDP
Date: Wed, 25 Mar 2020 17:48:57 +0100	[thread overview]
Message-ID: <877dz8peh2.fsf@toke.dk> (raw)
In-Reply-To: <20200324184311.4cfb4911@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>

Jakub Kicinski <kuba@kernel.org> writes:

> On Tue, 24 Mar 2020 17:54:07 -0700 Andrii Nakryiko wrote:
>> On Tue, Mar 24, 2020 at 11:13 AM Toke Høiland-Jørgensen <toke@redhat.com> wrote:
>> >
>> > From: Toke Høiland-Jørgensen <toke@redhat.com>
>> >
>> > While it is currently possible for userspace to specify that an existing
>> > XDP program should not be replaced when attaching to an interface, there is
>> > no mechanism to safely replace a specific XDP program with another.
>> >
>> > This patch adds a new netlink attribute, IFLA_XDP_EXPECTED_ID, which can be
>> > set along with IFLA_XDP_FD. If set, the kernel will check that the program
>> > currently loaded on the interface matches the expected one, and fail the
>> > operation if it does not. This corresponds to a 'cmpxchg' memory operation.
>> > Setting the new attribute with a negative value means that no program is
>> > expected to be attached, which corresponds to setting the UPDATE_IF_NOEXIST
>> > flag.
>> >
>> > A new companion flag, XDP_FLAGS_EXPECT_ID, is also added to explicitly
>> > request checking of the EXPECTED_ID attribute. This is needed for userspace
>> > to discover whether the kernel supports the new attribute.  
>> 
>> Doesn't it feel inconsistent in UAPI that FD is used to specify XDP
>> program to be attached, but ID is used to specify expected XDP
>> program? Especially that the same cgroup use case is using
>> (consistently) prog FDs. Or is it another case where XDP needs its own
>> special way?
>
> There was a comment during review of v1, I wish you spoke up then.
>
> The prog ID is what dump returns, so the consistency can go either way
> (note that this API predates object IDs). Since XDP uses IDs internally
> it's just simpler to take prog ID.
>
> But it's a detail, so if you feel strongly I don't really mind.

Using an FD instead of an ID does make this more extensible (such as
supporting bpf_link FDs in the future; see my other reply to Alexei). So
I'll respin this, and switch it back to EXPECTED_FD.

-Toke


  reply	other threads:[~2020-03-25 16:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-24 18:12 [PATCH bpf-next v3 0/4] XDP: Support atomic replacement of XDP interface attachments Toke Høiland-Jørgensen
2020-03-24 18:12 ` [PATCH bpf-next v3 1/4] xdp: Support specifying expected existing program when attaching XDP Toke Høiland-Jørgensen
2020-03-24 19:40   ` Jakub Kicinski
2020-03-25  0:54   ` Andrii Nakryiko
2020-03-25  1:43     ` Jakub Kicinski
2020-03-25 16:48       ` Toke Høiland-Jørgensen [this message]
2020-03-25  1:46   ` Alexei Starovoitov
2020-03-25 16:48     ` Toke Høiland-Jørgensen
2020-03-24 18:12 ` [PATCH bpf-next v3 2/4] tools: Add EXPECTED_ID-related definitions in if_link.h Toke Høiland-Jørgensen
2020-03-24 18:12 ` [PATCH bpf-next v3 3/4] libbpf: Add function to set link XDP fd while specifying old program Toke Høiland-Jørgensen
2020-03-24 18:12 ` [PATCH bpf-next v3 4/4] selftests/bpf: Add tests for attaching XDP programs Toke Høiland-Jørgensen

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=877dz8peh2.fsf@toke.dk \
    --to=toke@redhat.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andriin@fb.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=brouer@redhat.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kuba@kernel.org \
    --cc=lmb@cloudflare.com \
    --cc=netdev@vger.kernel.org \
    --cc=rdna@fb.com \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.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).