Lines Matching +full:reseed +full:- +full:disable
1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
156 if (error == 0 && req->newptr) { in sysctl_net_inet_tcp_mss_check()
178 if (error == 0 && req->newptr) { in sysctl_net_inet_tcp_mss_v6_check()
198 * with packet generation and sending. Set to zero to disable MINMSS
214 * stacks negotiate TS, but don't send them when sending keep-alive segments.
239 …"If the TCP stack does pacing, is there a limit (-1 = no, 0 = no pacing N = number of connections)…
241 static int tcp_dgp_limit = -1;
243 &tcp_dgp_limit, -1,
244 "If the TCP stack does DGP, is there a limit (-1 = no, 0 = no dgp N = number of connections)");
270 &tcp_tcbhashsize, 0, "Size of TCP control-block hashtable");
306 if (error == 0 && req->newptr) { in sysctl_net_inet_tcp_map_limit_check()
368 tp->t_dsack_pack++; in tcp_record_dsack()
371 tp->t_dsack_bytes += (end - start); in tcp_record_dsack()
372 TCPSTAT_ADD(tcps_dsack_bytes, (end - start)); in tcp_record_dsack()
374 tp->t_dsack_tlp_bytes += (start - end); in tcp_record_dsack()
375 TCPSTAT_ADD(tcps_dsack_bytes, (start - end)); in tcp_record_dsack()
379 tp->t_dsack_bytes += (end - start); in tcp_record_dsack()
380 TCPSTAT_ADD(tcps_dsack_tlp_bytes, (end - start)); in tcp_record_dsack()
382 tp->t_dsack_tlp_bytes += (start - end); in tcp_record_dsack()
383 TCPSTAT_ADD(tcps_dsack_tlp_bytes, (start - end)); in tcp_record_dsack()
396 if (strcmp(f->tf_name, fs->function_set_name) == 0) { in find_tcp_functions_locked()
397 blk = f->tf_fb; in find_tcp_functions_locked()
412 if (f->tf_fb == blk) { in find_tcp_fb_locked()
431 refcount_acquire(&blk->tfb_refcnt); in find_and_ref_tcp_functions()
444 refcount_acquire(&rblk->tfb_refcnt); in find_and_ref_tcp_fb()
460 if ((f->tf_fb == blk) && in find_tcp_function_alias()
461 (strncmp(f->tf_name, blk->tfb_tcp_block_name, in find_tcp_function_alias()
464 strncpy(fs->function_set_name, f->tf_name, in find_tcp_function_alias()
472 fs->function_set_name[TCP_FUNCTION_NAME_LEN_MAX - 1] = '\0'; in find_tcp_function_alias()
474 fs->function_set_name[0] = '\0'; in find_tcp_function_alias()
487 refcount_acquire(&rblk->tfb_refcnt); in find_and_ref_tcp_default_fb()
498 KASSERT(tp->t_fb != &tcp_def_funcblk, in tcp_switch_back_to_default()
499 ("%s: called by the built-in default stack", __func__)); in tcp_switch_back_to_default()
501 if (tp->t_fb->tfb_tcp_timer_stop_all != NULL) in tcp_switch_back_to_default()
502 tp->t_fb->tfb_tcp_timer_stop_all(tp); in tcp_switch_back_to_default()
506 * Start by trying the current user-selected in tcp_switch_back_to_default()
507 * default, unless this stack is the user-selected in tcp_switch_back_to_default()
511 if (tfb == tp->t_fb) { in tcp_switch_back_to_default()
512 refcount_release(&tfb->tfb_refcnt); in tcp_switch_back_to_default()
516 if (tfb != NULL && (*tfb->tfb_tcp_handoff_ok)(tp)) { in tcp_switch_back_to_default()
517 refcount_release(&tfb->tfb_refcnt); in tcp_switch_back_to_default()
523 if (tfb->tfb_tcp_fb_init == NULL || in tcp_switch_back_to_default()
524 (*tfb->tfb_tcp_fb_init)(tp, &ptr) == 0) { in tcp_switch_back_to_default()
526 if (tp->t_fb->tfb_tcp_fb_fini != NULL) in tcp_switch_back_to_default()
527 (*tp->t_fb->tfb_tcp_fb_fini)(tp, 0); in tcp_switch_back_to_default()
528 refcount_release(&tp->t_fb->tfb_refcnt); in tcp_switch_back_to_default()
530 tp->t_fb = tfb; in tcp_switch_back_to_default()
531 tp->t_fb_ptr = ptr; in tcp_switch_back_to_default()
538 refcount_release(&tfb->tfb_refcnt); in tcp_switch_back_to_default()
542 * If that wasn't feasible, use the built-in default in tcp_switch_back_to_default()
550 if ((*tfb->tfb_tcp_handoff_ok)(tp)) { in tcp_switch_back_to_default()
554 if (tfb->tfb_tcp_fb_init != NULL && in tcp_switch_back_to_default()
555 (*tfb->tfb_tcp_fb_init)(tp, &ptr)) { in tcp_switch_back_to_default()
560 if (tp->t_fb->tfb_tcp_fb_fini != NULL) in tcp_switch_back_to_default()
561 (*tp->t_fb->tfb_tcp_fb_fini)(tp, 0); in tcp_switch_back_to_default()
562 refcount_release(&tp->t_fb->tfb_refcnt); in tcp_switch_back_to_default()
564 tp->t_fb = tfb; in tcp_switch_back_to_default()
565 tp->t_fb_ptr = ptr; in tcp_switch_back_to_default()
582 if ((m->m_flags & M_PKTHDR) == 0) { in tcp_recv_udp_tunneled_packet()
588 if (m->m_len < off + sizeof(struct udphdr) + thlen && in tcp_recv_udp_tunneled_packet()
596 thlen = th->th_off << 2; in tcp_recv_udp_tunneled_packet()
597 if (m->m_len < off + sizeof(struct udphdr) + thlen) { in tcp_recv_udp_tunneled_packet()
608 m->m_pkthdr.tcp_tun_port = port = uh->uh_sport; in tcp_recv_udp_tunneled_packet()
609 bcopy(th, uh, m->m_len - off); in tcp_recv_udp_tunneled_packet()
610 m->m_len -= sizeof(struct udphdr); in tcp_recv_udp_tunneled_packet()
611 m->m_pkthdr.len -= sizeof(struct udphdr); in tcp_recv_udp_tunneled_packet()
614 * both UDP and TCP for c-sum. So in tcp_recv_udp_tunneled_packet()
617 * with the flag (m->m_pkthdr.csum_flags). in tcp_recv_udp_tunneled_packet()
619 switch (iph->ip_v) { in tcp_recv_udp_tunneled_packet()
622 iph->ip_len = htons(ntohs(iph->ip_len) - sizeof(struct udphdr)); in tcp_recv_udp_tunneled_packet()
629 ip6->ip6_plen = htons(ntohs(ip6->ip6_plen) - sizeof(struct udphdr)); in tcp_recv_udp_tunneled_packet()
656 strcpy(fs.function_set_name, blk->tfb_tcp_block_name); in sysctl_net_inet_default_tcp_functions()
657 fs.pcbcnt = blk->tfb_refcnt; in sysctl_net_inet_default_tcp_functions()
664 if (error != 0 || req->newptr == NULL) in sysctl_net_inet_default_tcp_functions()
670 (blk->tfb_flags & TCP_FUNC_BEING_REMOVED)) { in sysctl_net_inet_default_tcp_functions()
674 if ((blk->tfb_flags & TCP_FUNC_DEFAULT_OK) == 0) { in sysctl_net_inet_default_tcp_functions()
711 linesz = snprintf(cp, bufsz, "\n%-32s%c %-32s %s\n", "Stack", 'D', in sysctl_net_inet_list_available()
714 bufsz -= linesz; in sysctl_net_inet_list_available()
719 alias = (f->tf_name != f->tf_fb->tfb_tcp_block_name); in sysctl_net_inet_list_available()
720 linesz = snprintf(cp, bufsz, "%-32s%c %-32s %u\n", in sysctl_net_inet_list_available()
721 f->tf_fb->tfb_tcp_block_name, in sysctl_net_inet_list_available()
722 (f->tf_fb == V_tcp_func_set_ptr) ? '*' : ' ', in sysctl_net_inet_list_available()
723 alias ? f->tf_name : "-", in sysctl_net_inet_list_available()
724 f->tf_fb->tfb_refcnt); in sysctl_net_inet_list_available()
730 bufsz -= linesz; in sysctl_net_inet_list_available()
799 /* Already running -- must stop first */ in tcp_over_udp_start()
805 /* Already running -- must stop first */ in tcp_over_udp_start()
812 curthread->td_ucred, curthread))) { in tcp_over_udp_start()
838 curthread->td_ucred, curthread))) { in tcp_over_udp_start()
874 (req->newptr != NULL)) { in sysctl_net_inet_tcp_udp_tunneling_port_check()
911 if (error == 0 && req->newptr) { in sysctl_net_inet_tcp_udp_tunneling_overhead_check()
940 if (req->newptr != NULL) in sysctl_net_inet_list_func_info()
947 if (req->oldptr != NULL) { in sysctl_net_inet_list_func_info()
962 if (req->oldptr == NULL) { in sysctl_net_inet_list_func_info()
971 if (req->oldptr != NULL) { in sysctl_net_inet_list_func_info()
973 tfi.tfi_refcnt = f->tf_fb->tfb_refcnt; in sysctl_net_inet_list_func_info()
974 tfi.tfi_id = f->tf_fb->tfb_id; in sysctl_net_inet_list_func_info()
975 (void)strlcpy(tfi.tfi_alias, f->tf_name, in sysctl_net_inet_list_func_info()
978 f->tf_fb->tfb_tcp_block_name, sizeof(tfi.tfi_name)); in sysctl_net_inet_list_func_info()
993 if (req->oldptr == NULL) in sysctl_net_inet_list_func_info()
1003 "List TCP function block name-to-ID mappings");
1022 * The init() fuction from the default can *never* return non-zero i.e.
1035 KASSERT(tp->t_state < TCPS_TIME_WAIT, in tcp_default_fb_init()
1037 tp->t_state)); in tcp_default_fb_init()
1044 tp->t_flags &= ~TF_GPUTINPROG; in tcp_default_fb_init()
1047 if ((tp->t_state == TCPS_SYN_SENT) || in tcp_default_fb_init()
1048 (tp->t_state == TCPS_SYN_RECEIVED)) in tcp_default_fb_init()
1049 rexmt = tcp_rexmit_initial * tcp_backoff[tp->t_rxtshift]; in tcp_default_fb_init()
1051 rexmt = TCP_REXMTVAL(tp) * tcp_backoff[tp->t_rxtshift]; in tcp_default_fb_init()
1052 if (tp->t_rxtshift == 0) in tcp_default_fb_init()
1053 tp->t_rxtcur = rexmt; in tcp_default_fb_init()
1055 TCPT_RANGESET(tp->t_rxtcur, rexmt, tp->t_rttmin, TCPTV_REXMTMAX); in tcp_default_fb_init()
1061 if (tp->t_state <= TCPS_LISTEN || tp->t_state >= TCPS_TIME_WAIT) in tcp_default_fb_init()
1068 if ((!TCPS_HAVEESTABLISHED(tp->t_state) || sbavail(&so->so_snd) || in tcp_default_fb_init()
1069 tp->snd_una != tp->snd_max) && !(tcp_timer_active(tp, TT_REXMT) || in tcp_default_fb_init()
1076 if (TCPS_HAVEESTABLISHED(tp->t_state) && tp->snd_wnd == 0 && in tcp_default_fb_init()
1077 (int32_t)(tp->snd_nxt - tp->snd_una) < in tcp_default_fb_init()
1078 (int32_t)sbavail(&so->so_snd)) in tcp_default_fb_init()
1084 /* All non-embryonic sessions get a keepalive timer. */ in tcp_default_fb_init()
1087 TCPS_HAVEESTABLISHED(tp->t_state) ? TP_KEEPIDLE(tp) : in tcp_default_fb_init()
1094 if IN_FASTRECOVERY(tp->t_flags) { in tcp_default_fb_init()
1095 if (tp->sackhint.recover_fs == 0) in tcp_default_fb_init()
1096 tp->sackhint.recover_fs = max(1, in tcp_default_fb_init()
1097 tp->snd_nxt - tp->snd_una); in tcp_default_fb_init()
1118 tp->t_acktime = 0; in tcp_default_fb_fini()
1149 hashsize = 1 << (fls(size) - 1); in maketcp_hashsize()
1159 * blk->tfb_tcp_block_name as a stack name. Therefore, you should
1160 * explicitly include blk->tfb_tcp_block_name in the list of names if
1180 ("%s: Called with non-positive length of name list", __func__)); in register_tcp_functions_as_names()
1189 if ((blk->tfb_tcp_output == NULL) || in register_tcp_functions_as_names()
1190 (blk->tfb_tcp_do_segment == NULL) || in register_tcp_functions_as_names()
1191 (blk->tfb_tcp_ctloutput == NULL) || in register_tcp_functions_as_names()
1192 (blk->tfb_tcp_handoff_ok == NULL) || in register_tcp_functions_as_names()
1193 (strlen(blk->tfb_tcp_block_name) == 0)) { in register_tcp_functions_as_names()
1202 while (--i >= 0) in register_tcp_functions_as_names()
1216 if (blk->tfb_flags & TCP_FUNC_BEING_REMOVED) { in register_tcp_functions_as_names()
1220 refcount_init(&blk->tfb_refcnt, 0); in register_tcp_functions_as_names()
1221 blk->tfb_id = atomic_fetchadd_int(&next_tcp_stack_id, 1); in register_tcp_functions_as_names()
1230 f[i]->tf_fb = blk; in register_tcp_functions_as_names()
1231 (void)strlcpy(f[i]->tf_name, names[i], sizeof(f[i]->tf_name)); in register_tcp_functions_as_names()
1244 tcp_fb_cnt--; in register_tcp_functions_as_names()
1246 f[i]->tf_fb = NULL; in register_tcp_functions_as_names()
1271 name_list[0] = blk->tfb_tcp_block_name; in register_tcp_functions_as_name()
1278 * blk->tfb_tcp_block_name.
1314 /* You can't un-register the default */ in deregister_tcp_functions()
1332 blk->tfb_flags |= TCP_FUNC_BEING_REMOVED; in deregister_tcp_functions()
1337 if (force && blk->tfb_refcnt) { in deregister_tcp_functions()
1352 if (tp == NULL || tp->t_fb != blk) in deregister_tcp_functions()
1362 if (blk->tfb_refcnt) { in deregister_tcp_functions()
1375 tcp_fb_cnt--; in deregister_tcp_functions()
1376 f->tf_fb = NULL; in deregister_tcp_functions()
1638 if ((inp->inp_vflag & INP_IPV6) != 0) { in tcpip_fillheaders()
1642 ip6->ip6_flow = (ip6->ip6_flow & ~IPV6_FLOWINFO_MASK) | in tcpip_fillheaders()
1643 (inp->inp_flow & IPV6_FLOWINFO_MASK); in tcpip_fillheaders()
1644 ip6->ip6_vfc = (ip6->ip6_vfc & ~IPV6_VERSION_MASK) | in tcpip_fillheaders()
1647 ip6->ip6_nxt = IPPROTO_TCP; in tcpip_fillheaders()
1649 ip6->ip6_nxt = IPPROTO_UDP; in tcpip_fillheaders()
1650 ip6->ip6_plen = htons(sizeof(struct tcphdr)); in tcpip_fillheaders()
1651 ip6->ip6_src = inp->in6p_laddr; in tcpip_fillheaders()
1652 ip6->ip6_dst = inp->in6p_faddr; in tcpip_fillheaders()
1663 ip->ip_v = IPVERSION; in tcpip_fillheaders()
1664 ip->ip_hl = 5; in tcpip_fillheaders()
1665 ip->ip_tos = inp->inp_ip_tos; in tcpip_fillheaders()
1666 ip->ip_len = 0; in tcpip_fillheaders()
1667 ip->ip_id = 0; in tcpip_fillheaders()
1668 ip->ip_off = 0; in tcpip_fillheaders()
1669 ip->ip_ttl = inp->inp_ip_ttl; in tcpip_fillheaders()
1670 ip->ip_sum = 0; in tcpip_fillheaders()
1672 ip->ip_p = IPPROTO_TCP; in tcpip_fillheaders()
1674 ip->ip_p = IPPROTO_UDP; in tcpip_fillheaders()
1675 ip->ip_src = inp->inp_laddr; in tcpip_fillheaders()
1676 ip->ip_dst = inp->inp_faddr; in tcpip_fillheaders()
1679 th->th_sport = inp->inp_lport; in tcpip_fillheaders()
1680 th->th_dport = inp->inp_fport; in tcpip_fillheaders()
1681 th->th_seq = 0; in tcpip_fillheaders()
1682 th->th_ack = 0; in tcpip_fillheaders()
1683 th->th_off = 5; in tcpip_fillheaders()
1685 th->th_win = 0; in tcpip_fillheaders()
1686 th->th_urp = 0; in tcpip_fillheaders()
1687 th->th_sum = 0; /* in_pseudo() is called later for ipv4 */ in tcpip_fillheaders()
1703 tcpip_fillheaders(inp, 0, (void *)&t->tt_ipgen, (void *)&t->tt_t); in tcpip_maketemplate()
1751 isipv6 = ((struct ip *)ipgen)->ip_v == (IPV6_VERSION >> 4); in tcp_respond()
1764 if (isipv6 && ip6 && (ip6->ip6_nxt == IPPROTO_UDP)) in tcp_respond()
1765 port = m->m_pkthdr.tcp_tun_port; in tcp_respond()
1768 if (ip && (ip->ip_p == IPPROTO_UDP)) in tcp_respond()
1769 port = m->m_pkthdr.tcp_tun_port; in tcp_respond()
1773 port = tp->t_port; in tcp_respond()
1779 win = sbspace(&inp->inp_socket->so_rcv); in tcp_respond()
1780 if (win > TCP_MAXWIN << tp->rcv_scale) in tcp_respond()
1781 win = TCP_MAXWIN << tp->rcv_scale; in tcp_respond()
1783 if ((tp->t_flags & TF_NOOPT) == 0) in tcp_respond()
1790 m->m_data += max_linkhdr; in tcp_respond()
1800 uh->uh_sport = htons(V_tcp_udp_tunneling_port); in tcp_respond()
1801 uh->uh_dport = port; in tcp_respond()
1813 uh->uh_sport = htons(V_tcp_udp_tunneling_port); in tcp_respond()
1814 uh->uh_dport = port; in tcp_respond()
1836 n->m_data += max_linkhdr; in tcp_respond()
1844 xchg(ip6->ip6_dst, ip6->ip6_src, struct in6_addr); in tcp_respond()
1849 uh->uh_sport = htons(V_tcp_udp_tunneling_port); in tcp_respond()
1850 uh->uh_dport = port; in tcp_respond()
1858 xchg(ip->ip_dst.s_addr, ip->ip_src.s_addr, uint32_t); in tcp_respond()
1863 uh->uh_sport = htons(V_tcp_udp_tunneling_port); in tcp_respond()
1864 uh->uh_dport = port; in tcp_respond()
1869 xchg(nth->th_dport, nth->th_sport, uint16_t); in tcp_respond()
1878 m_freem(m->m_next); in tcp_respond()
1879 m->m_next = NULL; in tcp_respond()
1880 m->m_data = (caddr_t)ipgen; in tcp_respond()
1882 m->m_flags &= ~(M_TSTMP | M_TSTMP_LRO); in tcp_respond()
1886 xchg(ip6->ip6_dst, ip6->ip6_src, struct in6_addr); in tcp_respond()
1891 xchg(ip->ip_dst.s_addr, ip->ip_src.s_addr, uint32_t); in tcp_respond()
1900 nth->th_sport = th->th_sport; in tcp_respond()
1901 nth->th_dport = th->th_dport; in tcp_respond()
1903 xchg(nth->th_dport, nth->th_sport, uint16_t); in tcp_respond()
1920 m->m_len = 0; in tcp_respond()
1925 m->m_len = tlen; in tcp_respond()
1931 m->m_next = m_get(M_NOWAIT, MT_DATA); in tcp_respond()
1932 if (m->m_next) { in tcp_respond()
1933 optp = mtod(m->m_next, u_char *); in tcp_respond()
1934 optm = m->m_next; in tcp_respond()
1944 if (tp->t_flags & TF_RCVD_TSTMP) { in tcp_respond()
1945 to.to_tsval = tcp_ts_getticks() + tp->ts_offset; in tcp_respond()
1946 to.to_tsecr = tp->ts_recent; in tcp_respond()
1950 /* TCP-MD5 (RFC2385). */ in tcp_respond()
1951 if (tp->t_flags & TF_SIGNATURE) in tcp_respond()
1958 optm->m_len += optlen; in tcp_respond()
1964 ulen = tlen - sizeof(struct ip6_hdr); in tcp_respond()
1965 uh->uh_ulen = htons(ulen); in tcp_respond()
1967 ip6->ip6_flow = htonl(ect << IPV6_FLOWLABEL_LEN); in tcp_respond()
1968 ip6->ip6_vfc = IPV6_VERSION; in tcp_respond()
1970 ip6->ip6_nxt = IPPROTO_UDP; in tcp_respond()
1972 ip6->ip6_nxt = IPPROTO_TCP; in tcp_respond()
1973 ip6->ip6_plen = htons(tlen - sizeof(*ip6)); in tcp_respond()
1982 ulen = tlen - sizeof(struct ip); in tcp_respond()
1983 uh->uh_ulen = htons(ulen); in tcp_respond()
1985 ip->ip_len = htons(tlen); in tcp_respond()
1987 ip->ip_tos = inp->inp_ip_tos & ~IPTOS_ECN_MASK; in tcp_respond()
1988 ip->ip_ttl = inp->inp_ip_ttl; in tcp_respond()
1990 ip->ip_tos = 0; in tcp_respond()
1991 ip->ip_ttl = V_ip_defttl; in tcp_respond()
1993 ip->ip_tos |= ect; in tcp_respond()
1995 ip->ip_p = IPPROTO_UDP; in tcp_respond()
1997 ip->ip_p = IPPROTO_TCP; in tcp_respond()
2000 ip->ip_off |= htons(IP_DF); in tcp_respond()
2003 m->m_pkthdr.len = tlen; in tcp_respond()
2004 m->m_pkthdr.rcvif = NULL; in tcp_respond()
2021 nth->th_seq = htonl(seq); in tcp_respond()
2022 nth->th_ack = htonl(ack); in tcp_respond()
2023 nth->th_off = (sizeof (struct tcphdr) + optlen) >> 2; in tcp_respond()
2030 nth->th_win = htons((u_short) (win >> tp->rcv_scale)); in tcp_respond()
2032 nth->th_win = htons((u_short)win); in tcp_respond()
2033 nth->th_urp = 0; in tcp_respond()
2048 m->m_pkthdr.csum_flags = CSUM_UDP_IPV6; in tcp_respond()
2049 m->m_pkthdr.csum_data = offsetof(struct udphdr, uh_sum); in tcp_respond()
2050 uh->uh_sum = in6_cksum_pseudo(ip6, ulen, IPPROTO_UDP, 0); in tcp_respond()
2051 nth->th_sum = 0; in tcp_respond()
2053 m->m_pkthdr.csum_flags = CSUM_TCP_IPV6; in tcp_respond()
2054 m->m_pkthdr.csum_data = offsetof(struct tcphdr, th_sum); in tcp_respond()
2055 nth->th_sum = in6_cksum_pseudo(ip6, in tcp_respond()
2056 tlen - sizeof(struct ip6_hdr), IPPROTO_TCP, 0); in tcp_respond()
2058 ip6->ip6_hlim = in6_selecthlim(inp, NULL); in tcp_respond()
2067 uh->uh_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, in tcp_respond()
2069 m->m_pkthdr.csum_flags = CSUM_UDP; in tcp_respond()
2070 m->m_pkthdr.csum_data = offsetof(struct udphdr, uh_sum); in tcp_respond()
2071 nth->th_sum = 0; in tcp_respond()
2073 m->m_pkthdr.csum_flags = CSUM_TCP; in tcp_respond()
2074 m->m_pkthdr.csum_data = offsetof(struct tcphdr, th_sum); in tcp_respond()
2075 nth->th_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, in tcp_respond()
2076 htons((u_short)(tlen - sizeof(struct ip) + ip->ip_p))); in tcp_respond()
2092 log.u_bbr.pkts_out = tp->t_maxseg; in tcp_respond()
2119 (tp->t_state == TCPS_CLOSED || in tcp_respond()
2120 (tp->t_state > TCPS_LISTEN && tp->t_port != port)), in tcp_respond()
2124 ntohs(port), tcpstates[tp->t_state])); in tcp_respond()
2137 output_ret = ip6_output(m, inp ? inp->in6p_outputopts : NULL, in tcp_respond()
2151 lgb->tlb_errno = output_ret; in tcp_respond()
2170 if (tp->t_challenge_ack_end < now) { in tcp_send_challenge_ack()
2171 tp->t_challenge_ack_cnt = 0; in tcp_send_challenge_ack()
2172 tp->t_challenge_ack_end = now + in tcp_send_challenge_ack()
2179 if (tp->t_challenge_ack_cnt < V_tcp_ack_war_cnt) { in tcp_send_challenge_ack()
2181 tp->t_challenge_ack_cnt++; in tcp_send_challenge_ack()
2187 tcp_respond(tp, mtod(m, void *), th, m, tp->rcv_nxt, in tcp_send_challenge_ack()
2188 tp->snd_nxt, TH_ACK); in tcp_send_challenge_ack()
2189 tp->last_ack_sent = tp->rcv_nxt; in tcp_send_challenge_ack()
2205 int isipv6 = (inp->inp_vflag & INP_IPV6) != 0; in tcp_newtcpcb()
2213 bzero(&tp->t_start_zero, t_zero_size); in tcp_newtcpcb()
2216 tp->t_ccv.tp = tp; in tcp_newtcpcb()
2220 KASSERT(listening_tcb->t_fb != NULL, in tcp_newtcpcb()
2221 ("tcp_newtcpcb: listening_tcb->t_fb is NULL")); in tcp_newtcpcb()
2222 if (listening_tcb->t_fb->tfb_flags & TCP_FUNC_BEING_REMOVED) { in tcp_newtcpcb()
2226 tp->t_fb = listening_tcb->t_fb; in tcp_newtcpcb()
2228 tp->t_fb = V_tcp_func_set_ptr; in tcp_newtcpcb()
2230 refcount_acquire(&tp->t_fb->tfb_refcnt); in tcp_newtcpcb()
2231 KASSERT((tp->t_fb->tfb_flags & TCP_FUNC_BEING_REMOVED) == 0, in tcp_newtcpcb()
2236 if (CC_ALGO(listening_tcb)->flags & CC_MODULE_BEING_REMOVED) { in tcp_newtcpcb()
2238 if (tp->t_fb->tfb_tcp_fb_fini) in tcp_newtcpcb()
2239 (*tp->t_fb->tfb_tcp_fb_fini)(tp, 1); in tcp_newtcpcb()
2240 refcount_release(&tp->t_fb->tfb_refcnt); in tcp_newtcpcb()
2248 if (CC_ALGO(tp)->cb_init != NULL) in tcp_newtcpcb()
2249 if (CC_ALGO(tp)->cb_init(&tp->t_ccv, NULL) > 0) { in tcp_newtcpcb()
2251 if (tp->t_fb->tfb_tcp_fb_fini) in tcp_newtcpcb()
2252 (*tp->t_fb->tfb_tcp_fb_fini)(tp, 1); in tcp_newtcpcb()
2253 refcount_release(&tp->t_fb->tfb_refcnt); in tcp_newtcpcb()
2258 if (khelp_init_osd(HELPER_CLASS_TCP, &tp->t_osd)) { in tcp_newtcpcb()
2259 if (CC_ALGO(tp)->cb_destroy != NULL) in tcp_newtcpcb()
2260 CC_ALGO(tp)->cb_destroy(&tp->t_ccv); in tcp_newtcpcb()
2263 if (tp->t_fb->tfb_tcp_fb_fini) in tcp_newtcpcb()
2264 (*tp->t_fb->tfb_tcp_fb_fini)(tp, 1); in tcp_newtcpcb()
2265 refcount_release(&tp->t_fb->tfb_refcnt); in tcp_newtcpcb()
2270 TAILQ_INIT(&tp->t_segq); in tcp_newtcpcb()
2271 STAILQ_INIT(&tp->t_inqueue); in tcp_newtcpcb()
2272 tp->t_maxseg = in tcp_newtcpcb()
2281 tp->t_hpts_cpu = HPTS_CPU_NONE; in tcp_newtcpcb()
2282 tp->t_lro_cpu = HPTS_CPU_NONE; in tcp_newtcpcb()
2284 callout_init_rw(&tp->t_callout, &inp->inp_lock, in tcp_newtcpcb()
2287 tp->t_timers[i] = SBT_MAX; in tcp_newtcpcb()
2294 tp->t_flags = (TF_REQ_SCALE|TF_REQ_TSTMP); in tcp_newtcpcb()
2297 tp->t_flags = TF_REQ_SCALE; in tcp_newtcpcb()
2300 tp->t_flags = TF_REQ_TSTMP; in tcp_newtcpcb()
2304 tp->t_flags |= TF_SACK_PERMIT; in tcp_newtcpcb()
2305 TAILQ_INIT(&tp->snd_holes); in tcp_newtcpcb()
2312 tp->t_srtt = TCPTV_SRTTBASE; in tcp_newtcpcb()
2313 tp->t_rttvar = ((tcp_rexmit_initial - TCPTV_SRTTBASE) << TCP_RTTVAR_SHIFT) / 4; in tcp_newtcpcb()
2314 tp->t_rttmin = tcp_rexmit_min; in tcp_newtcpcb()
2315 tp->t_rxtcur = tcp_rexmit_initial; in tcp_newtcpcb()
2316 tp->snd_cwnd = TCP_MAXWIN << TCP_MAX_WINSHIFT; in tcp_newtcpcb()
2317 tp->snd_ssthresh = TCP_MAXWIN << TCP_MAX_WINSHIFT; in tcp_newtcpcb()
2318 tp->t_rcvtime = ticks; in tcp_newtcpcb()
2320 tp->t_tmr_granularity = TCP_TMR_GRANULARITY_TICKS; in tcp_newtcpcb()
2324 * which may match an IPv4-mapped IPv6 address. in tcp_newtcpcb()
2326 inp->inp_ip_ttl = V_ip_defttl; in tcp_newtcpcb()
2328 /* Initialize the per-TCPCB log data. */ in tcp_newtcpcb()
2331 tp->t_pacing_rate = -1; in tcp_newtcpcb()
2332 if (tp->t_fb->tfb_tcp_fb_init) { in tcp_newtcpcb()
2333 if ((*tp->t_fb->tfb_tcp_fb_init)(tp, &tp->t_fb_ptr)) { in tcp_newtcpcb()
2334 if (CC_ALGO(tp)->cb_destroy != NULL) in tcp_newtcpcb()
2335 CC_ALGO(tp)->cb_destroy(&tp->t_ccv); in tcp_newtcpcb()
2339 khelp_destroy_osd(&tp->t_osd); in tcp_newtcpcb()
2341 refcount_release(&tp->t_fb->tfb_refcnt); in tcp_newtcpcb()
2347 tp->t_stats = stats_blob_alloc(V_tcp_perconn_stats_dflt_tpl, 0); in tcp_newtcpcb()
2350 tp->t_flags |= TF_LRD; in tcp_newtcpcb()
2368 if (TCPS_HAVERCVDSYN(tp->t_state)) { in tcp_drop()
2375 if (errno == ETIMEDOUT && tp->t_softerror) in tcp_drop()
2376 errno = tp->t_softerror; in tcp_drop()
2377 so->so_error = errno; in tcp_drop()
2388 bool isipv6 = (inp->inp_vflag & INP_IPV6) != 0; in tcp_discardcb()
2392 MPASS(!callout_active(&tp->t_callout)); in tcp_discardcb()
2393 MPASS(TAILQ_EMPTY(&tp->snd_holes)); in tcp_discardcb()
2400 if (tp->t_flags & TF_TOE) in tcp_discardcb()
2405 if (CC_ALGO(tp)->cb_destroy != NULL) in tcp_discardcb()
2406 CC_ALGO(tp)->cb_destroy(&tp->t_ccv); in tcp_discardcb()
2412 khelp_destroy_osd(&tp->t_osd); in tcp_discardcb()
2415 stats_blob_destroy(tp->t_stats); in tcp_discardcb()
2419 if ((m = STAILQ_FIRST(&tp->t_inqueue)) != NULL) { in tcp_discardcb()
2422 STAILQ_INIT(&tp->t_inqueue); in tcp_discardcb()
2423 STAILQ_FOREACH_FROM_SAFE(m, &tp->t_inqueue, m_stailqpkt, prev) in tcp_discardcb()
2426 TCPSTATES_DEC(tp->t_state); in tcp_discardcb()
2428 if (tp->t_fb->tfb_tcp_fb_fini) in tcp_discardcb()
2429 (*tp->t_fb->tfb_tcp_fb_fini)(tp, 1); in tcp_discardcb()
2449 if (tp->t_rttupdated >= 4) { in tcp_discardcb()
2460 ssthresh = tp->snd_ssthresh; in tcp_discardcb()
2461 if (ssthresh != 0 && ssthresh < so->so_snd.sb_hiwat / 2) { in tcp_discardcb()
2466 ssthresh = (ssthresh + tp->t_maxseg / 2) / tp->t_maxseg; in tcp_discardcb()
2469 ssthresh *= (tp->t_maxseg + in tcp_discardcb()
2483 metrics.hc_rtt = tp->t_srtt; in tcp_discardcb()
2484 metrics.hc_rttvar = tp->t_rttvar; in tcp_discardcb()
2485 metrics.hc_cwnd = tp->snd_cwnd; in tcp_discardcb()
2489 tcp_hc_update(&inp->inp_inc, &metrics); in tcp_discardcb()
2492 refcount_release(&tp->t_fb->tfb_refcnt); in tcp_discardcb()
2508 if (tp->t_state == TCPS_LISTEN) in tcp_close()
2513 * sockets as well as passively-created TFO sockets that transition in tcp_close()
2516 if (tp->t_tfo_pending) { in tcp_close()
2517 tcp_fastopen_decrement_counter(tp->t_tfo_pending); in tcp_close()
2518 tp->t_tfo_pending = NULL; in tcp_close()
2521 if (tp->t_fb->tfb_tcp_timer_stop_all != NULL) in tcp_close()
2522 tp->t_fb->tfb_tcp_timer_stop_all(tp); in tcp_close()
2525 if (tp->t_state != TCPS_CLOSED) in tcp_close()
2527 KASSERT(inp->inp_socket != NULL, ("tcp_close: inp_socket NULL")); in tcp_close()
2530 if (inp->inp_flags & INP_SOCKREF) { in tcp_close()
2531 inp->inp_flags &= ~INP_SOCKREF; in tcp_close()
2545 * reporting soft errors (yet - a kqueue filter may be added).
2564 if (tp->t_state == TCPS_ESTABLISHED && in tcp_notify()
2567 if (inp->inp_route.ro_nh) { in tcp_notify()
2568 NH_FREE(inp->inp_route.ro_nh); in tcp_notify()
2569 inp->inp_route.ro_nh = (struct nhop_object *)NULL; in tcp_notify()
2572 } else if (tp->t_state < TCPS_ESTABLISHED && tp->t_rxtshift > 3 && in tcp_notify()
2573 tp->t_softerror) { in tcp_notify()
2580 tp->t_softerror = error; in tcp_notify()
2584 wakeup( &so->so_timeo); in tcp_notify()
2599 if (req->newptr != NULL) in tcp_pcblist()
2602 if (req->oldptr == NULL) { in tcp_pcblist()
2608 req->oldidx = 2 * (sizeof xig) + n * sizeof(struct xtcpcb); in tcp_pcblist()
2630 if (inp->inp_gencnt <= xig.xig_gen && in tcp_pcblist()
2631 cr_canseeinpcb(req->td->td_ucred, inp) == 0) { in tcp_pcblist()
2677 if (req->newptr == NULL) in tcp_getcred()
2679 error = priv_check(req->td, PRIV_NETINET_GETCRED); in tcp_getcred()
2691 error = cr_canseeinpcb(req->td->td_ucred, inp); in tcp_getcred()
2693 cru2x(inp->inp_cred, &xuc); in tcp_getcred()
2721 if (req->newptr == NULL) in tcp6_getcred()
2723 error = priv_check(req->td, PRIV_NETINET_GETCRED); in tcp6_getcred()
2759 error = cr_canseeinpcb(req->td->td_ucred, inp); in tcp6_getcred()
2761 cru2x(inp->inp_cred, &xuc); in tcp6_getcred()
2777 /* Path MTU to try next when a fragmentation-needed message is received. */
2781 int mtu = ntohs(icp->icmp_nextmtu); in tcp_next_pmtu()
2785 mtu = ip_next_mtu(ntohs(ip->ip_len), 1); in tcp_next_pmtu()
2818 if (V_icmp_may_rst && icp->icmp_type == ICMP_TIMXCEED) in tcp_ctlinput_with_port()
2827 ip = &icp->icmp_ip; in tcp_ctlinput_with_port()
2828 th = (struct tcphdr *)((caddr_t)ip + (ip->ip_hl << 2)); in tcp_ctlinput_with_port()
2829 icmp_tcp_seq = th->th_seq; in tcp_ctlinput_with_port()
2830 inp = in_pcblookup(&V_tcbinfo, ip->ip_dst, th->th_dport, ip->ip_src, in tcp_ctlinput_with_port()
2831 th->th_sport, INPLOOKUP_WLOCKPCB, NULL); in tcp_ctlinput_with_port()
2835 if (tp->t_flags & TF_TOE && errno == EMSGSIZE) { in tcp_ctlinput_with_port()
2845 if (tp->t_port != port) in tcp_ctlinput_with_port()
2847 if (SEQ_GEQ(ntohl(icmp_tcp_seq), tp->snd_una) && in tcp_ctlinput_with_port()
2848 SEQ_LT(ntohl(icmp_tcp_seq), tp->snd_max)) { in tcp_ctlinput_with_port()
2860 if (mtu < tp->t_maxseg + in tcp_ctlinput_with_port()
2863 inc.inc_faddr = ip->ip_dst; in tcp_ctlinput_with_port()
2865 inp->inp_inc.inc_fibnum; in tcp_ctlinput_with_port()
2874 inc.inc_fport = th->th_dport; in tcp_ctlinput_with_port()
2875 inc.inc_lport = th->th_sport; in tcp_ctlinput_with_port()
2876 inc.inc_faddr = ip->ip_dst; in tcp_ctlinput_with_port()
2877 inc.inc_laddr = ip->ip_src; in tcp_ctlinput_with_port()
2902 outer_ip = (struct ip *)((caddr_t)icmp - sizeof(struct ip)); in tcp_ctlinput_viaudp()
2903 inner_ip = &icmp->icmp_ip; in tcp_ctlinput_viaudp()
2904 i_hlen = inner_ip->ip_hl << 2; in tcp_ctlinput_viaudp()
2905 o_len = ntohs(outer_ip->ip_len); in tcp_ctlinput_viaudp()
2913 if (ntohs(udp->uh_sport) != V_tcp_udp_tunneling_port) { in tcp_ctlinput_viaudp()
2916 port = udp->uh_dport; in tcp_ctlinput_viaudp()
2921 o_len -= sizeof(struct udphdr); in tcp_ctlinput_viaudp()
2922 outer_ip->ip_len = htons(o_len); in tcp_ctlinput_viaudp()
2932 int mtu = ntohl(icmp6->icmp6_mtu); in tcp6_next_pmtu()
2939 mtu = IPV6_MMTU - 8; /* XXXNP: what is the adjustment for? */ in tcp6_next_pmtu()
2963 icmp6 = ip6cp->ip6c_icmp6; in tcp6_ctlinput_with_port()
2964 m = ip6cp->ip6c_m; in tcp6_ctlinput_with_port()
2965 ip6 = ip6cp->ip6c_ip6; in tcp6_ctlinput_with_port()
2966 off = ip6cp->ip6c_off; in tcp6_ctlinput_with_port()
2967 dst = &ip6cp->ip6c_finaldst->sin6_addr; in tcp6_ctlinput_with_port()
2985 * - administratively prohibited in tcp6_ctlinput_with_port()
2986 * - port unreachable in tcp6_ctlinput_with_port()
2987 * - time exceeded in transit in tcp6_ctlinput_with_port()
2988 * - unknown next header in tcp6_ctlinput_with_port()
2991 ((icmp6->icmp6_type == ICMP6_DST_UNREACH && in tcp6_ctlinput_with_port()
2992 (icmp6->icmp6_code == ICMP6_DST_UNREACH_ADMIN || in tcp6_ctlinput_with_port()
2993 icmp6->icmp6_code == ICMP6_DST_UNREACH_NOPORT)) || in tcp6_ctlinput_with_port()
2994 (icmp6->icmp6_type == ICMP6_TIME_EXCEEDED && in tcp6_ctlinput_with_port()
2995 icmp6->icmp6_code == ICMP6_TIME_EXCEED_TRANSIT) || in tcp6_ctlinput_with_port()
2996 (icmp6->icmp6_type == ICMP6_PARAM_PROB && in tcp6_ctlinput_with_port()
2997 icmp6->icmp6_code == ICMP6_PARAMPROB_NEXTHEADER))) in tcp6_ctlinput_with_port()
3008 (m->m_pkthdr.len < in tcp6_ctlinput_with_port()
3014 inp = in6_pcblookup(&V_tcbinfo, &ip6->ip6_dst, t_ports.th_dport, in tcp6_ctlinput_with_port()
3015 &ip6->ip6_src, t_ports.th_sport, INPLOOKUP_WLOCKPCB, NULL); in tcp6_ctlinput_with_port()
3017 if (m->m_pkthdr.len < (int32_t) (off + sizeof(tcp_seq))) { in tcp6_ctlinput_with_port()
3024 if (tp->t_flags & TF_TOE && errno == EMSGSIZE) { in tcp6_ctlinput_with_port()
3031 if (tp->t_port != port) in tcp6_ctlinput_with_port()
3033 if (SEQ_GEQ(ntohl(icmp_tcp_seq), tp->snd_una) && in tcp6_ctlinput_with_port()
3034 SEQ_LT(ntohl(icmp_tcp_seq), tp->snd_max)) { in tcp6_ctlinput_with_port()
3049 m->m_pkthdr.rcvif, NULL)) in tcp6_ctlinput_with_port()
3055 if (mtu < tp->t_maxseg + in tcp6_ctlinput_with_port()
3072 inc.inc6_laddr = ip6->ip6_src; in tcp6_ctlinput_with_port()
3094 m = m_pulldown(ip6cp->ip6c_m, ip6cp->ip6c_off, sizeof(struct udphdr), NULL); in tcp6_ctlinput_viaudp()
3099 if (ntohs(udp->uh_sport) != V_tcp_udp_tunneling_port) { in tcp6_ctlinput_viaudp()
3102 port = udp->uh_dport; in tcp6_ctlinput_viaudp()
3104 if ((m->m_flags & M_PKTHDR) == 0) { in tcp6_ctlinput_viaudp()
3105 ip6cp->ip6c_m->m_pkthdr.len -= sizeof(struct udphdr); in tcp6_ctlinput_viaudp()
3123 SipHash_Update(&ctx, &inc->inc_fport, sizeof(uint16_t)); in tcp_keyed_hash()
3124 SipHash_Update(&ctx, &inc->inc_lport, sizeof(uint16_t)); in tcp_keyed_hash()
3125 switch (inc->inc_flags & INC_ISIPV6) { in tcp_keyed_hash()
3128 SipHash_Update(&ctx, &inc->inc_faddr, sizeof(struct in_addr)); in tcp_keyed_hash()
3129 SipHash_Update(&ctx, &inc->inc_laddr, sizeof(struct in_addr)); in tcp_keyed_hash()
3134 SipHash_Update(&ctx, &inc->inc6_faddr, sizeof(struct in6_addr)); in tcp_keyed_hash()
3135 SipHash_Update(&ctx, &inc->inc6_laddr, sizeof(struct in6_addr)); in tcp_keyed_hash()
3165 * 1. In SYN-ACK packets.
3168 * All ISNs for SYN-ACK packets are generated by the syncache. See
3207 #define ISN_RANDOM_INCREMENT (4096 - 1)
3229 /* Seed if this is the first use, reseed if requested. */ in tcp_new_isn()
3244 ISN_BYTES_PER_SECOND / hz * (ticks - V_isn_last); in tcp_new_isn()
3257 * connection state is SYN-SENT, drop the connection. This behavior
3269 if (tp->t_state != TCPS_SYN_SENT) in tcp_drop_syn_sent()
3272 if (tp->t_flags & TF_FASTOPEN) in tcp_drop_syn_sent()
3292 return (tcp_mtudisc(inp, -1)); in tcp_mtudisc_notify()
3306 tcp_mss_update(tp, -1, mtuoffer, NULL, NULL); in tcp_mtudisc()
3308 so = inp->inp_socket; in tcp_mtudisc()
3311 if (so->so_snd.sb_hiwat < tp->t_maxseg) { in tcp_mtudisc()
3312 tp->t_maxseg = so->so_snd.sb_hiwat; in tcp_mtudisc()
3313 if (tp->t_maxseg < V_tcp_mssdflt) { in tcp_mtudisc()
3319 tp->t_flags2 |= TF2_PROC_SACK_PROHIBIT; in tcp_mtudisc()
3321 tp->t_flags2 &= ~TF2_PROC_SACK_PROHIBIT; in tcp_mtudisc()
3327 tp->t_rtttime = 0; in tcp_mtudisc()
3328 tp->snd_nxt = tp->snd_una; in tcp_mtudisc()
3330 tp->snd_recover = tp->snd_max; in tcp_mtudisc()
3331 if (tp->t_flags & TF_SACK_PERMIT) in tcp_mtudisc()
3332 EXIT_FASTRECOVERY(tp->t_flags); in tcp_mtudisc()
3333 if (tp->t_fb->tfb_tcp_mtu_chg != NULL) { in tcp_mtudisc()
3340 tp->t_fb->tfb_tcp_mtu_chg(tp); in tcp_mtudisc()
3350 * Look-up the routing entry to the peer of this inpcb. If no route
3364 if (inc->inc_faddr.s_addr != INADDR_ANY) { in tcp_maxmtu()
3365 nh = fib4_lookup(inc->inc_fibnum, inc->inc_faddr, 0, NHR_NONE, 0); in tcp_maxmtu()
3369 ifp = nh->nh_ifp; in tcp_maxmtu()
3370 maxmtu = nh->nh_mtu; in tcp_maxmtu()
3374 if (ifp->if_capenable & IFCAP_TSO4 && in tcp_maxmtu()
3375 ifp->if_hwassist & CSUM_TSO) { in tcp_maxmtu()
3376 cap->ifcap |= CSUM_TSO; in tcp_maxmtu()
3377 cap->tsomax = ifp->if_hw_tsomax; in tcp_maxmtu()
3378 cap->tsomaxsegcount = ifp->if_hw_tsomaxsegcount; in tcp_maxmtu()
3379 cap->tsomaxsegsize = ifp->if_hw_tsomaxsegsize; in tcp_maxmtu()
3381 cap->ipsec_tso = (ifp->if_capenable2 & in tcp_maxmtu()
3402 if (inc->inc_flags & INC_IPV6MINMTU) in tcp_maxmtu6()
3405 if (!IN6_IS_ADDR_UNSPECIFIED(&inc->inc6_faddr)) { in tcp_maxmtu6()
3406 in6_splitscope(&inc->inc6_faddr, &dst6, &scopeid); in tcp_maxmtu6()
3407 nh = fib6_lookup(inc->inc_fibnum, &dst6, scopeid, NHR_NONE, 0); in tcp_maxmtu6()
3411 ifp = nh->nh_ifp; in tcp_maxmtu6()
3412 maxmtu = nh->nh_mtu; in tcp_maxmtu6()
3416 if (ifp->if_capenable & IFCAP_TSO6 && in tcp_maxmtu6()
3417 ifp->if_hwassist & CSUM_TSO) { in tcp_maxmtu6()
3418 cap->ifcap |= CSUM_TSO; in tcp_maxmtu6()
3419 cap->tsomax = ifp->if_hw_tsomax; in tcp_maxmtu6()
3420 cap->tsomaxsegcount = ifp->if_hw_tsomaxsegcount; in tcp_maxmtu6()
3421 cap->tsomaxsegsize = ifp->if_hw_tsomaxsegsize; in tcp_maxmtu6()
3422 cap->ipsec_tso = false; /* XXXKIB */ in tcp_maxmtu6()
3453 inp->inp_inc.inc_flags |= INC_IPV6MINMTU; in tcp6_use_min_mtu()
3454 if ((tp->t_state >= TCPS_SYN_SENT) && in tcp6_use_min_mtu()
3455 (inp->inp_inc.inc_flags & INC_ISIPV6)) { in tcp6_use_min_mtu()
3458 opt = inp->in6p_outputopts; in tcp6_use_min_mtu()
3459 if (opt != NULL && opt->ip6po_minmtu == IP6PO_MINMTU_ALL && in tcp6_use_min_mtu()
3460 tp->t_maxseg > TCP6_MSS) { in tcp6_use_min_mtu()
3461 tp->t_maxseg = TCP6_MSS; in tcp6_use_min_mtu()
3462 if (tp->t_maxseg < V_tcp_mssdflt) { in tcp6_use_min_mtu()
3468 tp->t_flags2 |= TF2_PROC_SACK_PROHIBIT; in tcp6_use_min_mtu()
3470 tp->t_flags2 &= ~TF2_PROC_SACK_PROHIBIT; in tcp6_use_min_mtu()
3486 if (tp->t_flags & TF_NOOPT) in tcp_maxseg()
3487 return (tp->t_maxseg); in tcp_maxseg()
3496 if (TCPS_HAVEESTABLISHED(tp->t_state)) { in tcp_maxseg()
3497 if (tp->t_flags & TF_RCVD_TSTMP) in tcp_maxseg()
3502 if (tp->t_flags & TF_SIGNATURE) in tcp_maxseg()
3505 if ((tp->t_flags & TF_SACK_PERMIT) && tp->rcv_numsacks > 0) { in tcp_maxseg()
3507 optlen += tp->rcv_numsacks * TCPOLEN_SACK; in tcp_maxseg()
3511 if (tp->t_flags & TF_REQ_TSTMP) in tcp_maxseg()
3515 if (tp->t_flags & TF_REQ_SCALE) in tcp_maxseg()
3518 if (tp->t_flags & TF_SIGNATURE) in tcp_maxseg()
3521 if (tp->t_flags & TF_SACK_PERMIT) in tcp_maxseg()
3525 return (tp->t_maxseg - optlen); in tcp_maxseg()
3534 if (tp->t_flags & TF_NOOPT) in tcp_fixed_maxseg()
3535 return (tp->t_maxseg); in tcp_fixed_maxseg()
3545 if (TCPS_HAVEESTABLISHED(tp->t_state)) { in tcp_fixed_maxseg()
3546 if (tp->t_flags & TF_RCVD_TSTMP) in tcp_fixed_maxseg()
3551 if (tp->t_flags & TF_SIGNATURE) in tcp_fixed_maxseg()
3555 if (tp->t_flags & TF_REQ_TSTMP) in tcp_fixed_maxseg()
3559 if (tp->t_flags & TF_REQ_SCALE) in tcp_fixed_maxseg()
3562 if (tp->t_flags & TF_SIGNATURE) in tcp_fixed_maxseg()
3565 if (tp->t_flags & TF_SACK_PERMIT) in tcp_fixed_maxseg()
3569 return (tp->t_maxseg - optlen); in tcp_fixed_maxseg()
3596 if (req->oldptr != NULL || req->oldlen != 0) in sysctl_drop()
3598 if (req->newptr == NULL) in sysctl_drop()
3600 if (req->newlen < sizeof(addrs)) in sysctl_drop()
3611 if (fin6->sin6_len != sizeof(struct sockaddr_in6) || in sysctl_drop()
3612 lin6->sin6_len != sizeof(struct sockaddr_in6)) in sysctl_drop()
3614 if (IN6_IS_ADDR_V4MAPPED(&fin6->sin6_addr)) { in sysctl_drop()
3615 if (!IN6_IS_ADDR_V4MAPPED(&lin6->sin6_addr)) in sysctl_drop()
3637 if (fin->sin_len != sizeof(struct sockaddr_in) || in sysctl_drop()
3638 lin->sin_len != sizeof(struct sockaddr_in)) in sysctl_drop()
3649 inp = in6_pcblookup(&V_tcbinfo, &fin6->sin6_addr, in sysctl_drop()
3650 fin6->sin6_port, &lin6->sin6_addr, lin6->sin6_port, in sysctl_drop()
3656 inp = in_pcblookup(&V_tcbinfo, fin->sin_addr, fin->sin_port, in sysctl_drop()
3657 lin->sin_addr, lin->sin_port, INPLOOKUP_WLOCKPCB, NULL); in sysctl_drop()
3662 if (!SOLISTENING(inp->inp_socket)) { in sysctl_drop()
3714 if (req->oldptr != NULL || req->oldlen != 0) in sysctl_switch_tls()
3716 if (req->newptr == NULL) in sysctl_switch_tls()
3718 if (req->newlen < sizeof(addrs)) in sysctl_switch_tls()
3729 if (fin6->sin6_len != sizeof(struct sockaddr_in6) || in sysctl_switch_tls()
3730 lin6->sin6_len != sizeof(struct sockaddr_in6)) in sysctl_switch_tls()
3732 if (IN6_IS_ADDR_V4MAPPED(&fin6->sin6_addr)) { in sysctl_switch_tls()
3733 if (!IN6_IS_ADDR_V4MAPPED(&lin6->sin6_addr)) in sysctl_switch_tls()
3755 if (fin->sin_len != sizeof(struct sockaddr_in) || in sysctl_switch_tls()
3756 lin->sin_len != sizeof(struct sockaddr_in)) in sysctl_switch_tls()
3767 inp = in6_pcblookup(&V_tcbinfo, &fin6->sin6_addr, in sysctl_switch_tls()
3768 fin6->sin6_port, &lin6->sin6_addr, lin6->sin6_port, in sysctl_switch_tls()
3774 inp = in_pcblookup(&V_tcbinfo, fin->sin_addr, fin->sin_port, in sysctl_switch_tls()
3775 lin->sin_addr, lin->sin_port, INPLOOKUP_WLOCKPCB, NULL); in sysctl_switch_tls()
3783 so = inp->inp_socket; in sysctl_switch_tls()
3871 if (inc && ((inc->inc_flags & INC_ISIPV6) == 0)) { in tcp_log_addr()
3872 inet_ntoa_r(inc->inc_faddr, sp); in tcp_log_addr()
3874 sprintf(sp, "]:%i to [", ntohs(inc->inc_fport)); in tcp_log_addr()
3876 inet_ntoa_r(inc->inc_laddr, sp); in tcp_log_addr()
3878 sprintf(sp, "]:%i", ntohs(inc->inc_lport)); in tcp_log_addr()
3881 ip6_sprintf(sp, &inc->inc6_faddr); in tcp_log_addr()
3883 sprintf(sp, "]:%i to [", ntohs(inc->inc_fport)); in tcp_log_addr()
3885 ip6_sprintf(sp, &inc->inc6_laddr); in tcp_log_addr()
3887 sprintf(sp, "]:%i", ntohs(inc->inc_lport)); in tcp_log_addr()
3889 ip6_sprintf(sp, &ip6->ip6_src); in tcp_log_addr()
3891 sprintf(sp, "]:%i to [", ntohs(th->th_sport)); in tcp_log_addr()
3893 ip6_sprintf(sp, &ip6->ip6_dst); in tcp_log_addr()
3895 sprintf(sp, "]:%i", ntohs(th->th_dport)); in tcp_log_addr()
3899 inet_ntoa_r(ip->ip_src, sp); in tcp_log_addr()
3901 sprintf(sp, "]:%i to [", ntohs(th->th_sport)); in tcp_log_addr()
3903 inet_ntoa_r(ip->ip_dst, sp); in tcp_log_addr()
3905 sprintf(sp, "]:%i", ntohs(th->th_dport)); in tcp_log_addr()
3914 if (*(s + size - 1) != '\0') in tcp_log_addr()
3928 int pstate = tp->t_state; in tcp_state_change()
3931 TCPSTATES_DEC(tp->t_state); in tcp_state_change()
3933 tp->t_state = newstate; in tcp_state_change()
3938 * Create an external-format (``xtcpcb'') structure using the information in
3939 * the kernel-format tcpcb structure pointed to by tp. This is done to
3942 * information-hiding if we decide that some of this information should be
3952 xt->t_state = tp->t_state; in tcp_inptoxtp()
3953 xt->t_logstate = tcp_get_bblog_state(tp); in tcp_inptoxtp()
3954 xt->t_flags = tp->t_flags; in tcp_inptoxtp()
3955 xt->t_sndzerowin = tp->t_sndzerowin; in tcp_inptoxtp()
3956 xt->t_sndrexmitpack = tp->t_sndrexmitpack; in tcp_inptoxtp()
3957 xt->t_rcvoopack = tp->t_rcvoopack; in tcp_inptoxtp()
3958 xt->t_rcv_wnd = tp->rcv_wnd; in tcp_inptoxtp()
3959 xt->t_snd_wnd = tp->snd_wnd; in tcp_inptoxtp()
3960 xt->t_snd_cwnd = tp->snd_cwnd; in tcp_inptoxtp()
3961 xt->t_snd_ssthresh = tp->snd_ssthresh; in tcp_inptoxtp()
3962 xt->t_dsack_bytes = tp->t_dsack_bytes; in tcp_inptoxtp()
3963 xt->t_dsack_tlp_bytes = tp->t_dsack_tlp_bytes; in tcp_inptoxtp()
3964 xt->t_dsack_pack = tp->t_dsack_pack; in tcp_inptoxtp()
3965 xt->t_maxseg = tp->t_maxseg; in tcp_inptoxtp()
3966 xt->xt_ecn = (tp->t_flags2 & TF2_ECN_PERMIT) ? 1 : 0 + in tcp_inptoxtp()
3967 (tp->t_flags2 & TF2_ACE_PERMIT) ? 2 : 0; in tcp_inptoxtp()
3971 if (tp->t_timers[which] != SBT_MAX) \ in tcp_inptoxtp()
3972 xt->where = (tp->t_timers[which] - now) / SBT_1MS; \ in tcp_inptoxtp()
3974 xt->where = 0; \ in tcp_inptoxtp()
3982 xt->t_rcvtime = 1000 * (ticks - tp->t_rcvtime) / hz; in tcp_inptoxtp()
3984 xt->xt_encaps_port = tp->t_port; in tcp_inptoxtp()
3985 bcopy(tp->t_fb->tfb_tcp_block_name, xt->xt_stack, in tcp_inptoxtp()
3987 bcopy(CC_ALGO(tp)->name, xt->xt_cc, TCP_CA_NAME_MAX); in tcp_inptoxtp()
3989 (void)tcp_log_get_id(tp, xt->xt_logid); in tcp_inptoxtp()
3992 xt->xt_len = sizeof(struct xtcpcb); in tcp_inptoxtp()
3993 in_pcbtoxinpcb(inp, &xt->xt_inp); in tcp_inptoxtp()
4011 bit = 1U << (status - 1); in tcp_log_end_status()
4012 if (bit & tp->t_end_info_status) { in tcp_log_end_status()
4017 if (tp->t_end_info_bytes[i] == TCP_EI_EMPTY_SLOT) { in tcp_log_end_status()
4018 tp->t_end_info_bytes[i] = status; in tcp_log_end_status()
4019 tp->t_end_info_status |= bit; in tcp_log_end_status()
4029 if ((tcp_pacing_limit == -1) || in tcp_can_enable_pacing()
4043 if ((tcp_dgp_limit == -1) || in tcp_incr_dgp_pacing_cnt()
4061 ret = atomic_fetchadd_int(&number_of_dgp_connections, -1); in tcp_dec_dgp_pacing_cnt()
4063 KASSERT(ret != 0, ("number_of_dgp_connections -1 would cause wrap?")); in tcp_dec_dgp_pacing_cnt()
4065 if (tcp_dgp_limit != -1) { in tcp_dec_dgp_pacing_cnt()
4084 ret = atomic_fetchadd_int(&number_of_tcp_connections_pacing, -1); in tcp_decrement_paced_conn()
4086 KASSERT(ret != 0, ("tcp_paced_connection_exits -1 would cause wrap?")); in tcp_decrement_paced_conn()
4088 if (tcp_pacing_limit != -1) { in tcp_decrement_paced_conn()
4119 if (SEQ_LT(th->th_ack, tp->snd_una)) { in tcp_do_ack_accounting()
4121 if (to->to_flags & TOF_SACK) { in tcp_do_ack_accounting()
4122 if (tp->t_flags2 & TF2_TCP_ACCOUNTING) { in tcp_do_ack_accounting()
4123 tp->tcp_cnt_counters[ACK_SACK]++; in tcp_do_ack_accounting()
4127 if (tp->t_flags2 & TF2_TCP_ACCOUNTING) { in tcp_do_ack_accounting()
4128 tp->tcp_cnt_counters[ACK_BEHIND]++; in tcp_do_ack_accounting()
4132 } else if (th->th_ack == tp->snd_una) { in tcp_do_ack_accounting()
4134 if (to->to_flags & TOF_SACK) { in tcp_do_ack_accounting()
4135 if (tp->t_flags2 & TF2_TCP_ACCOUNTING) { in tcp_do_ack_accounting()
4136 tp->tcp_cnt_counters[ACK_SACK]++; in tcp_do_ack_accounting()
4139 } else if (tiwin != tp->snd_wnd) { in tcp_do_ack_accounting()
4140 if (tp->t_flags2 & TF2_TCP_ACCOUNTING) { in tcp_do_ack_accounting()
4141 tp->tcp_cnt_counters[ACK_RWND]++; in tcp_do_ack_accounting()
4145 if (tp->t_flags2 & TF2_TCP_ACCOUNTING) { in tcp_do_ack_accounting()
4146 tp->tcp_cnt_counters[ACK_DUPACK]++; in tcp_do_ack_accounting()
4151 if (!SEQ_GT(th->th_ack, tp->snd_max)) { in tcp_do_ack_accounting()
4152 if (tp->t_flags2 & TF2_TCP_ACCOUNTING) { in tcp_do_ack_accounting()
4153 tp->tcp_cnt_counters[CNT_OF_ACKS_IN] += (((th->th_ack - tp->snd_una) + mss - 1)/mss); in tcp_do_ack_accounting()
4156 if (to->to_flags & TOF_SACK) { in tcp_do_ack_accounting()
4157 if (tp->t_flags2 & TF2_TCP_ACCOUNTING) { in tcp_do_ack_accounting()
4158 tp->tcp_cnt_counters[ACK_CUMACK_SACK]++; in tcp_do_ack_accounting()
4162 if (tp->t_flags2 & TF2_TCP_ACCOUNTING) { in tcp_do_ack_accounting()
4163 tp->tcp_cnt_counters[ACK_CUMACK]++; in tcp_do_ack_accounting()
4174 if (tp->t_tmr_granularity == granularity) { in tcp_change_time_units()
4179 KASSERT((tp->t_tmr_granularity == TCP_TMR_GRANULARITY_TICKS), in tcp_change_time_units()
4181 tp->t_tmr_granularity, tp)); in tcp_change_time_units()
4182 tp->t_rttlow = TICKS_2_USEC(tp->t_rttlow); in tcp_change_time_units()
4183 if (tp->t_srtt > 1) { in tcp_change_time_units()
4186 val = tp->t_srtt >> TCP_RTT_SHIFT; in tcp_change_time_units()
4187 frac = tp->t_srtt & 0x1f; in tcp_change_time_units()
4188 tp->t_srtt = TICKS_2_USEC(val); in tcp_change_time_units()
4200 tp->t_srtt += frac; in tcp_change_time_units()
4203 if (tp->t_rttvar) { in tcp_change_time_units()
4206 val = tp->t_rttvar >> TCP_RTTVAR_SHIFT; in tcp_change_time_units()
4207 frac = tp->t_rttvar & 0x1f; in tcp_change_time_units()
4208 tp->t_rttvar = TICKS_2_USEC(val); in tcp_change_time_units()
4220 tp->t_rttvar += frac; in tcp_change_time_units()
4223 tp->t_tmr_granularity = TCP_TMR_GRANULARITY_USEC; in tcp_change_time_units()
4226 KASSERT((tp->t_tmr_granularity == TCP_TMR_GRANULARITY_USEC), in tcp_change_time_units()
4228 tp->t_tmr_granularity, tp)); in tcp_change_time_units()
4229 if (tp->t_srtt > 1) { in tcp_change_time_units()
4232 val = USEC_2_TICKS(tp->t_srtt); in tcp_change_time_units()
4233 frac = tp->t_srtt % (HPTS_USEC_IN_SEC / hz); in tcp_change_time_units()
4234 tp->t_srtt = val << TCP_RTT_SHIFT; in tcp_change_time_units()
4247 tp->t_srtt += frac; in tcp_change_time_units()
4250 if (tp->t_rttvar) { in tcp_change_time_units()
4253 val = USEC_2_TICKS(tp->t_rttvar); in tcp_change_time_units()
4254 frac = tp->t_rttvar % (HPTS_USEC_IN_SEC / hz); in tcp_change_time_units()
4255 tp->t_rttvar = val << TCP_RTTVAR_SHIFT; in tcp_change_time_units()
4268 tp->t_rttvar += frac; in tcp_change_time_units()
4271 tp->t_rttlow = USEC_2_TICKS(tp->t_rttlow); in tcp_change_time_units()
4272 tp->t_tmr_granularity = TCP_TMR_GRANULARITY_TICKS; in tcp_change_time_units()
4295 if (tp->t_flags2 & TF2_MBUF_L_ACKS) in tcp_handle_orphaned_packets()
4297 if ((tp->t_flags2 & TF2_SUPPORTS_MBUFQ) == 0 && in tcp_handle_orphaned_packets()
4298 !STAILQ_EMPTY(&tp->t_inqueue)) { in tcp_handle_orphaned_packets()
4309 m = STAILQ_FIRST(&tp->t_inqueue); in tcp_handle_orphaned_packets()
4310 STAILQ_INIT(&tp->t_inqueue); in tcp_handle_orphaned_packets()
4311 STAILQ_FOREACH_FROM_SAFE(m, &tp->t_inqueue, m_stailqpkt, save) in tcp_handle_orphaned_packets()
4319 STAILQ_FOREACH_SAFE(m, &tp->t_inqueue, m_stailqpkt, save) { in tcp_handle_orphaned_packets()
4320 if (m->m_flags & M_ACKCMP) { in tcp_handle_orphaned_packets()
4321 if (m == STAILQ_FIRST(&tp->t_inqueue)) in tcp_handle_orphaned_packets()
4322 STAILQ_REMOVE_HEAD(&tp->t_inqueue, in tcp_handle_orphaned_packets()
4325 STAILQ_REMOVE_AFTER(&tp->t_inqueue, in tcp_handle_orphaned_packets()
4342 tls = so->so_snd.sb_tls_info; in tcp_estimate_tls_overhead()
4346 rec_oh = tls->params.tls_hlen + tls->params.tls_tlen; in tcp_estimate_tls_overhead()
4347 records = ((tls_usr_bytes + tls->params.max_frame_len - 1)/tls->params.max_frame_len); in tcp_estimate_tls_overhead()
4370 log.u_bbr.rttProp = req->timestamp; in tcp_req_log_req_info()
4371 log.u_bbr.delRate = req->start; in tcp_req_log_req_info()
4372 log.u_bbr.cur_del_rate = req->end; in tcp_req_log_req_info()
4373 log.u_bbr.flex1 = req->start_seq; in tcp_req_log_req_info()
4374 log.u_bbr.flex2 = req->end_seq; in tcp_req_log_req_info()
4375 log.u_bbr.flex3 = req->flags; in tcp_req_log_req_info()
4376 log.u_bbr.flex4 = ((req->localtime >> 32) & 0x00000000ffffffff); in tcp_req_log_req_info()
4377 log.u_bbr.flex5 = (req->localtime & 0x00000000ffffffff); in tcp_req_log_req_info()
4384 log.u_bbr.lt_epoch = ((req->cspr >> 32) & 0x00000000ffffffff); in tcp_req_log_req_info()
4385 log.u_bbr.pkts_out |= (req->cspr & 0x00000000ffffffff); in tcp_req_log_req_info()
4386 log.u_bbr.applimited = tp->t_tcpreq_closed; in tcp_req_log_req_info()
4388 log.u_bbr.applimited |= tp->t_tcpreq_open; in tcp_req_log_req_info()
4390 log.u_bbr.applimited |= tp->t_tcpreq_req; in tcp_req_log_req_info()
4393 &tptosocket(tp)->so_rcv, in tcp_req_log_req_info()
4394 &tptosocket(tp)->so_snd, in tcp_req_log_req_info()
4403 if (tp->t_tcpreq_req > 0) in tcp_req_free_a_slot()
4404 tp->t_tcpreq_req--; in tcp_req_free_a_slot()
4405 if (ent->flags & TCP_TRK_TRACK_FLG_OPEN) { in tcp_req_free_a_slot()
4406 if (tp->t_tcpreq_open > 0) in tcp_req_free_a_slot()
4407 tp->t_tcpreq_open--; in tcp_req_free_a_slot()
4409 if (tp->t_tcpreq_closed > 0) in tcp_req_free_a_slot()
4410 tp->t_tcpreq_closed--; in tcp_req_free_a_slot()
4412 ent->flags = TCP_TRK_TRACK_FLG_EMPTY; in tcp_req_free_a_slot()
4423 ent = &tp->t_tcpreq_info[i]; in tcp_req_check_for_stale_entries()
4424 if (ent->flags != TCP_TRK_TRACK_FLG_USED) { in tcp_req_check_for_stale_entries()
4433 if (ts >= ent->localtime) in tcp_req_check_for_stale_entries()
4434 time_delta = ts - ent->localtime; in tcp_req_check_for_stale_entries()
4445 * No sendfile in a our time-limit in tcp_req_check_for_stale_entries()
4449 tcp_req_log_req_info(tp, &tp->t_tcpreq_info[i], i, TCP_TRK_REQ_LOG_STALE, in tcp_req_check_for_stale_entries()
4455 ent = &tp->t_tcpreq_info[oldest]; in tcp_req_check_for_stale_entries()
4456 tcp_req_log_req_info(tp, &tp->t_tcpreq_info[i], i, TCP_TRK_REQ_LOG_STALE, in tcp_req_check_for_stale_entries()
4469 if (tp->t_tcpreq_req == 0) in tcp_req_check_for_comp()
4471 if (tp->t_tcpreq_closed == 0) in tcp_req_check_for_comp()
4474 ent = &tp->t_tcpreq_info[i]; in tcp_req_check_for_comp()
4476 if (ent->flags == TCP_TRK_TRACK_FLG_EMPTY) in tcp_req_check_for_comp()
4479 if (ent->flags & TCP_TRK_TRACK_FLG_OPEN) in tcp_req_check_for_comp()
4481 if (SEQ_GEQ(ack_point, ent->end_seq)) { in tcp_req_check_for_comp()
4482 /* We are past it -- free it */ in tcp_req_check_for_comp()
4495 if (tp->t_tcpreq_req == 0) in tcp_req_is_entry_comp()
4496 return (-1); in tcp_req_is_entry_comp()
4497 if (tp->t_tcpreq_closed == 0) in tcp_req_is_entry_comp()
4498 return (-1); in tcp_req_is_entry_comp()
4499 if (ent->flags == TCP_TRK_TRACK_FLG_EMPTY) in tcp_req_is_entry_comp()
4500 return (-1); in tcp_req_is_entry_comp()
4501 if (SEQ_GEQ(ack_point, ent->end_seq)) { in tcp_req_is_entry_comp()
4518 if (tp->t_tcpreq_req == 0) { in tcp_req_find_a_req_that_is_completed_by()
4523 ent = &tp->t_tcpreq_info[i]; in tcp_req_find_a_req_that_is_completed_by()
4524 if (ent->flags == TCP_TRK_TRACK_FLG_EMPTY) in tcp_req_find_a_req_that_is_completed_by()
4526 if ((ent->flags & TCP_TRK_TRACK_FLG_OPEN) == 0) { in tcp_req_find_a_req_that_is_completed_by()
4527 if (SEQ_GEQ(th_ack, ent->end_seq)) { in tcp_req_find_a_req_that_is_completed_by()
4542 if (tp->t_tcpreq_req == 0) { in tcp_req_find_req_for_seq()
4547 ent = &tp->t_tcpreq_info[i]; in tcp_req_find_req_for_seq()
4550 if (ent->flags == TCP_TRK_TRACK_FLG_EMPTY) { in tcp_req_find_req_for_seq()
4553 if (ent->flags & TCP_TRK_TRACK_FLG_OPEN) { in tcp_req_find_req_for_seq()
4561 if ((SEQ_GEQ(seq, ent->start_seq)) || in tcp_req_find_req_for_seq()
4562 (tp->t_tcpreq_closed == 0)) in tcp_req_find_req_for_seq()
4570 if ((SEQ_GEQ(seq, ent->start_seq)) && in tcp_req_find_req_for_seq()
4571 (SEQ_LT(seq, ent->end_seq))) { in tcp_req_find_req_for_seq()
4587 tcp_req_check_for_comp(tp, tp->snd_una); in tcp_req_alloc_req_full()
4589 if (tp->t_tcpreq_req) in tcp_req_alloc_req_full()
4591 (tp->t_tcpreq_req >= MAX_TCP_TRK_REQ)); in tcp_req_alloc_req_full()
4593 if (tp->t_tcpreq_req) { in tcp_req_alloc_req_full()
4595 fil = &tp->t_tcpreq_info[i]; in tcp_req_alloc_req_full()
4596 if ((fil->flags & TCP_TRK_TRACK_FLG_USED) == 0) in tcp_req_alloc_req_full()
4598 if ((fil->timestamp == req->timestamp) && in tcp_req_alloc_req_full()
4599 (fil->start == req->start) && in tcp_req_alloc_req_full()
4600 ((fil->flags & TCP_TRK_TRACK_FLG_OPEN) || in tcp_req_alloc_req_full()
4601 (fil->end == req->end))) { in tcp_req_alloc_req_full()
4614 if (tp->t_tcpreq_req >= MAX_TCP_TRK_REQ) { in tcp_req_alloc_req_full()
4617 tcp_req_log_req_info(tp, &tp->t_tcpreq_info[i], in tcp_req_alloc_req_full()
4623 fil = &tp->t_tcpreq_info[i]; in tcp_req_alloc_req_full()
4624 if (fil->flags == TCP_TRK_TRACK_FLG_EMPTY) { in tcp_req_alloc_req_full()
4626 fil->flags = TCP_TRK_TRACK_FLG_USED; in tcp_req_alloc_req_full()
4627 fil->timestamp = req->timestamp; in tcp_req_alloc_req_full()
4628 fil->playout_ms = req->playout_ms; in tcp_req_alloc_req_full()
4629 fil->localtime = ts; in tcp_req_alloc_req_full()
4630 fil->start = req->start; in tcp_req_alloc_req_full()
4631 if (req->flags & TCP_LOG_HTTPD_RANGE_END) { in tcp_req_alloc_req_full()
4632 fil->end = req->end; in tcp_req_alloc_req_full()
4634 fil->end = 0; in tcp_req_alloc_req_full()
4635 fil->flags |= TCP_TRK_TRACK_FLG_OPEN; in tcp_req_alloc_req_full()
4642 fil->sbcc_at_s = tptosocket(tp)->so_snd.sb_ccc; in tcp_req_alloc_req_full()
4643 fil->start_seq = tp->snd_una + in tcp_req_alloc_req_full()
4644 tptosocket(tp)->so_snd.sb_ccc; in tcp_req_alloc_req_full()
4645 if (req->flags & TCP_LOG_HTTPD_RANGE_END) in tcp_req_alloc_req_full()
4646 fil->end_seq = (fil->start_seq + ((uint32_t)(fil->end - fil->start))); in tcp_req_alloc_req_full()
4648 fil->end_seq = 0; in tcp_req_alloc_req_full()
4649 if (tptosocket(tp)->so_snd.sb_tls_info) { in tcp_req_alloc_req_full()
4654 fil->end_seq += tcp_estimate_tls_overhead( in tcp_req_alloc_req_full()
4655 tptosocket(tp), (fil->end - fil->start)); in tcp_req_alloc_req_full()
4657 tp->t_tcpreq_req++; in tcp_req_alloc_req_full()
4658 if (fil->flags & TCP_TRK_TRACK_FLG_OPEN) in tcp_req_alloc_req_full()
4659 tp->t_tcpreq_open++; in tcp_req_alloc_req_full()
4661 tp->t_tcpreq_closed++; in tcp_req_alloc_req_full()
4674 (void)tcp_req_alloc_req_full(tp, &user->tcp_req, ts, 1); in tcp_req_alloc_req()
4685 &tptosocket(tp)->so_rcv, in tcp_log_socket_option()
4686 &tptosocket(tp)->so_snd, in tcp_log_socket_option()
4691 l->tlb_flex1 = option_num; in tcp_log_socket_option()
4692 l->tlb_flex2 = option_val; in tcp_log_socket_option()
4707 srtt = tp->t_srtt; in tcp_get_srtt()
4714 if (tp->t_tmr_granularity != granularity) { in tcp_get_srtt()
4727 if (tp->t_tmr_granularity == TCP_TMR_GRANULARITY_TICKS) in tcp_get_srtt()
4739 tp->t_sndtlppack++; in tcp_account_for_send()
4740 tp->t_sndtlpbyte += len; in tcp_account_for_send()
4744 tp->t_snd_rxt_bytes += len; in tcp_account_for_send()
4746 tp->t_sndbytes += len; in tcp_account_for_send()
4752 rexmit_percent = (1000ULL * tp->t_snd_rxt_bytes) / in tcp_account_for_send()
4753 (10ULL * (tp->t_snd_rxt_bytes + tp->t_sndbytes)); in tcp_account_for_send()