Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/tcp_seq.h
Show First 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | |||||
#define tcp_rcvseqinit(tp) \ | #define tcp_rcvseqinit(tp) \ | ||||
(tp)->rcv_adv = (tp)->rcv_nxt = (tp)->irs + 1 | (tp)->rcv_adv = (tp)->rcv_nxt = (tp)->irs + 1 | ||||
#define tcp_sendseqinit(tp) \ | #define tcp_sendseqinit(tp) \ | ||||
(tp)->snd_una = (tp)->snd_nxt = (tp)->snd_max = (tp)->snd_up = \ | (tp)->snd_una = (tp)->snd_nxt = (tp)->snd_max = (tp)->snd_up = \ | ||||
(tp)->snd_recover = (tp)->iss | (tp)->snd_recover = (tp)->iss | ||||
#ifdef _KERNEL | #ifdef _KERNEL | ||||
/* | /* | ||||
* RFC 7323 | |||||
* Section 5.4. Timestamp Clock | |||||
* | |||||
* (b) The timestamp clock must not be "too fast". | |||||
* | |||||
* The recycling time of the timestamp clock MUST be greater than | |||||
* MSL seconds. Since the clock (timestamp) is 32 bits and the | |||||
* worst-case MSL is 255 seconds, the maximum acceptable clock | |||||
* frequency is one tick every 59 ns. | |||||
*/ | |||||
/* | |||||
* The minimum permissible timestamp is 59ns. However, to reduce calculation | |||||
* overhead we use 256 - (8 bit shift). | |||||
* - (1<<32)/(1000000000/59) == 253 | |||||
* - (1<<32)/(1000000000/60) == 257 | |||||
* | |||||
* | |||||
* Note that MSL should be a function of RTT. Although 60ns is more than sufficient resolution for | |||||
* the time being a 255s MSL on data center network with a sub-millisecond RTT doesn't make a whole | |||||
* lot of senese. In the future the MSL should be determined dynamically or at the very least con- | |||||
* figurable per subnet. Nonetheless, fixing the timestamp clock at a rate corresponding to a 256s | |||||
* MSL gives us what we need for now while otherwise remaining as RFC compliant as possible. | |||||
* | |||||
*/ | |||||
#define SBT_MINTS_SHIFT 8 | |||||
#define MIN_TS_STEP 2 | |||||
#define TS_1S (SBT_1S >> SBT_MINTS_SHIFT) | |||||
#define SBT_MINTS (1 << SBT_MINTS_SHIFT) | |||||
/* minimum rtt is ~1us (60ns * 16) */ | |||||
#define SBT_MINRTT (SBT_MINTS << 4) | |||||
/* | |||||
* Clock macros for RFC 1323 timestamps. | * Clock macros for RFC 1323 timestamps. | ||||
*/ | */ | ||||
#define TCP_TS_TO_SBT(_t) ((_t) << SBT_MINTS_SHIFT) | |||||
#define TCP_SBT_TO_TS(_t) ((_t) >> SBT_MINTS_SHIFT) | |||||
#define MAX_TS_STEP ((1<<30)) | |||||
/* | |||||
* RFC defined MSL: 255s ( 2s rounding slop) | |||||
*/ | |||||
#define TCP_PAWS_IDLE_SBT (SBT_MINTS*SBT_1S/2) | |||||
#include <sys/clock.h> | |||||
#define tcp_ts_getsbintime() (cpu_ts_getsbintime)() | |||||
#define TCP_TS_TO_TICKS(_t) ((_t) * hz / 1000) | #define TCP_TS_TO_TICKS(_t) ((_t) * hz / 1000) | ||||
/* Timestamp wrap-around time, 24 days. */ | /* Timestamp wrap-around time, 24 days. */ | ||||
#define TCP_PAWS_IDLE (24 * 24 * 60 * 60 * 1000) | #define TCP_PAWS_IDLE (24 * 24 * 60 * 60 * 1000) | ||||
/* | |||||
* tcp_ts_getticks() in ms, should be 1ms < x < 1000ms according to RFC 1323. | |||||
* We always use 1ms granularity independent of hz. | |||||
*/ | |||||
static __inline uint32_t | static __inline uint32_t | ||||
tcp_ts_getticks(void) | tcp_ts_getticks(void) | ||||
{ | { | ||||
struct timeval tv; | struct timeval tv; | ||||
/* | /* | ||||
* getmicrouptime() should be good enough for any 1-1000ms granularity. | * getmicrouptime() should be good enough for any 1-1000ms granularity. | ||||
* Do not use getmicrotime() here as it might break nfsroot/tcp. | * Do not use getmicrotime() here as it might break nfsroot/tcp. | ||||
*/ | */ | ||||
getmicrouptime(&tv); | getmicrouptime(&tv); | ||||
return (tv.tv_sec * 1000 + tv.tv_usec / 1000); | return (tv.tv_sec * 1000 + tv.tv_usec / 1000); | ||||
} | } | ||||
#endif /* _KERNEL */ | #endif /* _KERNEL */ | ||||
#endif /* _NETINET_TCP_SEQ_H_ */ | #endif /* _NETINET_TCP_SEQ_H_ */ |