mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-22 23:04:43 +00:00
tcp: add server ip to encrypt cookie in fast open
Encrypt the cookie with both server and client IPv4 addresses, such that multi-homed server will grant different cookies based on both the source and destination IPs. No client change is needed since cookie is opaque to the client. Signed-off-by: Yuchung Cheng <ycheng@google.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Acked-by: Neal Cardwell <ncardwell@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
469230d118
commit
149479d019
3 changed files with 15 additions and 11 deletions
|
@ -1316,9 +1316,11 @@ static bool tcp_fastopen_check(struct sock *sk, struct sk_buff *skb,
|
|||
tcp_rsk(req)->rcv_nxt = TCP_SKB_CB(skb)->end_seq;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (foc->len == TCP_FASTOPEN_COOKIE_SIZE) {
|
||||
if ((sysctl_tcp_fastopen & TFO_SERVER_COOKIE_NOT_CHKED) == 0) {
|
||||
tcp_fastopen_cookie_gen(ip_hdr(skb)->saddr, valid_foc);
|
||||
tcp_fastopen_cookie_gen(ip_hdr(skb)->saddr,
|
||||
ip_hdr(skb)->daddr, valid_foc);
|
||||
if ((valid_foc->len != TCP_FASTOPEN_COOKIE_SIZE) ||
|
||||
memcmp(&foc->val[0], &valid_foc->val[0],
|
||||
TCP_FASTOPEN_COOKIE_SIZE) != 0)
|
||||
|
@ -1329,14 +1331,16 @@ static bool tcp_fastopen_check(struct sock *sk, struct sk_buff *skb,
|
|||
tcp_rsk(req)->rcv_nxt = TCP_SKB_CB(skb)->end_seq;
|
||||
return true;
|
||||
} else if (foc->len == 0) { /* Client requesting a cookie */
|
||||
tcp_fastopen_cookie_gen(ip_hdr(skb)->saddr, valid_foc);
|
||||
tcp_fastopen_cookie_gen(ip_hdr(skb)->saddr,
|
||||
ip_hdr(skb)->daddr, valid_foc);
|
||||
NET_INC_STATS_BH(sock_net(sk),
|
||||
LINUX_MIB_TCPFASTOPENCOOKIEREQD);
|
||||
} else {
|
||||
/* Client sent a cookie with wrong size. Treat it
|
||||
* the same as invalid and return a valid one.
|
||||
*/
|
||||
tcp_fastopen_cookie_gen(ip_hdr(skb)->saddr, valid_foc);
|
||||
tcp_fastopen_cookie_gen(ip_hdr(skb)->saddr,
|
||||
ip_hdr(skb)->daddr, valid_foc);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue