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 8c6d5cf8a308..ecbe419e05ab 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -8033,11 +8033,13 @@ int dev_change_xdp_fd(struct net_device *dev, struct netlink_ext_ack *extack,
8033 enum bpf_netdev_command query; 8033 enum bpf_netdev_command query;
8034 struct bpf_prog *prog = NULL; 8034 struct bpf_prog *prog = NULL;
8035 bpf_op_t bpf_op, bpf_chk; 8035 bpf_op_t bpf_op, bpf_chk;
8036 bool offload;
8036 int err; 8037 int err;
8037 8038
8038 ASSERT_RTNL(); 8039 ASSERT_RTNL();
8039 8040
8040 query = flags & XDP_FLAGS_HW_MODE ? XDP_QUERY_PROG_HW : XDP_QUERY_PROG; 8041 offload = flags & XDP_FLAGS_HW_MODE;
8042 query = offload ? XDP_QUERY_PROG_HW : XDP_QUERY_PROG;
8041 8043
8042 bpf_op = bpf_chk = ops->ndo_bpf; 8044 bpf_op = bpf_chk = ops->ndo_bpf;
8043 if (!bpf_op && (flags & (XDP_FLAGS_DRV_MODE | XDP_FLAGS_HW_MODE))) { 8045 if (!bpf_op && (flags & (XDP_FLAGS_DRV_MODE | XDP_FLAGS_HW_MODE))) {
@@ -8050,8 +8052,7 @@ int dev_change_xdp_fd(struct net_device *dev, struct netlink_ext_ack *extack,
8050 bpf_chk = generic_xdp_install; 8052 bpf_chk = generic_xdp_install;
8051 8053
8052 if (fd >= 0) { 8054 if (fd >= 0) {
8053 if (__dev_xdp_query(dev, bpf_chk, XDP_QUERY_PROG) || 8055 if (!offload && __dev_xdp_query(dev, bpf_chk, XDP_QUERY_PROG)) {
8054 __dev_xdp_query(dev, bpf_chk, XDP_QUERY_PROG_HW)) {
8055 NL_SET_ERR_MSG(extack, "native and generic XDP can't be active at the same time"); 8056 NL_SET_ERR_MSG(extack, "native and generic XDP can't be active at the same time");
8056 return -EEXIST; 8057 return -EEXIST;
8057 } 8058 }
@@ -8066,8 +8067,7 @@ int dev_change_xdp_fd(struct net_device *dev, struct netlink_ext_ack *extack,
8066 if (IS_ERR(prog)) 8067 if (IS_ERR(prog))
8067 return PTR_ERR(prog); 8068 return PTR_ERR(prog);
8068 8069
8069 if (!(flags & XDP_FLAGS_HW_MODE) && 8070 if (!offload && bpf_prog_is_dev_bound(prog->aux)) {
8070 bpf_prog_is_dev_bound(prog->aux)) {
8071 NL_SET_ERR_MSG(extack, "using device-bound program without HW_MODE flag is not supported"); 8071 NL_SET_ERR_MSG(extack, "using device-bound program without HW_MODE flag is not supported");
8072 bpf_prog_put(prog); 8072 bpf_prog_put(prog);
8073 return -EINVAL; 8073 return -EINVAL;