aboutsummaryrefslogtreecommitdiff
path: root/sys/netinet/tcp_subr.c
diff options
context:
space:
mode:
authorRandall Stewart <rrs@FreeBSD.org>2016-04-28 13:27:12 +0000
committerRandall Stewart <rrs@FreeBSD.org>2016-04-28 13:27:12 +0000
commite5ad64562a541c3b882789adec036387efd2986c (patch)
treec82ebe02d26bb553d2eb18b0db5e5a73bb688e89 /sys/netinet/tcp_subr.c
parent329ee7e3dc2632c941ac63ad70833a95b91527e7 (diff)
downloadsrc-e5ad64562a541c3b882789adec036387efd2986c.tar.gz
src-e5ad64562a541c3b882789adec036387efd2986c.zip
This cleans up the timers code in TCP to start using the new
async_drain functionality. This as been tested in NF as well as by Verisign. Still to do in here is to remove all the old flags. They are currently left being maintained but probably are no longer needed. Sponsored by: Netflix Inc. Differential Revision: http://reviews.freebsd.org/D5924
Notes
Notes: svn path=/head/; revision=298743
Diffstat (limited to 'sys/netinet/tcp_subr.c')
-rw-r--r--sys/netinet/tcp_subr.c74
1 files changed, 16 insertions, 58 deletions
diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
index aa2429901778..178ea77eb81f 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -244,7 +244,6 @@ static struct inpcb *tcp_mtudisc_notify(struct inpcb *, int);
static void tcp_mtudisc(struct inpcb *, int);
static char * tcp_log_addr(struct in_conninfo *inc, struct tcphdr *th,
void *ip4hdr, const void *ip6hdr);
-static void tcp_timer_discard(struct tcpcb *, uint32_t);
static struct tcp_function_block tcp_def_funcblk = {
@@ -258,7 +257,6 @@ static struct tcp_function_block tcp_def_funcblk = {
NULL,
NULL,
NULL,
- NULL,
0,
0
};
@@ -528,7 +526,6 @@ register_tcp_functions(struct tcp_function_block *blk, int wait)
return (EINVAL);
}
if (blk->tfb_tcp_timer_stop_all ||
- blk->tfb_tcp_timers_left ||
blk->tfb_tcp_timer_activate ||
blk->tfb_tcp_timer_active ||
blk->tfb_tcp_timer_stop) {
@@ -537,7 +534,6 @@ register_tcp_functions(struct tcp_function_block *blk, int wait)
* must have them all.
*/
if ((blk->tfb_tcp_timer_stop_all == NULL) ||
- (blk->tfb_tcp_timers_left == NULL) ||
(blk->tfb_tcp_timer_activate == NULL) ||
(blk->tfb_tcp_timer_active == NULL) ||
(blk->tfb_tcp_timer_stop == NULL)) {
@@ -1343,13 +1339,21 @@ tcp_discardcb(struct tcpcb *tp)
* callout, and the last discard function called will take care of
* deleting the tcpcb.
*/
+ tp->t_timers->tt_draincnt = 0;
tcp_timer_stop(tp, TT_REXMT);
tcp_timer_stop(tp, TT_PERSIST);
tcp_timer_stop(tp, TT_KEEP);
tcp_timer_stop(tp, TT_2MSL);
tcp_timer_stop(tp, TT_DELACK);
if (tp->t_fb->tfb_tcp_timer_stop_all) {
- /* Call the stop-all function of the methods */
+ /*
+ * Call the stop-all function of the methods,
+ * this function should call the tcp_timer_stop()
+ * method with each of the function specific timeouts.
+ * That stop will be called via the tfb_tcp_timer_stop()
+ * which should use the async drain function of the
+ * callout system (see tcp_var.h).
+ */
tp->t_fb->tfb_tcp_timer_stop_all(tp);
}
@@ -1434,13 +1438,8 @@ tcp_discardcb(struct tcpcb *tp)
CC_ALGO(tp) = NULL;
inp->inp_ppcb = NULL;
- if ((tp->t_timers->tt_flags & TT_MASK) == 0) {
+ if (tp->t_timers->tt_draincnt == 0) {
/* We own the last reference on tcpcb, let's free it. */
- if ((tp->t_fb->tfb_tcp_timers_left) &&
- (tp->t_fb->tfb_tcp_timers_left(tp))) {
- /* Some fb timers left running! */
- return;
- }
if (tp->t_fb->tfb_tcp_fb_fini)
(*tp->t_fb->tfb_tcp_fb_fini)(tp);
refcount_release(&tp->t_fb->tfb_refcnt);
@@ -1453,45 +1452,12 @@ tcp_discardcb(struct tcpcb *tp)
}
void
-tcp_timer_2msl_discard(void *xtp)
-{
-
- tcp_timer_discard((struct tcpcb *)xtp, TT_2MSL);
-}
-
-void
-tcp_timer_keep_discard(void *xtp)
-{
-
- tcp_timer_discard((struct tcpcb *)xtp, TT_KEEP);
-}
-
-void
-tcp_timer_persist_discard(void *xtp)
-{
-
- tcp_timer_discard((struct tcpcb *)xtp, TT_PERSIST);
-}
-
-void
-tcp_timer_rexmt_discard(void *xtp)
-{
-
- tcp_timer_discard((struct tcpcb *)xtp, TT_REXMT);
-}
-
-void
-tcp_timer_delack_discard(void *xtp)
-{
-
- tcp_timer_discard((struct tcpcb *)xtp, TT_DELACK);
-}
-
-void
-tcp_timer_discard(struct tcpcb *tp, uint32_t timer_type)
+tcp_timer_discard(void *ptp)
{
struct inpcb *inp;
-
+ struct tcpcb *tp;
+
+ tp = (struct tcpcb *)ptp;
CURVNET_SET(tp->t_vnet);
INP_INFO_RLOCK(&V_tcbinfo);
inp = tp->t_inpcb;
@@ -1500,16 +1466,9 @@ tcp_timer_discard(struct tcpcb *tp, uint32_t timer_type)
INP_WLOCK(inp);
KASSERT((tp->t_timers->tt_flags & TT_STOPPED) != 0,
("%s: tcpcb has to be stopped here", __func__));
- KASSERT((tp->t_timers->tt_flags & timer_type) != 0,
- ("%s: discard callout should be running", __func__));
- tp->t_timers->tt_flags &= ~timer_type;
- if ((tp->t_timers->tt_flags & TT_MASK) == 0) {
+ tp->t_timers->tt_draincnt--;
+ if (tp->t_timers->tt_draincnt == 0) {
/* We own the last reference on this tcpcb, let's free it. */
- if ((tp->t_fb->tfb_tcp_timers_left) &&
- (tp->t_fb->tfb_tcp_timers_left(tp))) {
- /* Some fb timers left running! */
- goto leave;
- }
if (tp->t_fb->tfb_tcp_fb_fini)
(*tp->t_fb->tfb_tcp_fb_fini)(tp);
refcount_release(&tp->t_fb->tfb_refcnt);
@@ -1521,7 +1480,6 @@ tcp_timer_discard(struct tcpcb *tp, uint32_t timer_type)
return;
}
}
-leave:
INP_WUNLOCK(inp);
INP_INFO_RUNLOCK(&V_tcbinfo);
CURVNET_RESTORE();