Changeset View
Changeset View
Standalone View
Standalone View
head/sys/netinet/tcp_syncache.c
Show First 20 Lines • Show All 1,491 Lines • ▼ Show 20 Lines | #endif | ||||
if (V_tcp_do_rfc1323) { | if (V_tcp_do_rfc1323) { | ||||
/* | /* | ||||
* A timestamp received in a SYN makes | * A timestamp received in a SYN makes | ||||
* it ok to send timestamp requests and replies. | * it ok to send timestamp requests and replies. | ||||
*/ | */ | ||||
if (to->to_flags & TOF_TS) { | if (to->to_flags & TOF_TS) { | ||||
sc->sc_tsreflect = to->to_tsval; | sc->sc_tsreflect = to->to_tsval; | ||||
sc->sc_flags |= SCF_TIMESTAMP; | sc->sc_flags |= SCF_TIMESTAMP; | ||||
sc->sc_tsoff = tcp_new_ts_offset(inc); | |||||
} | } | ||||
if (to->to_flags & TOF_SCALE) { | if (to->to_flags & TOF_SCALE) { | ||||
int wscale = 0; | int wscale = 0; | ||||
/* | /* | ||||
* Pick the smallest possible scaling factor that | * Pick the smallest possible scaling factor that | ||||
* will still allow us to scale up to sb_max, aka | * will still allow us to scale up to sb_max, aka | ||||
* kern.ipc.maxsockbuf. | * kern.ipc.maxsockbuf. | ||||
▲ Show 20 Lines • Show All 522 Lines • ▼ Show 20 Lines | syncookie_generate(struct syncache_head *sch, struct syncache *sc) | ||||
* Put the flags into the hash and XOR them to get better ISS number | * Put the flags into the hash and XOR them to get better ISS number | ||||
* variance. This doesn't enhance the cryptographic strength and is | * variance. This doesn't enhance the cryptographic strength and is | ||||
* done to prevent the 8 cookie bits from showing up directly on the | * done to prevent the 8 cookie bits from showing up directly on the | ||||
* wire. | * wire. | ||||
*/ | */ | ||||
iss = hash & ~0xff; | iss = hash & ~0xff; | ||||
iss |= cookie.cookie ^ (hash >> 24); | iss |= cookie.cookie ^ (hash >> 24); | ||||
/* Randomize the timestamp. */ | |||||
if (sc->sc_flags & SCF_TIMESTAMP) { | |||||
sc->sc_tsoff = arc4random() - tcp_ts_getticks(); | |||||
} | |||||
TCPSTAT_INC(tcps_sc_sendcookie); | TCPSTAT_INC(tcps_sc_sendcookie); | ||||
return (iss); | return (iss); | ||||
} | } | ||||
static struct syncache * | static struct syncache * | ||||
syncookie_lookup(struct in_conninfo *inc, struct syncache_head *sch, | syncookie_lookup(struct in_conninfo *inc, struct syncache_head *sch, | ||||
struct syncache *sc, struct tcphdr *th, struct tcpopt *to, | struct syncache *sc, struct tcphdr *th, struct tcpopt *to, | ||||
struct socket *lso) | struct socket *lso) | ||||
▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | #endif | ||||
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) { | ||||
sc->sc_flags |= SCF_TIMESTAMP; | sc->sc_flags |= SCF_TIMESTAMP; | ||||
sc->sc_tsreflect = to->to_tsval; | sc->sc_tsreflect = to->to_tsval; | ||||
sc->sc_tsoff = to->to_tsecr - tcp_ts_getticks(); | sc->sc_tsoff = tcp_new_ts_offset(inc); | ||||
} | } | ||||
if (to->to_flags & TOF_SIGNATURE) | if (to->to_flags & TOF_SIGNATURE) | ||||
sc->sc_flags |= SCF_SIGNATURE; | sc->sc_flags |= SCF_SIGNATURE; | ||||
sc->sc_rxmits = 0; | sc->sc_rxmits = 0; | ||||
TCPSTAT_INC(tcps_sc_recvcookie); | TCPSTAT_INC(tcps_sc_recvcookie); | ||||
▲ Show 20 Lines • Show All 118 Lines • Show Last 20 Lines |