Make arp have its own mowner

This helped me to debug mbuf leaks in arp.
(if_arp.c rev. 1.298)
This commit is contained in:
yamt 2022-11-19 08:00:51 +00:00
parent b471b82f34
commit 34172d955e
5 changed files with 31 additions and 9 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_llatbl.c,v 1.34 2022/05/24 20:50:20 andvar Exp $ */
/* $NetBSD: if_llatbl.c,v 1.35 2022/11/19 08:00:51 yamt Exp $ */
/*
* Copyright (c) 2004 Luigi Rizzo, Alessandro Cerri. All rights reserved.
* Copyright (c) 2004-2008 Qing Li. All rights reserved.
@ -540,6 +540,9 @@ lltable_allocate_htbl(uint32_t hsize)
llt->llt_foreach_entry = htable_foreach_lle;
llt->llt_free_tbl = htable_free_tbl;
#ifdef MBUFTRACE
llt->llt_mowner = NULL;
#endif
return (llt);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_llatbl.h,v 1.18 2020/09/14 15:09:57 roy Exp $ */
/* $NetBSD: if_llatbl.h,v 1.19 2022/11/19 08:00:51 yamt Exp $ */
/*
* Copyright (c) 2004 Luigi Rizzo, Alessandro Cerri. All rights reserved.
* Copyright (c) 2004-2008 Qing Li. All rights reserved.
@ -34,6 +34,7 @@
#if defined(_KERNEL_OPT)
#include "opt_gateway.h"
#include "opt_mbuftrace.h"
#endif
#include <sys/rwlock.h>
@ -232,6 +233,9 @@ struct lltable {
llt_unlink_entry_t *llt_unlink_entry;
llt_fill_sa_entry_t *llt_fill_sa_entry;
llt_free_tbl_t *llt_free_tbl;
#ifdef MBUFTRACE
struct mowner *llt_mowner;
#endif
};
MALLOC_DECLARE(M_LLTABLE);

View File

@ -1,4 +1,4 @@
/* $NetBSD: nd.c,v 1.4 2020/09/15 23:40:03 roy Exp $ */
/* $NetBSD: nd.c,v 1.5 2022/11/19 08:00:51 yamt Exp $ */
/*
* Copyright (c) 2020 The NetBSD Foundation, Inc.
@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nd.c,v 1.4 2020/09/15 23:40:03 roy Exp $");
__KERNEL_RCSID(0, "$NetBSD: nd.c,v 1.5 2022/11/19 08:00:51 yamt Exp $");
#include <sys/callout.h>
#include <sys/mbuf.h>
@ -359,6 +359,9 @@ nd_resolve(struct llentry *ln, const struct rtentry *rt, struct mbuf *m,
ln->ln_state == ND_LLINFO_WAITDELETE)
ln->ln_state = ND_LLINFO_INCOMPLETE;
#ifdef MBUFTRACE
m_claimm(m, ln->lle_tbl->llt_mowner);
#endif
if (ln->ln_hold != NULL) {
struct mbuf *m_hold;
int i;

View File

@ -1,4 +1,4 @@
/* $NetBSD: in.c,v 1.245 2022/11/17 05:02:11 knakahara Exp $ */
/* $NetBSD: in.c,v 1.246 2022/11/19 08:00:51 yamt Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -91,7 +91,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.245 2022/11/17 05:02:11 knakahara Exp $");
__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.246 2022/11/19 08:00:51 yamt Exp $");
#include "arp.h"
@ -2415,7 +2415,7 @@ in_sysctl_init(struct sysctllog **clog)
#if NARP > 0
static struct lltable *
in_lltattach(struct ifnet *ifp)
in_lltattach(struct ifnet *ifp, struct in_ifinfo *ii)
{
struct lltable *llt;
@ -2431,6 +2431,12 @@ in_lltattach(struct ifnet *ifp)
llt->llt_fill_sa_entry = in_lltable_fill_sa_entry;
llt->llt_free_entry = in_lltable_free_entry;
llt->llt_match_prefix = in_lltable_match_prefix;
#ifdef MBUFTRACE
struct mowner *mowner = &ii->ii_mowner;
mowner_init_owner(mowner, ifp->if_xname, "arp");
MOWNER_ATTACH(mowner);
llt->llt_mowner = mowner;
#endif
lltable_link(llt);
return (llt);
@ -2446,7 +2452,7 @@ in_domifattach(struct ifnet *ifp)
ii = kmem_zalloc(sizeof(struct in_ifinfo), KM_SLEEP);
#if NARP > 0
ii->ii_llt = in_lltattach(ifp);
ii->ii_llt = in_lltattach(ifp, ii);
#endif
#ifdef IPSELSRC
@ -2467,6 +2473,9 @@ in_domifdetach(struct ifnet *ifp, void *aux)
#endif
#if NARP > 0
lltable_free(ii->ii_llt);
#ifdef MBUFTRACE
MOWNER_DETACH(&ii->ii_mowner);
#endif
#endif
kmem_free(ii, sizeof(struct in_ifinfo));
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: in_var.h,v 1.102 2021/03/08 22:01:18 christos Exp $ */
/* $NetBSD: in_var.h,v 1.103 2022/11/19 08:00:51 yamt Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -357,6 +357,9 @@ in_get_ia_from_ifp_psref(struct ifnet *ifp, struct psref *psref)
struct in_ifinfo {
struct lltable *ii_llt; /* ARP state */
struct in_ifsysctl *ii_selsrc;
#ifdef MBUFTRACE
struct mowner ii_mowner;
#endif
};
#endif /* _KERNEL */