Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/tcp_subr.c
Show First 20 Lines • Show All 745 Lines • ▼ Show 20 Lines | maketcp_hashsize(int size) | ||||
if (hashsize < size) { | if (hashsize < size) { | ||||
hashsize = 1 << (fls(size) - 1); | hashsize = 1 << (fls(size) - 1); | ||||
} | } | ||||
return (hashsize); | return (hashsize); | ||||
} | } | ||||
static volatile int next_tcp_stack_id = 1; | static volatile int next_tcp_stack_id = 1; | ||||
#if !defined(__amd64__) && !defined(__i386__) | |||||
static sbintime_t | |||||
cpu_ts_getsbintime_(void) | |||||
{ | |||||
struct bintime bt; | |||||
getbinuptime(&bt); | |||||
sbt = bt.frac >> SBT_MINTS_SHIFT; | |||||
return (sbt); | |||||
} | |||||
#endif | |||||
/* | /* | ||||
* Register a TCP function block with the name provided in the names | * Register a TCP function block with the name provided in the names | ||||
* array. (Note that this function does NOT automatically register | * array. (Note that this function does NOT automatically register | ||||
* blk->tfb_tcp_block_name as a stack name. Therefore, you should | * blk->tfb_tcp_block_name as a stack name. Therefore, you should | ||||
* explicitly include blk->tfb_tcp_block_name in the list of names if | * explicitly include blk->tfb_tcp_block_name in the list of names if | ||||
* you wish to register the stack with that name.) | * you wish to register the stack with that name.) | ||||
* | * | ||||
* Either all name registrations will succeed or all will fail. If | * Either all name registrations will succeed or all will fail. If | ||||
▲ Show 20 Lines • Show All 354 Lines • ▼ Show 20 Lines | #undef TCP_MINPROTOHDR | ||||
ISN_LOCK_INIT(); | ISN_LOCK_INIT(); | ||||
EVENTHANDLER_REGISTER(shutdown_pre_sync, tcp_fini, NULL, | EVENTHANDLER_REGISTER(shutdown_pre_sync, tcp_fini, NULL, | ||||
SHUTDOWN_PRI_DEFAULT); | SHUTDOWN_PRI_DEFAULT); | ||||
EVENTHANDLER_REGISTER(maxsockets_change, tcp_zone_change, NULL, | EVENTHANDLER_REGISTER(maxsockets_change, tcp_zone_change, NULL, | ||||
EVENTHANDLER_PRI_ANY); | EVENTHANDLER_PRI_ANY); | ||||
#ifdef TCPPCAP | #ifdef TCPPCAP | ||||
tcp_pcap_init(); | tcp_pcap_init(); | ||||
#endif | #endif | ||||
#if !defined(__amd64__) && !defined(__i386__) | |||||
cpu_tcp_ts_getsbintime = cpu_tcp_ts_getsbintime_; | |||||
#endif | |||||
} | } | ||||
#ifdef VIMAGE | #ifdef VIMAGE | ||||
static void | static void | ||||
tcp_destroy(void *unused __unused) | tcp_destroy(void *unused __unused) | ||||
{ | { | ||||
int n; | int n; | ||||
#ifdef TCP_HHOOK | #ifdef TCP_HHOOK | ||||
▲ Show 20 Lines • Show All 306 Lines • ▼ Show 20 Lines | if (incl_opts) { | ||||
} else { | } else { | ||||
optp = (u_char *) (nth + 1); | optp = (u_char *) (nth + 1); | ||||
optm = m; | optm = m; | ||||
} | } | ||||
} | } | ||||
if (incl_opts) { | if (incl_opts) { | ||||
/* Timestamps. */ | /* Timestamps. */ | ||||
if (tp->t_flags & TF_RCVD_TSTMP) { | if (tp->t_flags & TF_RCVD_TSTMP) { | ||||
to.to_tsval = tcp_ts_getticks() + tp->ts_offset; | to.to_tsval = TCP_SBT_TO_TS(tcp_ts_getsbintime()); | ||||
to.to_tsecr = tp->ts_recent; | to.to_tsecr = tp->ts_recent; | ||||
to.to_flags |= TOF_TS; | to.to_flags |= TOF_TS; | ||||
} | } | ||||
#if defined(IPSEC_SUPPORT) || defined(TCP_SIGNATURE) | #if defined(IPSEC_SUPPORT) || defined(TCP_SIGNATURE) | ||||
/* TCP-MD5 (RFC2385). */ | /* TCP-MD5 (RFC2385). */ | ||||
if (tp->t_flags & TF_SIGNATURE) | if (tp->t_flags & TF_SIGNATURE) | ||||
to.to_flags |= TOF_SIGNATURE; | to.to_flags |= TOF_SIGNATURE; | ||||
#endif | #endif | ||||
▲ Show 20 Lines • Show All 195 Lines • ▼ Show 20 Lines | #endif /* INET6 */ | ||||
/* | /* | ||||
* Init srtt to TCPTV_SRTTBASE (0), so we can tell that we have no | * Init srtt to TCPTV_SRTTBASE (0), so we can tell that we have no | ||||
* rtt estimate. Set rttvar so that srtt + 4 * rttvar gives | * rtt estimate. Set rttvar so that srtt + 4 * rttvar gives | ||||
* reasonable initial retransmit time. | * reasonable initial retransmit time. | ||||
*/ | */ | ||||
tp->t_srtt = TCPTV_SRTTBASE; | tp->t_srtt = TCPTV_SRTTBASE; | ||||
tp->t_rttvar = ((TCPTV_RTOBASE - TCPTV_SRTTBASE) << TCP_RTTVAR_SHIFT) / 4; | tp->t_rttvar = ((TCPTV_RTOBASE - TCPTV_SRTTBASE) << TCP_RTTVAR_SHIFT) / 4; | ||||
tp->t_rttmin = tcp_rexmit_min; | tp->t_rttmin = tcp_rexmit_min*tick_sbt; | ||||
tp->t_rxtcur = TCPTV_RTOBASE; | tp->t_rxtcur = TCPTV_RTOBASE*tick_sbt; | ||||
tp->t_delack = tcp_delacktime*tick_sbt; | |||||
tp->snd_cwnd = TCP_MAXWIN << TCP_MAX_WINSHIFT; | tp->snd_cwnd = TCP_MAXWIN << TCP_MAX_WINSHIFT; | ||||
tp->snd_ssthresh = TCP_MAXWIN << TCP_MAX_WINSHIFT; | tp->snd_ssthresh = TCP_MAXWIN << TCP_MAX_WINSHIFT; | ||||
tp->t_rcvtime = ticks; | tp->t_rcvtime = tcp_ts_getsbintime(); | ||||
/* | /* | ||||
* IPv4 TTL initialization is necessary for an IPv6 socket as well, | * IPv4 TTL initialization is necessary for an IPv6 socket as well, | ||||
* because the socket may be bound to an IPv6 wildcard address, | * because the socket may be bound to an IPv6 wildcard address, | ||||
* which may match an IPv4-mapped IPv6 address. | * which may match an IPv4-mapped IPv6 address. | ||||
*/ | */ | ||||
inp->inp_ip_ttl = V_ip_defttl; | inp->inp_ip_ttl = V_ip_defttl; | ||||
inp->inp_ppcb = tp; | inp->inp_ppcb = tp; | ||||
#ifdef TCPPCAP | #ifdef TCPPCAP | ||||
▲ Show 20 Lines • Show All 180 Lines • ▼ Show 20 Lines | |||||
#ifdef INET6 | #ifdef INET6 | ||||
) | ) | ||||
#endif | #endif | ||||
); | ); | ||||
} else | } else | ||||
ssthresh = 0; | ssthresh = 0; | ||||
metrics.rmx_ssthresh = ssthresh; | metrics.rmx_ssthresh = ssthresh; | ||||
metrics.rmx_rtt = tp->t_srtt; | |||||
metrics.rmx_rttvar = tp->t_rttvar; | metrics.rmx_rtt = tp->t_srtt / SBT_1US; | ||||
metrics.rmx_rttvar = tp->t_rttvar / SBT_1US; | |||||
metrics.rmx_cwnd = tp->snd_cwnd; | metrics.rmx_cwnd = tp->snd_cwnd; | ||||
metrics.rmx_sendpipe = 0; | metrics.rmx_sendpipe = 0; | ||||
metrics.rmx_recvpipe = 0; | metrics.rmx_recvpipe = 0; | ||||
tcp_hc_update(&inp->inp_inc, &metrics); | tcp_hc_update(&inp->inp_inc, &metrics); | ||||
} | } | ||||
/* free the reassembly queue, if any */ | /* free the reassembly queue, if any */ | ||||
▲ Show 20 Lines • Show All 1,351 Lines • Show Last 20 Lines |