提交 b2a7df99 编写于 作者: J Jakub Kicinski 提交者: Zheng Zengkai

net: transition netdev reg state earlier in run_todo

net-next inclusion
from net-next-v5.17-rc5
commit ae68db14
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4VZN0?from=project-issue

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?id=ae68db14b6164ce46beffaf35eb7c9bb2f92fee3

--------------------------------

In prep for unregistering netdevs out of order move the netdev
state validation and change outside of the loop.

While at it modernize this code and use WARN() instead of
pr_err() + dump_stack().
Reviewed-by: NEric Dumazet <edumazet@google.com>
Reviewed-by: NXin Long <lucien.xin@gmail.com>
Link: https://lore.kernel.org/r/20220215225310.3679266-1-kuba@kernel.orgSigned-off-by: NJakub Kicinski <kuba@kernel.org>
Signed-off-by: NZiyang Xuan <william.xuanziyang@huawei.com>
Reviewed-by: NWei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 c8801769
...@@ -10336,6 +10336,7 @@ static void netdev_wait_allrefs(struct net_device *dev) ...@@ -10336,6 +10336,7 @@ static void netdev_wait_allrefs(struct net_device *dev)
*/ */
void netdev_run_todo(void) void netdev_run_todo(void)
{ {
struct net_device *dev, *tmp;
struct list_head list; struct list_head list;
#ifdef CONFIG_LOCKDEP #ifdef CONFIG_LOCKDEP
struct list_head unlink_list; struct list_head unlink_list;
...@@ -10356,24 +10357,23 @@ void netdev_run_todo(void) ...@@ -10356,24 +10357,23 @@ void netdev_run_todo(void)
__rtnl_unlock(); __rtnl_unlock();
/* Wait for rcu callbacks to finish before next phase */ /* Wait for rcu callbacks to finish before next phase */
if (!list_empty(&list)) if (!list_empty(&list))
rcu_barrier(); rcu_barrier();
while (!list_empty(&list)) { list_for_each_entry_safe(dev, tmp, &list, todo_list) {
struct net_device *dev
= list_first_entry(&list, struct net_device, todo_list);
list_del(&dev->todo_list);
if (unlikely(dev->reg_state != NETREG_UNREGISTERING)) { if (unlikely(dev->reg_state != NETREG_UNREGISTERING)) {
pr_err("network todo '%s' but state %d\n", netdev_WARN(dev, "run_todo but not unregistering\n");
dev->name, dev->reg_state); list_del(&dev->todo_list);
dump_stack();
continue; continue;
} }
dev->reg_state = NETREG_UNREGISTERED; dev->reg_state = NETREG_UNREGISTERED;
}
while (!list_empty(&list)) {
dev = list_first_entry(&list, struct net_device, todo_list);
list_del(&dev->todo_list);
netdev_wait_allrefs(dev); netdev_wait_allrefs(dev);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册