net: track the queue count at unregistration
Subsystems (2)
cover net: track the queue count at unregistration
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/[email protected]/T/
A patch fixing one issue linked to this was merged ealier,
https://lore.kernel.org/all/[email protected]/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(+)
Signature · 1 line
2.33.1
PATCH 1/2 net-sysfs: update the queue counts in the unregistration path
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.
--- net/core/net-sysfs.c | 3 +++ 1 file changed, 3 insertions(+)
net/core/net-sysfs.c +3 -0
@@ -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
Signature · 1 line
2.33.1
PATCH 2/2 net-sysfs: warn if new queue objects are being created during device unregistration
In reply to Antoine TenartCalling 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.
--- net/core/net-sysfs.c | 7 +++++++ 1 file changed, 7 insertions(+)
net/core/net-sysfs.c +7 -0
@@ -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) {
Signature · 1 line
2.33.1
This series was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · 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/[email protected]/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!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html