Commit 681f19c6 authored by Robert Olsson's avatar Robert Olsson Committed by Chris Wright

[PATCH] PKTGEN: Fix module load/unload races.

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarChris Wright <chrisw@sous-sol.org>
parent 8d312ae1
...@@ -147,6 +147,7 @@ ...@@ -147,6 +147,7 @@
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/wait.h> #include <linux/wait.h>
#include <linux/completion.h>
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <net/checksum.h> #include <net/checksum.h>
#include <net/ipv6.h> #include <net/ipv6.h>
...@@ -206,6 +207,11 @@ static struct proc_dir_entry *pg_proc_dir = NULL; ...@@ -206,6 +207,11 @@ static struct proc_dir_entry *pg_proc_dir = NULL;
#define VLAN_TAG_SIZE(x) ((x)->vlan_id == 0xffff ? 0 : 4) #define VLAN_TAG_SIZE(x) ((x)->vlan_id == 0xffff ? 0 : 4)
#define SVLAN_TAG_SIZE(x) ((x)->svlan_id == 0xffff ? 0 : 4) #define SVLAN_TAG_SIZE(x) ((x)->svlan_id == 0xffff ? 0 : 4)
struct pktgen_thread_info {
struct pktgen_thread *t;
struct completion *c;
};
struct flow_state { struct flow_state {
__u32 cur_daddr; __u32 cur_daddr;
int count; int count;
...@@ -3264,10 +3270,11 @@ out:; ...@@ -3264,10 +3270,11 @@ out:;
* Main loop of the thread goes here * Main loop of the thread goes here
*/ */
static void pktgen_thread_worker(struct pktgen_thread *t) static void pktgen_thread_worker(struct pktgen_thread_info *info)
{ {
DEFINE_WAIT(wait); DEFINE_WAIT(wait);
struct pktgen_dev *pkt_dev = NULL; struct pktgen_dev *pkt_dev = NULL;
struct pktgen_thread *t = info->t;
int cpu = t->cpu; int cpu = t->cpu;
sigset_t tmpsig; sigset_t tmpsig;
u32 max_before_softirq; u32 max_before_softirq;
...@@ -3307,6 +3314,8 @@ static void pktgen_thread_worker(struct pktgen_thread *t) ...@@ -3307,6 +3314,8 @@ static void pktgen_thread_worker(struct pktgen_thread *t)
__set_current_state(TASK_INTERRUPTIBLE); __set_current_state(TASK_INTERRUPTIBLE);
mb(); mb();
complete(info->c);
while (1) { while (1) {
__set_current_state(TASK_RUNNING); __set_current_state(TASK_RUNNING);
...@@ -3518,6 +3527,8 @@ static struct pktgen_thread *__init pktgen_find_thread(const char *name) ...@@ -3518,6 +3527,8 @@ static struct pktgen_thread *__init pktgen_find_thread(const char *name)
static int __init pktgen_create_thread(const char *name, int cpu) static int __init pktgen_create_thread(const char *name, int cpu)
{ {
int err; int err;
struct pktgen_thread_info info;
struct completion started;
struct pktgen_thread *t = NULL; struct pktgen_thread *t = NULL;
struct proc_dir_entry *pe; struct proc_dir_entry *pe;
...@@ -3558,7 +3569,11 @@ static int __init pktgen_create_thread(const char *name, int cpu) ...@@ -3558,7 +3569,11 @@ static int __init pktgen_create_thread(const char *name, int cpu)
t->removed = 0; t->removed = 0;
err = kernel_thread((void *)pktgen_thread_worker, (void *)t, init_completion(&started);
info.t = t;
info.c = &started;
err = kernel_thread((void *)pktgen_thread_worker, (void *)&info,
CLONE_FS | CLONE_FILES | CLONE_SIGHAND); CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
if (err < 0) { if (err < 0) {
printk("pktgen: kernel_thread() failed for cpu %d\n", t->cpu); printk("pktgen: kernel_thread() failed for cpu %d\n", t->cpu);
...@@ -3568,6 +3583,7 @@ static int __init pktgen_create_thread(const char *name, int cpu) ...@@ -3568,6 +3583,7 @@ static int __init pktgen_create_thread(const char *name, int cpu)
return err; return err;
} }
wait_for_completion(&started);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment