From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jakub Kicinski Subject: [RFC bpf-next 6/6] ethtool: don't allow disabling queues with umem installed Date: Thu, 26 Jul 2018 14:41:48 -0700 Message-ID: <20180726214148.2087-7-jakub.kicinski@netronome.com> References: <20180726214148.2087-1-jakub.kicinski@netronome.com> Cc: oss-drivers@netronome.com, netdev@vger.kernel.org, Jakub Kicinski To: alexei.starovoitov@gmail.com, daniel@iogearbox.net, brouer@redhat.com, =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Magnus Karlsson Return-path: Received: from mail-qt0-f194.google.com ([209.85.216.194]:39389 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731709AbeGZXBY (ORCPT ); Thu, 26 Jul 2018 19:01:24 -0400 Received: by mail-qt0-f194.google.com with SMTP id q12-v6so3137815qtp.6 for ; Thu, 26 Jul 2018 14:42:42 -0700 (PDT) In-Reply-To: <20180726214148.2087-1-jakub.kicinski@netronome.com> Sender: netdev-owner@vger.kernel.org List-ID: We already check the RSS indirection table does not use queues which would be disabled by channel reconfiguration. Make sure user does not try to disable queues which have a UMEM and zero- -copy AF_XDP socket installed. Signed-off-by: Jakub Kicinski Reviewed-by: Quentin Monnet --- include/linux/netdevice.h | 8 ++++++++ net/core/ethtool.c | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index a5a34f0fb485..c0df40deec54 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -3566,7 +3566,15 @@ int dev_change_xdp_fd(struct net_device *dev, struct netlink_ext_ack *extack, int fd, u32 flags); u32 __dev_xdp_query(struct net_device *dev, bpf_op_t xdp_op, enum bpf_netdev_command cmd); + +#if defined(CONFIG_XDP_SOCKETS) int xdp_umem_query(struct net_device *dev, u16 queue_id); +#else +static inline int xdp_umem_query(struct net_device *dev, u16 queue_id) +{ + return 0; +} +#endif int __dev_forward_skb(struct net_device *dev, struct sk_buff *skb); int dev_forward_skb(struct net_device *dev, struct sk_buff *skb); diff --git a/net/core/ethtool.c b/net/core/ethtool.c index 4d5093577fe6..a8e693de5b11 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c @@ -1745,6 +1745,7 @@ static noinline_for_stack int ethtool_set_channels(struct net_device *dev, { struct ethtool_channels channels, curr = { .cmd = ETHTOOL_GCHANNELS }; u32 max_rx_in_use = 0; + unsigned int i; if (!dev->ethtool_ops->set_channels || !dev->ethtool_ops->get_channels) return -EOPNOTSUPP; @@ -1768,6 +1769,12 @@ static noinline_for_stack int ethtool_set_channels(struct net_device *dev, (channels.combined_count + channels.rx_count) <= max_rx_in_use) return -EINVAL; + /* Disabling channels, query zero-copy AF_XDP sockets */ + for (i = channels.combined_count + channels.rx_count; + i < curr.combined_count + curr.rx_count; i++) + if (xdp_umem_query(dev, i) > 0) + return -EINVAL; + return dev->ethtool_ops->set_channels(dev, &channels); } -- 2.17.1