net: xdp: allow generic and driver XDP on one interface
Since commit a25717d2b6
("xdp: support simultaneous driver and
hw XDP attachment") users can load an XDP program for offload and
in native driver mode simultaneously. Allow a similar mix of
offload and SKB mode/generic XDP.
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
This commit is contained in:
parent
52158f0097
commit
9ee963d6a1
|
@ -7976,11 +7976,13 @@ int dev_change_xdp_fd(struct net_device *dev, struct netlink_ext_ack *extack,
|
|||
enum bpf_netdev_command query;
|
||||
struct bpf_prog *prog = NULL;
|
||||
bpf_op_t bpf_op, bpf_chk;
|
||||
bool offload;
|
||||
int err;
|
||||
|
||||
ASSERT_RTNL();
|
||||
|
||||
query = flags & XDP_FLAGS_HW_MODE ? XDP_QUERY_PROG_HW : XDP_QUERY_PROG;
|
||||
offload = flags & XDP_FLAGS_HW_MODE;
|
||||
query = offload ? XDP_QUERY_PROG_HW : XDP_QUERY_PROG;
|
||||
|
||||
bpf_op = bpf_chk = ops->ndo_bpf;
|
||||
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,
|
|||
bpf_chk = generic_xdp_install;
|
||||
|
||||
if (fd >= 0) {
|
||||
if (__dev_xdp_query(dev, bpf_chk, XDP_QUERY_PROG) ||
|
||||
__dev_xdp_query(dev, bpf_chk, XDP_QUERY_PROG_HW)) {
|
||||
if (!offload && __dev_xdp_query(dev, bpf_chk, XDP_QUERY_PROG)) {
|
||||
NL_SET_ERR_MSG(extack, "native and generic XDP can't be active at the same time");
|
||||
return -EEXIST;
|
||||
}
|
||||
|
@ -8009,8 +8010,7 @@ int dev_change_xdp_fd(struct net_device *dev, struct netlink_ext_ack *extack,
|
|||
if (IS_ERR(prog))
|
||||
return PTR_ERR(prog);
|
||||
|
||||
if (!(flags & XDP_FLAGS_HW_MODE) &&
|
||||
bpf_prog_is_dev_bound(prog->aux)) {
|
||||
if (!offload && bpf_prog_is_dev_bound(prog->aux)) {
|
||||
NL_SET_ERR_MSG(extack, "using device-bound program without HW_MODE flag is not supported");
|
||||
bpf_prog_put(prog);
|
||||
return -EINVAL;
|
||||
|
|
Loading…
Reference in New Issue