diff options
author | Daniel Borkmann <daniel@iogearbox.net> | 2017-05-12 01:04:45 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-05-11 21:30:57 -0400 |
commit | 0489df9a430e9607de8130a6bc4bf4c02f96eaf1 (patch) | |
tree | 88f00a27ce3e1e8c94269f687dcbcf951b4c9f1b /net | |
parent | 0a5539f66133a02b24f9cc43da5b84b7e6f3f436 (diff) | |
download | op-kernel-dev-0489df9a430e9607de8130a6bc4bf4c02f96eaf1.zip op-kernel-dev-0489df9a430e9607de8130a6bc4bf4c02f96eaf1.tar.gz |
xdp: add flag to enforce driver mode
After commit b5cdae3291f7 ("net: Generic XDP") we automatically fall
back to a generic XDP variant if the driver does not support native
XDP. Allow for an option where the user can specify that always the
native XDP variant should be selected and in case it's not supported
by a driver, just bail out.
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/core/dev.c | 2 | ||||
-rw-r--r-- | net/core/rtnetlink.c | 5 |
2 files changed, 7 insertions, 0 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index 96cf83d..e56cb71 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -6873,6 +6873,8 @@ int dev_change_xdp_fd(struct net_device *dev, struct netlink_ext_ack *extack, ASSERT_RTNL(); xdp_op = ops->ndo_xdp; + if (!xdp_op && (flags & XDP_FLAGS_DRV_MODE)) + return -EOPNOTSUPP; if (!xdp_op || (flags & XDP_FLAGS_SKB_MODE)) xdp_op = generic_xdp_install; diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index bcb0f610..dda9f16 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -2199,6 +2199,11 @@ static int do_setlink(const struct sk_buff *skb, err = -EINVAL; goto errout; } + if ((xdp_flags & XDP_FLAGS_SKB_MODE) && + (xdp_flags & XDP_FLAGS_DRV_MODE)) { + err = -EINVAL; + goto errout; + } } if (xdp[IFLA_XDP_FD]) { |