diff options
| author | Luigi Rizzo <luigi@FreeBSD.org> | 2015-07-19 18:07:25 +0000 |
|---|---|---|
| committer | Luigi Rizzo <luigi@FreeBSD.org> | 2015-07-19 18:07:25 +0000 |
| commit | 847adfb7b309db039b91591e545ed5c3f28a3416 (patch) | |
| tree | 53c257919e0af2de1b7a21f03661e4e25c7e744e /sys/dev/netmap | |
| parent | 10b8ef3d6a7e3419068f1c39a24e389651f2321c (diff) | |
Notes
Diffstat (limited to 'sys/dev/netmap')
| -rw-r--r-- | sys/dev/netmap/netmap.c | 5 | ||||
| -rw-r--r-- | sys/dev/netmap/netmap_freebsd.c | 14 | ||||
| -rw-r--r-- | sys/dev/netmap/netmap_kern.h | 1 |
3 files changed, 18 insertions, 2 deletions
diff --git a/sys/dev/netmap/netmap.c b/sys/dev/netmap/netmap.c index 60a31727860c6..8094fe35256c6 100644 --- a/sys/dev/netmap/netmap.c +++ b/sys/dev/netmap/netmap.c @@ -542,6 +542,7 @@ SYSCTL_INT(_dev_netmap, OID_AUTO, generic_ringsize, CTLFLAG_RW, &netmap_generic_ SYSCTL_INT(_dev_netmap, OID_AUTO, generic_rings, CTLFLAG_RW, &netmap_generic_rings, 0 , ""); NMG_LOCK_T netmap_global_lock; +int netmap_use_count = 0; /* number of active netmap instances */ /* * mark the ring as stopped, and run through the locks @@ -975,11 +976,11 @@ netmap_dtor_locked(struct netmap_priv_d *priv) { struct netmap_adapter *na = priv->np_na; - /* number of active mmaps on this fd (FreeBSD only) */ + /* number of active references to this fd */ if (--priv->np_refs > 0) { return 0; } - + netmap_use_count--; if (!na) { return 1; //XXX is it correct? } diff --git a/sys/dev/netmap/netmap_freebsd.c b/sys/dev/netmap/netmap_freebsd.c index 31c7cf02dd5bb..8490ae85670bf 100644 --- a/sys/dev/netmap/netmap_freebsd.c +++ b/sys/dev/netmap/netmap_freebsd.c @@ -642,6 +642,10 @@ netmap_open(struct cdev *dev, int oflags, int devtype, struct thread *td) error = devfs_set_cdevpriv(priv, netmap_dtor); if (error) { free(priv, M_DEVBUF); + } else { + NMG_LOCK(); + netmap_use_count++; + NMG_UNLOCK(); } return error; } @@ -827,6 +831,16 @@ netmap_loader(__unused struct module *module, int event, __unused void *arg) break; case MOD_UNLOAD: + /* + * if some one is still using netmap, + * then the module can not be unloaded. + */ + if (netmap_use_count) { + D("netmap module can not be unloaded - netmap_use_count: %d", + netmap_use_count); + error = EBUSY; + break; + } netmap_fini(); break; diff --git a/sys/dev/netmap/netmap_kern.h b/sys/dev/netmap/netmap_kern.h index b46050df9e005..d38b3b242da95 100644 --- a/sys/dev/netmap/netmap_kern.h +++ b/sys/dev/netmap/netmap_kern.h @@ -1247,6 +1247,7 @@ extern int netmap_txsync_retry; extern int netmap_generic_mit; extern int netmap_generic_ringsize; extern int netmap_generic_rings; +extern int netmap_use_count; /* * NA returns a pointer to the struct netmap adapter from the ifp, |
