Skip to content

Commit

Permalink
net: Queue net_cleanup_work only if there is first net added
Browse files Browse the repository at this point in the history
When llist_add() returns false, cleanup_net() hasn't made its
llist_del_all(), while the work has already been scheduled
by the first queuer. So, we may skip queue_work() in this case.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Kirill Tkhai authored and David S. Miller committed Feb 20, 2018
1 parent 65b7b5b commit 8349efd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions net/core/net_namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -582,8 +582,8 @@ static DECLARE_WORK(net_cleanup_work, cleanup_net);
void __put_net(struct net *net)
{
/* Cleanup the network namespace in process context */
llist_add(&net->cleanup_list, &cleanup_list);
queue_work(netns_wq, &net_cleanup_work);
if (llist_add(&net->cleanup_list, &cleanup_list))
queue_work(netns_wq, &net_cleanup_work);
}
EXPORT_SYMBOL_GPL(__put_net);

Expand Down

0 comments on commit 8349efd

Please sign in to comment.