From: Björn Töpel <bjorn.to...@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.to...@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

Reply via email to