tcp: Disable usec TS for SYN Cookie.
Subsystems (3)
Kuniyuki Iwashima
reviewerPATCH 1/1 tcp: Disable usec TS for SYN Cookie.
cookie_tcp_reqsk_alloc() sets tcp_rsk(req)->req_usec_ts to false unconditionally.
If want_cookie is true in tcp_conn_request(), we should not set tcp_rsk(req)->req_usec_ts.
Let's not call dst_tcp_usec_ts() for SYN Cookie.
--- net/ipv4/syncookies.c | 3 --- net/ipv4/tcp_input.c | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-)
net/ipv4/syncookies.c +0 -3
@@ -76,12 +76,9 @@ u64 cookie_init_timestamp(struct request_sock *req, u64 now)if (ts > ts_now) ts -= (1UL <<TSBITS ); -if (tcp_rsk (req)->req_usec_ts) -return ts *NSEC_PER_USEC ;return ts *NSEC_PER_MSEC ; } -static __u32 secure_tcp_syn_cookie (__be32 saddr,__be32 daddr,__be16 sport,__be16 dport,__u32 sseq,__u32 data) {
net/ipv4/tcp_input.c +2 -1
@@ -7720,7 +7720,8 @@ int tcp_conn_request(struct request_sock_ops *rsk_ops, st = af_ops->init_seq_and_ts_off (net, skb);if (tmp_opt.tstamp_ok) { -tcp_rsk (req)->req_usec_ts =dst_tcp_usec_ts (dst); +if (!want_cookie) +tcp_rsk (req)->req_usec_ts =dst_tcp_usec_ts (dst);tcp_rsk (req)->ts_off = st.ts_off; }if (!want_cookie && !isn) {
Signature · 1 line
2.54.0.rc1.513.gad8abe7a5a-goog
Quoted 8 lines · Kuniyuki Iwashima
cookie_tcp_reqsk_alloc()sets tcp_rsk(req)->req_usec_ts to false unconditionally.If
want_cookieis true intcp_conn_request(), we should not set tcp_rsk(req)->req_usec_ts.Let's not call
dst_tcp_usec_ts()for SYN Cookie.
May I ask why ?
TCP usec TS are based on routing. this feature is not part of SYN and/or SYNACK options.
Both side must have:
ip route ... feature tcp_usec_ts
syncookies are orthogonal to this constraint, so TCP flows can use usec TS just fine.
pw-bot: cr
Kuniyuki Iwashima
reviewerQuoted 6 lines · Eric Dumazet
Quoted 4 lines · Kuniyuki Iwashima
cookie_tcp_reqsk_alloc()sets tcp_rsk(req)->req_usec_ts to false unconditionally.
Quoted 6 lines
Quoted 4 lines
If
want_cookieis true intcp_conn_request(), we should not set tcp_rsk(req)->req_usec_ts.Let's not call
dst_tcp_usec_ts()for SYN Cookie.May I ask why ?
Sorry, I missed tcp_skb_timestamp_ts() properly restores the cookie TS generated by cookie_init_timestamp() to ms unit.
Still we don't need to call dst_tcp_usec_ts() for SYN cookie, but this was more like a cleanup patch.
Quoted 12 lines
TCP usec TS are based on routing. this feature is not part of SYN and/or SYNACK options.
Both side must have:
ip route ... feature
tcp_usec_tssyncookies are orthogonal to this constraint, so TCP flows can use usec TS just fine.
pw-bot: cr
Quoted 13 lines · Kuniyuki Iwashima
Quoted 11 lines · Eric Dumazet
Quoted 8 lines · Kuniyuki Iwashima
cookie_tcp_reqsk_alloc()sets tcp_rsk(req)->req_usec_ts to false unconditionally.If
want_cookieis true intcp_conn_request(), we should not set tcp_rsk(req)->req_usec_ts.Let's not call
dst_tcp_usec_ts()for SYN Cookie.
Quoted 7 lines
Quoted 1 line
May I ask why ?
Sorry, I missed
tcp_skb_timestamp_ts()properly restores the cookie TS generated bycookie_init_timestamp()to ms unit.Still we don't need to call
dst_tcp_usec_ts()for SYN cookie, but this was more like a cleanup patch.
Okay, but consider the standard path (or fast path) has to call it. dst_tcp_usec_ts() is a mere dst_feature(dst, RTAX_FEATURE_TCP_USEC_TS), which is pretty fast.
Adding a conditional branch won't help.