mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-25 11:37:56 +00:00
Fix reference count leak with L2 caching.
ip_forward, TCP/IPv6, and probably SCTP leaked references to L2 cache entry because they used their own routes on the stack, not in_pcb routes. The original model for route caching was callers that provided a route structure to ip{,6}input() would keep the route, and this model was used for L2 caching as well. Instead, change L2 caching to be done by default only when using a route structure in the in_pcb; the pcb deallocation code frees L2 as well as L3 cacches. A separate change will add route caching to TCP/IPv6. Another suggestion was to have the transport protocols indicate willingness to use L2 caching, but this approach keeps the changes in the network level Reviewed by: ae gnn MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D10059
This commit is contained in:
parent
55b903e2e0
commit
8c1960d506
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=315956
@ -328,6 +328,12 @@ in_pcballoc(struct socket *so, struct inpcbinfo *pcbinfo)
|
||||
#endif
|
||||
inp->inp_gencnt = ++pcbinfo->ipi_gencnt;
|
||||
refcount_init(&inp->inp_refcount, 1); /* Reference from inpcbinfo */
|
||||
|
||||
/*
|
||||
* Routes in inpcb's can cache L2 as well; they are guaranteed
|
||||
* to be cleaned up.
|
||||
*/
|
||||
inp->inp_route.ro_flags = RT_LLE_CACHE;
|
||||
INP_LIST_WUNLOCK(pcbinfo);
|
||||
#if defined(IPSEC) || defined(IPSEC_SUPPORT) || defined(MAC)
|
||||
out:
|
||||
|
@ -242,8 +242,7 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags,
|
||||
if (ro == NULL) {
|
||||
ro = &iproute;
|
||||
bzero(ro, sizeof (*ro));
|
||||
} else
|
||||
ro->ro_flags |= RT_LLE_CACHE;
|
||||
}
|
||||
|
||||
#ifdef FLOWTABLE
|
||||
if (ro->ro_rt == NULL)
|
||||
|
@ -494,8 +494,7 @@ ip6_output(struct mbuf *m0, struct ip6_pktopts *opt,
|
||||
if (ro == NULL) {
|
||||
ro = &ip6route;
|
||||
bzero((caddr_t)ro, sizeof(*ro));
|
||||
} else
|
||||
ro->ro_flags |= RT_LLE_CACHE;
|
||||
}
|
||||
ro_pmtu = ro;
|
||||
if (opt && opt->ip6po_rthdr)
|
||||
ro = &opt->ip6po_route;
|
||||
|
Loading…
Reference in New Issue
Block a user