Skip to content

Commit

Permalink
[PKTGEN]: Use proc_create() to setup ->proc_fops first
Browse files Browse the repository at this point in the history
Use proc_create() to make sure that ->proc_fops be setup before gluing
PDE to main tree.

Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Wang Chen authored and David S. Miller committed Feb 28, 2008
1 parent 46ecf0b commit 25296d5
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions net/core/pktgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -3570,14 +3570,14 @@ static int pktgen_add_device(struct pktgen_thread *t, const char *ifname)
if (err)
goto out1;

pkt_dev->entry = create_proc_entry(ifname, 0600, pg_proc_dir);
pkt_dev->entry = proc_create(ifname, 0600,
pg_proc_dir, &pktgen_if_fops);
if (!pkt_dev->entry) {
printk(KERN_ERR "pktgen: cannot create %s/%s procfs entry.\n",
PG_PROC_DIR, ifname);
err = -EINVAL;
goto out2;
}
pkt_dev->entry->proc_fops = &pktgen_if_fops;
pkt_dev->entry->data = pkt_dev;
#ifdef CONFIG_XFRM
pkt_dev->ipsmode = XFRM_MODE_TRANSPORT;
Expand Down Expand Up @@ -3628,7 +3628,7 @@ static int __init pktgen_create_thread(int cpu)
kthread_bind(p, cpu);
t->tsk = p;

pe = create_proc_entry(t->tsk->comm, 0600, pg_proc_dir);
pe = proc_create(t->tsk->comm, 0600, pg_proc_dir, &pktgen_thread_fops);
if (!pe) {
printk(KERN_ERR "pktgen: cannot create %s/%s procfs entry.\n",
PG_PROC_DIR, t->tsk->comm);
Expand All @@ -3638,7 +3638,6 @@ static int __init pktgen_create_thread(int cpu)
return -EINVAL;
}

pe->proc_fops = &pktgen_thread_fops;
pe->data = t;

wake_up_process(p);
Expand Down Expand Up @@ -3709,15 +3708,14 @@ static int __init pg_init(void)
return -ENODEV;
pg_proc_dir->owner = THIS_MODULE;

pe = create_proc_entry(PGCTRL, 0600, pg_proc_dir);
pe = proc_create(PGCTRL, 0600, pg_proc_dir, &pktgen_fops);
if (pe == NULL) {
printk(KERN_ERR "pktgen: ERROR: cannot create %s "
"procfs entry.\n", PGCTRL);
proc_net_remove(&init_net, PG_PROC_DIR);
return -EINVAL;
}

pe->proc_fops = &pktgen_fops;
pe->data = NULL;

/* Register us to receive netdevice events */
Expand Down

0 comments on commit 25296d5

Please sign in to comment.