netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@helsinki.fi>
To: netdev@vger.kernel.org
Cc: Yuchung Cheng <ycheng@google.com>,
	Neal Cardwell <ncardwell@google.com>,
	Eric Dumazet <eric.dumazet@gmail.com>,
	Olivier Tilmans <olivier.tilmans@nokia-bell-labs.com>
Subject: [RFC PATCH 04/28] tcp: create FLAG_TS_PROGRESS
Date: Wed, 18 Mar 2020 11:37:45 +0200	[thread overview]
Message-ID: <1584524289-24187-4-git-send-email-ilpo.jarvinen@helsinki.fi> (raw)
In-Reply-To: <1584524289-24187-2-git-send-email-ilpo.jarvinen@helsinki.fi>

From: Ilpo Järvinen <ilpo.jarvinen@cs.helsinki.fi>

Whenever timestamp advances, it declares progress which
can be used the other parts of the stack to decide that
the ACK is the most recent one seen so far.

AccECN will use this flag when deciding whether to update
CEP from the ACE field or not.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@cs.helsinki.fi>
---
 net/ipv4/tcp_input.c | 34 +++++++++++++++++++++++++---------
 1 file changed, 25 insertions(+), 9 deletions(-)

diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 860938e0f1b6..7c444541cefd 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -100,6 +100,7 @@ int sysctl_tcp_max_orphans __read_mostly = NR_FILE;
 #define FLAG_UPDATE_TS_RECENT	0x4000 /* tcp_replace_ts_recent() */
 #define FLAG_NO_CHALLENGE_ACK	0x8000 /* do not call tcp_send_challenge_ack()	*/
 #define FLAG_ACK_MAYBE_DELAYED	0x10000 /* Likely a delayed ACK */
+#define FLAG_TS_PROGRESS	0x20000 /* Positive timestamp delta */
 
 #define FLAG_ACKED		(FLAG_DATA_ACKED|FLAG_SYN_ACKED)
 #define FLAG_NOT_DUP		(FLAG_DATA|FLAG_WIN_UPDATE|FLAG_ACKED)
@@ -3492,8 +3493,16 @@ static void tcp_store_ts_recent(struct tcp_sock *tp)
 	tp->rx_opt.ts_recent_stamp = ktime_get_seconds();
 }
 
-static void tcp_replace_ts_recent(struct tcp_sock *tp, u32 seq)
+static int __tcp_replace_ts_recent(struct tcp_sock *tp, s32 tstamp_delta)
 {
+	tcp_store_ts_recent(tp);
+	return tstamp_delta > 0 ? FLAG_TS_PROGRESS : 0;
+}
+
+static int tcp_replace_ts_recent(struct tcp_sock *tp, u32 seq)
+{
+	s32 delta;
+
 	if (tp->rx_opt.saw_tstamp && !after(seq, tp->rcv_wup)) {
 		/* PAWS bug workaround wrt. ACK frames, the PAWS discard
 		 * extra check below makes sure this can only happen
@@ -3502,9 +3511,13 @@ static void tcp_replace_ts_recent(struct tcp_sock *tp, u32 seq)
 		 * Not only, also it occurs for expired timestamps.
 		 */
 
-		if (tcp_paws_check(&tp->rx_opt, 0))
-			tcp_store_ts_recent(tp);
+		if (tcp_paws_check(&tp->rx_opt, 0)) {
+			delta = tp->rx_opt.rcv_tsval - tp->rx_opt.ts_recent;
+			return __tcp_replace_ts_recent(tp, delta);
+		}
 	}
+
+	return 0;
 }
 
 /* This routine deals with acks during a TLP episode.
@@ -3656,7 +3669,7 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)
 	 * is in window.
 	 */
 	if (flag & FLAG_UPDATE_TS_RECENT)
