aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2010-05-18 01:35:36 -0400
committerDavid S. Miller <davem@davemloft.net>2010-05-18 01:35:36 -0400
commitde213e5eedecdfb1b1eea7e6be28bc64cac5c078 (patch)
treedee5fa7e4874332b65c95dc2e9ee463a5652c519 /net
parenteedf042a63ffef050ebc015de19b52dc065e830b (diff)
tcp: tcp_synack_options() fix
Commit 33ad798c924b4a (tcp: options clean up) introduced a problem if MD5+SACK+timestamps were used in initial SYN message. Some stacks (old linux for example) try to negotiate MD5+SACK+TSTAMP sessions, but since 40 bytes of tcp options space are not enough to store all the bits needed, we chose to disable timestamps in this case. We send a SYN-ACK _without_ timestamp option, but socket has timestamps enabled and all further outgoing messages contain a TS block, all with the initial timestamp of the remote peer. Fix is to really disable timestamps option for the whole session. Reported-by: Bijay Singh <Bijay.Singh@guavus.com> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/tcp_output.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 18a3302480c..b4ed957f201 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -668,7 +668,6 @@ static unsigned tcp_synack_options(struct sock *sk,
668 u8 cookie_plus = (xvp != NULL && !xvp->cookie_out_never) ? 668 u8 cookie_plus = (xvp != NULL && !xvp->cookie_out_never) ?
669 xvp->cookie_plus : 669 xvp->cookie_plus :
670 0; 670 0;
671 bool doing_ts = ireq->tstamp_ok;
672 671
673#ifdef CONFIG_TCP_MD5SIG 672#ifdef CONFIG_TCP_MD5SIG
674 *md5 = tcp_rsk(req)->af_specific->md5_lookup(sk, req); 673 *md5 = tcp_rsk(req)->af_specific->md5_lookup(sk, req);
@@ -681,7 +680,7 @@ static unsigned tcp_synack_options(struct sock *sk,
681 * rather than TS in order to fit in better with old, 680 * rather than TS in order to fit in better with old,
682 * buggy kernels, but that was deemed to be unnecessary. 681 * buggy kernels, but that was deemed to be unnecessary.
683 */ 682 */
684 doing_ts &= !ireq->sack_ok; 683 ireq->tstamp_ok &= !ireq->sack_ok;
685 } 684 }
686#else 685#else
687 *md5 = NULL; 686 *md5 = NULL;
@@ -696,7 +695,7 @@ static unsigned tcp_synack_options(struct sock *sk,
696 opts->options |= OPTION_WSCALE; 695 opts->options |= OPTION_WSCALE;
697 remaining -= TCPOLEN_WSCALE_ALIGNED; 696 remaining -= TCPOLEN_WSCALE_ALIGNED;
698 } 697 }
699 if (likely(doing_ts)) { 698 if (likely(ireq->tstamp_ok)) {
700 opts->options |= OPTION_TS; 699 opts->options |= OPTION_TS;
701 opts->tsval = TCP_SKB_CB(skb)->when; 700 opts->tsval = TCP_SKB_CB(skb)->when;
702 opts->tsecr = req->ts_recent; 701 opts->tsecr = req->ts_recent;
@@ -704,7 +703,7 @@ static unsigned tcp_synack_options(struct sock *sk,
704 } 703 }
705 if (likely(ireq->sack_ok)) { 704 if (likely(ireq->sack_ok)) {
706 opts->options |= OPTION_SACK_ADVERTISE; 705 opts->options |= OPTION_SACK_ADVERTISE;
707 if (unlikely(!doing_ts)) 706 if (unlikely(!ireq->tstamp_ok))
708 remaining -= TCPOLEN_SACKPERM_ALIGNED; 707 remaining -= TCPOLEN_SACKPERM_ALIGNED;
709 } 708 }
710 709
@@ -712,7 +711,7 @@ static unsigned tcp_synack_options(struct sock *sk,
712 * If the <SYN> options fit, the same options should fit now! 711 * If the <SYN> options fit, the same options should fit now!
713 */ 712 */
714 if (*md5 == NULL && 713 if (*md5 == NULL &&
715 doing_ts && 714 ireq->tstamp_ok &&
716 cookie_plus > TCPOLEN_COOKIE_BASE) { 715 cookie_plus > TCPOLEN_COOKIE_BASE) {
717 int need = cookie_plus; /* has TCPOLEN_COOKIE_BASE */ 716 int need = cookie_plus; /* has TCPOLEN_COOKIE_BASE */
718 717