diff options
| author | ozaki-r <ozaki-r@NetBSD.org> | 2018-03-06 07:27:55 +0000 |
|---|---|---|
| committer | ozaki-r <ozaki-r@NetBSD.org> | 2018-03-06 07:27:55 +0000 |
| commit | 189cfbc96fa2dcb47b5f0e57a9400a886ae7489c (patch) | |
| tree | 1b4bb456a58231454ba8371526e5d2141a9b2725 /sys/net | |
| parent | 39d7ee4d3c5f654bfdd179ab64dc54fd17d7673b (diff) | |
Use pool(9) for llentry allocations
llentry is easy to be leaked and pool suits for it because pool is usable to
detect leaks.
Also sweep unnecessary wrappers for llentry, in_llentry and in6_llentry.
Diffstat (limited to 'sys/net')
| -rw-r--r-- | sys/net/if_llatbl.c | 24 | ||||
| -rw-r--r-- | sys/net/if_llatbl.h | 5 |
2 files changed, 27 insertions, 2 deletions
diff --git a/sys/net/if_llatbl.c b/sys/net/if_llatbl.c index 57f6b49ffa1..7fc7d19602d 100644 --- a/sys/net/if_llatbl.c +++ b/sys/net/if_llatbl.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_llatbl.c,v 1.25 2018/03/06 07:25:27 ozaki-r Exp $ */ +/* $NetBSD: if_llatbl.c,v 1.26 2018/03/06 07:27:55 ozaki-r Exp $ */ /* * Copyright (c) 2004 Luigi Rizzo, Alessandro Cerri. All rights reserved. * Copyright (c) 2004-2008 Qing Li. All rights reserved. @@ -67,6 +67,7 @@ static SLIST_HEAD(, lltable) lltables; krwlock_t lltable_rwlock; +static struct pool llentry_pool; static void lltable_unlink(struct lltable *llt); static void llentries_unlink(struct lltable *llt, struct llentries *head); @@ -335,6 +336,24 @@ lltable_drop_entry_queue(struct llentry *lle) return (pkts_dropped); } +struct llentry * +llentry_pool_get(int flags) +{ + struct llentry *lle; + + lle = pool_get(&llentry_pool, flags); + if (lle != NULL) + memset(lle, 0, sizeof(*lle)); + return lle; +} + +void +llentry_pool_put(struct llentry *lle) +{ + + pool_put(&llentry_pool, lle); +} + /* * Deletes an address from the address table. * This function is called by the timer functions @@ -747,6 +766,9 @@ lltableinit(void) SLIST_INIT(&lltables); rw_init(&lltable_rwlock); + + pool_init(&llentry_pool, sizeof(struct llentry), 0, 0, 0, "llentrypl", + NULL, IPL_SOFTNET); } #ifdef __FreeBSD__ diff --git a/sys/net/if_llatbl.h b/sys/net/if_llatbl.h index e53c2c75abd..4c5d13e986c 100644 --- a/sys/net/if_llatbl.h +++ b/sys/net/if_llatbl.h @@ -1,4 +1,4 @@ -/* $NetBSD: if_llatbl.h,v 1.13 2017/11/10 07:24:28 ozaki-r Exp $ */ +/* $NetBSD: if_llatbl.h,v 1.14 2018/03/06 07:27:55 ozaki-r Exp $ */ /* * Copyright (c) 2004 Luigi Rizzo, Alessandro Cerri. All rights reserved. * Copyright (c) 2004-2008 Qing Li. All rights reserved. @@ -266,6 +266,9 @@ size_t llentry_free(struct llentry *); struct llentry *llentry_alloc(struct ifnet *, struct lltable *, struct sockaddr_storage *); +struct llentry *llentry_pool_get(int); +void llentry_pool_put(struct llentry *); + /* helper functions */ size_t lltable_drop_entry_queue(struct llentry *); |
