aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/core/pktgen.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 4d8ce93cd503..77a59980b579 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -1931,7 +1931,7 @@ static int pktgen_device_event(struct notifier_block *unused,
1931{ 1931{
1932 struct net_device *dev = ptr; 1932 struct net_device *dev = ptr;
1933 1933
1934 if (!net_eq(dev_net(dev), &init_net)) 1934 if (!net_eq(dev_net(dev), &init_net) || pktgen_exiting)
1935 return NOTIFY_DONE; 1935 return NOTIFY_DONE;
1936 1936
1937 /* It is OK that we do not hold the group lock right now, 1937 /* It is OK that we do not hold the group lock right now,
@@ -3755,12 +3755,18 @@ static void __exit pg_cleanup(void)
3755{ 3755{
3756 struct pktgen_thread *t; 3756 struct pktgen_thread *t;
3757 struct list_head *q, *n; 3757 struct list_head *q, *n;
3758 struct list_head list;
3758 3759
3759 /* Stop all interfaces & threads */ 3760 /* Stop all interfaces & threads */
3760 pktgen_exiting = true; 3761 pktgen_exiting = true;
3761 3762
3762 list_for_each_safe(q, n, &pktgen_threads) { 3763 mutex_lock(&pktgen_thread_lock);
3764 list_splice(&list, &pktgen_threads);
3765 mutex_unlock(&pktgen_thread_lock);
3766
3767 list_for_each_safe(q, n, &list) {
3763 t = list_entry(q, struct pktgen_thread, th_list); 3768 t = list_entry(q, struct pktgen_thread, th_list);
3769 list_del(&t->th_list);
3764 kthread_stop(t->tsk); 3770 kthread_stop(t->tsk);
3765 kfree(t); 3771 kfree(t);
3766 } 3772 }