Changeset View
Changeset View
Standalone View
Standalone View
head/sys/netinet/tcp_syncache.c
Show First 20 Lines • Show All 1,258 Lines • ▼ Show 20 Lines | #endif | ||||
KASSERT((th->th_flags & (TH_RST|TH_ACK|TH_SYN)) == TH_SYN, | KASSERT((th->th_flags & (TH_RST|TH_ACK|TH_SYN)) == TH_SYN, | ||||
("%s: unexpected tcp flags", __func__)); | ("%s: unexpected tcp flags", __func__)); | ||||
/* | /* | ||||
* Combine all so/tp operations very early to drop the INP lock as | * Combine all so/tp operations very early to drop the INP lock as | ||||
* soon as possible. | * soon as possible. | ||||
*/ | */ | ||||
so = *lsop; | so = *lsop; | ||||
KASSERT(SOLISTENING(so), ("%s: %p not listening", __func__, so)); | |||||
tp = sototcpcb(so); | tp = sototcpcb(so); | ||||
cred = crhold(so->so_cred); | cred = crhold(so->so_cred); | ||||
#ifdef INET6 | #ifdef INET6 | ||||
if ((inc->inc_flags & INC_ISIPV6) && | if ((inc->inc_flags & INC_ISIPV6) && | ||||
(inp->inp_flags & IN6P_AUTOFLOWLABEL)) | (inp->inp_flags & IN6P_AUTOFLOWLABEL)) | ||||
autoflowlabel = 1; | autoflowlabel = 1; | ||||
#endif | #endif | ||||
ip_ttl = inp->inp_ip_ttl; | ip_ttl = inp->inp_ip_ttl; | ||||
ip_tos = inp->inp_ip_tos; | ip_tos = inp->inp_ip_tos; | ||||
win = sbspace(&so->so_rcv); | win = so->sol_sbrcv_hiwat; | ||||
ltflags = (tp->t_flags & (TF_NOOPT | TF_SIGNATURE)); | ltflags = (tp->t_flags & (TF_NOOPT | TF_SIGNATURE)); | ||||
#ifdef TCP_RFC7413 | #ifdef TCP_RFC7413 | ||||
if (V_tcp_fastopen_enabled && IS_FASTOPEN(tp->t_flags) && | if (V_tcp_fastopen_enabled && IS_FASTOPEN(tp->t_flags) && | ||||
(tp->t_tfo_pending != NULL) && (to->to_flags & TOF_FASTOPEN)) { | (tp->t_tfo_pending != NULL) && (to->to_flags & TOF_FASTOPEN)) { | ||||
/* | /* | ||||
* Limit the number of pending TFO connections to | * Limit the number of pending TFO connections to | ||||
* approximately half of the queue limit. This prevents TFO | * approximately half of the queue limit. This prevents TFO | ||||
* SYN floods from starving the service by filling the | * SYN floods from starving the service by filling the | ||||
* listen queue with bogus TFO connections. | * listen queue with bogus TFO connections. | ||||
*/ | */ | ||||
if (atomic_fetchadd_int(tp->t_tfo_pending, 1) <= | if (atomic_fetchadd_int(tp->t_tfo_pending, 1) <= | ||||
(so->so_qlimit / 2)) { | (so->sol_qlimit / 2)) { | ||||
int result; | int result; | ||||
result = tcp_fastopen_check_cookie(inc, | result = tcp_fastopen_check_cookie(inc, | ||||
to->to_tfo_cookie, to->to_tfo_len, | to->to_tfo_cookie, to->to_tfo_len, | ||||
&tfo_response_cookie); | &tfo_response_cookie); | ||||
tfo_cookie_valid = (result > 0); | tfo_cookie_valid = (result > 0); | ||||
tfo_response_cookie_valid = (result >= 0); | tfo_response_cookie_valid = (result >= 0); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 811 Lines • ▼ Show 20 Lines | #endif | ||||
/* Only use wscale if it was enabled in the orignal SYN. */ | /* Only use wscale if it was enabled in the orignal SYN. */ | ||||
if (cookie.flags.wscale_idx > 0) { | if (cookie.flags.wscale_idx > 0) { | ||||
sc->sc_requested_r_scale = wscale; | sc->sc_requested_r_scale = wscale; | ||||
sc->sc_requested_s_scale = tcp_sc_wstab[cookie.flags.wscale_idx]; | sc->sc_requested_s_scale = tcp_sc_wstab[cookie.flags.wscale_idx]; | ||||
sc->sc_flags |= SCF_WINSCALE; | sc->sc_flags |= SCF_WINSCALE; | ||||
} | } | ||||
wnd = sbspace(&lso->so_rcv); | wnd = lso->sol_sbrcv_hiwat; | ||||
wnd = imax(wnd, 0); | wnd = imax(wnd, 0); | ||||
wnd = imin(wnd, TCP_MAXWIN); | wnd = imin(wnd, TCP_MAXWIN); | ||||
sc->sc_wnd = wnd; | sc->sc_wnd = wnd; | ||||
if (cookie.flags.sack_ok) | if (cookie.flags.sack_ok) | ||||
sc->sc_flags |= SCF_SACK; | sc->sc_flags |= SCF_SACK; | ||||
if (to->to_flags & TOF_TS) { | if (to->to_flags & TOF_TS) { | ||||
▲ Show 20 Lines • Show All 130 Lines • Show Last 20 Lines |