diff options
author | andre <andre@FreeBSD.org> | 2003-11-20 20:07:39 +0000 |
---|---|---|
committer | andre <andre@FreeBSD.org> | 2003-11-20 20:07:39 +0000 |
commit | 6164d7c280688f20cf827e8374984c6e0175fab0 (patch) | |
tree | f947a08d66395dd498056038f0c360783fa281c7 /sys/netinet/tcp_usrreq.c | |
parent | 6dca20de0718f19b3cdc5a7d5ebb71cd54b2374e (diff) | |
download | FreeBSD-src-6164d7c280688f20cf827e8374984c6e0175fab0.zip FreeBSD-src-6164d7c280688f20cf827e8374984c6e0175fab0.tar.gz |
Introduce tcp_hostcache and remove the tcp specific metrics from
the routing table. Move all usage and references in the tcp stack
from the routing table metrics to the tcp hostcache.
It caches measured parameters of past tcp sessions to provide better
initial start values for following connections from or to the same
source or destination. Depending on the network parameters to/from
the remote host this can lead to significant speedups for new tcp
connections after the first one because they inherit and shortcut
the learning curve.
tcp_hostcache is designed for multiple concurrent access in SMP
environments with high contention and is hash indexed by remote
ip address.
It removes significant locking requirements from the tcp stack with
regard to the routing table.
Reviewed by: sam (mentor), bms
Reviewed by: -net, -current, core@kame.net (IPv6 parts)
Approved by: re (scottl)
Diffstat (limited to 'sys/netinet/tcp_usrreq.c')
-rw-r--r-- | sys/netinet/tcp_usrreq.c | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index 7035227..17566c8 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -848,12 +848,13 @@ tcp_connect(tp, nam, td) struct inpcb *inp = tp->t_inpcb, *oinp; struct socket *so = inp->inp_socket; struct tcptw *otw; - struct rmxp_tao *taop; - struct rmxp_tao tao_noncached; + struct rmxp_tao tao; struct in_addr laddr; u_short lport; int error; + bzero(&tao, sizeof(tao)); + if (inp->inp_lport == 0) { error = in_pcbbind(inp, (struct sockaddr *)0, td); if (error) @@ -902,20 +903,22 @@ tcp_connect(tp, nam, td) * Generate a CC value for this connection and * check whether CC or CCnew should be used. */ - if ((taop = tcp_gettaocache(&tp->t_inpcb->inp_inc)) == NULL) { - taop = &tao_noncached; - bzero(taop, sizeof(*taop)); - } + if (tcp_do_rfc1644) + tcp_hc_gettao(&inp->inp_inc, &tao); tp->cc_send = CC_INC(tcp_ccgen); - if (taop->tao_ccsent != 0 && - CC_GEQ(tp->cc_send, taop->tao_ccsent)) { - taop->tao_ccsent = tp->cc_send; + if (tao.tao_ccsent != 0 && + CC_GEQ(tp->cc_send, tao.tao_ccsent)) { + tao.tao_ccsent = tp->cc_send; } else { - taop->tao_ccsent = 0; + tao.tao_ccsent = 0; tp->t_flags |= TF_SENDCCNEW; } + if (tcp_do_rfc1644) + tcp_hc_updatetao(&inp->inp_inc, TCP_HC_TAO_CCSENT, + tao.tao_ccsent, 0); + return 0; } @@ -931,10 +934,11 @@ tcp6_connect(tp, nam, td) struct tcptw *otw; struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)nam; struct in6_addr *addr6; - struct rmxp_tao *taop; - struct rmxp_tao tao_noncached; + struct rmxp_tao tao; int error; + bzero(&tao, sizeof(tao)); + if (inp->inp_lport == 0) { error = in6_pcbbind(inp, (struct sockaddr *)0, td); if (error) @@ -991,19 +995,20 @@ tcp6_connect(tp, nam, td) * Generate a CC value for this connection and * check whether CC or CCnew should be used. */ - if ((taop = tcp_gettaocache(&tp->t_inpcb->inp_inc)) == NULL) { - taop = &tao_noncached; - bzero(taop, sizeof(*taop)); - } + if (tcp_do_rfc1644) + tcp_hc_gettao(&inp->inp_inc, &tao); tp->cc_send = CC_INC(tcp_ccgen); - if (taop->tao_ccsent != 0 && - CC_GEQ(tp->cc_send, taop->tao_ccsent)) { - taop->tao_ccsent = tp->cc_send; + if (tao.tao_ccsent != 0 && + CC_GEQ(tp->cc_send, tao.tao_ccsent)) { + tao.tao_ccsent = tp->cc_send; } else { - taop->tao_ccsent = 0; + tao.tao_ccsent = 0; tp->t_flags |= TF_SENDCCNEW; } + if (tcp_do_rfc1644) + tcp_hc_updatetao(&inp->inp_inc, TCP_HC_TAO_CCSENT, + tao.tao_ccsent, 0); return 0; } |