git: 53af69038164 - main - tcp: remove INP_TIMEWAIT flag
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 07 Oct 2022 02:35:42 UTC
The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=53af690381641290d252455b3c227c8a0920811b commit 53af690381641290d252455b3c227c8a0920811b Author: Gleb Smirnoff <glebius@FreeBSD.org> AuthorDate: 2022-10-07 02:22:23 +0000 Commit: Gleb Smirnoff <glebius@FreeBSD.org> CommitDate: 2022-10-07 02:24:37 +0000 tcp: remove INP_TIMEWAIT flag Mechanically cleanup INP_TIMEWAIT from the kernel sources. After 0d7445193ab, this commit shall not cause any functional changes. Note: this flag was very often checked together with INP_DROPPED. If we modify in_pcblookup*() not to return INP_DROPPED pcbs, we will be able to remove most of this checks and turn them to assertions. Some of them can be turned into assertions right now, but that should be carefully done on a case by case basis. Differential revision: https://reviews.freebsd.org/D36400 --- sys/dev/cxgbe/crypto/t6_kern_tls.c | 4 +-- sys/dev/cxgbe/cxgbei/cxgbei.c | 4 +-- sys/dev/cxgbe/cxgbei/icl_cxgbei.c | 11 ++++---- sys/dev/cxgbe/iw_cxgbe/qp.c | 2 +- sys/dev/cxgbe/tom/t4_cpl_io.c | 10 +++---- sys/dev/cxgbe/tom/t4_ddp.c | 2 +- sys/dev/cxgbe/tom/t4_tls.c | 4 +-- sys/kern/uipc_ktls.c | 19 +++++++------- sys/netinet/in_pcb.c | 9 ++----- sys/netinet/in_pcb.h | 7 +++-- sys/netinet/siftr.c | 10 +++---- sys/netinet/tcp_hpts.c | 6 ++--- sys/netinet/tcp_log_buf.c | 6 ++--- sys/netinet/tcp_lro.c | 3 +-- sys/netinet/tcp_stacks/bbr.c | 2 +- sys/netinet/tcp_stacks/rack.c | 2 +- sys/netinet/tcp_subr.c | 21 +++++---------- sys/netinet/tcp_timer.c | 8 +++--- sys/netinet/tcp_usrreq.c | 54 +++++++++++++++----------------------- sys/netinet/toecore.c | 2 +- sys/netinet6/in6_pcb.c | 3 --- sys/netinet6/ip6_output.c | 8 +++--- sys/netipsec/xform_tcp.c | 4 +-- 23 files changed, 83 insertions(+), 118 deletions(-) diff --git a/sys/dev/cxgbe/crypto/t6_kern_tls.c b/sys/dev/cxgbe/crypto/t6_kern_tls.c index 1374530f941f..4340c5484763 100644 --- a/sys/dev/cxgbe/crypto/t6_kern_tls.c +++ b/sys/dev/cxgbe/crypto/t6_kern_tls.c @@ -462,7 +462,7 @@ t6_tls_tag_alloc(struct ifnet *ifp, union if_snd_tag_alloc_params *params, inp = params->tls.inp; INP_RLOCK(inp); - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_DROPPED) { INP_RUNLOCK(inp); error = ECONNRESET; goto failed; @@ -504,7 +504,7 @@ t6_tls_tag_alloc(struct ifnet *ifp, union if_snd_tag_alloc_params *params, goto failed; } - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_DROPPED) { INP_RUNLOCK(inp); error = ECONNRESET; goto failed; diff --git a/sys/dev/cxgbe/cxgbei/cxgbei.c b/sys/dev/cxgbe/cxgbei/cxgbei.c index b6dc5d5c3577..d11465e4567d 100644 --- a/sys/dev/cxgbe/cxgbei/cxgbei.c +++ b/sys/dev/cxgbe/cxgbei/cxgbei.c @@ -502,7 +502,7 @@ do_rx_iscsi_ddp(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m) } INP_WLOCK(inp); - if (__predict_false(inp->inp_flags & (INP_DROPPED | INP_TIMEWAIT))) { + if (__predict_false(inp->inp_flags & INP_DROPPED)) { CTR4(KTR_CXGBE, "%s: tid %u, rx (%d bytes), inp_flags 0x%x", __func__, tid, pdu_len, inp->inp_flags); INP_WUNLOCK(inp); @@ -655,7 +655,7 @@ do_rx_iscsi_cmp(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m) } INP_WLOCK(inp); - if (__predict_false(inp->inp_flags & (INP_DROPPED | INP_TIMEWAIT))) { + if (__predict_false(inp->inp_flags & INP_DROPPED)) { CTR4(KTR_CXGBE, "%s: tid %u, rx (%d bytes), inp_flags 0x%x", __func__, tid, pdu_len, inp->inp_flags); INP_WUNLOCK(inp); diff --git a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c index 1b896516d546..82201b358e91 100644 --- a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c +++ b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c @@ -478,8 +478,7 @@ icl_cxgbei_tx_main(void *arg) INP_WLOCK(inp); ICL_CONN_UNLOCK(ic); - if (__predict_false(inp->inp_flags & (INP_DROPPED | - INP_TIMEWAIT)) || + if (__predict_false(inp->inp_flags & INP_DROPPED) || __predict_false((toep->flags & TPF_ATTACHED) == 0)) { mbufq_drain(&mq); } else { @@ -1007,7 +1006,7 @@ find_offload_adapter(struct adapter *sc, void *arg) inp = sotoinpcb(so); INP_WLOCK(inp); - if ((inp->inp_flags & (INP_DROPPED | INP_TIMEWAIT)) == 0) { + if ((inp->inp_flags & INP_DROPPED) == 0) { tp = intotcpcb(inp); if (tp->t_flags & TF_TOE && tp->tod == &td->tod) fa->sc = sc; /* Found. */ @@ -1164,7 +1163,7 @@ icl_cxgbei_conn_handoff(struct icl_conn *ic, int fd) inp = sotoinpcb(so); INP_WLOCK(inp); tp = intotcpcb(inp); - if (inp->inp_flags & (INP_DROPPED | INP_TIMEWAIT)) { + if (inp->inp_flags & INP_DROPPED) { INP_WUNLOCK(inp); error = ENOTCONN; goto out; @@ -1506,7 +1505,7 @@ no_ddp: */ inp = sotoinpcb(ic->ic_socket); INP_WLOCK(inp); - if ((inp->inp_flags & (INP_DROPPED | INP_TIMEWAIT)) != 0) { + if ((inp->inp_flags & INP_DROPPED) != 0) { INP_WUNLOCK(inp); mbufq_drain(&mq); t4_free_page_pods(prsv); @@ -1683,7 +1682,7 @@ no_ddp: inp = sotoinpcb(ic->ic_socket); INP_WLOCK(inp); ICL_CONN_UNLOCK(ic); - if ((inp->inp_flags & (INP_DROPPED | INP_TIMEWAIT)) != 0) { + if ((inp->inp_flags & INP_DROPPED) != 0) { INP_WUNLOCK(inp); mbufq_drain(&mq); t4_free_page_pods(prsv); diff --git a/sys/dev/cxgbe/iw_cxgbe/qp.c b/sys/dev/cxgbe/iw_cxgbe/qp.c index b2901f93988e..d3d4c0573a6f 100644 --- a/sys/dev/cxgbe/iw_cxgbe/qp.c +++ b/sys/dev/cxgbe/iw_cxgbe/qp.c @@ -1316,7 +1316,7 @@ creds(struct toepcb *toep, struct inpcb *inp, size_t wrsize) CTR3(KTR_IW_CXGBE, "%s:creB %p %u", __func__, toep , wrsize); INP_WLOCK(inp); - if ((inp->inp_flags & (INP_DROPPED | INP_TIMEWAIT)) != 0) { + if ((inp->inp_flags & INP_DROPPED) != 0) { INP_WUNLOCK(inp); return (EINVAL); } diff --git a/sys/dev/cxgbe/tom/t4_cpl_io.c b/sys/dev/cxgbe/tom/t4_cpl_io.c index 59d1c367f94c..bfc9eb3b76f7 100644 --- a/sys/dev/cxgbe/tom/t4_cpl_io.c +++ b/sys/dev/cxgbe/tom/t4_cpl_io.c @@ -288,7 +288,7 @@ send_reset(struct adapter *sc, struct toepcb *toep, uint32_t snd_nxt) * XXX: What's the correct way to tell that the inp hasn't been detached * from its socket? Should I even be flushing the snd buffer here? */ - if ((inp->inp_flags & (INP_DROPPED | INP_TIMEWAIT)) == 0) { + if ((inp->inp_flags & INP_DROPPED) == 0) { struct socket *so = inp->inp_socket; if (so != NULL) /* because I'm not sure. See comment above */ @@ -1611,7 +1611,7 @@ do_abort_req(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m) } toep->flags |= TPF_ABORT_SHUTDOWN; - if ((inp->inp_flags & (INP_DROPPED | INP_TIMEWAIT)) == 0) { + if ((inp->inp_flags & INP_DROPPED) == 0) { struct socket *so = inp->inp_socket; if (so != NULL) @@ -1701,7 +1701,7 @@ do_rx_data(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m) len = m->m_pkthdr.len; INP_WLOCK(inp); - if (inp->inp_flags & (INP_DROPPED | INP_TIMEWAIT)) { + if (inp->inp_flags & INP_DROPPED) { CTR4(KTR_CXGBE, "%s: tid %u, rx (%d bytes), inp_flags 0x%x", __func__, tid, len, inp->inp_flags); INP_WUNLOCK(inp); @@ -1874,7 +1874,7 @@ do_fw4_ack(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m) return (0); } - KASSERT((inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) == 0, + KASSERT((inp->inp_flags & INP_DROPPED) == 0, ("%s: inp_flags 0x%x", __func__, inp->inp_flags)); tp = intotcpcb(inp); @@ -2290,7 +2290,7 @@ sendanother: inp = toep->inp; INP_WLOCK(inp); - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_DROPPED) { INP_WUNLOCK(inp); SOCK_IO_SEND_UNLOCK(so); error = ECONNRESET; diff --git a/sys/dev/cxgbe/tom/t4_ddp.c b/sys/dev/cxgbe/tom/t4_ddp.c index 11fea91b060e..605157286bb2 100644 --- a/sys/dev/cxgbe/tom/t4_ddp.c +++ b/sys/dev/cxgbe/tom/t4_ddp.c @@ -504,7 +504,7 @@ handle_ddp_data(struct toepcb *toep, __be32 ddp_report, __be32 rcv_nxt, int len) db = &toep->ddp.db[db_idx]; job = db->job; - if (__predict_false(inp->inp_flags & (INP_DROPPED | INP_TIMEWAIT))) { + if (__predict_false(inp->inp_flags & INP_DROPPED)) { /* * This can happen due to an administrative tcpdrop(8). * Just fail the request with ECONNRESET. diff --git a/sys/dev/cxgbe/tom/t4_tls.c b/sys/dev/cxgbe/tom/t4_tls.c index 447943b5b9db..9f9d4a48de93 100644 --- a/sys/dev/cxgbe/tom/t4_tls.c +++ b/sys/dev/cxgbe/tom/t4_tls.c @@ -894,7 +894,7 @@ do_tls_data(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m) ("%s: payload length mismatch", __func__)); INP_WLOCK(inp); - if (inp->inp_flags & (INP_DROPPED | INP_TIMEWAIT)) { + if (inp->inp_flags & INP_DROPPED) { CTR4(KTR_CXGBE, "%s: tid %u, rx (%d bytes), inp_flags 0x%x", __func__, tid, len, inp->inp_flags); INP_WUNLOCK(inp); @@ -964,7 +964,7 @@ do_rx_tls_cmp(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m) ("%s: payload length mismatch", __func__)); INP_WLOCK(inp); - if (inp->inp_flags & (INP_DROPPED | INP_TIMEWAIT)) { + if (inp->inp_flags & INP_DROPPED) { CTR4(KTR_CXGBE, "%s: tid %u, rx (%d bytes), inp_flags 0x%x", __func__, tid, len, inp->inp_flags); INP_WUNLOCK(inp); diff --git a/sys/kern/uipc_ktls.c b/sys/kern/uipc_ktls.c index bf91b774c0dc..83fcc9e70546 100644 --- a/sys/kern/uipc_ktls.c +++ b/sys/kern/uipc_ktls.c @@ -865,7 +865,7 @@ ktls_try_toe(struct socket *so, struct ktls_session *tls, int direction) inp = so->so_pcb; INP_WLOCK(inp); - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_DROPPED) { INP_WUNLOCK(inp); return (ECONNRESET); } @@ -916,7 +916,7 @@ ktls_alloc_snd_tag(struct inpcb *inp, struct ktls_session *tls, bool force, int error; INP_RLOCK(inp); - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_DROPPED) { INP_RUNLOCK(inp); return (ECONNRESET); } @@ -1016,7 +1016,7 @@ ktls_alloc_rcv_tag(struct inpcb *inp, struct ktls_session *tls, return (ENXIO); INP_RLOCK(inp); - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_DROPPED) { INP_RUNLOCK(inp); return (ECONNRESET); } @@ -1463,7 +1463,7 @@ ktls_get_rx_sequence(struct inpcb *inp, uint32_t *tcpseq, uint64_t *tlsseq) INP_RUNLOCK(inp); return (EINVAL); } - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_DROPPED) { INP_RUNLOCK(inp); return (ECONNRESET); } @@ -1625,7 +1625,7 @@ ktls_reset_receive_tag(void *context, int pending) ifp = NULL; INP_RLOCK(inp); - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_DROPPED) { INP_RUNLOCK(inp); goto out; } @@ -1746,8 +1746,7 @@ ktls_reset_send_tag(void *context, int pending) NET_EPOCH_ENTER(et); INP_WLOCK(inp); if (!in_pcbrele_wlocked(inp)) { - if (!(inp->inp_flags & INP_TIMEWAIT) && - !(inp->inp_flags & INP_DROPPED)) { + if (!(inp->inp_flags & INP_DROPPED)) { tp = intotcpcb(inp); CURVNET_SET(tp->t_vnet); tp = tcp_drop(tp, ECONNABORTED); @@ -2288,7 +2287,7 @@ ktls_resync_ifnet(struct socket *so, uint32_t tls_len, uint64_t tls_rcd_num) return (EINVAL); INP_RLOCK(inp); - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_DROPPED) { INP_RUNLOCK(inp); return (ECONNRESET); } @@ -3178,7 +3177,7 @@ ktls_disable_ifnet_help(void *context, int pending __unused) INP_WLOCK(inp); so = inp->inp_socket; MPASS(so != NULL); - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_DROPPED) { goto out; } @@ -3189,7 +3188,7 @@ ktls_disable_ifnet_help(void *context, int pending __unused) if (err == 0) { counter_u64_add(ktls_ifnet_disable_ok, 1); /* ktls_set_tx_mode() drops inp wlock, so recheck flags */ - if ((inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) == 0 && + if ((inp->inp_flags & INP_DROPPED) == 0 && (tp = intotcpcb(inp)) != NULL && tp->t_fb->tfb_hwtls_change != NULL) (*tp->t_fb->tfb_hwtls_change)(tp, 0); diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index 9dd6d3d019ca..75889b2011ac 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -1047,7 +1047,6 @@ in_pcbbind_setup(struct inpcb *inp, struct sockaddr *nam, in_addr_t *laddrp, */ if (t && ((inp->inp_flags2 & INP_BINDMULTI) == 0) && - ((t->inp_flags & INP_TIMEWAIT) == 0) && (so->so_type != SOCK_STREAM || ntohl(t->inp_faddr.s_addr) == INADDR_ANY) && (ntohl(sin->sin_addr.s_addr) != INADDR_ANY || @@ -2865,7 +2864,7 @@ sysctl_setsockopt(SYSCTL_HANDLER_ARGS, struct inpcbinfo *pcbinfo, } while ((inp = inp_next(&inpi)) != NULL) if (inp->inp_gencnt == params->sop_id) { - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_DROPPED) { INP_WUNLOCK(inp); return (ECONNRESET); } @@ -3015,10 +3014,6 @@ db_print_inpflags(int inp_flags) db_printf("%sIN6P_AUTOFLOWLABEL", comma ? ", " : ""); comma = 1; } - if (inp_flags & INP_TIMEWAIT) { - db_printf("%sINP_TIMEWAIT", comma ? ", " : ""); - comma = 1; - } if (inp_flags & INP_ONESBCAST) { db_printf("%sINP_ONESBCAST", comma ? ", " : ""); comma = 1; @@ -3234,7 +3229,7 @@ in_pcbattach_txrtlmt(struct inpcb *inp, struct ifnet *ifp, * down, allocating a new send tag is not allowed. Else send * tags may leak. */ - if (*st != NULL || (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) != 0) + if (*st != NULL || (inp->inp_flags & INP_DROPPED) != 0) return (EINVAL); error = m_snd_tag_alloc(ifp, ¶ms, st); diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h index 331474999163..a72ae5742d4e 100644 --- a/sys/netinet/in_pcb.h +++ b/sys/netinet/in_pcb.h @@ -205,9 +205,8 @@ struct in_conninfo { * to a field, a write lock must generally be held. * * netinet/netinet6-layer code should not assume that the inp_socket pointer - * is safe to dereference without inp_lock being held, even for protocols - * other than TCP (where the inpcb persists during TIMEWAIT even after the - * socket has been freed), or there may be close(2)-related races. + * is safe to dereference without inp_lock being held, there may be + * close(2)-related races. * * The inp_vflag field is overloaded, and would otherwise ideally be (c). */ @@ -641,7 +640,7 @@ int inp_so_options(const struct inpcb *inp); #define IN6P_RTHDRDSTOPTS 0x00200000 /* receive dstoptions before rthdr */ #define IN6P_TCLASS 0x00400000 /* receive traffic class value */ #define IN6P_AUTOFLOWLABEL 0x00800000 /* attach flowlabel automatically */ -#define INP_TIMEWAIT 0x01000000 /* in TIMEWAIT, ppcb is tcptw */ +/* was INP_TIMEWAIT 0x01000000 */ #define INP_ONESBCAST 0x02000000 /* send all-ones broadcast */ #define INP_DROPPED 0x04000000 /* protocol drop flag */ #define INP_SOCKREF 0x08000000 /* strong socket reference */ diff --git a/sys/netinet/siftr.c b/sys/netinet/siftr.c index b326218a8729..c025c06d7f32 100644 --- a/sys/netinet/siftr.c +++ b/sys/netinet/siftr.c @@ -896,10 +896,9 @@ siftr_chkpkt(struct mbuf **m, struct ifnet *ifp, int flags, /* * If we can't find the TCP control block (happens occasionaly for a - * packet sent during the shutdown phase of a TCP connection), - * or we're in the timewait state, bail + * packet sent during the shutdown phase of a TCP connection), bail */ - if (tp == NULL || inp->inp_flags & INP_TIMEWAIT) { + if (tp == NULL) { if (dir == PFIL_IN) ss->nskip_in_tcpcb++; else @@ -1081,10 +1080,9 @@ siftr_chkpkt6(struct mbuf **m, struct ifnet *ifp, int flags, /* * If we can't find the TCP control block (happens occasionaly for a - * packet sent during the shutdown phase of a TCP connection), - * or we're in the timewait state, bail. + * packet sent during the shutdown phase of a TCP connection), bail */ - if (tp == NULL || inp->inp_flags & INP_TIMEWAIT) { + if (tp == NULL) { if (dir == PFIL_IN) ss->nskip_in_tcpcb++; else diff --git a/sys/netinet/tcp_hpts.c b/sys/netinet/tcp_hpts.c index 828ce16e8dad..3ed0c1e27c58 100644 --- a/sys/netinet/tcp_hpts.c +++ b/sys/netinet/tcp_hpts.c @@ -501,7 +501,7 @@ inp_hpts_insert(struct inpcb *inp, struct tcp_hpts_entry *hpts) INP_WLOCK_ASSERT(inp); HPTS_MTX_ASSERT(hpts); MPASS(hpts->p_cpu == inp->inp_hpts_cpu); - MPASS(!(inp->inp_flags & (INP_DROPPED|INP_TIMEWAIT))); + MPASS(!(inp->inp_flags & INP_DROPPED)); hptsh = &hpts->p_hptss[inp->inp_hptsslot]; @@ -811,7 +811,7 @@ tcp_hpts_insert_diag(struct inpcb *inp, uint32_t slot, int32_t line, struct hpts INP_WLOCK_ASSERT(inp); MPASS(!tcp_in_hpts(inp)); - MPASS(!(inp->inp_flags & (INP_DROPPED|INP_TIMEWAIT))); + MPASS(!(inp->inp_flags & INP_DROPPED)); /* * We now return the next-slot the hpts will be on, beyond its @@ -1279,7 +1279,7 @@ again: } MPASS(inp->inp_in_hpts == IHPTS_ONQUEUE); - MPASS(!(inp->inp_flags & (INP_DROPPED|INP_TIMEWAIT))); + MPASS(!(inp->inp_flags & INP_DROPPED)); KASSERT(runningslot == inp->inp_hptsslot, ("Hpts:%p inp:%p slot mis-aligned %u vs %u", hpts, inp, runningslot, inp->inp_hptsslot)); diff --git a/sys/netinet/tcp_log_buf.c b/sys/netinet/tcp_log_buf.c index 5ec4acf367d5..6baf1bce4623 100644 --- a/sys/netinet/tcp_log_buf.c +++ b/sys/netinet/tcp_log_buf.c @@ -485,7 +485,7 @@ tcp_log_remove_id_node(struct inpcb *inp, struct tcpcb *tp, } #define RECHECK_INP_CLEAN(cleanup) do { \ - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { \ + if (inp->inp_flags & INP_DROPPED) { \ rv = ECONNRESET; \ cleanup; \ goto done; \ @@ -2037,7 +2037,7 @@ tcp_log_getlogbuf(struct sockopt *sopt, struct tcpcb *tp) if (error) { /* Restore list */ INP_WLOCK(inp); - if ((inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) == 0) { + if ((inp->inp_flags & INP_DROPPED) == 0) { tp = intotcpcb(inp); /* Merge the two lists. */ @@ -2211,7 +2211,7 @@ tcp_log_dump_tp_logbuf(struct tcpcb *tp, char *reason, int how, bool force) * may end up dropping some entries. That seems like a * small price to pay for safety. */ - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_DROPPED) { free(entry, M_TCPLOGDEV); #ifdef TCPLOG_DEBUG_COUNTERS counter_u64_add(tcp_log_que_fail2, 1); diff --git a/sys/netinet/tcp_lro.c b/sys/netinet/tcp_lro.c index a4fc5580dfc7..9ec7736aef2f 100644 --- a/sys/netinet/tcp_lro.c +++ b/sys/netinet/tcp_lro.c @@ -1359,8 +1359,7 @@ tcp_lro_flush_tcphpts(struct lro_ctrl *lc, struct lro_entry *le) tp = intotcpcb(inp); /* Check if the inp is dead, Jim. */ - if (tp == NULL || - (inp->inp_flags & (INP_DROPPED | INP_TIMEWAIT))) { + if (tp == NULL || (inp->inp_flags & INP_DROPPED)) { INP_WUNLOCK(inp); return (TCP_LRO_CANNOT); } diff --git a/sys/netinet/tcp_stacks/bbr.c b/sys/netinet/tcp_stacks/bbr.c index 31b5c2cc78dc..40d3a40dbe38 100644 --- a/sys/netinet/tcp_stacks/bbr.c +++ b/sys/netinet/tcp_stacks/bbr.c @@ -14280,7 +14280,7 @@ bbr_set_sockopt(struct inpcb *inp, struct sockopt *sopt) if (error) return (error); INP_WLOCK(inp); - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_DROPPED) { INP_WUNLOCK(inp); return (ECONNRESET); } diff --git a/sys/netinet/tcp_stacks/rack.c b/sys/netinet/tcp_stacks/rack.c index 740ec73a17df..74503bc8a1b2 100644 --- a/sys/netinet/tcp_stacks/rack.c +++ b/sys/netinet/tcp_stacks/rack.c @@ -20481,7 +20481,7 @@ rack_set_sockopt(struct inpcb *inp, struct sockopt *sopt) if (error) return (error); INP_WLOCK(inp); - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_DROPPED) { INP_WUNLOCK(inp); return (ECONNRESET); } diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index c50f416351c3..8fdaab35fb19 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -1373,8 +1373,6 @@ deregister_tcp_functions(struct tcp_function_block *blk, bool quiesce, VNET_FOREACH(vnet_iter) { CURVNET_SET(vnet_iter); while ((inp = inp_next(&inpi)) != NULL) { - if (inp->inp_flags & INP_TIMEWAIT) - continue; tp = intotcpcb(inp); if (tp == NULL || tp->t_fb != blk) continue; @@ -1434,8 +1432,6 @@ tcp_drain(void) * useful. */ while ((inpb = inp_next(&inpi)) != NULL) { - if (inpb->inp_flags & INP_TIMEWAIT) - continue; if ((tcpb = intotcpcb(inpb)) != NULL) { tcp_reass_flush(tcpb); tcp_clean_sackreport(tcpb); @@ -2596,8 +2592,7 @@ tcp_notify(struct inpcb *inp, int error) INP_WLOCK_ASSERT(inp); - if ((inp->inp_flags & INP_TIMEWAIT) || - (inp->inp_flags & INP_DROPPED)) + if (inp->inp_flags & INP_DROPPED) return (inp); tp = intotcpcb(inp); @@ -2879,8 +2874,7 @@ tcp_ctlinput_with_port(struct icmp *icp, uint16_t port) inp = in_pcblookup(&V_tcbinfo, ip->ip_dst, th->th_dport, ip->ip_src, th->th_sport, INPLOOKUP_WLOCKPCB, NULL); if (inp != NULL) { - if (!(inp->inp_flags & INP_TIMEWAIT) && - !(inp->inp_flags & INP_DROPPED) && + if (!(inp->inp_flags & INP_DROPPED) && !(inp->inp_socket == NULL)) { tp = intotcpcb(inp); #ifdef TCP_OFFLOAD @@ -3073,8 +3067,7 @@ tcp6_ctlinput_with_port(struct ip6ctlparam *ip6cp, uint16_t port) } m_copydata(m, off, sizeof(tcp_seq), (caddr_t)&icmp_tcp_seq); if (inp != NULL) { - if (!(inp->inp_flags & INP_TIMEWAIT) && - !(inp->inp_flags & INP_DROPPED) && + if (!(inp->inp_flags & INP_DROPPED) && !(inp->inp_socket == NULL)) { tp = intotcpcb(inp); #ifdef TCP_OFFLOAD @@ -3324,8 +3317,7 @@ tcp_drop_syn_sent(struct inpcb *inp, int errno) NET_EPOCH_ASSERT(); INP_WLOCK_ASSERT(inp); - if ((inp->inp_flags & INP_TIMEWAIT) || - (inp->inp_flags & INP_DROPPED)) + if (inp->inp_flags & INP_DROPPED) return (inp); tp = intotcpcb(inp); @@ -3362,8 +3354,7 @@ tcp_mtudisc(struct inpcb *inp, int mtuoffer) struct socket *so; INP_WLOCK_ASSERT(inp); - if ((inp->inp_flags & INP_TIMEWAIT) || - (inp->inp_flags & INP_DROPPED)) + if (inp->inp_flags & INP_DROPPED) return (inp); tp = intotcpcb(inp); @@ -3822,7 +3813,7 @@ sysctl_switch_tls(SYSCTL_HANDLER_ARGS) } NET_EPOCH_EXIT(et); if (inp != NULL) { - if ((inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) != 0 || + if ((inp->inp_flags & INP_DROPPED) != 0 || inp->inp_socket == NULL) { error = ECONNRESET; INP_WUNLOCK(inp); diff --git a/sys/netinet/tcp_timer.c b/sys/netinet/tcp_timer.c index f4915da6e77c..391b9dfdbc05 100644 --- a/sys/netinet/tcp_timer.c +++ b/sys/netinet/tcp_timer.c @@ -335,7 +335,7 @@ tcp_timer_2msl(void *xtp) return; } callout_deactivate(&tp->t_timers->tt_2msl); - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_DROPPED) { INP_WUNLOCK(inp); CURVNET_RESTORE(); return; @@ -408,7 +408,7 @@ tcp_timer_keep(void *xtp) return; } callout_deactivate(&tp->t_timers->tt_keep); - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_DROPPED) { INP_WUNLOCK(inp); CURVNET_RESTORE(); return; @@ -552,7 +552,7 @@ tcp_timer_persist(void *xtp) return; } callout_deactivate(&tp->t_timers->tt_persist); - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_DROPPED) { INP_WUNLOCK(inp); CURVNET_RESTORE(); return; @@ -636,7 +636,7 @@ tcp_timer_rexmt(void * xtp) return; } callout_deactivate(&tp->t_timers->tt_rexmt); - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_DROPPED) { INP_WUNLOCK(inp); CURVNET_RESTORE(); return; diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index 43acc0ad1719..d069c804bcc4 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -264,7 +264,7 @@ tcp_usr_bind(struct socket *so, struct sockaddr *nam, struct thread *td) inp = sotoinpcb(so); KASSERT(inp != NULL, ("tcp_usr_bind: inp == NULL")); INP_WLOCK(inp); - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_DROPPED) { error = EINVAL; goto out; } @@ -314,7 +314,7 @@ tcp6_usr_bind(struct socket *so, struct sockaddr *nam, struct thread *td) KASSERT(inp != NULL, ("tcp6_usr_bind: inp == NULL")); INP_WLOCK(inp); vflagsav = inp->inp_vflag; - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_DROPPED) { error = EINVAL; goto out; } @@ -374,7 +374,7 @@ tcp_usr_listen(struct socket *so, int backlog, struct thread *td) inp = sotoinpcb(so); KASSERT(inp != NULL, ("tcp_usr_listen: inp == NULL")); INP_WLOCK(inp); - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_DROPPED) { error = EINVAL; goto out; } @@ -427,7 +427,7 @@ tcp6_usr_listen(struct socket *so, int backlog, struct thread *td) inp = sotoinpcb(so); KASSERT(inp != NULL, ("tcp6_usr_listen: inp == NULL")); INP_WLOCK(inp); - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_DROPPED) { error = EINVAL; goto out; } @@ -511,10 +511,6 @@ tcp_usr_connect(struct socket *so, struct sockaddr *nam, struct thread *td) inp = sotoinpcb(so); KASSERT(inp != NULL, ("tcp_usr_connect: inp == NULL")); INP_WLOCK(inp); - if (inp->inp_flags & INP_TIMEWAIT) { - error = EADDRINUSE; - goto out; - } if (inp->inp_flags & INP_DROPPED) { error = ECONNREFUSED; goto out; @@ -579,10 +575,6 @@ tcp6_usr_connect(struct socket *so, struct sockaddr *nam, struct thread *td) INP_WLOCK(inp); vflagsav = inp->inp_vflag; incflagsav = inp->inp_inc.inc_flags; - if (inp->inp_flags & INP_TIMEWAIT) { - error = EADDRINUSE; - goto out; - } if (inp->inp_flags & INP_DROPPED) { error = ECONNREFUSED; goto out; @@ -704,8 +696,6 @@ tcp_usr_disconnect(struct socket *so) inp = sotoinpcb(so); KASSERT(inp != NULL, ("tcp_usr_disconnect: inp == NULL")); INP_WLOCK(inp); - if (inp->inp_flags & INP_TIMEWAIT) - goto out; if (inp->inp_flags & INP_DROPPED) { error = ECONNRESET; goto out; @@ -744,7 +734,7 @@ tcp_usr_accept(struct socket *so, struct sockaddr **nam) inp = sotoinpcb(so); KASSERT(inp != NULL, ("tcp_usr_accept: inp == NULL")); INP_WLOCK(inp); - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_DROPPED) { error = ECONNABORTED; goto out; } @@ -794,7 +784,7 @@ tcp6_usr_accept(struct socket *so, struct sockaddr **nam) KASSERT(inp != NULL, ("tcp6_usr_accept: inp == NULL")); NET_EPOCH_ENTER(et); INP_WLOCK(inp); - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_DROPPED) { error = ECONNABORTED; goto out; } @@ -847,7 +837,7 @@ tcp_usr_shutdown(struct socket *so) inp = sotoinpcb(so); KASSERT(inp != NULL, ("inp == NULL")); INP_WLOCK(inp); - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_DROPPED) { INP_WUNLOCK(inp); return (ECONNRESET); } @@ -881,7 +871,7 @@ tcp_usr_rcvd(struct socket *so, int flags) inp = sotoinpcb(so); KASSERT(inp != NULL, ("tcp_usr_rcvd: inp == NULL")); INP_WLOCK(inp); - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_DROPPED) { INP_WUNLOCK(inp); return (ECONNRESET); } @@ -953,7 +943,7 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m, inp = sotoinpcb(so); KASSERT(inp != NULL, ("tcp_usr_send: inp == NULL")); INP_WLOCK(inp); - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_DROPPED) { if (m != NULL && (flags & PRUS_NOTREADY) == 0) m_freem(m); INP_WUNLOCK(inp); @@ -1251,7 +1241,7 @@ tcp_usr_ready(struct socket *so, struct mbuf *m, int count) inp = sotoinpcb(so); INP_WLOCK(inp); - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_DROPPED) { INP_WUNLOCK(inp); mb_free_notready(m, count); return (ECONNRESET); @@ -1294,8 +1284,7 @@ tcp_usr_abort(struct socket *so) /* * If we still have full TCP state, and we're not dropped, drop. */ - if (!(inp->inp_flags & INP_TIMEWAIT) && - !(inp->inp_flags & INP_DROPPED)) { + if (!(inp->inp_flags & INP_DROPPED)) { tp = intotcpcb(inp); TCPDEBUG1(); tp = tcp_drop(tp, ECONNABORTED); @@ -1336,8 +1325,7 @@ tcp_usr_close(struct socket *so) * If we still have full TCP state, and we're not dropped, initiate * a disconnect. */ - if (!(inp->inp_flags & INP_TIMEWAIT) && - !(inp->inp_flags & INP_DROPPED)) { + if (!(inp->inp_flags & INP_DROPPED)) { tp = intotcpcb(inp); tp->t_flags |= TF_CLOSED; TCPDEBUG1(); @@ -1385,7 +1373,7 @@ tcp_usr_rcvoob(struct socket *so, struct mbuf *m, int flags) inp = sotoinpcb(so); KASSERT(inp != NULL, ("tcp_usr_rcvoob: inp == NULL")); INP_WLOCK(inp); - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_DROPPED) { error = ECONNRESET; goto out; } @@ -1662,7 +1650,7 @@ tcp_fill_info(struct tcpcb *tp, struct tcp_info *ti) */ #define INP_WLOCK_RECHECK_CLEANUP(inp, cleanup) do { \ INP_WLOCK(inp); \ - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { \ + if (inp->inp_flags & INP_DROPPED) { \ INP_WUNLOCK(inp); \ cleanup; \ return (ECONNRESET); \ @@ -1680,7 +1668,7 @@ tcp_ctloutput_set(struct inpcb *inp, struct sockopt *sopt) MPASS(sopt->sopt_dir == SOPT_SET); INP_WLOCK_ASSERT(inp); - KASSERT((inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) == 0, + KASSERT((inp->inp_flags & INP_DROPPED) == 0, ("inp_flags == %x", inp->inp_flags)); KASSERT(so != NULL, ("inp_socket == NULL")); @@ -1736,7 +1724,7 @@ tcp_ctloutput_set(struct inpcb *inp, struct sockopt *sopt) return (error); } INP_WLOCK(inp); - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_DROPPED) { INP_WUNLOCK(inp); return (ECONNRESET); } @@ -1754,7 +1742,7 @@ tcp_ctloutput_set(struct inpcb *inp, struct sockopt *sopt) return (error); INP_WLOCK(inp); - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_DROPPED) { INP_WUNLOCK(inp); return (ECONNRESET); } @@ -1857,7 +1845,7 @@ tcp_ctloutput_get(struct inpcb *inp, struct sockopt *sopt) MPASS(sopt->sopt_dir == SOPT_GET); INP_WLOCK_ASSERT(inp); - KASSERT((inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) == 0, + KASSERT((inp->inp_flags & INP_DROPPED) == 0, ("inp_flags == %x", inp->inp_flags)); KASSERT(so != NULL, ("inp_socket == NULL")); @@ -1907,7 +1895,7 @@ tcp_ctloutput(struct socket *so, struct sockopt *sopt) KASSERT(inp != NULL, ("tcp_ctloutput: inp == NULL")); INP_WLOCK(inp); - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_DROPPED) { INP_WUNLOCK(inp); return (ECONNRESET); } @@ -2016,7 +2004,7 @@ no_mem_needed: */ memset(&cc_mem, 0, sizeof(cc_mem)); INP_WLOCK(inp); - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_DROPPED) { INP_WUNLOCK(inp); if (ptr) free(ptr, M_CC_MEM); @@ -2092,7 +2080,7 @@ tcp_default_ctloutput(struct inpcb *inp, struct sockopt *sopt) size_t len; INP_WLOCK_ASSERT(inp); - KASSERT((inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) == 0, + KASSERT((inp->inp_flags & INP_DROPPED) == 0, ("inp_flags == %x", inp->inp_flags)); KASSERT(inp->inp_socket != NULL, ("inp_socket == NULL")); diff --git a/sys/netinet/toecore.c b/sys/netinet/toecore.c index a185103df3a7..a078d9cea51f 100644 --- a/sys/netinet/toecore.c +++ b/sys/netinet/toecore.c @@ -220,7 +220,7 @@ toe_listen_start(struct inpcb *inp, void *arg) KASSERT(inp->inp_pcbinfo == &V_tcbinfo, ("%s: inp is not a TCP inp", __func__)); - if (inp->inp_flags & (INP_DROPPED | INP_TIMEWAIT)) + if (inp->inp_flags & INP_DROPPED) return; tp = intotcpcb(inp); diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c index 516d83fa846c..176a5227c9a1 100644 --- a/sys/netinet6/in6_pcb.c +++ b/sys/netinet6/in6_pcb.c @@ -255,7 +255,6 @@ in6_pcbbind(struct inpcb *inp, struct sockaddr *nam, INPLOOKUP_WILDCARD, cred); if (t && ((inp->inp_flags2 & INP_BINDMULTI) == 0) && - ((t->inp_flags & INP_TIMEWAIT) == 0) && (so->so_type != SOCK_STREAM || IN6_IS_ADDR_UNSPECIFIED(&t->in6p_faddr)) && (!IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr) || @@ -286,8 +285,6 @@ in6_pcbbind(struct inpcb *inp, struct sockaddr *nam, INPLOOKUP_WILDCARD, cred); if (t && ((inp->inp_flags2 & INP_BINDMULTI) == 0) && - ((t->inp_flags & - INP_TIMEWAIT) == 0) && (so->so_type != SOCK_STREAM || ntohl(t->inp_faddr.s_addr) == INADDR_ANY) && diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c index b976b0583515..f00f718445f5 100644 --- a/sys/netinet6/ip6_output.c +++ b/sys/netinet6/ip6_output.c @@ -1844,7 +1844,7 @@ do { \ break; } INP_WLOCK(inp); - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_DROPPED) { INP_WUNLOCK(inp); return (ECONNRESET); } @@ -1990,7 +1990,7 @@ do { \ { struct ip6_pktopts **optp; INP_WLOCK(inp); - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_DROPPED) { INP_WUNLOCK(inp); return (ECONNRESET); } @@ -2082,7 +2082,7 @@ do { \ optlen = sopt->sopt_valsize; optbuf = optbuf_storage; INP_WLOCK(inp); - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_DROPPED) { INP_WUNLOCK(inp); return (ECONNRESET); } @@ -2577,7 +2577,7 @@ ip6_pcbopt(int optname, u_char *buf, int len, struct ip6_pktopts **pktopt, optdata = malloc(sopt->sopt_valsize, M_TEMP, M_WAITOK); \ malloc_optdata = true; \ INP_RLOCK(inp); \ - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { \ + if (inp->inp_flags & INP_DROPPED) { \ INP_RUNLOCK(inp); \ free(optdata, M_TEMP); \ return (ECONNRESET); \ diff --git a/sys/netipsec/xform_tcp.c b/sys/netipsec/xform_tcp.c index ce2552f0a205..42c63813e63c 100644 --- a/sys/netipsec/xform_tcp.c +++ b/sys/netipsec/xform_tcp.c @@ -86,7 +86,7 @@ tcp_ipsec_pcbctl(struct inpcb *inp, struct sockopt *sopt) if (sopt->sopt_dir == SOPT_GET) { INP_RLOCK(inp); - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_DROPPED) { INP_RUNLOCK(inp); return (ECONNRESET); } @@ -104,7 +104,7 @@ tcp_ipsec_pcbctl(struct inpcb *inp, struct sockopt *sopt) /* INP_WLOCK_RECHECK */ INP_WLOCK(inp); - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_DROPPED) { INP_WUNLOCK(inp); return (ECONNRESET); }