BPF List
 help / color / mirror / Atom feed
From: "Björn Töpel" <bjorn.topel@gmail.com>
To: ast@kernel.org, daniel@iogearbox.net, netdev@vger.kernel.org
Cc: "Björn Töpel" <bjorn.topel@intel.com>,
	magnus.karlsson@intel.com, toke@redhat.com, brouer@redhat.com,
	bpf@vger.kernel.org, jakub.kicinski@netronome.com,
	saeedm@mellanox.com
Subject: [PATCH bpf-next v3 5/5] net: xdp: remove xdp_attachment_flags_ok() and flags member
Date: Mon, 10 Jun 2019 18:02:34 +0200	[thread overview]
Message-ID: <20190610160234.4070-6-bjorn.topel@gmail.com> (raw)
In-Reply-To: <20190610160234.4070-1-bjorn.topel@gmail.com>

From: Björn Töpel <bjorn.topel@intel.com>

The attachment flags check is done in the generic netdev code, so
there is no need for this function anymore. Remove it and all uses of
it.

Further; Passing flags from struct netdev_bpf when attaching an XDP
program is no longer necessary, so let us remove that member.

Signed-off-by: Björn Töpel <bjorn.topel@intel.com>
---
 drivers/net/ethernet/netronome/nfp/nfp_net_common.c |  6 ------
 drivers/net/netdevsim/bpf.c                         |  3 ---
 include/linux/netdevice.h                           |  1 -
 include/net/xdp.h                                   |  3 ---
 net/core/dev.c                                      |  1 -
 net/core/xdp.c                                      | 13 -------------
 6 files changed, 27 deletions(-)

diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
index 2a9683db54e5..c164da24c28c 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
@@ -3497,9 +3497,6 @@ static int nfp_net_xdp_setup_drv(struct nfp_net *nn, struct netdev_bpf *bpf)
 	struct nfp_net_dp *dp;
 	int err;
 
