Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/tcp_syncache.c
Show First 20 Lines • Show All 1,628 Lines • ▼ Show 20 Lines | #endif | ||||
hlen = | hlen = | ||||
#ifdef INET6 | #ifdef INET6 | ||||
(sc->sc_inc.inc_flags & INC_ISIPV6) ? sizeof(struct ip6_hdr) : | (sc->sc_inc.inc_flags & INC_ISIPV6) ? sizeof(struct ip6_hdr) : | ||||
#endif | #endif | ||||
sizeof(struct ip); | sizeof(struct ip); | ||||
tlen = hlen + sizeof(struct tcphdr); | tlen = hlen + sizeof(struct tcphdr); | ||||
/* Determine MSS we advertize to other end of connection. */ | /* Determine MSS we advertize to other end of connection. */ | ||||
mssopt = tcp_mssopt(&sc->sc_inc); | mssopt = max(tcp_mssopt(&sc->sc_inc), V_tcp_minmss); | ||||
tuexen: I would prefer
```
mssopt = max(tcp_mssopt(&sc->sc_inc), V_tcp_minmss);
```
instead of the two… | |||||
Not Done Inline ActionsSure, I will regenerate the patch. sepherosa_gmail.com: Sure, I will regenerate the patch. | |||||
if (sc->sc_peer_mss) | |||||
mssopt = max( min(sc->sc_peer_mss, mssopt), V_tcp_minmss); | |||||
/* XXX: Assume that the entire packet will fit in a header mbuf. */ | /* XXX: Assume that the entire packet will fit in a header mbuf. */ | ||||
KASSERT(max_linkhdr + tlen + TCP_MAXOLEN <= MHLEN, | KASSERT(max_linkhdr + tlen + TCP_MAXOLEN <= MHLEN, | ||||
("syncache: mbuf too small")); | ("syncache: mbuf too small")); | ||||
/* Create the IP+TCP header from scratch. */ | /* Create the IP+TCP header from scratch. */ | ||||
m = m_gethdr(M_NOWAIT, MT_DATA); | m = m_gethdr(M_NOWAIT, MT_DATA); | ||||
if (m == NULL) | if (m == NULL) | ||||
▲ Show 20 Lines • Show All 332 Lines • ▼ Show 20 Lines | #endif | ||||
SipHash_Final((u_int8_t *)&siphash, &ctx); | SipHash_Final((u_int8_t *)&siphash, &ctx); | ||||
return (siphash[0] ^ siphash[1]); | return (siphash[0] ^ siphash[1]); | ||||
} | } | ||||
static tcp_seq | static tcp_seq | ||||
syncookie_generate(struct syncache_head *sch, struct syncache *sc) | syncookie_generate(struct syncache_head *sch, struct syncache *sc) | ||||
{ | { | ||||
u_int i, mss, secbit, wscale; | u_int i, secbit, wscale; | ||||
uint32_t iss, hash; | uint32_t iss, hash; | ||||
uint8_t *secbits; | uint8_t *secbits; | ||||
union syncookie cookie; | union syncookie cookie; | ||||
SCH_LOCK_ASSERT(sch); | SCH_LOCK_ASSERT(sch); | ||||
cookie.cookie = 0; | cookie.cookie = 0; | ||||
/* Map our computed MSS into the 3-bit index. */ | /* Map our computed MSS into the 3-bit index. */ | ||||
mss = min(tcp_mssopt(&sc->sc_inc), max(sc->sc_peer_mss, V_tcp_minmss)); | for (i = nitems(tcp_sc_msstab) - 1; | ||||
for (i = nitems(tcp_sc_msstab) - 1; tcp_sc_msstab[i] > mss && i > 0; | tcp_sc_msstab[i] > sc->sc_peer_mss && i > 0; | ||||
karelsUnsubmitted Not Done Inline ActionsWhy are we using sc_peer_mss here? I thought that was the term that was to be removed. karels: Why are we using sc_peer_mss here? I thought that was the term that was to be removed. | |||||
sepherosa_gmail.comAuthorUnsubmitted Not Done Inline ActionsSyn cookie encodes the MSS announcement from SYN sender that's why sc_peer_mss is used here. So it's correct to use sc_peer_mss here. sepherosa_gmail.com: Syn cookie encodes the MSS announcement from SYN sender that's why sc_peer_mss is used here. | |||||
karelsUnsubmitted Not Done Inline ActionsSorry, I got it backwards. This is correct for syncookie. karels: Sorry, I got it backwards. This is correct for syncookie. | |||||
i--) | i--) | ||||
; | ; | ||||
cookie.flags.mss_idx = i; | cookie.flags.mss_idx = i; | ||||
/* | /* | ||||
* Map the send window scale into the 3-bit index but only if | * Map the send window scale into the 3-bit index but only if | ||||
* the wscale option was received. | * the wscale option was received. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 250 Lines • Show Last 20 Lines |
I would prefer
instead of the two lines.