| 867 | } |
| 868 | |
| 869 | void |
| 870 | tcp_fastopen_connect(struct tcpcb *tp) |
| 871 | { |
| 872 | struct inpcb *inp; |
| 873 | struct tcp_fastopen_ccache_bucket *ccb; |
| 874 | struct tcp_fastopen_ccache_entry *cce; |
| 875 | sbintime_t now; |
| 876 | uint16_t server_mss; |
| 877 | uint64_t psk_cookie; |
| 878 | |
| 879 | psk_cookie = 0; |
| 880 | inp = tp->t_inpcb; |
| 881 | cce = tcp_fastopen_ccache_lookup(&inp->inp_inc, &ccb); |
| 882 | if (cce) { |
| 883 | if (cce->disable_time == 0) { |
| 884 | if ((cce->cookie_len > 0) && |
| 885 | (tp->t_tfo_client_cookie_len == |
| 886 | TCP_FASTOPEN_PSK_LEN)) { |
| 887 | psk_cookie = |
| 888 | tcp_fastopen_make_psk_cookie( |
| 889 | tp->t_tfo_cookie.client, |
| 890 | cce->cookie, cce->cookie_len); |
| 891 | } else { |
| 892 | tp->t_tfo_client_cookie_len = cce->cookie_len; |
| 893 | memcpy(tp->t_tfo_cookie.client, cce->cookie, |
| 894 | cce->cookie_len); |
| 895 | } |
| 896 | server_mss = cce->server_mss; |
| 897 | CCB_UNLOCK(ccb); |
| 898 | if (tp->t_tfo_client_cookie_len == |
| 899 | TCP_FASTOPEN_PSK_LEN && psk_cookie) { |
| 900 | tp->t_tfo_client_cookie_len = |
| 901 | TCP_FASTOPEN_COOKIE_LEN; |
| 902 | memcpy(tp->t_tfo_cookie.client, &psk_cookie, |
| 903 | TCP_FASTOPEN_COOKIE_LEN); |
| 904 | } |
| 905 | tcp_mss(tp, server_mss ? server_mss : -1); |
| 906 | tp->snd_wnd = tp->t_maxseg; |
| 907 | } else { |
| 908 | /* |
| 909 | * The path is disabled. Check the time and |
| 910 | * possibly re-enable. |
| 911 | */ |
| 912 | now = getsbinuptime(); |
| 913 | if (now - cce->disable_time > |
| 914 | ((sbintime_t)V_tcp_fastopen_path_disable_time << 32)) { |
| 915 | /* |
| 916 | * Re-enable path. Force a TFO cookie |
| 917 | * request. Forget the old MSS as it may be |
| 918 | * bogus now, and we will rediscover it in |
| 919 | * the SYN|ACK. |
| 920 | */ |
| 921 | cce->disable_time = 0; |
| 922 | cce->server_mss = 0; |
| 923 | cce->cookie_len = 0; |
| 924 | /* |
| 925 | * tp->t_tfo... cookie details are already |
| 926 | * zero from the tcpcb init. |
no test coverage detected