netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: alexei.starovoitov@gmail.com, daniel@iogearbox.net,
	brouer@redhat.com, "Björn Töpel" <bjorn.topel@intel.com>,
	"Magnus Karlsson" <magnus.karlsson@intel.com>
Cc: oss-drivers@netronome.com, netdev@vger.kernel.org,
	Jakub Kicinski <jakub.kicinski@netronome.com>
Subject: [RFC bpf-next 6/6] ethtool: don't allow disabling queues with umem installed
Date: Thu, 26 Jul 2018 14:41:48 -0700	[thread overview]
Message-ID: <20180726214148.2087-7-jakub.kicinski@netronome.com> (raw)
In-Reply-To: <20180726214148.2087-1-jakub.kicinski@netronome.com>

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 <jakub.kicinski@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
---
 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

  parent reply	other threads:[~2018-07-26 23:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-26 21:41 [RFC bpf-next 0/6] net: xsk: minor improvements around queue handling Jakub Kicinski
2018-07-26 21:41 ` [RFC bpf-next 1/6] net: update real_num_rx_queues even when !CONFIG_SYSFS Jakub Kicinski
2018-07-26 21:41 ` [RFC bpf-next 2/6] xsk: refactor xdp_umem_assign_dev() Jakub Kicinski
2018-07-30 11:41   ` Björn Töpel
2018-07-26 21:41 ` [RFC bpf-next 3/6] xsk: don't allow umem replace at stack level Jakub Kicinski
2018-07-30 12:00   ` Björn Töpel
2018-07-26 21:41 ` [RFC bpf-next 4/6] xsk: don't allow installing UMEM beyond the number of queues Jakub Kicinski
2018-07-26 21:41 ` [RFC bpf-next 5/6] ethtool: rename local variable max -> curr Jakub Kicinski
2018-07-26 21:41 ` Jakub Kicinski [this message]
2018-07-30 12:49 ` [RFC bpf-next 0/6] net: xsk: minor improvements around queue handling Björn Töpel
2018-07-31  2:49   ` Jakub Kicinski
2018-07-31  7:15     ` Björn Töpel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180726214148.2087-7-jakub.kicinski@netronome.com \
    --to=jakub.kicinski@netronome.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=bjorn.topel@intel.com \
    --cc=brouer@redhat.com \
    --cc=daniel@iogearbox.net \
    --cc=magnus.karlsson@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=oss-drivers@netronome.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).