tcp: RFC7413 option support for Fast Open server
Fast Open has been using the experimental option with a magic number (RFC6994) to request and grant Fast Open cookies. This patch enables the server to support the official IANA option 34 in RFC7413 in addition. The change has passed all existing Fast Open tests with both old and new options at Google. Signed-off-by: Daniel Lee <Longinus00@gmail.com> Signed-off-by: Yuchung Cheng <ycheng@google.com> Signed-off-by: Neal Cardwell <ncardwell@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
812034f116
commit
7f9b838b71
@@ -518,17 +518,26 @@ static void tcp_options_write(__be32 *ptr, struct tcp_sock *tp,
|
||||
|
||||
if (unlikely(OPTION_FAST_OPEN_COOKIE & options)) {
|
||||
struct tcp_fastopen_cookie *foc = opts->fastopen_cookie;
|
||||
u8 *p = (u8 *)ptr;
|
||||
u32 len; /* Fast Open option length */
|
||||
|
||||
*ptr++ = htonl((TCPOPT_EXP << 24) |
|
||||
((TCPOLEN_EXP_FASTOPEN_BASE + foc->len) << 16) |
|
||||
TCPOPT_FASTOPEN_MAGIC);
|
||||
|
||||
memcpy(ptr, foc->val, foc->len);
|
||||
if ((foc->len & 3) == 2) {
|
||||
u8 *align = ((u8 *)ptr) + foc->len;
|
||||
align[0] = align[1] = TCPOPT_NOP;
|
||||
if (foc->exp) {
|
||||
len = TCPOLEN_EXP_FASTOPEN_BASE + foc->len;
|
||||
*ptr = htonl((TCPOPT_EXP << 24) | (len << 16) |
|
||||
TCPOPT_FASTOPEN_MAGIC);
|
||||
p += TCPOLEN_EXP_FASTOPEN_BASE;
|
||||
} else {
|
||||
len = TCPOLEN_FASTOPEN_BASE + foc->len;
|
||||
*p++ = TCPOPT_FASTOPEN;
|
||||
*p++ = len;
|
||||
}
|
||||
ptr += (foc->len + 3) >> 2;
|
||||
|
||||
memcpy(p, foc->val, foc->len);
|
||||
if ((len & 3) == 2) {
|
||||
p[foc->len] = TCPOPT_NOP;
|
||||
p[foc->len + 1] = TCPOPT_NOP;
|
||||
}
|
||||
ptr += (len + 3) >> 2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -641,8 +650,11 @@ static unsigned int tcp_synack_options(struct sock *sk,
|
||||
if (unlikely(!ireq->tstamp_ok))
|
||||
remaining -= TCPOLEN_SACKPERM_ALIGNED;
|
||||
}
|
||||
if (foc && foc->len >= 0) {
|
||||
u32 need = TCPOLEN_EXP_FASTOPEN_BASE + foc->len;
|
||||
if (foc != NULL && foc->len >= 0) {
|
||||
u32 need = foc->len;
|
||||
|
||||
need += foc->exp ? TCPOLEN_EXP_FASTOPEN_BASE :
|
||||
TCPOLEN_FASTOPEN_BASE;
|
||||
need = (need + 3) & ~3U; /* Align to 32 bits */
|
||||
if (remaining >= need) {
|
||||
opts->options |= OPTION_FAST_OPEN_COOKIE;
|
||||
|
Reference in New Issue
Block a user