Lines Matching +full:wakeup +full:- +full:rtt +full:- +full:timer
1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
159 if (error == 0 && req->newptr) { in sysctl_net_inet_tcp_mss_check()
181 if (error == 0 && req->newptr) { in sysctl_net_inet_tcp_mss_v6_check()
217 * stacks negotiate TS, but don't send them when sending keep-alive segments.
242 …"If the TCP stack does pacing, is there a limit (-1 = no, 0 = no pacing N = number of connections)…
244 static int tcp_dgp_limit = -1;
246 &tcp_dgp_limit, -1,
247 "If the TCP stack does DGP, is there a limit (-1 = no, 0 = no dgp N = number of connections)");
273 &tcp_tcbhashsize, 0, "Size of TCP control-block hashtable");
309 if (error == 0 && req->newptr) { in sysctl_net_inet_tcp_map_limit_check()
371 tp->t_dsack_pack++; in tcp_record_dsack()
374 tp->t_dsack_bytes += (end - start); in tcp_record_dsack()
375 TCPSTAT_ADD(tcps_dsack_bytes, (end - start)); in tcp_record_dsack()
377 tp->t_dsack_tlp_bytes += (start - end); in tcp_record_dsack()
378 TCPSTAT_ADD(tcps_dsack_bytes, (start - end)); in tcp_record_dsack()
382 tp->t_dsack_bytes += (end - start); in tcp_record_dsack()
383 TCPSTAT_ADD(tcps_dsack_tlp_bytes, (end - start)); in tcp_record_dsack()
385 tp->t_dsack_tlp_bytes += (start - end); in tcp_record_dsack()
386 TCPSTAT_ADD(tcps_dsack_tlp_bytes, (start - end)); in tcp_record_dsack()
399 if (strcmp(f->tf_name, fs->function_set_name) == 0) { in find_tcp_functions_locked()
400 blk = f->tf_fb; in find_tcp_functions_locked()
415 if (f->tf_fb == blk) { in find_tcp_fb_locked()
434 refcount_acquire(&blk->tfb_refcnt); in find_and_ref_tcp_functions()
447 refcount_acquire(&rblk->tfb_refcnt); in find_and_ref_tcp_fb()
463 if ((f->tf_fb == blk) && in find_tcp_function_alias()
464 (strncmp(f->tf_name, blk->tfb_tcp_block_name, in find_tcp_function_alias()
467 strncpy(fs->function_set_name, f->tf_name, in find_tcp_function_alias()
475 fs->function_set_name[TCP_FUNCTION_NAME_LEN_MAX - 1] = '\0'; in find_tcp_function_alias()
477 fs->function_set_name[0] = '\0'; in find_tcp_function_alias()
490 refcount_acquire(&rblk->tfb_refcnt); in find_and_ref_tcp_default_fb()
501 KASSERT(tp->t_fb != &tcp_def_funcblk, in tcp_switch_back_to_default()
502 ("%s: called by the built-in default stack", __func__)); in tcp_switch_back_to_default()
504 if (tp->t_fb->tfb_tcp_timer_stop_all != NULL) in tcp_switch_back_to_default()
505 tp->t_fb->tfb_tcp_timer_stop_all(tp); in tcp_switch_back_to_default()
509 * Start by trying the current user-selected in tcp_switch_back_to_default()
510 * default, unless this stack is the user-selected in tcp_switch_back_to_default()
514 if (tfb == tp->t_fb) { in tcp_switch_back_to_default()
515 refcount_release(&tfb->tfb_refcnt); in tcp_switch_back_to_default()
519 if (tfb != NULL && (*tfb->tfb_tcp_handoff_ok)(tp)) { in tcp_switch_back_to_default()
520 refcount_release(&tfb->tfb_refcnt); in tcp_switch_back_to_default()
526 if (tfb->tfb_tcp_fb_init == NULL || in tcp_switch_back_to_default()
527 (*tfb->tfb_tcp_fb_init)(tp, &ptr) == 0) { in tcp_switch_back_to_default()
529 if (tp->t_fb->tfb_tcp_fb_fini != NULL) in tcp_switch_back_to_default()
530 (*tp->t_fb->tfb_tcp_fb_fini)(tp, 0); in tcp_switch_back_to_default()
531 refcount_release(&tp->t_fb->tfb_refcnt); in tcp_switch_back_to_default()
533 tp->t_fb = tfb; in tcp_switch_back_to_default()
534 tp->t_fb_ptr = ptr; in tcp_switch_back_to_default()
541 refcount_release(&tfb->tfb_refcnt); in tcp_switch_back_to_default()
545 * If that wasn't feasible, use the built-in default in tcp_switch_back_to_default()
553 if ((*tfb->tfb_tcp_handoff_ok)(tp)) { in tcp_switch_back_to_default()
557 if (tfb->tfb_tcp_fb_init != NULL && in tcp_switch_back_to_default()
558 (*tfb->tfb_tcp_fb_init)(tp, &ptr)) { in tcp_switch_back_to_default()
563 if (tp->t_fb->tfb_tcp_fb_fini != NULL) in tcp_switch_back_to_default()
564 (*tp->t_fb->tfb_tcp_fb_fini)(tp, 0); in tcp_switch_back_to_default()
565 refcount_release(&tp->t_fb->tfb_refcnt); in tcp_switch_back_to_default()
567 tp->t_fb = tfb; in tcp_switch_back_to_default()
568 tp->t_fb_ptr = ptr; in tcp_switch_back_to_default()
585 if ((m->m_flags & M_PKTHDR) == 0) { in tcp_recv_udp_tunneled_packet()
591 if (m->m_len < off + sizeof(struct udphdr) + thlen && in tcp_recv_udp_tunneled_packet()
599 thlen = th->th_off << 2; in tcp_recv_udp_tunneled_packet()
600 if (m->m_len < off + sizeof(struct udphdr) + thlen) { in tcp_recv_udp_tunneled_packet()
611 m->m_pkthdr.tcp_tun_port = port = uh->uh_sport; in tcp_recv_udp_tunneled_packet()
612 bcopy(th, uh, m->m_len - off); in tcp_recv_udp_tunneled_packet()
613 m->m_len -= sizeof(struct udphdr); in tcp_recv_udp_tunneled_packet()
614 m->m_pkthdr.len -= sizeof(struct udphdr); in tcp_recv_udp_tunneled_packet()
617 * both UDP and TCP for c-sum. So in tcp_recv_udp_tunneled_packet()
620 * with the flag (m->m_pkthdr.csum_flags). in tcp_recv_udp_tunneled_packet()
622 switch (iph->ip_v) { in tcp_recv_udp_tunneled_packet()
625 iph->ip_len = htons(ntohs(iph->ip_len) - sizeof(struct udphdr)); in tcp_recv_udp_tunneled_packet()
632 ip6->ip6_plen = htons(ntohs(ip6->ip6_plen) - sizeof(struct udphdr)); in tcp_recv_udp_tunneled_packet()
659 strcpy(fs.function_set_name, blk->tfb_tcp_block_name); in sysctl_net_inet_default_tcp_functions()
660 fs.pcbcnt = blk->tfb_refcnt; in sysctl_net_inet_default_tcp_functions()
667 if (error != 0 || req->newptr == NULL) in sysctl_net_inet_default_tcp_functions()
673 (blk->tfb_flags & TCP_FUNC_BEING_REMOVED)) { in sysctl_net_inet_default_tcp_functions()
677 if ((blk->tfb_flags & TCP_FUNC_DEFAULT_OK) == 0) { in sysctl_net_inet_default_tcp_functions()
714 linesz = snprintf(cp, bufsz, "\n%-32s%c %-32s %s\n", "Stack", 'D', in sysctl_net_inet_list_available()
717 bufsz -= linesz; in sysctl_net_inet_list_available()
722 alias = (f->tf_name != f->tf_fb->tfb_tcp_block_name); in sysctl_net_inet_list_available()
723 linesz = snprintf(cp, bufsz, "%-32s%c %-32s %u\n", in sysctl_net_inet_list_available()
724 f->tf_fb->tfb_tcp_block_name, in sysctl_net_inet_list_available()
725 (f->tf_fb == V_tcp_func_set_ptr) ? '*' : ' ', in sysctl_net_inet_list_available()
726 alias ? f->tf_name : "-", in sysctl_net_inet_list_available()
727 f->tf_fb->tfb_refcnt); in sysctl_net_inet_list_available()
733 bufsz -= linesz; in sysctl_net_inet_list_available()
802 /* Already running -- must stop first */ in tcp_over_udp_start()
808 /* Already running -- must stop first */ in tcp_over_udp_start()
815 curthread->td_ucred, curthread))) { in tcp_over_udp_start()
841 curthread->td_ucred, curthread))) { in tcp_over_udp_start()
877 (req->newptr != NULL)) { in sysctl_net_inet_tcp_udp_tunneling_port_check()
914 if (error == 0 && req->newptr) { in sysctl_net_inet_tcp_udp_tunneling_overhead_check()
943 if (req->newptr != NULL) in sysctl_net_inet_list_func_info()
950 if (req->oldptr != NULL) { in sysctl_net_inet_list_func_info()
965 if (req->oldptr == NULL) { in sysctl_net_inet_list_func_info()
974 if (req->oldptr != NULL) { in sysctl_net_inet_list_func_info()
976 tfi.tfi_refcnt = f->tf_fb->tfb_refcnt; in sysctl_net_inet_list_func_info()
977 tfi.tfi_id = f->tf_fb->tfb_id; in sysctl_net_inet_list_func_info()
978 (void)strlcpy(tfi.tfi_alias, f->tf_name, in sysctl_net_inet_list_func_info()
981 f->tf_fb->tfb_tcp_block_name, sizeof(tfi.tfi_name)); in sysctl_net_inet_list_func_info()
996 if (req->oldptr == NULL) in sysctl_net_inet_list_func_info()
1006 "List TCP function block name-to-ID mappings");
1025 * The init() fuction from the default can *never* return non-zero i.e.
1038 KASSERT(tp->t_state < TCPS_TIME_WAIT, in tcp_default_fb_init()
1040 tp->t_state)); in tcp_default_fb_init()
1047 tp->t_flags &= ~TF_GPUTINPROG; in tcp_default_fb_init()
1050 if ((tp->t_state == TCPS_SYN_SENT) || in tcp_default_fb_init()
1051 (tp->t_state == TCPS_SYN_RECEIVED)) in tcp_default_fb_init()
1052 rexmt = tcp_rexmit_initial * tcp_backoff[tp->t_rxtshift]; in tcp_default_fb_init()
1054 rexmt = TCP_REXMTVAL(tp) * tcp_backoff[tp->t_rxtshift]; in tcp_default_fb_init()
1055 if (tp->t_rxtshift == 0) in tcp_default_fb_init()
1056 tp->t_rxtcur = rexmt; in tcp_default_fb_init()
1058 TCPT_RANGESET(tp->t_rxtcur, rexmt, tp->t_rttmin, TCPTV_REXMTMAX); in tcp_default_fb_init()
1064 if (tp->t_state <= TCPS_LISTEN || tp->t_state >= TCPS_TIME_WAIT) in tcp_default_fb_init()
1068 * Make sure some kind of transmission timer is set if there is in tcp_default_fb_init()
1071 if ((!TCPS_HAVEESTABLISHED(tp->t_state) || sbavail(&so->so_snd) || in tcp_default_fb_init()
1072 tp->snd_una != tp->snd_max) && !(tcp_timer_active(tp, TT_REXMT) || in tcp_default_fb_init()
1076 * be in the persist state, set the persist timer. Otherwise, in tcp_default_fb_init()
1077 * set the retransmit timer. in tcp_default_fb_init()
1079 if (TCPS_HAVEESTABLISHED(tp->t_state) && tp->snd_wnd == 0 && in tcp_default_fb_init()
1080 (int32_t)(tp->snd_nxt - tp->snd_una) < in tcp_default_fb_init()
1081 (int32_t)sbavail(&so->so_snd)) in tcp_default_fb_init()
1087 /* All non-embryonic sessions get a keepalive timer. */ in tcp_default_fb_init()
1090 TCPS_HAVEESTABLISHED(tp->t_state) ? TP_KEEPIDLE(tp) : in tcp_default_fb_init()
1097 if IN_FASTRECOVERY(tp->t_flags) { in tcp_default_fb_init()
1098 if (tp->sackhint.recover_fs == 0) in tcp_default_fb_init()
1099 tp->sackhint.recover_fs = max(1, in tcp_default_fb_init()
1100 tp->snd_nxt - tp->snd_una); in tcp_default_fb_init()
1121 tp->t_acktime = 0; in tcp_default_fb_fini()
1152 hashsize = 1 << (fls(size) - 1); in maketcp_hashsize()
1162 * blk->tfb_tcp_block_name as a stack name. Therefore, you should
1163 * explicitly include blk->tfb_tcp_block_name in the list of names if
1183 ("%s: Called with non-positive length of name list", __func__)); in register_tcp_functions_as_names()
1192 if ((blk->tfb_tcp_output == NULL) || in register_tcp_functions_as_names()
1193 (blk->tfb_tcp_do_segment == NULL) || in register_tcp_functions_as_names()
1194 (blk->tfb_tcp_ctloutput == NULL) || in register_tcp_functions_as_names()
1195 (blk->tfb_tcp_handoff_ok == NULL) || in register_tcp_functions_as_names()
1196 (strlen(blk->tfb_tcp_block_name) == 0)) { in register_tcp_functions_as_names()
1205 while (--i >= 0) in register_tcp_functions_as_names()
1219 if (blk->tfb_flags & TCP_FUNC_BEING_REMOVED) { in register_tcp_functions_as_names()
1223 refcount_init(&blk->tfb_refcnt, 0); in register_tcp_functions_as_names()
1224 blk->tfb_id = atomic_fetchadd_int(&next_tcp_stack_id, 1); in register_tcp_functions_as_names()
1233 f[i]->tf_fb = blk; in register_tcp_functions_as_names()
1234 (void)strlcpy(f[i]->tf_name, names[i], sizeof(f[i]->tf_name)); in register_tcp_functions_as_names()
1247 tcp_fb_cnt--; in register_tcp_functions_as_names()
1249 f[i]->tf_fb = NULL; in register_tcp_functions_as_names()
1274 name_list[0] = blk->tfb_tcp_block_name; in register_tcp_functions_as_name()
1281 * blk->tfb_tcp_block_name.
1317 /* You can't un-register the default */ in deregister_tcp_functions()
1335 blk->tfb_flags |= TCP_FUNC_BEING_REMOVED; in deregister_tcp_functions()
1340 if (force && blk->tfb_refcnt) { in deregister_tcp_functions()
1355 if (tp == NULL || tp->t_fb != blk) in deregister_tcp_functions()
1365 if (blk->tfb_refcnt) { in deregister_tcp_functions()
1378 tcp_fb_cnt--; in deregister_tcp_functions()
1379 f->tf_fb = NULL; in deregister_tcp_functions()
1422 tcp_pcap_drain(&(tcpb->t_inpkts)); in tcp_drain()
1423 tcp_pcap_drain(&(tcpb->t_outpkts)); in tcp_drain()
1651 if ((inp->inp_vflag & INP_IPV6) != 0) { in tcpip_fillheaders()
1655 ip6->ip6_flow = (ip6->ip6_flow & ~IPV6_FLOWINFO_MASK) | in tcpip_fillheaders()
1656 (inp->inp_flow & IPV6_FLOWINFO_MASK); in tcpip_fillheaders()
1657 ip6->ip6_vfc = (ip6->ip6_vfc & ~IPV6_VERSION_MASK) | in tcpip_fillheaders()
1660 ip6->ip6_nxt = IPPROTO_TCP; in tcpip_fillheaders()
1662 ip6->ip6_nxt = IPPROTO_UDP; in tcpip_fillheaders()
1663 ip6->ip6_plen = htons(sizeof(struct tcphdr)); in tcpip_fillheaders()
1664 ip6->ip6_src = inp->in6p_laddr; in tcpip_fillheaders()
1665 ip6->ip6_dst = inp->in6p_faddr; in tcpip_fillheaders()
1676 ip->ip_v = IPVERSION; in tcpip_fillheaders()
1677 ip->ip_hl = 5; in tcpip_fillheaders()
1678 ip->ip_tos = inp->inp_ip_tos; in tcpip_fillheaders()
1679 ip->ip_len = 0; in tcpip_fillheaders()
1680 ip->ip_id = 0; in tcpip_fillheaders()
1681 ip->ip_off = 0; in tcpip_fillheaders()
1682 ip->ip_ttl = inp->inp_ip_ttl; in tcpip_fillheaders()
1683 ip->ip_sum = 0; in tcpip_fillheaders()
1685 ip->ip_p = IPPROTO_TCP; in tcpip_fillheaders()
1687 ip->ip_p = IPPROTO_UDP; in tcpip_fillheaders()
1688 ip->ip_src = inp->inp_laddr; in tcpip_fillheaders()
1689 ip->ip_dst = inp->inp_faddr; in tcpip_fillheaders()
1692 th->th_sport = inp->inp_lport; in tcpip_fillheaders()
1693 th->th_dport = inp->inp_fport; in tcpip_fillheaders()
1694 th->th_seq = 0; in tcpip_fillheaders()
1695 th->th_ack = 0; in tcpip_fillheaders()
1696 th->th_off = 5; in tcpip_fillheaders()
1698 th->th_win = 0; in tcpip_fillheaders()
1699 th->th_urp = 0; in tcpip_fillheaders()
1700 th->th_sum = 0; /* in_pseudo() is called later for ipv4 */ in tcpip_fillheaders()
1716 tcpip_fillheaders(inp, 0, (void *)&t->tt_ipgen, (void *)&t->tt_t); in tcpip_maketemplate()
1764 isipv6 = ((struct ip *)ipgen)->ip_v == (IPV6_VERSION >> 4); in tcp_respond()
1777 if (isipv6 && ip6 && (ip6->ip6_nxt == IPPROTO_UDP)) in tcp_respond()
1778 port = m->m_pkthdr.tcp_tun_port; in tcp_respond()
1781 if (ip && (ip->ip_p == IPPROTO_UDP)) in tcp_respond()
1782 port = m->m_pkthdr.tcp_tun_port; in tcp_respond()
1786 port = tp->t_port; in tcp_respond()
1792 win = sbspace(&inp->inp_socket->so_rcv); in tcp_respond()
1793 if (win > TCP_MAXWIN << tp->rcv_scale) in tcp_respond()
1794 win = TCP_MAXWIN << tp->rcv_scale; in tcp_respond()
1796 if ((tp->t_flags & TF_NOOPT) == 0) in tcp_respond()
1803 m->m_data += max_linkhdr; in tcp_respond()
1813 uh->uh_sport = htons(V_tcp_udp_tunneling_port); in tcp_respond()
1814 uh->uh_dport = port; in tcp_respond()
1826 uh->uh_sport = htons(V_tcp_udp_tunneling_port); in tcp_respond()
1827 uh->uh_dport = port; in tcp_respond()
1849 n->m_data += max_linkhdr; in tcp_respond()
1857 xchg(ip6->ip6_dst, ip6->ip6_src, struct in6_addr); in tcp_respond()
1862 uh->uh_sport = htons(V_tcp_udp_tunneling_port); in tcp_respond()
1863 uh->uh_dport = port; in tcp_respond()
1871 xchg(ip->ip_dst.s_addr, ip->ip_src.s_addr, uint32_t); in tcp_respond()
1876 uh->uh_sport = htons(V_tcp_udp_tunneling_port); in tcp_respond()
1877 uh->uh_dport = port; in tcp_respond()
1882 xchg(nth->th_dport, nth->th_sport, uint16_t); in tcp_respond()
1891 m_freem(m->m_next); in tcp_respond()
1892 m->m_next = NULL; in tcp_respond()
1893 m->m_data = (caddr_t)ipgen; in tcp_respond()
1895 m->m_flags &= ~(M_TSTMP | M_TSTMP_LRO); in tcp_respond()
1899 xchg(ip6->ip6_dst, ip6->ip6_src, struct in6_addr); in tcp_respond()
1904 xchg(ip->ip_dst.s_addr, ip->ip_src.s_addr, uint32_t); in tcp_respond()
1913 nth->th_sport = th->th_sport; in tcp_respond()
1914 nth->th_dport = th->th_dport; in tcp_respond()
1916 xchg(nth->th_dport, nth->th_sport, uint16_t); in tcp_respond()
1933 m->m_len = 0; in tcp_respond()
1938 m->m_len = tlen; in tcp_respond()
1944 m->m_next = m_get(M_NOWAIT, MT_DATA); in tcp_respond()
1945 if (m->m_next) { in tcp_respond()
1946 optp = mtod(m->m_next, u_char *); in tcp_respond()
1947 optm = m->m_next; in tcp_respond()
1957 if (tp->t_flags & TF_RCVD_TSTMP) { in tcp_respond()
1958 to.to_tsval = tcp_ts_getticks() + tp->ts_offset; in tcp_respond()
1959 to.to_tsecr = tp->ts_recent; in tcp_respond()
1963 /* TCP-MD5 (RFC2385). */ in tcp_respond()
1964 if (tp->t_flags & TF_SIGNATURE) in tcp_respond()
1971 optm->m_len += optlen; in tcp_respond()
1977 ulen = tlen - sizeof(struct ip6_hdr); in tcp_respond()
1978 uh->uh_ulen = htons(ulen); in tcp_respond()
1980 ip6->ip6_flow = htonl(ect << IPV6_FLOWLABEL_LEN); in tcp_respond()
1981 ip6->ip6_vfc = IPV6_VERSION; in tcp_respond()
1983 ip6->ip6_nxt = IPPROTO_UDP; in tcp_respond()
1985 ip6->ip6_nxt = IPPROTO_TCP; in tcp_respond()
1986 ip6->ip6_plen = htons(tlen - sizeof(*ip6)); in tcp_respond()
1995 ulen = tlen - sizeof(struct ip); in tcp_respond()
1996 uh->uh_ulen = htons(ulen); in tcp_respond()
1998 ip->ip_len = htons(tlen); in tcp_respond()
2000 ip->ip_tos = inp->inp_ip_tos & ~IPTOS_ECN_MASK; in tcp_respond()
2001 ip->ip_ttl = inp->inp_ip_ttl; in tcp_respond()
2003 ip->ip_tos = 0; in tcp_respond()
2004 ip->ip_ttl = V_ip_defttl; in tcp_respond()
2006 ip->ip_tos |= ect; in tcp_respond()
2008 ip->ip_p = IPPROTO_UDP; in tcp_respond()
2010 ip->ip_p = IPPROTO_TCP; in tcp_respond()
2013 ip->ip_off |= htons(IP_DF); in tcp_respond()
2016 m->m_pkthdr.len = tlen; in tcp_respond()
2017 m->m_pkthdr.rcvif = NULL; in tcp_respond()
2034 nth->th_seq = htonl(seq); in tcp_respond()
2035 nth->th_ack = htonl(ack); in tcp_respond()
2036 nth->th_off = (sizeof (struct tcphdr) + optlen) >> 2; in tcp_respond()
2043 nth->th_win = htons((u_short) (win >> tp->rcv_scale)); in tcp_respond()
2045 nth->th_win = htons((u_short)win); in tcp_respond()
2046 nth->th_urp = 0; in tcp_respond()
2061 m->m_pkthdr.csum_flags = CSUM_UDP_IPV6; in tcp_respond()
2062 m->m_pkthdr.csum_data = offsetof(struct udphdr, uh_sum); in tcp_respond()
2063 uh->uh_sum = in6_cksum_pseudo(ip6, ulen, IPPROTO_UDP, 0); in tcp_respond()
2064 nth->th_sum = 0; in tcp_respond()
2066 m->m_pkthdr.csum_flags = CSUM_TCP_IPV6; in tcp_respond()
2067 m->m_pkthdr.csum_data = offsetof(struct tcphdr, th_sum); in tcp_respond()
2068 nth->th_sum = in6_cksum_pseudo(ip6, in tcp_respond()
2069 tlen - sizeof(struct ip6_hdr), IPPROTO_TCP, 0); in tcp_respond()
2071 ip6->ip6_hlim = in6_selecthlim(inp, NULL); in tcp_respond()
2080 uh->uh_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, in tcp_respond()
2082 m->m_pkthdr.csum_flags = CSUM_UDP; in tcp_respond()
2083 m->m_pkthdr.csum_data = offsetof(struct udphdr, uh_sum); in tcp_respond()
2084 nth->th_sum = 0; in tcp_respond()
2086 m->m_pkthdr.csum_flags = CSUM_TCP; in tcp_respond()
2087 m->m_pkthdr.csum_data = offsetof(struct tcphdr, th_sum); in tcp_respond()
2088 nth->th_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, in tcp_respond()
2089 htons((u_short)(tlen - sizeof(struct ip) + ip->ip_p))); in tcp_respond()
2105 log.u_bbr.pkts_out = tp->t_maxseg; in tcp_respond()
2132 (tp->t_state == TCPS_CLOSED || in tcp_respond()
2133 (tp->t_state > TCPS_LISTEN && tp->t_port != port)), in tcp_respond()
2137 ntohs(port), tcpstates[tp->t_state])); in tcp_respond()
2150 output_ret = ip6_output(m, inp ? inp->in6p_outputopts : NULL, in tcp_respond()
2164 lgb->tlb_errno = output_ret; in tcp_respond()
2183 if (tp->t_challenge_ack_end < now) { in tcp_send_challenge_ack()
2184 tp->t_challenge_ack_cnt = 0; in tcp_send_challenge_ack()
2185 tp->t_challenge_ack_end = now + in tcp_send_challenge_ack()
2192 if (tp->t_challenge_ack_cnt < V_tcp_ack_war_cnt) { in tcp_send_challenge_ack()
2194 tp->t_challenge_ack_cnt++; in tcp_send_challenge_ack()
2200 tcp_respond(tp, mtod(m, void *), th, m, tp->rcv_nxt, in tcp_send_challenge_ack()
2201 tp->snd_nxt, TH_ACK); in tcp_send_challenge_ack()
2202 tp->last_ack_sent = tp->rcv_nxt; in tcp_send_challenge_ack()
2218 int isipv6 = (inp->inp_vflag & INP_IPV6) != 0; in tcp_newtcpcb()
2226 bzero(&tp->t_start_zero, t_zero_size); in tcp_newtcpcb()
2229 tp->t_ccv.tp = tp; in tcp_newtcpcb()
2233 KASSERT(listening_tcb->t_fb != NULL, in tcp_newtcpcb()
2234 ("tcp_newtcpcb: listening_tcb->t_fb is NULL")); in tcp_newtcpcb()
2235 if (listening_tcb->t_fb->tfb_flags & TCP_FUNC_BEING_REMOVED) { in tcp_newtcpcb()
2239 tp->t_fb = listening_tcb->t_fb; in tcp_newtcpcb()
2241 tp->t_fb = V_tcp_func_set_ptr; in tcp_newtcpcb()
2243 refcount_acquire(&tp->t_fb->tfb_refcnt); in tcp_newtcpcb()
2244 KASSERT((tp->t_fb->tfb_flags & TCP_FUNC_BEING_REMOVED) == 0, in tcp_newtcpcb()
2249 if (CC_ALGO(listening_tcb)->flags & CC_MODULE_BEING_REMOVED) { 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()
2261 if (CC_ALGO(tp)->cb_init != NULL) in tcp_newtcpcb()
2262 if (CC_ALGO(tp)->cb_init(&tp->t_ccv, NULL) > 0) { in tcp_newtcpcb()
2264 if (tp->t_fb->tfb_tcp_fb_fini) in tcp_newtcpcb()
2265 (*tp->t_fb->tfb_tcp_fb_fini)(tp, 1); in tcp_newtcpcb()
2266 refcount_release(&tp->t_fb->tfb_refcnt); in tcp_newtcpcb()
2271 if (khelp_init_osd(HELPER_CLASS_TCP, &tp->t_osd)) { in tcp_newtcpcb()
2272 if (CC_ALGO(tp)->cb_destroy != NULL) in tcp_newtcpcb()
2273 CC_ALGO(tp)->cb_destroy(&tp->t_ccv); in tcp_newtcpcb()
2276 if (tp->t_fb->tfb_tcp_fb_fini) in tcp_newtcpcb()
2277 (*tp->t_fb->tfb_tcp_fb_fini)(tp, 1); in tcp_newtcpcb()
2278 refcount_release(&tp->t_fb->tfb_refcnt); in tcp_newtcpcb()
2283 TAILQ_INIT(&tp->t_segq); in tcp_newtcpcb()
2284 STAILQ_INIT(&tp->t_inqueue); in tcp_newtcpcb()
2285 tp->t_maxseg = in tcp_newtcpcb()
2294 tp->t_hpts_cpu = HPTS_CPU_NONE; in tcp_newtcpcb()
2295 tp->t_lro_cpu = HPTS_CPU_NONE; in tcp_newtcpcb()
2297 callout_init_rw(&tp->t_callout, &inp->inp_lock, in tcp_newtcpcb()
2300 tp->t_timers[i] = SBT_MAX; in tcp_newtcpcb()
2307 tp->t_flags = (TF_REQ_SCALE|TF_REQ_TSTMP); in tcp_newtcpcb()
2310 tp->t_flags = TF_REQ_SCALE; in tcp_newtcpcb()
2313 tp->t_flags = TF_REQ_TSTMP; in tcp_newtcpcb()
2317 tp->t_flags |= TF_SACK_PERMIT; in tcp_newtcpcb()
2318 TAILQ_INIT(&tp->snd_holes); in tcp_newtcpcb()
2322 * rtt estimate. Set rttvar so that srtt + 4 * rttvar gives in tcp_newtcpcb()
2325 tp->t_srtt = TCPTV_SRTTBASE; in tcp_newtcpcb()
2326 tp->t_rttvar = ((tcp_rexmit_initial - TCPTV_SRTTBASE) << TCP_RTTVAR_SHIFT) / 4; in tcp_newtcpcb()
2327 tp->t_rttmin = tcp_rexmit_min; in tcp_newtcpcb()
2328 tp->t_rxtcur = tcp_rexmit_initial; in tcp_newtcpcb()
2329 tp->snd_cwnd = TCP_MAXWIN << TCP_MAX_WINSHIFT; in tcp_newtcpcb()
2330 tp->snd_ssthresh = TCP_MAXWIN << TCP_MAX_WINSHIFT; in tcp_newtcpcb()
2331 tp->t_rcvtime = ticks; in tcp_newtcpcb()
2333 tp->t_tmr_granularity = TCP_TMR_GRANULARITY_TICKS; in tcp_newtcpcb()
2337 * which may match an IPv4-mapped IPv6 address. in tcp_newtcpcb()
2339 inp->inp_ip_ttl = V_ip_defttl; in tcp_newtcpcb()
2347 /* Initialize the per-TCPCB log data. */ in tcp_newtcpcb()
2350 tp->t_pacing_rate = -1; in tcp_newtcpcb()
2351 if (tp->t_fb->tfb_tcp_fb_init) { in tcp_newtcpcb()
2352 if ((*tp->t_fb->tfb_tcp_fb_init)(tp, &tp->t_fb_ptr)) { in tcp_newtcpcb()
2353 if (CC_ALGO(tp)->cb_destroy != NULL) in tcp_newtcpcb()
2354 CC_ALGO(tp)->cb_destroy(&tp->t_ccv); in tcp_newtcpcb()
2358 khelp_destroy_osd(&tp->t_osd); in tcp_newtcpcb()
2360 refcount_release(&tp->t_fb->tfb_refcnt); in tcp_newtcpcb()
2366 tp->t_stats = stats_blob_alloc(V_tcp_perconn_stats_dflt_tpl, 0); in tcp_newtcpcb()
2369 tp->t_flags |= TF_LRD; in tcp_newtcpcb()
2387 if (TCPS_HAVERCVDSYN(tp->t_state)) { in tcp_drop()
2394 if (errno == ETIMEDOUT && tp->t_softerror) in tcp_drop()
2395 errno = tp->t_softerror; in tcp_drop()
2396 so->so_error = errno; in tcp_drop()
2407 bool isipv6 = (inp->inp_vflag & INP_IPV6) != 0; in tcp_discardcb()
2411 MPASS(!callout_active(&tp->t_callout)); in tcp_discardcb()
2412 MPASS(TAILQ_EMPTY(&tp->snd_holes)); in tcp_discardcb()
2419 if (tp->t_flags & TF_TOE) in tcp_discardcb()
2424 tcp_pcap_drain(&(tp->t_inpkts)); in tcp_discardcb()
2425 tcp_pcap_drain(&(tp->t_outpkts)); in tcp_discardcb()
2429 if (CC_ALGO(tp)->cb_destroy != NULL) in tcp_discardcb()
2430 CC_ALGO(tp)->cb_destroy(&tp->t_ccv); in tcp_discardcb()
2436 khelp_destroy_osd(&tp->t_osd); in tcp_discardcb()
2439 stats_blob_destroy(tp->t_stats); in tcp_discardcb()
2443 if ((m = STAILQ_FIRST(&tp->t_inqueue)) != NULL) { in tcp_discardcb()
2446 STAILQ_INIT(&tp->t_inqueue); in tcp_discardcb()
2447 STAILQ_FOREACH_FROM_SAFE(m, &tp->t_inqueue, m_stailqpkt, prev) in tcp_discardcb()
2450 TCPSTATES_DEC(tp->t_state); in tcp_discardcb()
2452 if (tp->t_fb->tfb_tcp_fb_fini) in tcp_discardcb()
2453 (*tp->t_fb->tfb_tcp_fb_fini)(tp, 1); in tcp_discardcb()
2461 * save the rtt and rttvar in the routing entry. in tcp_discardcb()
2462 * 'Enough' is arbitrarily defined as 4 rtt samples. in tcp_discardcb()
2465 * and we could save a bogus rtt. The danger is not high in tcp_discardcb()
2473 if (tp->t_rttupdated >= 4) { in tcp_discardcb()
2484 ssthresh = tp->snd_ssthresh; in tcp_discardcb()
2485 if (ssthresh != 0 && ssthresh < so->so_snd.sb_hiwat / 2) { in tcp_discardcb()
2490 ssthresh = (ssthresh + tp->t_maxseg / 2) / tp->t_maxseg; in tcp_discardcb()
2493 ssthresh *= (tp->t_maxseg + in tcp_discardcb()
2507 metrics.hc_rtt = tp->t_srtt; in tcp_discardcb()
2508 metrics.hc_rttvar = tp->t_rttvar; in tcp_discardcb()
2509 metrics.hc_cwnd = tp->snd_cwnd; in tcp_discardcb()
2513 tcp_hc_update(&inp->inp_inc, &metrics); in tcp_discardcb()
2516 refcount_release(&tp->t_fb->tfb_refcnt); in tcp_discardcb()
2532 if (tp->t_state == TCPS_LISTEN) in tcp_close()
2537 * sockets as well as passively-created TFO sockets that transition in tcp_close()
2540 if (tp->t_tfo_pending) { in tcp_close()
2541 tcp_fastopen_decrement_counter(tp->t_tfo_pending); in tcp_close()
2542 tp->t_tfo_pending = NULL; in tcp_close()
2545 if (tp->t_fb->tfb_tcp_timer_stop_all != NULL) in tcp_close()
2546 tp->t_fb->tfb_tcp_timer_stop_all(tp); in tcp_close()
2549 if (tp->t_state != TCPS_CLOSED) in tcp_close()
2551 KASSERT(inp->inp_socket != NULL, ("tcp_close: inp_socket NULL")); in tcp_close()
2554 if (inp->inp_flags & INP_SOCKREF) { in tcp_close()
2555 inp->inp_flags &= ~INP_SOCKREF; in tcp_close()
2569 * reporting soft errors (yet - a kqueue filter may be added).
2588 if (tp->t_state == TCPS_ESTABLISHED && in tcp_notify()
2591 if (inp->inp_route.ro_nh) { in tcp_notify()
2592 NH_FREE(inp->inp_route.ro_nh); in tcp_notify()
2593 inp->inp_route.ro_nh = (struct nhop_object *)NULL; in tcp_notify()
2596 } else if (tp->t_state < TCPS_ESTABLISHED && tp->t_rxtshift > 3 && in tcp_notify()
2597 tp->t_softerror) { in tcp_notify()
2604 tp->t_softerror = error; in tcp_notify()
2608 wakeup( &so->so_timeo); in tcp_notify()
2623 if (req->newptr != NULL) in tcp_pcblist()
2626 if (req->oldptr == NULL) { in tcp_pcblist()
2632 req->oldidx = 2 * (sizeof xig) + n * sizeof(struct xtcpcb); in tcp_pcblist()
2654 if (inp->inp_gencnt <= xig.xig_gen && in tcp_pcblist()
2655 cr_canseeinpcb(req->td->td_ucred, inp) == 0) { in tcp_pcblist()
2701 error = priv_check(req->td, PRIV_NETINET_GETCRED); in tcp_getcred()
2713 error = cr_canseeinpcb(req->td->td_ucred, inp); in tcp_getcred()
2715 cru2x(inp->inp_cred, &xuc); in tcp_getcred()
2743 error = priv_check(req->td, PRIV_NETINET_GETCRED); in tcp6_getcred()
2779 error = cr_canseeinpcb(req->td->td_ucred, inp); in tcp6_getcred()
2781 cru2x(inp->inp_cred, &xuc); in tcp6_getcred()
2797 /* Path MTU to try next when a fragmentation-needed message is received. */
2801 int mtu = ntohs(icp->icmp_nextmtu); in tcp_next_pmtu()
2805 mtu = ip_next_mtu(ntohs(ip->ip_len), 1); in tcp_next_pmtu()
2838 if (V_icmp_may_rst && icp->icmp_type == ICMP_TIMXCEED) in tcp_ctlinput_with_port()
2847 ip = &icp->icmp_ip; in tcp_ctlinput_with_port()
2848 th = (struct tcphdr *)((caddr_t)ip + (ip->ip_hl << 2)); in tcp_ctlinput_with_port()
2849 icmp_tcp_seq = th->th_seq; in tcp_ctlinput_with_port()
2850 inp = in_pcblookup(&V_tcbinfo, ip->ip_dst, th->th_dport, ip->ip_src, in tcp_ctlinput_with_port()
2851 th->th_sport, INPLOOKUP_WLOCKPCB, NULL); in tcp_ctlinput_with_port()
2855 if (tp->t_flags & TF_TOE && errno == EMSGSIZE) { in tcp_ctlinput_with_port()
2865 if (tp->t_port != port) in tcp_ctlinput_with_port()
2867 if (SEQ_GEQ(ntohl(icmp_tcp_seq), tp->snd_una) && in tcp_ctlinput_with_port()
2868 SEQ_LT(ntohl(icmp_tcp_seq), tp->snd_max)) { in tcp_ctlinput_with_port()
2880 if (mtu < tp->t_maxseg + in tcp_ctlinput_with_port()
2883 inc.inc_faddr = ip->ip_dst; in tcp_ctlinput_with_port()
2885 inp->inp_inc.inc_fibnum; in tcp_ctlinput_with_port()
2894 inc.inc_fport = th->th_dport; in tcp_ctlinput_with_port()
2895 inc.inc_lport = th->th_sport; in tcp_ctlinput_with_port()
2896 inc.inc_faddr = ip->ip_dst; in tcp_ctlinput_with_port()
2897 inc.inc_laddr = ip->ip_src; in tcp_ctlinput_with_port()
2922 outer_ip = (struct ip *)((caddr_t)icmp - sizeof(struct ip)); in tcp_ctlinput_viaudp()
2923 inner_ip = &icmp->icmp_ip; in tcp_ctlinput_viaudp()
2924 i_hlen = inner_ip->ip_hl << 2; in tcp_ctlinput_viaudp()
2925 o_len = ntohs(outer_ip->ip_len); in tcp_ctlinput_viaudp()
2933 if (ntohs(udp->uh_sport) != V_tcp_udp_tunneling_port) { in tcp_ctlinput_viaudp()
2936 port = udp->uh_dport; in tcp_ctlinput_viaudp()
2941 o_len -= sizeof(struct udphdr); in tcp_ctlinput_viaudp()
2942 outer_ip->ip_len = htons(o_len); in tcp_ctlinput_viaudp()
2952 int mtu = ntohl(icmp6->icmp6_mtu); in tcp6_next_pmtu()
2959 mtu = IPV6_MMTU - 8; /* XXXNP: what is the adjustment for? */ in tcp6_next_pmtu()
2983 icmp6 = ip6cp->ip6c_icmp6; in tcp6_ctlinput_with_port()
2984 m = ip6cp->ip6c_m; in tcp6_ctlinput_with_port()
2985 ip6 = ip6cp->ip6c_ip6; in tcp6_ctlinput_with_port()
2986 off = ip6cp->ip6c_off; in tcp6_ctlinput_with_port()
2987 dst = &ip6cp->ip6c_finaldst->sin6_addr; in tcp6_ctlinput_with_port()
3005 * - administratively prohibited in tcp6_ctlinput_with_port()
3006 * - port unreachable in tcp6_ctlinput_with_port()
3007 * - time exceeded in transit in tcp6_ctlinput_with_port()
3008 * - unknown next header in tcp6_ctlinput_with_port()
3011 ((icmp6->icmp6_type == ICMP6_DST_UNREACH && in tcp6_ctlinput_with_port()
3012 (icmp6->icmp6_code == ICMP6_DST_UNREACH_ADMIN || in tcp6_ctlinput_with_port()
3013 icmp6->icmp6_code == ICMP6_DST_UNREACH_NOPORT)) || in tcp6_ctlinput_with_port()
3014 (icmp6->icmp6_type == ICMP6_TIME_EXCEEDED && in tcp6_ctlinput_with_port()
3015 icmp6->icmp6_code == ICMP6_TIME_EXCEED_TRANSIT) || in tcp6_ctlinput_with_port()
3016 (icmp6->icmp6_type == ICMP6_PARAM_PROB && in tcp6_ctlinput_with_port()
3017 icmp6->icmp6_code == ICMP6_PARAMPROB_NEXTHEADER))) in tcp6_ctlinput_with_port()
3028 (m->m_pkthdr.len < in tcp6_ctlinput_with_port()
3034 inp = in6_pcblookup(&V_tcbinfo, &ip6->ip6_dst, t_ports.th_dport, in tcp6_ctlinput_with_port()
3035 &ip6->ip6_src, t_ports.th_sport, INPLOOKUP_WLOCKPCB, NULL); in tcp6_ctlinput_with_port()
3037 if (m->m_pkthdr.len < (int32_t) (off + sizeof(tcp_seq))) { in tcp6_ctlinput_with_port()
3044 if (tp->t_flags & TF_TOE && errno == EMSGSIZE) { in tcp6_ctlinput_with_port()
3051 if (tp->t_port != port) in tcp6_ctlinput_with_port()
3053 if (SEQ_GEQ(ntohl(icmp_tcp_seq), tp->snd_una) && in tcp6_ctlinput_with_port()
3054 SEQ_LT(ntohl(icmp_tcp_seq), tp->snd_max)) { in tcp6_ctlinput_with_port()
3069 m->m_pkthdr.rcvif, NULL)) in tcp6_ctlinput_with_port()
3075 if (mtu < tp->t_maxseg + in tcp6_ctlinput_with_port()
3092 inc.inc6_laddr = ip6->ip6_src; in tcp6_ctlinput_with_port()
3114 m = m_pulldown(ip6cp->ip6c_m, ip6cp->ip6c_off, sizeof(struct udphdr), NULL); in tcp6_ctlinput_viaudp()
3119 if (ntohs(udp->uh_sport) != V_tcp_udp_tunneling_port) { in tcp6_ctlinput_viaudp()
3122 port = udp->uh_dport; in tcp6_ctlinput_viaudp()
3124 if ((m->m_flags & M_PKTHDR) == 0) { in tcp6_ctlinput_viaudp()
3125 ip6cp->ip6c_m->m_pkthdr.len -= sizeof(struct udphdr); in tcp6_ctlinput_viaudp()
3143 SipHash_Update(&ctx, &inc->inc_fport, sizeof(uint16_t)); in tcp_keyed_hash()
3144 SipHash_Update(&ctx, &inc->inc_lport, sizeof(uint16_t)); in tcp_keyed_hash()
3145 switch (inc->inc_flags & INC_ISIPV6) { in tcp_keyed_hash()
3148 SipHash_Update(&ctx, &inc->inc_faddr, sizeof(struct in_addr)); in tcp_keyed_hash()
3149 SipHash_Update(&ctx, &inc->inc_laddr, sizeof(struct in_addr)); in tcp_keyed_hash()
3154 SipHash_Update(&ctx, &inc->inc6_faddr, sizeof(struct in6_addr)); in tcp_keyed_hash()
3155 SipHash_Update(&ctx, &inc->inc6_laddr, sizeof(struct in6_addr)); in tcp_keyed_hash()
3185 * 1. In SYN-ACK packets.
3188 * All ISNs for SYN-ACK packets are generated by the syncache. See
3199 * Time is based off the system timer, and is corrected so that it
3227 #define ISN_RANDOM_INCREMENT (4096 - 1)
3264 ISN_BYTES_PER_SECOND / hz * (ticks - V_isn_last); in tcp_new_isn()
3277 * connection state is SYN-SENT, drop the connection. This behavior
3289 if (tp->t_state != TCPS_SYN_SENT) in tcp_drop_syn_sent()
3292 if (tp->t_flags & TF_FASTOPEN) in tcp_drop_syn_sent()
3312 return (tcp_mtudisc(inp, -1)); in tcp_mtudisc_notify()
3326 tcp_mss_update(tp, -1, mtuoffer, NULL, NULL); in tcp_mtudisc()
3328 so = inp->inp_socket; in tcp_mtudisc()
3331 if (so->so_snd.sb_hiwat < tp->t_maxseg) { in tcp_mtudisc()
3332 tp->t_maxseg = so->so_snd.sb_hiwat; in tcp_mtudisc()
3333 if (tp->t_maxseg < V_tcp_mssdflt) { in tcp_mtudisc()
3339 tp->t_flags2 |= TF2_PROC_SACK_PROHIBIT; in tcp_mtudisc()
3341 tp->t_flags2 &= ~TF2_PROC_SACK_PROHIBIT; in tcp_mtudisc()
3347 tp->t_rtttime = 0; in tcp_mtudisc()
3348 tp->snd_nxt = tp->snd_una; in tcp_mtudisc()
3350 tp->snd_recover = tp->snd_max; in tcp_mtudisc()
3351 if (tp->t_flags & TF_SACK_PERMIT) in tcp_mtudisc()
3352 EXIT_FASTRECOVERY(tp->t_flags); in tcp_mtudisc()
3353 if (tp->t_fb->tfb_tcp_mtu_chg != NULL) { in tcp_mtudisc()
3360 tp->t_fb->tfb_tcp_mtu_chg(tp); in tcp_mtudisc()
3370 * Look-up the routing entry to the peer of this inpcb. If no route
3384 if (inc->inc_faddr.s_addr != INADDR_ANY) { in tcp_maxmtu()
3385 nh = fib4_lookup(inc->inc_fibnum, inc->inc_faddr, 0, NHR_NONE, 0); in tcp_maxmtu()
3389 ifp = nh->nh_ifp; in tcp_maxmtu()
3390 maxmtu = nh->nh_mtu; in tcp_maxmtu()
3394 if (ifp->if_capenable & IFCAP_TSO4 && in tcp_maxmtu()
3395 ifp->if_hwassist & CSUM_TSO) { in tcp_maxmtu()
3396 cap->ifcap |= CSUM_TSO; in tcp_maxmtu()
3397 cap->tsomax = ifp->if_hw_tsomax; in tcp_maxmtu()
3398 cap->tsomaxsegcount = ifp->if_hw_tsomaxsegcount; in tcp_maxmtu()
3399 cap->tsomaxsegsize = ifp->if_hw_tsomaxsegsize; in tcp_maxmtu()
3401 cap->ipsec_tso = (ifp->if_capenable2 & in tcp_maxmtu()
3422 if (inc->inc_flags & INC_IPV6MINMTU) in tcp_maxmtu6()
3425 if (!IN6_IS_ADDR_UNSPECIFIED(&inc->inc6_faddr)) { in tcp_maxmtu6()
3426 in6_splitscope(&inc->inc6_faddr, &dst6, &scopeid); in tcp_maxmtu6()
3427 nh = fib6_lookup(inc->inc_fibnum, &dst6, scopeid, NHR_NONE, 0); in tcp_maxmtu6()
3431 ifp = nh->nh_ifp; in tcp_maxmtu6()
3432 maxmtu = nh->nh_mtu; in tcp_maxmtu6()
3436 if (ifp->if_capenable & IFCAP_TSO6 && in tcp_maxmtu6()
3437 ifp->if_hwassist & CSUM_TSO) { in tcp_maxmtu6()
3438 cap->ifcap |= CSUM_TSO; in tcp_maxmtu6()
3439 cap->tsomax = ifp->if_hw_tsomax; in tcp_maxmtu6()
3440 cap->tsomaxsegcount = ifp->if_hw_tsomaxsegcount; in tcp_maxmtu6()
3441 cap->tsomaxsegsize = ifp->if_hw_tsomaxsegsize; in tcp_maxmtu6()
3442 cap->ipsec_tso = false; /* XXXKIB */ in tcp_maxmtu6()
3473 inp->inp_inc.inc_flags |= INC_IPV6MINMTU; in tcp6_use_min_mtu()
3474 if ((tp->t_state >= TCPS_SYN_SENT) && in tcp6_use_min_mtu()
3475 (inp->inp_inc.inc_flags & INC_ISIPV6)) { in tcp6_use_min_mtu()
3478 opt = inp->in6p_outputopts; in tcp6_use_min_mtu()
3479 if (opt != NULL && opt->ip6po_minmtu == IP6PO_MINMTU_ALL && in tcp6_use_min_mtu()
3480 tp->t_maxseg > TCP6_MSS) { in tcp6_use_min_mtu()
3481 tp->t_maxseg = TCP6_MSS; in tcp6_use_min_mtu()
3482 if (tp->t_maxseg < V_tcp_mssdflt) { in tcp6_use_min_mtu()
3488 tp->t_flags2 |= TF2_PROC_SACK_PROHIBIT; in tcp6_use_min_mtu()
3490 tp->t_flags2 &= ~TF2_PROC_SACK_PROHIBIT; in tcp6_use_min_mtu()
3506 if (tp->t_flags & TF_NOOPT) in tcp_maxseg()
3507 return (tp->t_maxseg); in tcp_maxseg()
3516 if (TCPS_HAVEESTABLISHED(tp->t_state)) { in tcp_maxseg()
3517 if (tp->t_flags & TF_RCVD_TSTMP) in tcp_maxseg()
3522 if (tp->t_flags & TF_SIGNATURE) in tcp_maxseg()
3525 if ((tp->t_flags & TF_SACK_PERMIT) && tp->rcv_numsacks > 0) { in tcp_maxseg()
3527 optlen += tp->rcv_numsacks * TCPOLEN_SACK; in tcp_maxseg()
3531 if (tp->t_flags & TF_REQ_TSTMP) in tcp_maxseg()
3535 if (tp->t_flags & TF_REQ_SCALE) in tcp_maxseg()
3538 if (tp->t_flags & TF_SIGNATURE) in tcp_maxseg()
3541 if (tp->t_flags & TF_SACK_PERMIT) in tcp_maxseg()
3545 return (tp->t_maxseg - optlen); in tcp_maxseg()
3554 if (tp->t_flags & TF_NOOPT) in tcp_fixed_maxseg()
3555 return (tp->t_maxseg); in tcp_fixed_maxseg()
3565 if (TCPS_HAVEESTABLISHED(tp->t_state)) { in tcp_fixed_maxseg()
3566 if (tp->t_flags & TF_RCVD_TSTMP) in tcp_fixed_maxseg()
3571 if (tp->t_flags & TF_SIGNATURE) in tcp_fixed_maxseg()
3575 if (tp->t_flags & TF_REQ_TSTMP) in tcp_fixed_maxseg()
3579 if (tp->t_flags & TF_REQ_SCALE) in tcp_fixed_maxseg()
3582 if (tp->t_flags & TF_SIGNATURE) in tcp_fixed_maxseg()
3585 if (tp->t_flags & TF_SACK_PERMIT) in tcp_fixed_maxseg()
3589 return (tp->t_maxseg - optlen); in tcp_fixed_maxseg()
3616 if (req->oldptr != NULL || req->oldlen != 0) in sysctl_drop()
3618 if (req->newptr == NULL) in sysctl_drop()
3620 if (req->newlen < sizeof(addrs)) in sysctl_drop()
3631 if (fin6->sin6_len != sizeof(struct sockaddr_in6) || in sysctl_drop()
3632 lin6->sin6_len != sizeof(struct sockaddr_in6)) in sysctl_drop()
3634 if (IN6_IS_ADDR_V4MAPPED(&fin6->sin6_addr)) { in sysctl_drop()
3635 if (!IN6_IS_ADDR_V4MAPPED(&lin6->sin6_addr)) in sysctl_drop()
3657 if (fin->sin_len != sizeof(struct sockaddr_in) || in sysctl_drop()
3658 lin->sin_len != sizeof(struct sockaddr_in)) in sysctl_drop()
3669 inp = in6_pcblookup(&V_tcbinfo, &fin6->sin6_addr, in sysctl_drop()
3670 fin6->sin6_port, &lin6->sin6_addr, lin6->sin6_port, in sysctl_drop()
3676 inp = in_pcblookup(&V_tcbinfo, fin->sin_addr, fin->sin_port, in sysctl_drop()
3677 lin->sin_addr, lin->sin_port, INPLOOKUP_WLOCKPCB, NULL); in sysctl_drop()
3682 if (!SOLISTENING(inp->inp_socket)) { in sysctl_drop()
3734 if (req->oldptr != NULL || req->oldlen != 0) in sysctl_switch_tls()
3736 if (req->newptr == NULL) in sysctl_switch_tls()
3738 if (req->newlen < sizeof(addrs)) in sysctl_switch_tls()
3749 if (fin6->sin6_len != sizeof(struct sockaddr_in6) || in sysctl_switch_tls()
3750 lin6->sin6_len != sizeof(struct sockaddr_in6)) in sysctl_switch_tls()
3752 if (IN6_IS_ADDR_V4MAPPED(&fin6->sin6_addr)) { in sysctl_switch_tls()
3753 if (!IN6_IS_ADDR_V4MAPPED(&lin6->sin6_addr)) in sysctl_switch_tls()
3775 if (fin->sin_len != sizeof(struct sockaddr_in) || in sysctl_switch_tls()
3776 lin->sin_len != sizeof(struct sockaddr_in)) in sysctl_switch_tls()
3787 inp = in6_pcblookup(&V_tcbinfo, &fin6->sin6_addr, in sysctl_switch_tls()
3788 fin6->sin6_port, &lin6->sin6_addr, lin6->sin6_port, in sysctl_switch_tls()
3794 inp = in_pcblookup(&V_tcbinfo, fin->sin_addr, fin->sin_port, in sysctl_switch_tls()
3795 lin->sin_addr, lin->sin_port, INPLOOKUP_WLOCKPCB, NULL); in sysctl_switch_tls()
3803 so = inp->inp_socket; in sysctl_switch_tls()
3891 if (inc && ((inc->inc_flags & INC_ISIPV6) == 0)) { in tcp_log_addr()
3892 inet_ntoa_r(inc->inc_faddr, sp); in tcp_log_addr()
3894 sprintf(sp, "]:%i to [", ntohs(inc->inc_fport)); in tcp_log_addr()
3896 inet_ntoa_r(inc->inc_laddr, sp); in tcp_log_addr()
3898 sprintf(sp, "]:%i", ntohs(inc->inc_lport)); in tcp_log_addr()
3901 ip6_sprintf(sp, &inc->inc6_faddr); in tcp_log_addr()
3903 sprintf(sp, "]:%i to [", ntohs(inc->inc_fport)); in tcp_log_addr()
3905 ip6_sprintf(sp, &inc->inc6_laddr); in tcp_log_addr()
3907 sprintf(sp, "]:%i", ntohs(inc->inc_lport)); in tcp_log_addr()
3909 ip6_sprintf(sp, &ip6->ip6_src); in tcp_log_addr()
3911 sprintf(sp, "]:%i to [", ntohs(th->th_sport)); in tcp_log_addr()
3913 ip6_sprintf(sp, &ip6->ip6_dst); in tcp_log_addr()
3915 sprintf(sp, "]:%i", ntohs(th->th_dport)); in tcp_log_addr()
3919 inet_ntoa_r(ip->ip_src, sp); in tcp_log_addr()
3921 sprintf(sp, "]:%i to [", ntohs(th->th_sport)); in tcp_log_addr()
3923 inet_ntoa_r(ip->ip_dst, sp); in tcp_log_addr()
3925 sprintf(sp, "]:%i", ntohs(th->th_dport)); in tcp_log_addr()
3934 if (*(s + size - 1) != '\0') in tcp_log_addr()
3948 int pstate = tp->t_state; in tcp_state_change()
3951 TCPSTATES_DEC(tp->t_state); in tcp_state_change()
3953 tp->t_state = newstate; in tcp_state_change()
3958 * Create an external-format (``xtcpcb'') structure using the information in
3959 * the kernel-format tcpcb structure pointed to by tp. This is done to
3962 * information-hiding if we decide that some of this information should be
3972 xt->t_state = tp->t_state; in tcp_inptoxtp()
3973 xt->t_logstate = tcp_get_bblog_state(tp); in tcp_inptoxtp()
3974 xt->t_flags = tp->t_flags; in tcp_inptoxtp()
3975 xt->t_sndzerowin = tp->t_sndzerowin; in tcp_inptoxtp()
3976 xt->t_sndrexmitpack = tp->t_sndrexmitpack; in tcp_inptoxtp()
3977 xt->t_rcvoopack = tp->t_rcvoopack; in tcp_inptoxtp()
3978 xt->t_rcv_wnd = tp->rcv_wnd; in tcp_inptoxtp()
3979 xt->t_snd_wnd = tp->snd_wnd; in tcp_inptoxtp()
3980 xt->t_snd_cwnd = tp->snd_cwnd; in tcp_inptoxtp()
3981 xt->t_snd_ssthresh = tp->snd_ssthresh; in tcp_inptoxtp()
3982 xt->t_dsack_bytes = tp->t_dsack_bytes; in tcp_inptoxtp()
3983 xt->t_dsack_tlp_bytes = tp->t_dsack_tlp_bytes; in tcp_inptoxtp()
3984 xt->t_dsack_pack = tp->t_dsack_pack; in tcp_inptoxtp()
3985 xt->t_maxseg = tp->t_maxseg; in tcp_inptoxtp()
3986 xt->xt_ecn = (tp->t_flags2 & TF2_ECN_PERMIT) ? 1 : 0 + in tcp_inptoxtp()
3987 (tp->t_flags2 & TF2_ACE_PERMIT) ? 2 : 0; in tcp_inptoxtp()
3991 if (tp->t_timers[which] != SBT_MAX) \ in tcp_inptoxtp()
3992 xt->where = (tp->t_timers[which] - now) / SBT_1MS; \ in tcp_inptoxtp()
3994 xt->where = 0; \ in tcp_inptoxtp()
4002 xt->t_rcvtime = 1000 * (ticks - tp->t_rcvtime) / hz; in tcp_inptoxtp()
4004 xt->xt_encaps_port = tp->t_port; in tcp_inptoxtp()
4005 bcopy(tp->t_fb->tfb_tcp_block_name, xt->xt_stack, in tcp_inptoxtp()
4007 bcopy(CC_ALGO(tp)->name, xt->xt_cc, TCP_CA_NAME_MAX); in tcp_inptoxtp()
4009 (void)tcp_log_get_id(tp, xt->xt_logid); in tcp_inptoxtp()
4012 xt->xt_len = sizeof(struct xtcpcb); in tcp_inptoxtp()
4013 in_pcbtoxinpcb(inp, &xt->xt_inp); in tcp_inptoxtp()
4031 bit = 1U << (status - 1); in tcp_log_end_status()
4032 if (bit & tp->t_end_info_status) { in tcp_log_end_status()
4037 if (tp->t_end_info_bytes[i] == TCP_EI_EMPTY_SLOT) { in tcp_log_end_status()
4038 tp->t_end_info_bytes[i] = status; in tcp_log_end_status()
4039 tp->t_end_info_status |= bit; in tcp_log_end_status()
4049 if ((tcp_pacing_limit == -1) || in tcp_can_enable_pacing()
4063 if ((tcp_dgp_limit == -1) || in tcp_incr_dgp_pacing_cnt()
4081 ret = atomic_fetchadd_int(&number_of_dgp_connections, -1); in tcp_dec_dgp_pacing_cnt()
4083 KASSERT(ret != 0, ("number_of_dgp_connections -1 would cause wrap?")); in tcp_dec_dgp_pacing_cnt()
4085 if (tcp_dgp_limit != -1) { in tcp_dec_dgp_pacing_cnt()
4104 ret = atomic_fetchadd_int(&number_of_tcp_connections_pacing, -1); in tcp_decrement_paced_conn()
4106 KASSERT(ret != 0, ("tcp_paced_connection_exits -1 would cause wrap?")); in tcp_decrement_paced_conn()
4108 if (tcp_pacing_limit != -1) { in tcp_decrement_paced_conn()
4126 * b) The timer granularity. in tcp_default_switch_failed()
4139 if (SEQ_LT(th->th_ack, tp->snd_una)) { in tcp_do_ack_accounting()
4141 if (to->to_flags & TOF_SACK) { in tcp_do_ack_accounting()
4142 if (tp->t_flags2 & TF2_TCP_ACCOUNTING) { in tcp_do_ack_accounting()
4143 tp->tcp_cnt_counters[ACK_SACK]++; in tcp_do_ack_accounting()
4147 if (tp->t_flags2 & TF2_TCP_ACCOUNTING) { in tcp_do_ack_accounting()
4148 tp->tcp_cnt_counters[ACK_BEHIND]++; in tcp_do_ack_accounting()
4152 } else if (th->th_ack == tp->snd_una) { in tcp_do_ack_accounting()
4154 if (to->to_flags & TOF_SACK) { in tcp_do_ack_accounting()
4155 if (tp->t_flags2 & TF2_TCP_ACCOUNTING) { in tcp_do_ack_accounting()
4156 tp->tcp_cnt_counters[ACK_SACK]++; in tcp_do_ack_accounting()
4159 } else if (tiwin != tp->snd_wnd) { in tcp_do_ack_accounting()
4160 if (tp->t_flags2 & TF2_TCP_ACCOUNTING) { in tcp_do_ack_accounting()
4161 tp->tcp_cnt_counters[ACK_RWND]++; in tcp_do_ack_accounting()
4165 if (tp->t_flags2 & TF2_TCP_ACCOUNTING) { in tcp_do_ack_accounting()
4166 tp->tcp_cnt_counters[ACK_DUPACK]++; in tcp_do_ack_accounting()
4171 if (!SEQ_GT(th->th_ack, tp->snd_max)) { in tcp_do_ack_accounting()
4172 if (tp->t_flags2 & TF2_TCP_ACCOUNTING) { in tcp_do_ack_accounting()
4173 tp->tcp_cnt_counters[CNT_OF_ACKS_IN] += (((th->th_ack - tp->snd_una) + mss - 1)/mss); in tcp_do_ack_accounting()
4176 if (to->to_flags & TOF_SACK) { in tcp_do_ack_accounting()
4177 if (tp->t_flags2 & TF2_TCP_ACCOUNTING) { in tcp_do_ack_accounting()
4178 tp->tcp_cnt_counters[ACK_CUMACK_SACK]++; in tcp_do_ack_accounting()
4182 if (tp->t_flags2 & TF2_TCP_ACCOUNTING) { in tcp_do_ack_accounting()
4183 tp->tcp_cnt_counters[ACK_CUMACK]++; in tcp_do_ack_accounting()
4194 if (tp->t_tmr_granularity == granularity) { in tcp_change_time_units()
4199 KASSERT((tp->t_tmr_granularity == TCP_TMR_GRANULARITY_TICKS), in tcp_change_time_units()
4201 tp->t_tmr_granularity, tp)); in tcp_change_time_units()
4202 tp->t_rttlow = TICKS_2_USEC(tp->t_rttlow); in tcp_change_time_units()
4203 if (tp->t_srtt > 1) { in tcp_change_time_units()
4206 val = tp->t_srtt >> TCP_RTT_SHIFT; in tcp_change_time_units()
4207 frac = tp->t_srtt & 0x1f; in tcp_change_time_units()
4208 tp->t_srtt = TICKS_2_USEC(val); in tcp_change_time_units()
4220 tp->t_srtt += frac; in tcp_change_time_units()
4223 if (tp->t_rttvar) { in tcp_change_time_units()
4226 val = tp->t_rttvar >> TCP_RTTVAR_SHIFT; in tcp_change_time_units()
4227 frac = tp->t_rttvar & 0x1f; in tcp_change_time_units()
4228 tp->t_rttvar = TICKS_2_USEC(val); in tcp_change_time_units()
4240 tp->t_rttvar += frac; in tcp_change_time_units()
4243 tp->t_tmr_granularity = TCP_TMR_GRANULARITY_USEC; in tcp_change_time_units()
4246 KASSERT((tp->t_tmr_granularity == TCP_TMR_GRANULARITY_USEC), in tcp_change_time_units()
4248 tp->t_tmr_granularity, tp)); in tcp_change_time_units()
4249 if (tp->t_srtt > 1) { in tcp_change_time_units()
4252 val = USEC_2_TICKS(tp->t_srtt); in tcp_change_time_units()
4253 frac = tp->t_srtt % (HPTS_USEC_IN_SEC / hz); in tcp_change_time_units()
4254 tp->t_srtt = val << TCP_RTT_SHIFT; in tcp_change_time_units()
4267 tp->t_srtt += frac; in tcp_change_time_units()
4270 if (tp->t_rttvar) { in tcp_change_time_units()
4273 val = USEC_2_TICKS(tp->t_rttvar); in tcp_change_time_units()
4274 frac = tp->t_rttvar % (HPTS_USEC_IN_SEC / hz); in tcp_change_time_units()
4275 tp->t_rttvar = val << TCP_RTTVAR_SHIFT; in tcp_change_time_units()
4288 tp->t_rttvar += frac; in tcp_change_time_units()
4291 tp->t_rttlow = USEC_2_TICKS(tp->t_rttlow); in tcp_change_time_units()
4292 tp->t_tmr_granularity = TCP_TMR_GRANULARITY_TICKS; in tcp_change_time_units()
4315 if (tp->t_flags2 & TF2_MBUF_L_ACKS) in tcp_handle_orphaned_packets()
4317 if ((tp->t_flags2 & TF2_SUPPORTS_MBUFQ) == 0 && in tcp_handle_orphaned_packets()
4318 !STAILQ_EMPTY(&tp->t_inqueue)) { in tcp_handle_orphaned_packets()
4329 m = STAILQ_FIRST(&tp->t_inqueue); in tcp_handle_orphaned_packets()
4330 STAILQ_INIT(&tp->t_inqueue); in tcp_handle_orphaned_packets()
4331 STAILQ_FOREACH_FROM_SAFE(m, &tp->t_inqueue, m_stailqpkt, save) in tcp_handle_orphaned_packets()
4339 STAILQ_FOREACH_SAFE(m, &tp->t_inqueue, m_stailqpkt, save) { in tcp_handle_orphaned_packets()
4340 if (m->m_flags & M_ACKCMP) { in tcp_handle_orphaned_packets()
4341 if (m == STAILQ_FIRST(&tp->t_inqueue)) in tcp_handle_orphaned_packets()
4342 STAILQ_REMOVE_HEAD(&tp->t_inqueue, in tcp_handle_orphaned_packets()
4345 STAILQ_REMOVE_AFTER(&tp->t_inqueue, in tcp_handle_orphaned_packets()
4362 tls = so->so_snd.sb_tls_info; in tcp_estimate_tls_overhead()
4366 rec_oh = tls->params.tls_hlen + tls->params.tls_tlen; in tcp_estimate_tls_overhead()
4367 records = ((tls_usr_bytes + tls->params.max_frame_len - 1)/tls->params.max_frame_len); in tcp_estimate_tls_overhead()
4390 log.u_bbr.rttProp = req->timestamp; in tcp_req_log_req_info()
4391 log.u_bbr.delRate = req->start; in tcp_req_log_req_info()
4392 log.u_bbr.cur_del_rate = req->end; in tcp_req_log_req_info()
4393 log.u_bbr.flex1 = req->start_seq; in tcp_req_log_req_info()
4394 log.u_bbr.flex2 = req->end_seq; in tcp_req_log_req_info()
4395 log.u_bbr.flex3 = req->flags; in tcp_req_log_req_info()
4396 log.u_bbr.flex4 = ((req->localtime >> 32) & 0x00000000ffffffff); in tcp_req_log_req_info()
4397 log.u_bbr.flex5 = (req->localtime & 0x00000000ffffffff); in tcp_req_log_req_info()
4404 log.u_bbr.lt_epoch = ((req->cspr >> 32) & 0x00000000ffffffff); in tcp_req_log_req_info()
4405 log.u_bbr.pkts_out |= (req->cspr & 0x00000000ffffffff); in tcp_req_log_req_info()
4406 log.u_bbr.applimited = tp->t_tcpreq_closed; in tcp_req_log_req_info()
4408 log.u_bbr.applimited |= tp->t_tcpreq_open; in tcp_req_log_req_info()
4410 log.u_bbr.applimited |= tp->t_tcpreq_req; in tcp_req_log_req_info()
4413 &tptosocket(tp)->so_rcv, in tcp_req_log_req_info()
4414 &tptosocket(tp)->so_snd, in tcp_req_log_req_info()
4423 if (tp->t_tcpreq_req > 0) in tcp_req_free_a_slot()
4424 tp->t_tcpreq_req--; in tcp_req_free_a_slot()
4425 if (ent->flags & TCP_TRK_TRACK_FLG_OPEN) { in tcp_req_free_a_slot()
4426 if (tp->t_tcpreq_open > 0) in tcp_req_free_a_slot()
4427 tp->t_tcpreq_open--; in tcp_req_free_a_slot()
4429 if (tp->t_tcpreq_closed > 0) in tcp_req_free_a_slot()
4430 tp->t_tcpreq_closed--; in tcp_req_free_a_slot()
4432 ent->flags = TCP_TRK_TRACK_FLG_EMPTY; in tcp_req_free_a_slot()
4443 ent = &tp->t_tcpreq_info[i]; in tcp_req_check_for_stale_entries()
4444 if (ent->flags != TCP_TRK_TRACK_FLG_USED) { in tcp_req_check_for_stale_entries()
4453 if (ts >= ent->localtime) in tcp_req_check_for_stale_entries()
4454 time_delta = ts - ent->localtime; in tcp_req_check_for_stale_entries()
4465 * No sendfile in a our time-limit in tcp_req_check_for_stale_entries()
4469 tcp_req_log_req_info(tp, &tp->t_tcpreq_info[i], i, TCP_TRK_REQ_LOG_STALE, in tcp_req_check_for_stale_entries()
4475 ent = &tp->t_tcpreq_info[oldest]; in tcp_req_check_for_stale_entries()
4476 tcp_req_log_req_info(tp, &tp->t_tcpreq_info[i], i, TCP_TRK_REQ_LOG_STALE, in tcp_req_check_for_stale_entries()
4489 if (tp->t_tcpreq_req == 0) in tcp_req_check_for_comp()
4491 if (tp->t_tcpreq_closed == 0) in tcp_req_check_for_comp()
4494 ent = &tp->t_tcpreq_info[i]; in tcp_req_check_for_comp()
4496 if (ent->flags == TCP_TRK_TRACK_FLG_EMPTY) in tcp_req_check_for_comp()
4499 if (ent->flags & TCP_TRK_TRACK_FLG_OPEN) in tcp_req_check_for_comp()
4501 if (SEQ_GEQ(ack_point, ent->end_seq)) { in tcp_req_check_for_comp()
4502 /* We are past it -- free it */ in tcp_req_check_for_comp()
4515 if (tp->t_tcpreq_req == 0) in tcp_req_is_entry_comp()
4516 return (-1); in tcp_req_is_entry_comp()
4517 if (tp->t_tcpreq_closed == 0) in tcp_req_is_entry_comp()
4518 return (-1); in tcp_req_is_entry_comp()
4519 if (ent->flags == TCP_TRK_TRACK_FLG_EMPTY) in tcp_req_is_entry_comp()
4520 return (-1); in tcp_req_is_entry_comp()
4521 if (SEQ_GEQ(ack_point, ent->end_seq)) { in tcp_req_is_entry_comp()
4538 if (tp->t_tcpreq_req == 0) { in tcp_req_find_a_req_that_is_completed_by()
4543 ent = &tp->t_tcpreq_info[i]; in tcp_req_find_a_req_that_is_completed_by()
4544 if (ent->flags == TCP_TRK_TRACK_FLG_EMPTY) in tcp_req_find_a_req_that_is_completed_by()
4546 if ((ent->flags & TCP_TRK_TRACK_FLG_OPEN) == 0) { in tcp_req_find_a_req_that_is_completed_by()
4547 if (SEQ_GEQ(th_ack, ent->end_seq)) { in tcp_req_find_a_req_that_is_completed_by()
4562 if (tp->t_tcpreq_req == 0) { in tcp_req_find_req_for_seq()
4567 ent = &tp->t_tcpreq_info[i]; in tcp_req_find_req_for_seq()
4570 if (ent->flags == TCP_TRK_TRACK_FLG_EMPTY) { in tcp_req_find_req_for_seq()
4573 if (ent->flags & TCP_TRK_TRACK_FLG_OPEN) { in tcp_req_find_req_for_seq()
4581 if ((SEQ_GEQ(seq, ent->start_seq)) || in tcp_req_find_req_for_seq()
4582 (tp->t_tcpreq_closed == 0)) in tcp_req_find_req_for_seq()
4590 if ((SEQ_GEQ(seq, ent->start_seq)) && in tcp_req_find_req_for_seq()
4591 (SEQ_LT(seq, ent->end_seq))) { in tcp_req_find_req_for_seq()
4607 tcp_req_check_for_comp(tp, tp->snd_una); in tcp_req_alloc_req_full()
4609 if (tp->t_tcpreq_req) in tcp_req_alloc_req_full()
4611 (tp->t_tcpreq_req >= MAX_TCP_TRK_REQ)); in tcp_req_alloc_req_full()
4613 if (tp->t_tcpreq_req) { in tcp_req_alloc_req_full()
4615 fil = &tp->t_tcpreq_info[i]; in tcp_req_alloc_req_full()
4616 if ((fil->flags & TCP_TRK_TRACK_FLG_USED) == 0) in tcp_req_alloc_req_full()
4618 if ((fil->timestamp == req->timestamp) && in tcp_req_alloc_req_full()
4619 (fil->start == req->start) && in tcp_req_alloc_req_full()
4620 ((fil->flags & TCP_TRK_TRACK_FLG_OPEN) || in tcp_req_alloc_req_full()
4621 (fil->end == req->end))) { in tcp_req_alloc_req_full()
4634 if (tp->t_tcpreq_req >= MAX_TCP_TRK_REQ) { in tcp_req_alloc_req_full()
4637 tcp_req_log_req_info(tp, &tp->t_tcpreq_info[i], in tcp_req_alloc_req_full()
4643 fil = &tp->t_tcpreq_info[i]; in tcp_req_alloc_req_full()
4644 if (fil->flags == TCP_TRK_TRACK_FLG_EMPTY) { in tcp_req_alloc_req_full()
4646 fil->flags = TCP_TRK_TRACK_FLG_USED; in tcp_req_alloc_req_full()
4647 fil->timestamp = req->timestamp; in tcp_req_alloc_req_full()
4648 fil->playout_ms = req->playout_ms; in tcp_req_alloc_req_full()
4649 fil->localtime = ts; in tcp_req_alloc_req_full()
4650 fil->start = req->start; in tcp_req_alloc_req_full()
4651 if (req->flags & TCP_LOG_HTTPD_RANGE_END) { in tcp_req_alloc_req_full()
4652 fil->end = req->end; in tcp_req_alloc_req_full()
4654 fil->end = 0; in tcp_req_alloc_req_full()
4655 fil->flags |= TCP_TRK_TRACK_FLG_OPEN; in tcp_req_alloc_req_full()
4662 fil->sbcc_at_s = tptosocket(tp)->so_snd.sb_ccc; in tcp_req_alloc_req_full()
4663 fil->start_seq = tp->snd_una + in tcp_req_alloc_req_full()
4664 tptosocket(tp)->so_snd.sb_ccc; in tcp_req_alloc_req_full()
4665 if (req->flags & TCP_LOG_HTTPD_RANGE_END) in tcp_req_alloc_req_full()
4666 fil->end_seq = (fil->start_seq + ((uint32_t)(fil->end - fil->start))); in tcp_req_alloc_req_full()
4668 fil->end_seq = 0; in tcp_req_alloc_req_full()
4669 if (tptosocket(tp)->so_snd.sb_tls_info) { in tcp_req_alloc_req_full()
4674 fil->end_seq += tcp_estimate_tls_overhead( in tcp_req_alloc_req_full()
4675 tptosocket(tp), (fil->end - fil->start)); in tcp_req_alloc_req_full()
4677 tp->t_tcpreq_req++; in tcp_req_alloc_req_full()
4678 if (fil->flags & TCP_TRK_TRACK_FLG_OPEN) in tcp_req_alloc_req_full()
4679 tp->t_tcpreq_open++; in tcp_req_alloc_req_full()
4681 tp->t_tcpreq_closed++; in tcp_req_alloc_req_full()
4694 (void)tcp_req_alloc_req_full(tp, &user->tcp_req, ts, 1); in tcp_req_alloc_req()
4705 &tptosocket(tp)->so_rcv, in tcp_log_socket_option()
4706 &tptosocket(tp)->so_snd, in tcp_log_socket_option()
4711 l->tlb_flex1 = option_num; in tcp_log_socket_option()
4712 l->tlb_flex2 = option_val; in tcp_log_socket_option()
4727 srtt = tp->t_srtt; in tcp_get_srtt()
4734 if (tp->t_tmr_granularity != granularity) { in tcp_get_srtt()
4747 if (tp->t_tmr_granularity == TCP_TMR_GRANULARITY_TICKS) in tcp_get_srtt()
4759 tp->t_sndtlppack++; in tcp_account_for_send()
4760 tp->t_sndtlpbyte += len; in tcp_account_for_send()
4764 tp->t_snd_rxt_bytes += len; in tcp_account_for_send()
4766 tp->t_sndbytes += len; in tcp_account_for_send()
4772 rexmit_percent = (1000ULL * tp->t_snd_rxt_bytes) / in tcp_account_for_send()
4773 (10ULL * (tp->t_snd_rxt_bytes + tp->t_sndbytes)); in tcp_account_for_send()