aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp_input.c
diff options
context:
space:
mode:
authorYuchung Cheng <ycheng@google.com>2012-07-19 02:43:05 -0400
committerDavid S. Miller <davem@davemloft.net>2012-07-19 13:55:36 -0400
commit2100c8d2d9db23c0a09901a782bb4e3b21bee298 (patch)
treefd5842c540bf77c3fa546797c1c8e94f054cc86c /net/ipv4/tcp_input.c
parent4cce66cdd14aa5006a011505865d932adb49f600 (diff)
net-tcp: Fast Open base
This patch impelements the common code for both the client and server. 1. TCP Fast Open option processing. Since Fast Open does not have an option number assigned by IANA yet, it shares the experiment option code 254 by implementing draft-ietf-tcpm-experimental-options with a 16 bits magic number 0xF989. This enables global experiments without clashing the scarce(2) experimental options available for TCP. When the draft status becomes standard (maybe), the client should switch to the new option number assigned while the server supports both numbers for transistion. 2. The new sysctl tcp_fastopen 3. A place holder init function Signed-off-by: Yuchung Cheng <ycheng@google.com> Acked-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/tcp_input.c')
-rw-r--r--net/ipv4/tcp_input.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index fdd49f1b7a5..a06bb8959e7 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -3732,7 +3732,8 @@ old_ack:
3732 * the fast version below fails. 3732 * the fast version below fails.
3733 */ 3733 */
3734void tcp_parse_options(const struct sk_buff *skb, struct tcp_options_received *opt_rx, 3734void tcp_parse_options(const struct sk_buff *skb, struct tcp_options_received *opt_rx,
3735 const u8 **hvpp, int estab) 3735 const u8 **hvpp, int estab,
3736 struct tcp_fastopen_cookie *foc)
3736{ 3737{
3737 const unsigned char *ptr; 3738 const unsigned char *ptr;
3738 const struct tcphdr *th = tcp_hdr(skb); 3739 const struct tcphdr *th = tcp_hdr(skb);
@@ -3839,8 +3840,25 @@ void tcp_parse_options(const struct sk_buff *skb, struct tcp_options_received *o
3839 break; 3840 break;
3840 } 3841 }
3841 break; 3842 break;
3842 }
3843 3843
3844 case TCPOPT_EXP:
3845 /* Fast Open option shares code 254 using a
3846 * 16 bits magic number. It's valid only in
3847 * SYN or SYN-ACK with an even size.
3848 */
3849 if (opsize < TCPOLEN_EXP_FASTOPEN_BASE ||
3850 get_unaligned_be16(ptr) != TCPOPT_FASTOPEN_MAGIC ||
3851 foc == NULL || !th->syn || (opsize & 1))
3852 break;
3853 foc->len = opsize - TCPOLEN_EXP_FASTOPEN_BASE;
3854 if (foc->len >= TCP_FASTOPEN_COOKIE_MIN &&
3855 foc->len <= TCP_FASTOPEN_COOKIE_MAX)
3856 memcpy(foc->val, ptr + 2, foc->len);
3857 else if (foc->len != 0)
3858 foc->len = -1;
3859 break;
3860
3861 }
3844 ptr += opsize-2; 3862 ptr += opsize-2;
3845 length -= opsize; 3863 length -= opsize;
3846 } 3864 }
@@ -3882,7 +3900,7 @@ static bool tcp_fast_parse_options(const struct sk_buff *skb,
3882 if (tcp_parse_aligned_timestamp(tp, th)) 3900 if (tcp_parse_aligned_timestamp(tp, th))
3883 return true; 3901 return true;
3884 } 3902 }
3885 tcp_parse_options(skb, &tp->rx_opt, hvpp, 1); 3903 tcp_parse_options(skb, &tp->rx_opt, hvpp, 1, NULL);
3886 return true; 3904 return true;
3887} 3905}
3888 3906
@@ -5637,7 +5655,7 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb,
5637 struct tcp_cookie_values *cvp = tp->cookie_values; 5655 struct tcp_cookie_values *cvp = tp->cookie_values;
5638 int saved_clamp = tp->rx_opt.mss_clamp; 5656 int saved_clamp = tp->rx_opt.mss_clamp;
5639 5657
5640 tcp_parse_options(skb, &tp->rx_opt, &hash_location, 0); 5658 tcp_parse_options(skb, &tp->rx_opt, &hash_location, 0, NULL);
5641 5659
5642 if (th->ack) { 5660 if (th->ack) {
5643 /* rfc793: 5661 /* rfc793: