From: "Toke Høiland-Jørgensen" <toke@redhat.com>
To: shaozhengchao <shaozhengchao@huawei.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"bpf@vger.kernel.org" <bpf@vger.kernel.org>,
"davem@davemloft.net" <davem@davemloft.net>,
"edumazet@google.com" <edumazet@google.com>,
"kuba@kernel.org" <kuba@kernel.org>,
"pabeni@redhat.com" <pabeni@redhat.com>
Cc: "ast@kernel.org" <ast@kernel.org>,
"daniel@iogearbox.net" <daniel@iogearbox.net>,
"hawk@kernel.org" <hawk@kernel.org>,
"john.fastabend@gmail.com" <john.fastabend@gmail.com>,
"andrii@kernel.org" <andrii@kernel.org>,
"kafai@fb.com" <kafai@fb.com>,
"songliubraving@fb.com" <songliubraving@fb.com>,
"yhs@fb.com" <yhs@fb.com>,
"kpsingh@kernel.org" <kpsingh@kernel.org>,
"bigeasy@linutronix.de" <bigeasy@linutronix.de>,
"imagedong@tencent.com" <imagedong@tencent.com>,
"petrm@nvidia.com" <petrm@nvidia.com>,
"memxor@gmail.com" <memxor@gmail.com>,
"arnd@arndb.de" <arnd@arndb.de>,
"weiyongjun (A)" <weiyongjun1@huawei.com>,
yuehaibing <yuehaibing@huawei.com>
Subject: Re: 答复: [PATCH bpf-next] bpf/xdp: Can't detach BPF XDP prog if not exist
Date: Thu, 05 May 2022 16:27:31 +0200 [thread overview]
Message-ID: <87tua43vho.fsf@toke.dk> (raw)
In-Reply-To: <594b5198d54c4c729728c20d167d9c2d@huawei.com>
shaozhengchao <shaozhengchao@huawei.com> writes:
> Thank you for your reply. I wiil change sample application firstly.
> But if kernel does nothing and return 0, maybe user will think setup
> is OK, actually It failed. Is this acceptable?
Your patch was about detach; what has that got to do with "setup is OK"?
As for detaching, it's possible to write the application in a way that
it will always get a consistent result. There are basically two cases
when using netlink to detach an XDP program (bpf_link has its own
semantics, so setting that aside here):
1. The application just wants to turn off XDP entirely on the interface
(e.g., 'ip link set dev XXX xdp off'). In this case you just send a
RTM_SETLINK message with an IFLA_XDP_FD of -1, and if you don't get
an error you can be sure that there is now no XDP program attached.
Whether this was because there was already no program attached, or
because you just detached it doesn't really matter in this case,
since you're doing an unspecific detach anyway.
2. You attached a program earlier, and now you want to detach that (and
only that) program. Or, equivalently, you queried the link and want
to detach the program you know is attached there. In this case you
send an RTM_SETLINK message with an IFLA_XDP_FD of -1 and an
IFLA_XDP_EXPECTED_FD referring to the existing program. In this case
you will get an error if that specific program is not in fact
attached, whether because it was detached or swapped out in the
meantime.
I don't see how case 1. is improved by returning ENOENT if there is no
program attached; if you care about detaching a specific program you'd
use case 2. anyway, and if you just want to check if a program is
attached, you'd do an RTM_GETLINK.
-Toke
prev parent reply other threads:[~2022-05-05 14:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-04 3:52 [PATCH bpf-next] bpf/xdp: Can't detach BPF XDP prog if not exist Zhengchao Shao
2022-05-04 11:19 ` Toke Høiland-Jørgensen
2022-05-05 8:21 ` 答复: " shaozhengchao
2022-05-05 14:27 ` Toke Høiland-Jørgensen [this message]
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=87tua43vho.fsf@toke.dk \
--to=toke@redhat.com \
--cc=andrii@kernel.org \
--cc=arnd@arndb.de \
--cc=ast@kernel.org \
--cc=bigeasy@linutronix.de \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=imagedong@tencent.com \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=memxor@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=petrm@nvidia.com \
--cc=shaozhengchao@huawei.com \
--cc=songliubraving@fb.com \
--cc=weiyongjun1@huawei.com \
--cc=yhs@fb.com \
--cc=yuehaibing@huawei.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