aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp_input.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4/tcp_input.c')
-rw-r--r--net/ipv4/tcp_input.c37
1 files changed, 29 insertions, 8 deletions
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 432c36649db3..181fc8234a52 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -4529,6 +4529,9 @@ int tcp_send_rcvq(struct sock *sk, struct msghdr *msg, size_t size)
4529 struct tcphdr *th; 4529 struct tcphdr *th;
4530 bool fragstolen; 4530 bool fragstolen;
4531 4531
4532 if (size == 0)
4533 return 0;
4534
4532 skb = alloc_skb(size + sizeof(*th), sk->sk_allocation); 4535 skb = alloc_skb(size + sizeof(*th), sk->sk_allocation);
4533 if (!skb) 4536 if (!skb)
4534 goto err; 4537 goto err;
@@ -5310,11 +5313,6 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb,
5310 goto discard; 5313 goto discard;
5311 } 5314 }
5312 5315
5313 /* ts_recent update must be made after we are sure that the packet
5314 * is in window.
5315 */
5316 tcp_replace_ts_recent(tp, TCP_SKB_CB(skb)->seq);
5317
5318 /* step 3: check security and precedence [ignored] */ 5316 /* step 3: check security and precedence [ignored] */
5319 5317
5320 /* step 4: Check for a SYN 5318 /* step 4: Check for a SYN
@@ -5549,6 +5547,11 @@ step5:
5549 if (th->ack && tcp_ack(sk, skb, FLAG_SLOWPATH) < 0) 5547 if (th->ack && tcp_ack(sk, skb, FLAG_SLOWPATH) < 0)
5550 goto discard; 5548 goto discard;
5551 5549
5550 /* ts_recent update must be made after we are sure that the packet
5551 * is in window.
5552 */
5553 tcp_replace_ts_recent(tp, TCP_SKB_CB(skb)->seq);
5554
5552 tcp_rcv_rtt_measure_ts(sk, skb); 5555 tcp_rcv_rtt_measure_ts(sk, skb);
5553 5556
5554 /* Process urgent data. */ 5557 /* Process urgent data. */
@@ -5642,10 +5645,15 @@ static bool tcp_rcv_fastopen_synack(struct sock *sk, struct sk_buff *synack,
5642 tcp_fastopen_cache_set(sk, mss, cookie, syn_drop); 5645 tcp_fastopen_cache_set(sk, mss, cookie, syn_drop);
5643 5646
5644 if (data) { /* Retransmit unacked data in SYN */ 5647 if (data) { /* Retransmit unacked data in SYN */
5645 tcp_retransmit_skb(sk, data); 5648 tcp_for_write_queue_from(data, sk) {
5649 if (data == tcp_send_head(sk) ||
5650 __tcp_retransmit_skb(sk, data))
5651 break;
5652 }
5646 tcp_rearm_rto(sk); 5653 tcp_rearm_rto(sk);
5647 return true; 5654 return true;
5648 } 5655 }
5656 tp->syn_data_acked = tp->syn_data;
5649 return false; 5657 return false;
5650} 5658}
5651 5659
@@ -5963,7 +5971,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
5963 5971
5964 req = tp->fastopen_rsk; 5972 req = tp->fastopen_rsk;
5965 if (req != NULL) { 5973 if (req != NULL) {
5966 BUG_ON(sk->sk_state != TCP_SYN_RECV && 5974 WARN_ON_ONCE(sk->sk_state != TCP_SYN_RECV &&
5967 sk->sk_state != TCP_FIN_WAIT1); 5975 sk->sk_state != TCP_FIN_WAIT1);
5968 5976
5969 if (tcp_check_req(sk, skb, req, NULL, true) == NULL) 5977 if (tcp_check_req(sk, skb, req, NULL, true) == NULL)
@@ -6052,7 +6060,15 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
6052 * ACK we have received, this would have acknowledged 6060 * ACK we have received, this would have acknowledged
6053 * our SYNACK so stop the SYNACK timer. 6061 * our SYNACK so stop the SYNACK timer.
6054 */ 6062 */
6055 if (acceptable && req != NULL) { 6063 if (req != NULL) {
6064 /* Return RST if ack_seq is invalid.
6065 * Note that RFC793 only says to generate a
6066 * DUPACK for it but for TCP Fast Open it seems
6067 * better to treat this case like TCP_SYN_RECV
6068 * above.
6069 */
6070 if (!acceptable)
6071 return 1;
6056 /* We no longer need the request sock. */ 6072 /* We no longer need the request sock. */
6057 reqsk_fastopen_remove(sk, req, false); 6073 reqsk_fastopen_remove(sk, req, false);
6058 tcp_rearm_rto(sk); 6074 tcp_rearm_rto(sk);
@@ -6118,6 +6134,11 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
6118 } else 6134 } else
6119 goto discard; 6135 goto discard;
6120 6136
6137 /* ts_recent update must be made after we are sure that the packet
6138 * is in window.
6139 */
6140 tcp_replace_ts_recent(tp, TCP_SKB_CB(skb)->seq);
6141
6121 /* step 6: check the URG bit */ 6142 /* step 6: check the URG bit */
6122 tcp_urg(sk, skb, th); 6143 tcp_urg(sk, skb, th);
6123 6144