diff options
-rw-r--r-- | sys/netinet/in_pcb.c | 16 | ||||
-rw-r--r-- | sys/netinet/tcp_subr.c | 7 | ||||
-rw-r--r-- | sys/netinet/tcp_timer.c | 19 | ||||
-rw-r--r-- | sys/netinet/tcp_timewait.c | 7 | ||||
-rw-r--r-- | sys/netinet/tcp_var.h | 2 |
5 files changed, 20 insertions, 31 deletions
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index ddb9e3c..b117b13 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -903,7 +903,6 @@ in_pcblookup_local(struct inpcbinfo *pcbinfo, struct in_addr laddr, u_int lport_arg, int wild_okay) { struct inpcb *inp; - struct tcptw *tw; #ifdef INET6 int matchwild = 3 + INP_LOOKUP_MAPPED_PCB_COST; #else @@ -949,7 +948,6 @@ in_pcblookup_local(struct inpcbinfo *pcbinfo, struct in_addr laddr, * First see if this local port is in use by looking on the * port hash list. */ - retrylookup: porthash = &pcbinfo->porthashbase[INP_PCBPORTHASH(lport, pcbinfo->porthashmask)]; LIST_FOREACH(phd, porthash, phd_hash) { @@ -982,20 +980,6 @@ in_pcblookup_local(struct inpcbinfo *pcbinfo, struct in_addr laddr, if ((inp->inp_vflag & INP_IPV6) != 0) wildcard += INP_LOOKUP_MAPPED_PCB_COST; #endif - /* - * Clean out old time_wait sockets if they - * are clogging up needed local ports. - */ - if ((inp->inp_vflag & INP_TIMEWAIT) != 0) { - tw = intotw(inp); - if (tw != NULL && - tcp_twrecycleable(tw)) { - INP_LOCK(inp); - tcp_twclose(tw, 0); - match = NULL; - goto retrylookup; - } - } if (inp->inp_faddr.s_addr != INADDR_ANY) wildcard++; if (inp->inp_laddr.s_addr != INADDR_ANY) { diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index 05451e3..22a5e26 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -1808,6 +1808,7 @@ tcp_twstart(struct tcpcb *tp) INP_UNLOCK(inp); } +#if 0 /* * The appromixate rate of ISN increase of Microsoft TCP stacks; * the actual rate is slightly higher due to the addition of @@ -1822,10 +1823,6 @@ tcp_twstart(struct tcpcb *tp) * Determine if the ISN we will generate has advanced beyond the last * sequence number used by the previous connection. If so, indicate * that it is safe to recycle this tw socket by returning 1. - * - * XXXRW: This function should assert the inpcb lock as it does multiple - * non-atomic reads from the tcptw, but is currently called without it from - * in_pcb.c:in_pcblookup_local(). */ int tcp_twrecycleable(struct tcptw *tw) @@ -1833,6 +1830,7 @@ tcp_twrecycleable(struct tcptw *tw) tcp_seq new_iss = tw->iss; tcp_seq new_irs = tw->irs; + INP_INFO_WLOCK_ASSERT(&tcbinfo); new_iss += (ticks - tw->t_starttime) * (ISN_BYTES_PER_SECOND / hz); new_irs += (ticks - tw->t_starttime) * (MS_ISN_BYTES_PER_SECOND / hz); @@ -1841,6 +1839,7 @@ tcp_twrecycleable(struct tcptw *tw) else return (0); } +#endif void tcp_twclose(struct tcptw *tw, int reuse) diff --git a/sys/netinet/tcp_timer.c b/sys/netinet/tcp_timer.c index 5c105b4..ca0bd36 100644 --- a/sys/netinet/tcp_timer.c +++ b/sys/netinet/tcp_timer.c @@ -288,15 +288,20 @@ tcp_timer_2msl_tw(int reuse) int i; INP_INFO_WLOCK_ASSERT(&tcbinfo); - for (i = 0; i < 2; i++) { + for (i = 0; i < TWLIST_NLISTS; i++) { twl = tw_2msl_list[i]; tw_tail = &twl->tw_tail; - tw = LIST_FIRST(&twl->tw_list); - if (tw == tw_tail || (!reuse && tw->tw_time > ticks)) - continue; - INP_LOCK(tw->tw_inpcb); - tcp_twclose(tw, reuse); - return (reuse ? tw : NULL); + + for (;;) { + tw = LIST_FIRST(&twl->tw_list); + if (tw == tw_tail || (!reuse && tw->tw_time > ticks)) + break; + INP_LOCK(tw->tw_inpcb); + tcp_twclose(tw, reuse); + if (reuse) + return (tw); + } + } return (NULL); } diff --git a/sys/netinet/tcp_timewait.c b/sys/netinet/tcp_timewait.c index 05451e3..22a5e26 100644 --- a/sys/netinet/tcp_timewait.c +++ b/sys/netinet/tcp_timewait.c @@ -1808,6 +1808,7 @@ tcp_twstart(struct tcpcb *tp) INP_UNLOCK(inp); } +#if 0 /* * The appromixate rate of ISN increase of Microsoft TCP stacks; * the actual rate is slightly higher due to the addition of @@ -1822,10 +1823,6 @@ tcp_twstart(struct tcpcb *tp) * Determine if the ISN we will generate has advanced beyond the last * sequence number used by the previous connection. If so, indicate * that it is safe to recycle this tw socket by returning 1. - * - * XXXRW: This function should assert the inpcb lock as it does multiple - * non-atomic reads from the tcptw, but is currently called without it from - * in_pcb.c:in_pcblookup_local(). */ int tcp_twrecycleable(struct tcptw *tw) @@ -1833,6 +1830,7 @@ tcp_twrecycleable(struct tcptw *tw) tcp_seq new_iss = tw->iss; tcp_seq new_irs = tw->irs; + INP_INFO_WLOCK_ASSERT(&tcbinfo); new_iss += (ticks - tw->t_starttime) * (ISN_BYTES_PER_SECOND / hz); new_irs += (ticks - tw->t_starttime) * (MS_ISN_BYTES_PER_SECOND / hz); @@ -1841,6 +1839,7 @@ tcp_twrecycleable(struct tcptw *tw) else return (0); } +#endif void tcp_twclose(struct tcptw *tw, int reuse) diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index c58b44e..0831724 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -494,7 +494,9 @@ struct tcpcb * tcp_close(struct tcpcb *); void tcp_discardcb(struct tcpcb *); void tcp_twstart(struct tcpcb *); +#if 0 int tcp_twrecycleable(struct tcptw *tw); +#endif void tcp_twclose(struct tcptw *_tw, int _reuse); void tcp_ctlinput(int, struct sockaddr *, void *); int tcp_ctloutput(struct socket *, struct sockopt *); |