summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>2006-09-07 13:06:00 +0000
committerru <ru@FreeBSD.org>2006-09-07 13:06:00 +0000
commit0d416557b83f1cab7866408d2a3356d74f9e2f3c (patch)
treee02398a49c460cafd22200e8f849a887f6e31762
parentc9b5882a6eb5b95543c8cc67df0fa602a275d2e5 (diff)
downloadFreeBSD-src-0d416557b83f1cab7866408d2a3356d74f9e2f3c.zip
FreeBSD-src-0d416557b83f1cab7866408d2a3356d74f9e2f3c.tar.gz
Back when we had T/TCP support, we used to apply different
timeouts for TCP and T/TCP connections in the TIME_WAIT state, and we had two separate timed wait queues for them. Now that is has gone, the timeout is always 2*MSL again, and there is no reason to keep two queues (the first was unused anyway!). Also, reimplement the remaining queue using a TAILQ (it was technically impossible before, with two queues).
-rw-r--r--sys/netinet/tcp_input.c4
-rw-r--r--sys/netinet/tcp_reass.c4
-rw-r--r--sys/netinet/tcp_subr.c5
-rw-r--r--sys/netinet/tcp_timer.c63
-rw-r--r--sys/netinet/tcp_timer.h2
-rw-r--r--sys/netinet/tcp_timewait.c5
-rw-r--r--sys/netinet/tcp_var.h2
7 files changed, 30 insertions, 55 deletions
diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c
index 0699193..18b20e7 100644
--- a/sys/netinet/tcp_input.c
+++ b/sys/netinet/tcp_input.c
@@ -3187,7 +3187,7 @@ tcp_timewait(inp, to, th, m, tlen)
const int isipv6 = 0;
#endif
- /* tcbinfo lock required for tcp_twclose(), tcp_2msl_reset. */
+ /* tcbinfo lock required for tcp_twclose(), tcp_timer_2msl_reset(). */
INP_INFO_WLOCK_ASSERT(&tcbinfo);
INP_LOCK_ASSERT(inp);
@@ -3256,7 +3256,7 @@ tcp_timewait(inp, to, th, m, tlen)
if (thflags & TH_FIN) {
seq = th->th_seq + tlen + (thflags & TH_SYN ? 1 : 0);
if (seq + 1 == tw->rcv_nxt)
- tcp_timer_2msl_reset(tw, 2 * tcp_msl, 1);
+ tcp_timer_2msl_reset(tw, 1);
}
/*
diff --git a/sys/netinet/tcp_reass.c b/sys/netinet/tcp_reass.c
index 0699193..18b20e7 100644
--- a/sys/netinet/tcp_reass.c
+++ b/sys/netinet/tcp_reass.c
@@ -3187,7 +3187,7 @@ tcp_timewait(inp, to, th, m, tlen)
const int isipv6 = 0;
#endif
- /* tcbinfo lock required for tcp_twclose(), tcp_2msl_reset. */
+ /* tcbinfo lock required for tcp_twclose(), tcp_timer_2msl_reset(). */
INP_INFO_WLOCK_ASSERT(&tcbinfo);
INP_LOCK_ASSERT(inp);
@@ -3256,7 +3256,7 @@ tcp_timewait(inp, to, th, m, tlen)
if (thflags & TH_FIN) {
seq = th->th_seq + tlen + (thflags & TH_SYN ? 1 : 0);
if (seq + 1 == tw->rcv_nxt)
- tcp_timer_2msl_reset(tw, 2 * tcp_msl, 1);
+ tcp_timer_2msl_reset(tw, 1);
}
/*
diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
index 39acf62..85d5a9e 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -1736,7 +1736,7 @@ tcp_twstart(struct tcpcb *tp)
{
struct tcptw *tw;
struct inpcb *inp;
- int tw_time, acknow;
+ int acknow;
struct socket *so;
INP_INFO_WLOCK_ASSERT(&tcbinfo); /* tcp_timer_2msl_reset(). */
@@ -1781,7 +1781,6 @@ tcp_twstart(struct tcpcb *tp)
* be used for fin-wait-2 state also, then we may need
* a ts_recent from the last segment.
*/
- tw_time = 2 * tcp_msl;
acknow = tp->t_flags & TF_ACKNOW;
/*
@@ -1803,7 +1802,7 @@ tcp_twstart(struct tcpcb *tp)
tcp_twrespond(tw, TH_ACK);
inp->inp_ppcb = tw;
inp->inp_vflag |= INP_TIMEWAIT;
- tcp_timer_2msl_reset(tw, tw_time, 0);
+ tcp_timer_2msl_reset(tw, 0);
/*
* If the inpcb owns the sole reference to the socket, then we can
diff --git a/sys/netinet/tcp_timer.c b/sys/netinet/tcp_timer.c
index a5db5a0..86d9c6a 100644
--- a/sys/netinet/tcp_timer.c
+++ b/sys/netinet/tcp_timer.c
@@ -230,45 +230,30 @@ tcp_timer_2msl(xtp)
}
/*
- * The timed wait lists contain references to each of the TCP sessions
- * currently TIME_WAIT state. The list pointers, including the list pointers
- * in each tcptw structure, are protected using the global tcbinfo lock,
- * which must be held over list iteration and modification.
+ * The timed wait queue contains references to each of the TCP sessions
+ * currently in the TIME_WAIT state. The queue pointers, including the
+ * queue pointers in each tcptw structure, are protected using the global
+ * tcbinfo lock, which must be held over queue iteration and modification.
*/
-struct twlist {
- LIST_HEAD(, tcptw) tw_list;
- struct tcptw tw_tail;
-};
-#define TWLIST_NLISTS 2
-static struct twlist twl_2msl[TWLIST_NLISTS];
+static TAILQ_HEAD(, tcptw) twq_2msl;
void
tcp_timer_init(void)
{
- int i;
- struct twlist *twl;
- for (i = 0; i < TWLIST_NLISTS; i++) {
- twl = &twl_2msl[i];
- LIST_INIT(&twl->tw_list);
- LIST_INSERT_HEAD(&twl->tw_list, &twl->tw_tail, tw_2msl);
- }
+ TAILQ_INIT(&twq_2msl);
}
void
-tcp_timer_2msl_reset(struct tcptw *tw, int timeo, int rearm)
+tcp_timer_2msl_reset(struct tcptw *tw, int rearm)
{
- int i;
- struct tcptw *tw_tail;
INP_INFO_WLOCK_ASSERT(&tcbinfo);
INP_LOCK_ASSERT(tw->tw_inpcb);
if (rearm)
- LIST_REMOVE(tw, tw_2msl);
- tw->tw_time = timeo + ticks;
- i = timeo > tcp_msl ? 1 : 0;
- tw_tail = &twl_2msl[i].tw_tail;
- LIST_INSERT_BEFORE(tw_tail, tw, tw_2msl);
+ TAILQ_REMOVE(&twq_2msl, tw, tw_2msl);
+ tw->tw_time = ticks + 2 * tcp_msl;
+ TAILQ_INSERT_TAIL(&twq_2msl, tw, tw_2msl);
}
void
@@ -276,31 +261,23 @@ tcp_timer_2msl_stop(struct tcptw *tw)
{
INP_INFO_WLOCK_ASSERT(&tcbinfo);
- LIST_REMOVE(tw, tw_2msl);
+ TAILQ_REMOVE(&twq_2msl, tw, tw_2msl);
}
struct tcptw *
tcp_timer_2msl_tw(int reuse)
{
- struct tcptw *tw, *tw_tail;
- struct twlist *twl;
- int i;
+ struct tcptw *tw;
INP_INFO_WLOCK_ASSERT(&tcbinfo);
- for (i = 0; i < TWLIST_NLISTS; i++) {
- twl = &twl_2msl[i];
- tw_tail = &twl->tw_tail;
-
- 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);
- }
-
+ for (;;) {
+ tw = TAILQ_FIRST(&twq_2msl);
+ if (tw == NULL || (!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_timer.h b/sys/netinet/tcp_timer.h
index 815a757..4b32cbb 100644
--- a/sys/netinet/tcp_timer.h
+++ b/sys/netinet/tcp_timer.h
@@ -156,7 +156,7 @@ void tcp_timer_init(void);
void tcp_timer_2msl(void *xtp);
struct tcptw *
tcp_timer_2msl_tw(int _reuse); /* XXX temporary */
-void tcp_timer_2msl_reset(struct tcptw *_tw, int _timeo, int rearm);
+void tcp_timer_2msl_reset(struct tcptw *_tw, int rearm);
void tcp_timer_2msl_stop(struct tcptw *_tw);
void tcp_timer_keep(void *xtp);
void tcp_timer_persist(void *xtp);
diff --git a/sys/netinet/tcp_timewait.c b/sys/netinet/tcp_timewait.c
index 39acf62..85d5a9e 100644
--- a/sys/netinet/tcp_timewait.c
+++ b/sys/netinet/tcp_timewait.c
@@ -1736,7 +1736,7 @@ tcp_twstart(struct tcpcb *tp)
{
struct tcptw *tw;
struct inpcb *inp;
- int tw_time, acknow;
+ int acknow;
struct socket *so;
INP_INFO_WLOCK_ASSERT(&tcbinfo); /* tcp_timer_2msl_reset(). */
@@ -1781,7 +1781,6 @@ tcp_twstart(struct tcpcb *tp)
* be used for fin-wait-2 state also, then we may need
* a ts_recent from the last segment.
*/
- tw_time = 2 * tcp_msl;
acknow = tp->t_flags & TF_ACKNOW;
/*
@@ -1803,7 +1802,7 @@ tcp_twstart(struct tcpcb *tp)
tcp_twrespond(tw, TH_ACK);
inp->inp_ppcb = tw;
inp->inp_vflag |= INP_TIMEWAIT;
- tcp_timer_2msl_reset(tw, tw_time, 0);
+ tcp_timer_2msl_reset(tw, 0);
/*
* If the inpcb owns the sole reference to the socket, then we can
diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h
index 4aa5cda..7658485 100644
--- a/sys/netinet/tcp_var.h
+++ b/sys/netinet/tcp_var.h
@@ -276,7 +276,7 @@ struct tcptw {
u_long t_recent;
u_long t_starttime;
int tw_time;
- LIST_ENTRY(tcptw) tw_2msl;
+ TAILQ_ENTRY(tcptw) tw_2msl;
};
#define intotcpcb(ip) ((struct tcpcb *)(ip)->inp_ppcb)
OpenPOWER on IntegriCloud