Skip to content

Commit

Permalink
net-sysfs: warn if new queue objects are being created during device …
Browse files Browse the repository at this point in the history
…unregistration

Calling netdev_queue_update_kobjects is allowed during device
unregistration since commit 5c56580 ("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 <[email protected]>
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
atenart authored and kuba-moo committed Dec 9, 2021
1 parent d7dac08 commit 5f1c802
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions net/core/net-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 5f1c802

Please sign in to comment.