All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] net: track the queue count at unregistration
@ 2021-12-07 14:57 Antoine Tenart
  2021-12-07 14:57 ` [PATCH net-next 1/2] net-sysfs: update the queue counts in the unregistration path Antoine Tenart
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Antoine Tenart @ 2021-12-07 14:57 UTC (permalink / raw)
  To: davem, kuba; +Cc: Antoine Tenart, alexander.duyck, netdev

Hello,

Those two patches allow to track the Rx and Tx queue count at
unregistration and help in detecting illegal addition of Tx queues after
unregister (a warning is added).

This follows discussions on the following thread,
https://lore.kernel.org/all/20211122162007.303623-1-atenart@kernel.org/T/

A patch fixing one issue linked to this was merged ealier,
https://lore.kernel.org/all/20211203101318.435618-1-atenart@kernel.org/T/

Thanks,
Antoine

Antoine Tenart (2):
  net-sysfs: update the queue counts in the unregistration path
  net-sysfs: warn if new queue objects are being created during device
    unregistration

 net/core/net-sysfs.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

-- 
2.33.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH net-next 1/2] net-sysfs: update the queue counts in the unregistration path
  2021-12-07 14:57 [PATCH net-next 0/2] net: track the queue count at unregistration Antoine Tenart
@ 2021-12-07 14:57 ` Antoine Tenart
  2021-12-07 14:57 ` [PATCH net-next 2/2] net-sysfs: warn if new queue objects are being created during device unregistration Antoine Tenart
  2021-12-09  2:50 ` [PATCH net-next 0/2] net: track the queue count at unregistration patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Antoine Tenart @ 2021-12-07 14:57 UTC (permalink / raw)
  To: davem, kuba; +Cc: Antoine Tenart, alexander.duyck, netdev

When updating Rx and Tx queue kobjects, the queue count should always be
updated to match the queue kobjects count. This was not done in the net
device unregistration path, fix it. Tracking all queue count updates
will allow in a following up patch to detect illegal updates.

Signed-off-by: Antoine Tenart <atenart@kernel.org>
---
 net/core/net-sysfs.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 3b2cdbbdc858..33f408c24205 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -1808,6 +1808,9 @@ static void remove_queue_kobjects(struct net_device *dev)
 
 	net_rx_queue_update_kobjects(dev, real_rx, 0);
 	netdev_queue_update_kobjects(dev, real_tx, 0);
+
+	dev->real_num_rx_queues = 0;
+	dev->real_num_tx_queues = 0;
 #ifdef CONFIG_SYSFS
 	kset_unregister(dev->queues_kset);
 #endif
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH net-next 2/2] net-sysfs: warn if new queue objects are being created during device unregistration
  2021-12-07 14:57 [PATCH net-next 0/2] net: track the queue count at unregistration Antoine Tenart
  2021-12-07 14:57 ` [PATCH net-next 1/2] net-sysfs: update the queue counts in the unregistration path Antoine Tenart
@ 2021-12-07 14:57 ` Antoine Tenart
  2021-12-09  2:50 ` [PATCH net-next 0/2] net: track the queue count at unregistration patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Antoine Tenart @ 2021-12-07 14:57 UTC (permalink / raw)
  To: davem, kuba; +Cc: Antoine Tenart, alexander.duyck, netdev

Calling netdev_queue_update_kobjects is allowed during device
unregistration since commit 5c56580b74e5 ("net: Adjust TX queue kobjects
if number of queues changes during unregister"). But this is solely to
allow queue unregistrations. Any path attempting to add new queues after
a device started its unregistration should be fixed.

This patch adds a warning to detect such illegal use.

Signed-off-by: Antoine Tenart <atenart@kernel.org>
---
 net/core/net-sysfs.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 33f408c24205..53ea262ecafd 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -1694,6 +1694,13 @@ netdev_queue_update_kobjects(struct net_device *dev, int old_num, int new_num)
 	int i;
 	int error = 0;
 
+	/* Tx queue kobjects are allowed to be updated when a device is being
+	 * unregistered, but solely to remove queues from qdiscs. Any path
+	 * adding queues should be fixed.
+	 */
+	WARN(dev->reg_state == NETREG_UNREGISTERING && new_num > old_num,
+	     "New queues can't be registered after device unregistration.");
+
 	for (i = old_num; i < new_num; i++) {
 		error = netdev_queue_add_kobject(dev, i);
 		if (error) {
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next 0/2] net: track the queue count at unregistration
  2021-12-07 14:57 [PATCH net-next 0/2] net: track the queue count at unregistration Antoine Tenart
  2021-12-07 14:57 ` [PATCH net-next 1/2] net-sysfs: update the queue counts in the unregistration path Antoine Tenart
  2021-12-07 14:57 ` [PATCH net-next 2/2] net-sysfs: warn if new queue objects are being created during device unregistration Antoine Tenart
@ 2021-12-09  2:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-12-09  2:50 UTC (permalink / raw)
  To: Antoine Tenart; +Cc: davem, kuba, alexander.duyck, netdev

Hello:

This series was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Tue,  7 Dec 2021 15:57:23 +0100 you wrote:
> Hello,
> 
> Those two patches allow to track the Rx and Tx queue count at
> unregistration and help in detecting illegal addition of Tx queues after
> unregister (a warning is added).
> 
> This follows discussions on the following thread,
> https://lore.kernel.org/all/20211122162007.303623-1-atenart@kernel.org/T/
> 
> [...]

Here is the summary with links:
  - [net-next,1/2] net-sysfs: update the queue counts in the unregistration path
    https://git.kernel.org/netdev/net-next/c/d7dac083414e
  - [net-next,2/2] net-sysfs: warn if new queue objects are being created during device unregistration
    https://git.kernel.org/netdev/net-next/c/5f1c802ca69b

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-12-09  2:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-07 14:57 [PATCH net-next 0/2] net: track the queue count at unregistration Antoine Tenart
2021-12-07 14:57 ` [PATCH net-next 1/2] net-sysfs: update the queue counts in the unregistration path Antoine Tenart
2021-12-07 14:57 ` [PATCH net-next 2/2] net-sysfs: warn if new queue objects are being created during device unregistration Antoine Tenart
2021-12-09  2:50 ` [PATCH net-next 0/2] net: track the queue count at unregistration patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.