[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220504035207.98221-1-shaozhengchao@huawei.com>
Date: Wed, 4 May 2022 11:52:07 +0800
From: Zhengchao Shao <shaozhengchao@...wei.com>
To: <netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<bpf@...r.kernel.org>, <davem@...emloft.net>,
<edumazet@...gle.com>, <kuba@...nel.org>, <pabeni@...hat.com>
CC: <ast@...nel.org>, <daniel@...earbox.net>, <hawk@...nel.org>,
<john.fastabend@...il.com>, <andrii@...nel.org>, <kafai@...com>,
<songliubraving@...com>, <yhs@...com>, <kpsingh@...nel.org>,
<bigeasy@...utronix.de>, <imagedong@...cent.com>,
<petrm@...dia.com>, <memxor@...il.com>, <arnd@...db.de>,
<weiyongjun1@...wei.com>, <shaozhengchao@...wei.com>,
<yuehaibing@...wei.com>
Subject: [PATCH bpf-next] bpf/xdp: Can't detach BPF XDP prog if not exist
if user sets nonexistent xdp_flags to detach xdp prog, kernel should
return err and tell user that detach failed with detail info.
Signed-off-by: Zhengchao Shao <shaozhengchao@...wei.com>
---
net/core/dev.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/net/core/dev.c b/net/core/dev.c
index 8ed0272bf32f..8ed05ef62c68 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -9149,6 +9149,12 @@ static int dev_xdp_attach(struct net_device *dev, struct netlink_ext_ack *extack
return -EBUSY;
}
+ /* no BPF XDP prog attached */
+ if (!new_prog && !(dev->xdp_state[mode].prog)) {
+ NL_SET_ERR_MSG(extack, "no BPF XDP prog attached");
+ return -ENOENT;
+ }
+
/* don't allow if an upper device already has a program */
netdev_for_each_upper_dev_rcu(dev, upper, iter) {
if (dev_xdp_prog_count(upper) > 0) {
--
2.17.1
Powered by blists - more mailing lists