diff options
author | Jakub Kicinski <jakub.kicinski@netronome.com> | 2019-02-05 23:03:21 -0500 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2019-02-06 09:35:42 -0500 |
commit | 9ee963d6a1a03a4302b230cd21476a3c269af284 (patch) | |
tree | 2badb283ac3aa999260b6dd3b5f37f5eb2e2d682 /net/core/dev.c | |
parent | 52158f009742b4726121cf51f6d5fd8590ef7996 (diff) |
net: xdp: allow generic and driver XDP on one interface
Since commit a25717d2b604 ("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>
Diffstat (limited to 'net/core/dev.c')
-rw-r--r-- | net/core/dev.c | 10 |
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; |