• Eric Dumazet's avatar
    tcp: fix cookie_init_timestamp() overflows · 73ed8e03
    Eric Dumazet authored
    cookie_init_timestamp() is supposed to return a 64bit timestamp
    suitable for both TSval determination and setting of skb->tstamp.
    
    Unfortunately it uses 32bit fields and overflows after
    2^32 * 10^6 nsec (~49 days) of uptime.
    
    Generated TSval are still correct, but skb->tstamp might be set
    far away in the past, potentially confusing other layers.
    
    tcp_ns_to_ts() is changed to return a full 64bit value,
    ts and ts_now variables are changed to u64 type,
    and TSMASK is removed in favor of shifts operations.
    
    While we are at it, change this sequence:
    		ts >>= TSBITS;
    		ts--;
    		ts <<= TSBITS;
    		ts |= options;
    to:
    		ts -= (1UL << TSBITS);
    
    Fixes: 9a568de4 ("tcp: switch TCP TS option (RFC 7323) to 1ms clock")
    Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    73ed8e03
syncookies.c 12.7 KB