-		tcp_replace_ts_recent(tp, TCP_SKB_CB(skb)->seq);
+		flag |= tcp_replace_ts_recent(tp, TCP_SKB_CB(skb)->seq);
 
 	if ((flag & (FLAG_SLOWPATH | FLAG_SND_UNA_ADVANCED)) ==
 	    FLAG_SND_UNA_ADVANCED) {
@@ -5608,6 +5621,8 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb)
 	    TCP_SKB_CB(skb)->seq == tp->rcv_nxt &&
 	    !after(TCP_SKB_CB(skb)->ack_seq, tp->snd_nxt)) {
 		int tcp_header_len = tp->tcp_header_len;
+		int flag = 0;
+		s32 tstamp_delta = 0;
 
 		/* Timestamp header prediction: tcp_header_len
 		 * is automatically equal to th->doff*4 due to pred_flags
@@ -5620,8 +5635,9 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb)
 			if (!tcp_parse_aligned_timestamp(tp, th))
 				goto slow_path;
 
+			tstamp_delta = tp->rx_opt.rcv_tsval - tp->rx_opt.ts_recent;
 			/* If PAWS failed, check it more carefully in slow path */
-			if ((s32)(tp->rx_opt.rcv_tsval - tp->rx_opt.ts_recent) < 0)
+			if (tstamp_delta < 0)
 				goto slow_path;
 
 			/* DO NOT update ts_recent here, if checksum fails
@@ -5641,12 +5657,12 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb)
 				if (tcp_header_len ==
 				    (sizeof(struct tcphdr) + TCPOLEN_TSTAMP_ALIGNED) &&
 				    tp->rcv_nxt == tp->rcv_wup)
-					tcp_store_ts_recent(tp);
+					flag |= __tcp_replace_ts_recent(tp, tstamp_delta);
 
 				/* We know that such packets are checksummed
 				 * on entry.
 				 */
-				tcp_ack(sk, skb, 0);
+				tcp_ack(sk, skb, flag);
 				__kfree_skb(skb);
 				tcp_data_snd_check(sk);
 				/* When receiving pure ack in fast path, update
@@ -5676,7 +5692,7 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb)
 			if (tcp_header_len ==
 			    (sizeof(struct tcphdr) + TCPOLEN_TSTAMP_ALIGNED) &&
 			    tp->rcv_nxt == tp->rcv_wup)
-				tcp_store_ts_recent(tp);
+				flag |= __tcp_replace_ts_recent(tp, tstamp_delta);
 
 			tcp_rcv_rtt_measure_ts(sk, skb);
 
@@ -5690,7 +5706,7 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb)
 
 			if (TCP_SKB_CB(skb)->ack_seq != tp->snd_una) {
 				/* Well, only one small jumplet in fast path... */
-				tcp_ack(sk, skb, FLAG_DATA);
+				tcp_ack(sk, skb, flag | FLAG_DATA);
 				tcp_data_snd_check(sk);
 				if (!inet_csk_ack_scheduled(sk))
 					goto no_ack;
-- 
2.20.1


  parent reply	other threads:[~2020-03-18  9:47 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-18  9:37 [RFC PATCH 02/28] tcp: fast path functions later Ilpo Järvinen
2020-03-18  9:37 ` [RFC PATCH 03/28] tcp: move tcp_in_ack_event later Ilpo Järvinen
2020-03-18  9:37 ` Ilpo Järvinen [this message]
2020-03-18  9:37 ` [RFC PATCH 05/28] tcp: extend TCP flags to allow AE bit/ACE field Ilpo Järvinen
2020-03-18  9:37 ` [RFC PATCH 06/28] tcp: reorganize SYN ECN code Ilpo Järvinen
2020-03-18  9:37 ` [RFC PATCH 07/28] tcp: rework {__,}tcp_ecn_check_ce() -> tcp_data_ecn_check() Ilpo Järvinen
2020-03-18  9:37 ` [RFC PATCH 08/28] tcp: helpers for ECN mode handling Ilpo Järvinen
2020-03-18  9:37 ` [RFC PATCH 09/28] gso: AccECN support Ilpo Järvinen
2020-03-18  9:37 ` [RFC PATCH 10/28] gro: prevent ACE field corruption & better AccECN handling Ilpo Järvinen
2020-03-18  9:37 ` [RFC PATCH 11/28] tcp: AccECN support to tcp_add_backlog Ilpo Järvinen
2020-03-18  9:37 ` [RFC PATCH 12/28] tcp: AccECN core Ilpo Järvinen
2020-03-18  9:37 ` [RFC PATCH 13/28] tcp: Pass flags to tcp_send_ack Ilpo Järvinen
2020-03-18  9:37 ` [RFC PATCH 14/28] tcp: AccECN negotiation Ilpo Järvinen
2020-03-18  9:37 ` [RFC PATCH 15/28] tcp: add AccECN rx byte counters Ilpo Järvinen
2020-03-18  9:37 ` [RFC PATCH 16/28] tcp: allow embedding leftover into option padding Ilpo Järvinen
2020-03-18  9:37 ` [RFC PATCH 17/28] tcp: AccECN needs to know delivered bytes Ilpo Järvinen
2020-03-18  9:37 ` [RFC PATCH 18/28] tcp: don't early return when sack doesn't fit Ilpo Järvinen
2020-03-18  9:38 ` [RFC PATCH 19/28] tcp: AccECN option Ilpo Järvinen
2020-03-18  9:38 ` [RFC PATCH 20/28] tcp: AccECN option send control Ilpo Järvinen
2020-03-18  9:38 ` [RFC PATCH 21/28] tcp: AccECN option beacon Ilpo Järvinen
2020-03-18  9:38 ` [RFC PATCH 22/28] tcp: AccECN option order bit & failure handling Ilpo Järvinen
2020-03-18  9:38 ` [RFC PATCH 23/28] tcp: AccECN option ceb/cep heuristic Ilpo Järvinen
2020-03-18  9:38 ` [RFC PATCH 24/28] tcp: try to fit AccECN option with SACK Ilpo Järvinen
2020-03-18  9:38 ` [RFC PATCH 25/28] tcp: try to avoid safer when ACKs are thinned Ilpo Järvinen
2020-03-18  9:38 ` [RFC PATCH 26/28] tcp: to prevent runaway AccECN cep/ACE deficit, limit GSO size Ilpo Järvinen
2020-03-18  9:38 ` [RFC PATCH 27/28] gro: flushing when CWR is set negatively affects AccECN Ilpo Järvinen
2020-03-18  9:38 ` [RFC PATCH 28/28] tcp: AccECN sysctl documentation Ilpo Järvinen
2020-03-18  9:43 [RFC PATCH 00/28]: Accurate ECN for TCP Ilpo Järvinen
2020-03-18  9:43 ` [RFC PATCH 04/28] tcp: create FLAG_TS_PROGRESS Ilpo Järvinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1584524289-24187-4-git-send-email-ilpo.jarvinen@helsinki.fi \
    --to=ilpo.jarvinen@helsinki.fi \
    --cc=eric.dumazet@gmail.com \
    --cc=ncardwell@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=olivier.tilmans@nokia-bell-labs.com \
    --cc=ycheng@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).