mirror of
https://git.FreeBSD.org/src.git
synced 2024-10-18 02:19:39 +00:00
netmap: fix refcount bug in netmap allocator
Symptom: when a single extmem memory region is provided to netmap multiple times, for multiple interfaces, the memory region is never released by netmap once all the existing file descriptors are closed. Fix the relevant condition in netmap_mem_drop(): release the memory when the last user of netmap_adapter is gone, rather then when the last user of netmap_mem_d is gone. MFC after: 2 weeks
This commit is contained in:
parent
bafaa70b6f
commit
09a1893398
@ -994,10 +994,12 @@ netmap_mem_restore(struct netmap_adapter *na)
|
||||
static void
|
||||
netmap_mem_drop(struct netmap_adapter *na)
|
||||
{
|
||||
/* if the native allocator had been overridden on regif,
|
||||
* restore it now and drop the temporary one
|
||||
*/
|
||||
if (netmap_mem_deref(na->nm_mem, na)) {
|
||||
netmap_mem_deref(na->nm_mem, na);
|
||||
|
||||
if (na->active_fds <= 0) {
|
||||
/* if the native allocator had been overridden on regif,
|
||||
* restore it now and drop the temporary one
|
||||
*/
|
||||
netmap_mem_restore(na);
|
||||
}
|
||||
}
|
||||
|
@ -323,7 +323,7 @@ netmap_mem_get_id(struct netmap_mem_d *nmd)
|
||||
|
||||
#ifdef NM_DEBUG_MEM_PUTGET
|
||||
#define NM_DBG_REFC(nmd, func, line) \
|
||||
nm_prinf("%d mem[%d:%d] -> %d", line, (nmd)->nm_id, (nmd)->nm_grp, (nmd)->refcount);
|
||||
nm_prinf("%s:%d mem[%d:%d] -> %d", func, line, (nmd)->nm_id, (nmd)->nm_grp, (nmd)->refcount);
|
||||
#else
|
||||
#define NM_DBG_REFC(nmd, func, line)
|
||||
#endif
|
||||
|
@ -986,7 +986,7 @@ nm_close(struct nm_desc *d)
|
||||
close(d->fd);
|
||||
}
|
||||
|
||||
bzero(d, sizeof(*d));
|
||||
bzero((char *)d, sizeof(*d));
|
||||
free(d);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user