aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/dev.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/core/dev.c')
-rw-r--r--net/core/dev.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index bfa4be42afff..78c3b48392e1 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -7976,11 +7976,13 @@ int dev_change_xdp_fd(struct net_device *dev, struct netlink_ext_ack *extack,
7976 enum bpf_netdev_command query; 7976 enum bpf_netdev_command query;
7977 struct bpf_prog *prog = NULL; 7977 struct bpf_prog *prog = NULL;
7978 bpf_op_t bpf_op, bpf_chk; 7978 bpf_op_t bpf_op, bpf_chk;
7979 bool offload;
7979 int err; 7980 int err;
7980 7981
7981 ASSERT_RTNL(); 7982 ASSERT_RTNL();
7982 7983
7983 query = flags & XDP_FLAGS_HW_MODE ? XDP_QUERY_PROG_HW : XDP_QUERY_PROG; 7984 offload = flags & XDP_FLAGS_HW_MODE;
7985 query = offload ? XDP_QUERY_PROG_HW : XDP_QUERY_PROG;
7984 7986
7985 bpf_op = bpf_chk = ops->ndo_bpf; 7987 bpf_op = bpf_chk = ops->ndo_bpf;
7986 if (!bpf_op && (flags & (XDP_FLAGS_DRV_MODE | XDP_FLAGS_HW_MODE))) { 7988 if (!bpf_op && (flags & (XDP_FLAGS_DRV_MODE | XDP_FLAGS_HW_MODE))) {
@@ -7993,8 +7995,7 @@ int dev_change_xdp_fd(struct net_device *dev, struct netlink_ext_ack *extack,
7993 bpf_chk = generic_xdp_install; 7995 bpf_chk = generic_xdp_install;
7994 7996
7995 if (fd >= 0) { 7997 if (fd >= 0) {
7996 if (__dev_xdp_query(dev, bpf_chk, XDP_QUERY_PROG) || 7998 if (!offload && __dev_xdp_query(dev, bpf_chk, XDP_QUERY_PROG)) {
7997 __dev_xdp_query(dev, bpf_chk, XDP_QUERY_PROG_HW)) {
7998 NL_SET_ERR_MSG(extack, "native and generic XDP can't be active at the same time"); 7999 NL_SET_ERR_MSG(extack, "native and generic XDP can't be active at the same time");
7999 return -EEXIST; 8000 return -EEXIST;
8000 } 8001 }
@@ -8009,8 +8010,7 @@ int dev_change_xdp_fd(struct net_device *dev, struct netlink_ext_ack *extack,
8009 if (IS_ERR(prog)) 8010 if (IS_ERR(prog))
8010 return PTR_ERR(prog); 8011 return PTR_ERR(prog);
8011 8012
8012 if (!(flags & XDP_FLAGS_HW_MODE) && 8013 if (!offload && bpf_prog_is_dev_bound(prog->aux)) {
8013 bpf_prog_is_dev_bound(prog->aux)) {
8014 NL_SET_ERR_MSG(extack, "using device-bound program without HW_MODE flag is not supported"); 8014 NL_SET_ERR_MSG(extack, "using device-bound program without HW_MODE flag is not supported");
8015 bpf_prog_put(prog); 8015 bpf_prog_put(prog);
8016 return -EINVAL; 8016 return -EINVAL;