Changeset View
Changeset View
Standalone View
Standalone View
head/sys/netinet/tcp_hostcache.c
Show All 26 Lines | |||||
* SUCH DAMAGE. | * SUCH DAMAGE. | ||||
*/ | */ | ||||
/* | /* | ||||
* The tcp_hostcache moves the tcp-specific cached metrics from the routing | * The tcp_hostcache moves the tcp-specific cached metrics from the routing | ||||
* table to a dedicated structure indexed by the remote IP address. It keeps | * table to a dedicated structure indexed by the remote IP address. It keeps | ||||
* information on the measured TCP parameters of past TCP sessions to allow | * information on the measured TCP parameters of past TCP sessions to allow | ||||
* better initial start values to be used with later connections to/from the | * better initial start values to be used with later connections to/from the | ||||
* same source. Depending on the network parameters (delay, bandwidth, max | * same source. Depending on the network parameters (delay, max MTU, | ||||
* MTU, congestion window) between local and remote sites, this can lead to | * congestion window) between local and remote sites, this can lead to | ||||
* significant speed-ups for new TCP connections after the first one. | * significant speed-ups for new TCP connections after the first one. | ||||
* | * | ||||
* Due to the tcp_hostcache, all TCP-specific metrics information in the | * Due to the tcp_hostcache, all TCP-specific metrics information in the | ||||
* routing table have been removed. The inpcb no longer keeps a pointer to | * routing table have been removed. The inpcb no longer keeps a pointer to | ||||
* the routing entry, and protocol-initiated route cloning has been removed | * the routing entry, and protocol-initiated route cloning has been removed | ||||
* as well. With these changes, the routing table has gone back to being | * as well. With these changes, the routing table has gone back to being | ||||
* more lightwight and only carries information related to packet forwarding. | * more lightwight and only carries information related to packet forwarding. | ||||
* | * | ||||
▲ Show 20 Lines • Show All 390 Lines • ▼ Show 20 Lines | tcp_hc_get(struct in_conninfo *inc, struct hc_metrics_lite *hc_metrics_lite) | ||||
} | } | ||||
hc_entry->rmx_hits++; | hc_entry->rmx_hits++; | ||||
hc_entry->rmx_expire = V_tcp_hostcache.expire; /* start over again */ | hc_entry->rmx_expire = V_tcp_hostcache.expire; /* start over again */ | ||||
hc_metrics_lite->rmx_mtu = hc_entry->rmx_mtu; | hc_metrics_lite->rmx_mtu = hc_entry->rmx_mtu; | ||||
hc_metrics_lite->rmx_ssthresh = hc_entry->rmx_ssthresh; | hc_metrics_lite->rmx_ssthresh = hc_entry->rmx_ssthresh; | ||||
hc_metrics_lite->rmx_rtt = hc_entry->rmx_rtt; | hc_metrics_lite->rmx_rtt = hc_entry->rmx_rtt; | ||||
hc_metrics_lite->rmx_rttvar = hc_entry->rmx_rttvar; | hc_metrics_lite->rmx_rttvar = hc_entry->rmx_rttvar; | ||||
hc_metrics_lite->rmx_bandwidth = hc_entry->rmx_bandwidth; | |||||
hc_metrics_lite->rmx_cwnd = hc_entry->rmx_cwnd; | hc_metrics_lite->rmx_cwnd = hc_entry->rmx_cwnd; | ||||
hc_metrics_lite->rmx_sendpipe = hc_entry->rmx_sendpipe; | hc_metrics_lite->rmx_sendpipe = hc_entry->rmx_sendpipe; | ||||
hc_metrics_lite->rmx_recvpipe = hc_entry->rmx_recvpipe; | hc_metrics_lite->rmx_recvpipe = hc_entry->rmx_recvpipe; | ||||
/* | /* | ||||
* Unlock bucket row. | * Unlock bucket row. | ||||
*/ | */ | ||||
THC_UNLOCK(&hc_entry->rmx_head->hch_mtx); | THC_UNLOCK(&hc_entry->rmx_head->hch_mtx); | ||||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | tcp_hc_update(struct in_conninfo *inc, struct hc_metrics_lite *hcml) | ||||
if (hcml->rmx_ssthresh != 0) { | if (hcml->rmx_ssthresh != 0) { | ||||
if (hc_entry->rmx_ssthresh == 0) | if (hc_entry->rmx_ssthresh == 0) | ||||
hc_entry->rmx_ssthresh = hcml->rmx_ssthresh; | hc_entry->rmx_ssthresh = hcml->rmx_ssthresh; | ||||
else | else | ||||
hc_entry->rmx_ssthresh = | hc_entry->rmx_ssthresh = | ||||
(hc_entry->rmx_ssthresh + hcml->rmx_ssthresh) / 2; | (hc_entry->rmx_ssthresh + hcml->rmx_ssthresh) / 2; | ||||
TCPSTAT_INC(tcps_cachedssthresh); | TCPSTAT_INC(tcps_cachedssthresh); | ||||
} | } | ||||
if (hcml->rmx_bandwidth != 0) { | |||||
if (hc_entry->rmx_bandwidth == 0) | |||||
hc_entry->rmx_bandwidth = hcml->rmx_bandwidth; | |||||
else | |||||
hc_entry->rmx_bandwidth = | |||||
(hc_entry->rmx_bandwidth + hcml->rmx_bandwidth) / 2; | |||||
/* TCPSTAT_INC(tcps_cachedbandwidth); */ | |||||
} | |||||
if (hcml->rmx_cwnd != 0) { | if (hcml->rmx_cwnd != 0) { | ||||
if (hc_entry->rmx_cwnd == 0) | if (hc_entry->rmx_cwnd == 0) | ||||
hc_entry->rmx_cwnd = hcml->rmx_cwnd; | hc_entry->rmx_cwnd = hcml->rmx_cwnd; | ||||
else | else | ||||
hc_entry->rmx_cwnd = | hc_entry->rmx_cwnd = | ||||
(hc_entry->rmx_cwnd + hcml->rmx_cwnd) / 2; | (hc_entry->rmx_cwnd + hcml->rmx_cwnd) / 2; | ||||
/* TCPSTAT_INC(tcps_cachedcwnd); */ | /* TCPSTAT_INC(tcps_cachedcwnd); */ | ||||
} | } | ||||
Show All 33 Lines | |||||
#ifdef INET6 | #ifdef INET6 | ||||
char ip6buf[INET6_ADDRSTRLEN]; | char ip6buf[INET6_ADDRSTRLEN]; | ||||
#endif | #endif | ||||
sbuf_new(&sb, NULL, linesize * (V_tcp_hostcache.cache_count + 1), | sbuf_new(&sb, NULL, linesize * (V_tcp_hostcache.cache_count + 1), | ||||
SBUF_INCLUDENUL); | SBUF_INCLUDENUL); | ||||
sbuf_printf(&sb, | sbuf_printf(&sb, | ||||
"\nIP address MTU SSTRESH RTT RTTVAR BANDWIDTH " | "\nIP address MTU SSTRESH RTT RTTVAR " | ||||
" CWND SENDPIPE RECVPIPE HITS UPD EXP\n"); | " CWND SENDPIPE RECVPIPE HITS UPD EXP\n"); | ||||
#define msec(u) (((u) + 500) / 1000) | #define msec(u) (((u) + 500) / 1000) | ||||
for (i = 0; i < V_tcp_hostcache.hashsize; i++) { | for (i = 0; i < V_tcp_hostcache.hashsize; i++) { | ||||
THC_LOCK(&V_tcp_hostcache.hashbase[i].hch_mtx); | THC_LOCK(&V_tcp_hostcache.hashbase[i].hch_mtx); | ||||
TAILQ_FOREACH(hc_entry, &V_tcp_hostcache.hashbase[i].hch_bucket, | TAILQ_FOREACH(hc_entry, &V_tcp_hostcache.hashbase[i].hch_bucket, | ||||
rmx_q) { | rmx_q) { | ||||
sbuf_printf(&sb, | sbuf_printf(&sb, | ||||
"%-15s %5lu %8lu %6lums %6lums %9lu %8lu %8lu %8lu " | "%-15s %5lu %8lu %6lums %6lums %8lu %8lu %8lu %4lu " | ||||
"%4lu %4lu %4i\n", | "%4lu %4i\n", | ||||
hc_entry->ip4.s_addr ? inet_ntoa(hc_entry->ip4) : | hc_entry->ip4.s_addr ? inet_ntoa(hc_entry->ip4) : | ||||
#ifdef INET6 | #ifdef INET6 | ||||
ip6_sprintf(ip6buf, &hc_entry->ip6), | ip6_sprintf(ip6buf, &hc_entry->ip6), | ||||
#else | #else | ||||
"IPv6?", | "IPv6?", | ||||
#endif | #endif | ||||
hc_entry->rmx_mtu, | hc_entry->rmx_mtu, | ||||
hc_entry->rmx_ssthresh, | hc_entry->rmx_ssthresh, | ||||
msec(hc_entry->rmx_rtt * | msec(hc_entry->rmx_rtt * | ||||
(RTM_RTTUNIT / (hz * TCP_RTT_SCALE))), | (RTM_RTTUNIT / (hz * TCP_RTT_SCALE))), | ||||
msec(hc_entry->rmx_rttvar * | msec(hc_entry->rmx_rttvar * | ||||
(RTM_RTTUNIT / (hz * TCP_RTTVAR_SCALE))), | (RTM_RTTUNIT / (hz * TCP_RTTVAR_SCALE))), | ||||
hc_entry->rmx_bandwidth * 8, | |||||
hc_entry->rmx_cwnd, | hc_entry->rmx_cwnd, | ||||
hc_entry->rmx_sendpipe, | hc_entry->rmx_sendpipe, | ||||
hc_entry->rmx_recvpipe, | hc_entry->rmx_recvpipe, | ||||
hc_entry->rmx_hits, | hc_entry->rmx_hits, | ||||
hc_entry->rmx_updates, | hc_entry->rmx_updates, | ||||
hc_entry->rmx_expire); | hc_entry->rmx_expire); | ||||
} | } | ||||
THC_UNLOCK(&V_tcp_hostcache.hashbase[i].hch_mtx); | THC_UNLOCK(&V_tcp_hostcache.hashbase[i].hch_mtx); | ||||
▲ Show 20 Lines • Show All 77 Lines • Show Last 20 Lines |