diff options
author | Matt Macy <mmacy@FreeBSD.org> | 2018-05-21 16:13:43 +0000 |
---|---|---|
committer | Matt Macy <mmacy@FreeBSD.org> | 2018-05-21 16:13:43 +0000 |
commit | f42a83f2a6272bafdceede9e3569aebccc04e7dc (patch) | |
tree | e5ee6ef88592096c26c5b14655c79659d4b926fa /sys/netinet | |
parent | 13679ebac967437911debb6ea0a162935545d5a0 (diff) | |
download | src-f42a83f2a6272bafdceede9e3569aebccc04e7dc.tar.gz src-f42a83f2a6272bafdceede9e3569aebccc04e7dc.zip |
inpcb: revert deferred inpcb free pending further review
Notes
Notes:
svn path=/head/; revision=333984
Diffstat (limited to 'sys/netinet')
-rw-r--r-- | sys/netinet/in_pcb.c | 69 | ||||
-rw-r--r-- | sys/netinet/in_pcb.h | 1 |
2 files changed, 30 insertions, 40 deletions
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index 62c8a4a67bac..e197b4ac4b36 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -1336,34 +1336,6 @@ in_pcblist_rele_rlocked(epoch_context_t ctx) free(il, M_TEMP); } -static void -in_pcbfree_deferred(epoch_context_t ctx) -{ - struct inpcb *inp; - struct inpcbinfo *pcbinfo; - - inp = __containerof(ctx, struct inpcb, inp_epoch_ctx); - pcbinfo = inp->inp_pcbinfo; - - INP_WLOCK(inp); - /* XXXRW: Do as much as possible here. */ -#if defined(IPSEC) || defined(IPSEC_SUPPORT) - if (inp->inp_sp != NULL) - ipsec_delete_pcbpolicy(inp); -#endif - if (inp->inp_options) - (void)m_free(inp->inp_options); - - inp->inp_vflag = 0; - inp->inp_flags2 |= INP_FREED; - crfree(inp->inp_cred); -#ifdef MAC - mac_inpcb_destroy(inp); -#endif - if (!in_pcbrele_wlocked(inp)) - INP_WUNLOCK(inp); -} - /* * Unconditionally schedule an inpcb to be freed by decrementing its * reference count, which should occur only after the inpcb has been detached @@ -1376,15 +1348,16 @@ in_pcbfree_deferred(epoch_context_t ctx) void in_pcbfree(struct inpcb *inp) { + struct inpcbinfo *pcbinfo = inp->inp_pcbinfo; + #ifdef INET6 struct ip6_moptions *im6o = NULL; #endif #ifdef INET struct ip_moptions *imo = NULL; #endif - struct inpcbinfo *pcbinfo = inp->inp_pcbinfo; - KASSERT(inp->inp_socket == NULL, ("%s: inp_socket != NULL", __func__)); + KASSERT((inp->inp_flags2 & INP_FREED) == 0, ("%s: called twice for pcb %p", __func__, inp)); if (inp->inp_flags2 & INP_FREED) { @@ -1400,27 +1373,45 @@ in_pcbfree(struct inpcb *inp) } #endif INP_WLOCK_ASSERT(inp); + #ifdef INET imo = inp->inp_moptions; inp->inp_moptions = NULL; - inp_freemoptions(imo); #endif + /* XXXRW: Do as much as possible here. */ +#if defined(IPSEC) || defined(IPSEC_SUPPORT) + if (inp->inp_sp != NULL) + ipsec_delete_pcbpolicy(inp); +#endif + INP_LIST_WLOCK(pcbinfo); + inp->inp_gencnt = ++pcbinfo->ipi_gencnt; + in_pcbremlists(inp); + INP_LIST_WUNLOCK(pcbinfo); #ifdef INET6 if (inp->inp_vflag & INP_IPV6PROTO) { ip6_freepcbopts(inp->in6p_outputopts); im6o = inp->in6p_moptions; inp->in6p_moptions = NULL; - ip6_freemoptions(im6o); } #endif - /* Remove first from list */ - INP_LIST_WLOCK(pcbinfo); - inp->inp_gencnt = ++pcbinfo->ipi_gencnt; - in_pcbremlists(inp); - INP_LIST_WUNLOCK(pcbinfo); + if (inp->inp_options) + (void)m_free(inp->inp_options); RO_INVALIDATE_CACHE(&inp->inp_route); - INP_WUNLOCK(inp); - epoch_call(net_epoch_preempt, &inp->inp_epoch_ctx, in_pcbfree_deferred); + + inp->inp_vflag = 0; + inp->inp_flags2 |= INP_FREED; + crfree(inp->inp_cred); +#ifdef MAC + mac_inpcb_destroy(inp); +#endif +#ifdef INET6 + ip6_freemoptions(im6o); +#endif +#ifdef INET + inp_freemoptions(imo); +#endif + if (!in_pcbrele_wlocked(inp)) + INP_WUNLOCK(inp); } /* diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h index 51c099dd680e..d00dd45615b6 100644 --- a/sys/netinet/in_pcb.h +++ b/sys/netinet/in_pcb.h @@ -328,7 +328,6 @@ struct inpcb { LIST_ENTRY(inpcb) inp_list; /* (p/l) list for all PCBs for proto */ /* (p[w]) for list iteration */ /* (p[r]/l) for addition/removal */ - struct epoch_context inp_epoch_ctx; }; #endif /* _KERNEL */ |