* [PATCH 2.5.69] pktgen module and dev cleanup
@ 2003-05-07 21:29 Stephen Hemminger
2003-05-08 15:37 ` David S. Miller
0 siblings, 1 reply; 2+ messages in thread
From: Stephen Hemminger @ 2003-05-07 21:29 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev
Fix pktgen so the /proc interface uses owner instead of inc/dec the
module ref count itself. Gets rid of warnings, and properly ref counts
all readers/writers now.
Change how network device ref count is acquired. Instead of forced inc,
just get reference via dev_get_by_name.
Use in_dev_get when looking at inet info, more race avoidance.
Built and tested with injection on gigabit ethernet and SMP machine.
Ref counts come out right during access, and can be unloaded fine.
diff -Nru a/net/core/pktgen.c b/net/core/pktgen.c
--- a/net/core/pktgen.c Wed May 7 14:21:14 2003
+++ b/net/core/pktgen.c Wed May 7 14:21:14 2003
@@ -226,21 +226,20 @@
{
struct net_device *odev;
- rtnl_lock();
- odev = __dev_get_by_name(info->outdev);
+ odev = dev_get_by_name(info->outdev);
if (!odev) {
sprintf(info->result, "No such netdevice: \"%s\"", info->outdev);
- goto out_unlock;
+ goto out;
}
if (odev->type != ARPHRD_ETHER) {
sprintf(info->result, "Not ethernet device: \"%s\"", info->outdev);
- goto out_unlock;
+ goto out_put;
}
if (!netif_running(odev)) {
sprintf(info->result, "Device is down: \"%s\"", info->outdev);
- goto out_unlock;
+ goto out_put;
}
/* Default to the interface's mac if not explicitly set. */
@@ -257,13 +256,13 @@
info->saddr_min = 0;
info->saddr_max = 0;
if (strlen(info->src_min) == 0) {
- if (odev->ip_ptr) {
- struct in_device *in_dev = odev->ip_ptr;
-
+ struct in_device *in_dev = in_dev_get(odev);
+ if (in_dev) {
if (in_dev->ifa_list) {
info->saddr_min = in_dev->ifa_list->ifa_address;
info->saddr_max = info->saddr_min;
}
+ in_dev_put(in_dev);
}
}
else {
@@ -282,13 +281,11 @@
info->cur_udp_dst = info->udp_dst_min;
info->cur_udp_src = info->udp_src_min;
- atomic_inc(&odev->refcnt);
- rtnl_unlock();
-
return odev;
-out_unlock:
- rtnl_unlock();
+out_put:
+ dev_put(odev);
+out:
return NULL;
}
@@ -1258,7 +1255,6 @@
}
if (!strcmp(name, "inject") || !strcmp(name, "start")) {
- MOD_INC_USE_COUNT;
if (info->busy) {
strcpy(info->result, "Already running...\n");
}
@@ -1268,7 +1264,6 @@
inject(info);
info->busy = 0;
}
- MOD_DEC_USE_COUNT;
return count;
}
@@ -1337,6 +1332,7 @@
pginfos[i].proc_ent->read_proc = proc_read;
pginfos[i].proc_ent->write_proc = proc_write;
pginfos[i].proc_ent->data = (void*)(long)(i);
+ pginfos[i].proc_ent->owner = THIS_MODULE;
sprintf(pginfos[i].busy_fname, "net/%s/pg_busy%i", PG_PROC_DIR, i);
pginfos[i].busy_proc_ent = create_proc_entry(pginfos[i].busy_fname, 0, 0);
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 2.5.69] pktgen module and dev cleanup
2003-05-07 21:29 [PATCH 2.5.69] pktgen module and dev cleanup Stephen Hemminger
@ 2003-05-08 15:37 ` David S. Miller
0 siblings, 0 replies; 2+ messages in thread
From: David S. Miller @ 2003-05-08 15:37 UTC (permalink / raw)
To: shemminger; +Cc: netdev
From: Stephen Hemminger <shemminger@osdl.org>
Date: Wed, 7 May 2003 14:29:11 -0700
Fix pktgen so the /proc interface uses owner instead of inc/dec the
module ref count itself. Gets rid of warnings, and properly ref counts
all readers/writers now.
Applied, thanks a lot Stephen.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-05-08 15:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-05-07 21:29 [PATCH 2.5.69] pktgen module and dev cleanup Stephen Hemminger
2003-05-08 15:37 ` David S. Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).