Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/tcp_syncache.c
Show First 20 Lines • Show All 1,391 Lines • ▼ Show 20 Lines | #endif | ||||
struct syncache scs; | struct syncache scs; | ||||
struct ucred *cred; | struct ucred *cred; | ||||
uint64_t tfo_response_cookie; | uint64_t tfo_response_cookie; | ||||
unsigned int *tfo_pending = NULL; | unsigned int *tfo_pending = NULL; | ||||
int tfo_cookie_valid = 0; | int tfo_cookie_valid = 0; | ||||
int tfo_response_cookie_valid = 0; | int tfo_response_cookie_valid = 0; | ||||
bool locked; | bool locked; | ||||
INP_WLOCK_ASSERT(inp); /* listen socket */ | INP_RLOCK_ASSERT(inp); /* listen socket */ | ||||
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; | ||||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | #endif | ||||
} | } | ||||
/* By the time we drop the lock these should no longer be used. */ | /* By the time we drop the lock these should no longer be used. */ | ||||
so = NULL; | so = NULL; | ||||
tp = NULL; | tp = NULL; | ||||
#ifdef MAC | #ifdef MAC | ||||
if (mac_syncache_init(&maclabel) != 0) { | if (mac_syncache_init(&maclabel) != 0) { | ||||
INP_WUNLOCK(inp); | INP_RUNLOCK(inp); | ||||
goto done; | goto done; | ||||
} else | } else | ||||
mac_syncache_create(maclabel, inp); | mac_syncache_create(maclabel, inp); | ||||
#endif | #endif | ||||
if (!tfo_cookie_valid) | if (!tfo_cookie_valid) | ||||
INP_WUNLOCK(inp); | INP_RUNLOCK(inp); | ||||
/* | /* | ||||
* Remember the IP options, if any. | * Remember the IP options, if any. | ||||
*/ | */ | ||||
#ifdef INET6 | #ifdef INET6 | ||||
if (!(inc->inc_flags & INC_ISIPV6)) | if (!(inc->inc_flags & INC_ISIPV6)) | ||||
#endif | #endif | ||||
#ifdef INET | #ifdef INET | ||||
Show All 36 Lines | if (syncache_cookiesonly()) { | ||||
locked = false; | locked = false; | ||||
} else { | } else { | ||||
sc = syncache_lookup(inc, &sch); /* returns locked sch */ | sc = syncache_lookup(inc, &sch); /* returns locked sch */ | ||||
locked = true; | locked = true; | ||||
SCH_LOCK_ASSERT(sch); | SCH_LOCK_ASSERT(sch); | ||||
} | } | ||||
if (sc != NULL) { | if (sc != NULL) { | ||||
if (tfo_cookie_valid) | if (tfo_cookie_valid) | ||||
INP_WUNLOCK(inp); | INP_RUNLOCK(inp); | ||||
TCPSTAT_INC(tcps_sc_dupsyn); | TCPSTAT_INC(tcps_sc_dupsyn); | ||||
if (ipopts) { | if (ipopts) { | ||||
/* | /* | ||||
* If we were remembering a previous source route, | * If we were remembering a previous source route, | ||||
* forget it and use the new one we've been given. | * forget it and use the new one we've been given. | ||||
*/ | */ | ||||
if (sc->sc_ipopts) | if (sc->sc_ipopts) | ||||
(void) m_free(sc->sc_ipopts); | (void) m_free(sc->sc_ipopts); | ||||
▲ Show 20 Lines • Show All 190 Lines • ▼ Show 20 Lines | if (autoflowlabel) { | ||||
sc->sc_flowlabel = htonl(sc->sc_flowlabel) & IPV6_FLOWLABEL_MASK; | sc->sc_flowlabel = htonl(sc->sc_flowlabel) & IPV6_FLOWLABEL_MASK; | ||||
} | } | ||||
#endif | #endif | ||||
if (locked) | if (locked) | ||||
SCH_UNLOCK(sch); | SCH_UNLOCK(sch); | ||||
if (tfo_cookie_valid) { | if (tfo_cookie_valid) { | ||||
syncache_tfo_expand(sc, lsop, m, tfo_response_cookie); | syncache_tfo_expand(sc, lsop, m, tfo_response_cookie); | ||||
/* INP_WUNLOCK(inp) will be performed by the caller */ | /* INP_RUNLOCK(inp) will be performed by the caller */ | ||||
rv = 1; | rv = 1; | ||||
goto tfo_expanded; | goto tfo_expanded; | ||||
} | } | ||||
TCP_PROBE5(receive, NULL, NULL, m, NULL, th); | TCP_PROBE5(receive, NULL, NULL, m, NULL, th); | ||||
/* | /* | ||||
* Do a standard 3-way handshake. | * Do a standard 3-way handshake. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 775 Lines • Show Last 20 Lines |