-	if (!xdp_attachment_flags_ok(&nn->xdp, bpf))
-		return -EBUSY;
-
 	if (!prog == !nn->dp.xdp_prog) {
 		WRITE_ONCE(nn->dp.xdp_prog, prog);
 		xdp_attachment_setup(&nn->xdp, bpf);
@@ -3528,9 +3525,6 @@ static int nfp_net_xdp_setup_hw(struct nfp_net *nn, struct netdev_bpf *bpf)
 {
 	int err;
 
-	if (!xdp_attachment_flags_ok(&nn->xdp_hw, bpf))
-		return -EBUSY;
-
 	err = nfp_app_xdp_offload(nn->app, nn, bpf->prog, bpf->extack);
 	if (err)
 		return err;
diff --git a/drivers/net/netdevsim/bpf.c b/drivers/net/netdevsim/bpf.c
index d03d31721e38..51b2430f1edc 100644
--- a/drivers/net/netdevsim/bpf.c
+++ b/drivers/net/netdevsim/bpf.c
@@ -190,9 +190,6 @@ nsim_xdp_set_prog(struct netdevsim *ns, struct netdev_bpf *bpf,
 {
 	int err;
 
-	if (!xdp_attachment_flags_ok(xdp, bpf))
-		return -EBUSY;
-
 	if (bpf->command == XDP_SETUP_PROG && !ns->bpf_xdpdrv_accept) {
 		NSIM_EA(bpf->extack, "driver XDP disabled in DebugFS");
 		return -EOPNOTSUPP;
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 6b700005288d..d7fa2c9fa031 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -879,7 +879,6 @@ struct netdev_bpf {
 	union {
 		/* XDP_SETUP_PROG */
 		struct {
-			u32 flags;
 			struct bpf_prog *prog;
 			struct netlink_ext_ack *extack;
 		};
diff --git a/include/net/xdp.h b/include/net/xdp.h
index 4ad4b20fe2c0..854267b3b624 100644
--- a/include/net/xdp.h
+++ b/include/net/xdp.h
@@ -155,12 +155,9 @@ xdp_data_meta_unsupported(const struct xdp_buff *xdp)
 
 struct xdp_attachment_info {
 	struct bpf_prog *prog;
-	u32 flags;
 };
 
 struct netdev_bpf;
-bool xdp_attachment_flags_ok(struct xdp_attachment_info *info,
-			     struct netdev_bpf *bpf);
 void xdp_attachment_setup(struct xdp_attachment_info *info,
 			  struct netdev_bpf *bpf);
 
diff --git a/net/core/dev.c b/net/core/dev.c
index bb5fbb395596..b0476545fbc8 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -8026,7 +8026,6 @@ static int dev_xdp_install(struct net_device *dev, bpf_op_t bpf_op,
 	}
 
 	xdp.extack = extack;
-	xdp.flags = flags;
 	xdp.prog = prog;
 
 	err = bpf_op(dev, &xdp);
diff --git a/net/core/xdp.c b/net/core/xdp.c
index 6f76ad995fef..b2cdebd0b17d 100644
--- a/net/core/xdp.c
+++ b/net/core/xdp.c
@@ -379,25 +379,12 @@ void xdp_return_buff(struct xdp_buff *xdp)
 }
 EXPORT_SYMBOL_GPL(xdp_return_buff);
 
-bool xdp_attachment_flags_ok(struct xdp_attachment_info *info,
-			     struct netdev_bpf *bpf)
-{
-	if (info->prog && (bpf->flags ^ info->flags) & XDP_FLAGS_MODES) {
-		NL_SET_ERR_MSG(bpf->extack,
-			       "program loaded with different flags");
-		return false;
-	}
-	return true;
-}
-EXPORT_SYMBOL_GPL(xdp_attachment_flags_ok);
-
 void xdp_attachment_setup(struct xdp_attachment_info *info,
 			  struct netdev_bpf *bpf)
 {
 	if (info->prog)
 		bpf_prog_put(info->prog);
 	info->prog = bpf->prog;
-	info->flags = bpf->flags;
 }
 EXPORT_SYMBOL_GPL(xdp_attachment_setup);
 
-- 
2.20.1


  parent reply	other threads:[~2019-06-10 16:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-10 16:02 [PATCH bpf-next v3 0/5] net: xdp: refactor XDP program queries Björn Töpel
2019-06-10 16:02 ` [PATCH bpf-next v3 1/5] net: xdp: refactor XDP_QUERY_PROG{,_HW} to netdev Björn Töpel
2019-06-10 16:02 ` [PATCH bpf-next v3 2/5] nfp, netdevsim: use dev_xdp_support_offload() function Björn Töpel
2019-06-10 16:02 ` [PATCH bpf-next v3 3/5] net: xdp: remove XDP_QUERY_PROG{,_HW} Björn Töpel
2019-06-10 16:02 ` [PATCH bpf-next v3 4/5] net: xdp: refactor XDP flags checking Björn Töpel
2019-06-10 16:02 ` Björn Töpel [this message]
2019-06-10 22:24 ` [PATCH bpf-next v3 0/5] net: xdp: refactor XDP program queries Jakub Kicinski
2019-06-11  7:24   ` Björn Töpel
2019-06-11 12:17     ` Toke Høiland-Jørgensen
2019-06-11 17:22     ` Jakub Kicinski
2019-06-12  5:38       ` Björn Töpel
2019-06-12 14:31     ` Jonathan Lemon

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=20190610160234.4070-6-bjorn.topel@gmail.com \
    --to=bjorn.topel@gmail.com \
    --cc=ast@kernel.org \
    --cc=bjorn.topel@intel.com \
    --cc=bpf@vger.kernel.org \
    --cc=brouer@redhat.com \
    --cc=daniel@iogearbox.net \
    --cc=jakub.kicinski@netronome.com \
    --cc=magnus.karlsson@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@mellanox.com \
    --cc=toke@redhat.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