All of lore.kernel.org
 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 15/28] tcp: add AccECN rx byte counters
Date: Wed, 18 Mar 2020 11:43:19 +0200	[thread overview]
Message-ID: <1584524612-24470-16-git-send-email-ilpo.jarvinen@helsinki.fi> (raw)
In-Reply-To: <1584524612-24470-1-git-send-email-ilpo.jarvinen@helsinki.fi>

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

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@cs.helsinki.fi>
---
 include/linux/tcp.h      |  1 +
 include/net/tcp.h        | 18 +++++++++++++++++-
 net/ipv4/tcp_input.c     | 13 +++++++++----
 net/ipv4/tcp_minisocks.c |  3 ++-
 4 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index a6b1d150cb05..6b81d7eb0117 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -323,6 +323,7 @@ struct tcp_sock {
 	u32	delivered_ce;	/* Like the above but only ECE marked packets */
 	u32	received_ce;	/* Like the above but for received CE marked packets */
 	u32	received_ce_tx; /* Like the above but max transmitted value */
+	u32	received_ecn_bytes[3];
 	u32	lost;		/* Total data packets lost incl. rexmits */
 	u32	app_limited;	/* limited until "delivered" reaches this val */
 	u64	first_tx_mstamp;  /* start of window send phase */
diff --git a/include/net/tcp.h b/include/net/tcp.h
index e1dd06bbb472..5824447b1fc5 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -429,7 +429,8 @@ static inline u32 tcp_accecn_ace_deficit(const struct tcp_sock *tp)
 bool tcp_accecn_validate_syn_feedback(struct sock *sk, u8 ace, u8 sent_ect);
 void tcp_accecn_third_ack(struct sock *sk, const struct sk_buff *skb,
 			  u8 syn_ect_snt);
-void tcp_ecn_received_counters(struct sock *sk, const struct sk_buff *skb);
+void tcp_ecn_received_counters(struct sock *sk, const struct sk_buff *skb,
+			       u32 payload_len);
 
 enum tcp_tw_status {
 	TCP_TW_SUCCESS = 0,
@@ -869,11 +870,26 @@ static inline u64 tcp_skb_timestamp_us(const struct sk_buff *skb)
  * See draft-ietf-tcpm-accurate-ecn for the latest values.
  */
 #define TCP_ACCECN_CEP_INIT_OFFSET 5
+#define TCP_ACCECN_E1B_INIT_OFFSET 0
+#define TCP_ACCECN_E0B_INIT_OFFSET 1
+#define TCP_ACCECN_CEB_INIT_OFFSET 0
+
+static inline void __tcp_accecn_init_bytes_counters(int *counter_array)
+{
+	BUILD_BUG_ON(INET_ECN_ECT_1 != 0x1);
+	BUILD_BUG_ON(INET_ECN_ECT_0 != 0x2);
+	BUILD_BUG_ON(INET_ECN_CE != 0x3);
+
+	counter_array[INET_ECN_ECT_1 - 1] = 0;
+	counter_array[INET_ECN_ECT_0 - 1] = 0;
+	counter_array[INET_ECN_CE - 1] = 0;
+}
 
 static inline void tcp_accecn_init_counters(struct tcp_sock *tp)
 {
 	tp->received_ce = 0;
 	tp->received_ce_tx = 0;
+	__tcp_accecn_init_bytes_counters(tp->received_ecn_bytes);
 }
 
 /* This is what the send packet queuing engine uses to pass
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index bf307be4c659..3109e3199906 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -5559,7 +5559,8 @@ static void tcp_urg(struct sock *sk, struct sk_buff *skb, const struct tcphdr *t
 }
 
 /* Updates Accurate ECN received counters from the received IP ECN field */
-void tcp_ecn_received_counters(struct sock *sk, const struct sk_buff *skb)
+void tcp_ecn_received_counters(struct sock *sk, const struct sk_buff *skb,
+			       u32 payload_len)
 {
 	struct tcp_sock *tp = tcp_sk(sk);
 	u8 ecnfield = TCP_SKB_CB(skb)->ip_dsfield & INET_ECN_MASK;
@@ -5570,6 +5571,10 @@ void tcp_ecn_received_counters(struct sock *sk, const struct sk_buff *skb)
 
 		/* ACE counter tracks *all* segments including pure acks */
 		tp->received_ce += is_ce * max_t(u16, 1, skb_shinfo(skb)->gso_segs);
+
+		if (payload_len > 0) {
+			tp->received_ecn_bytes[ecnfield - 1] += payload_len;
+		}
 	}
 }
 
@@ -5808,7 +5813,7 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb)
 				    tp->rcv_nxt == tp->rcv_wup)
 					flag |= __tcp_replace_ts_recent(tp, tstamp_delta);
 
-				tcp_ecn_received_counters(sk, skb);
+				tcp_ecn_received_counters(sk, skb, 0);
 
 				/* We know that such packets are checksummed
 				 * on entry.
@@ -5851,7 +5856,7 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb)
 
 			/* Bulk data transfer: receiver */
 			__skb_pull(skb, tcp_header_len);
-			tcp_ecn_received_counters(sk, skb);
+			tcp_ecn_received_counters(sk, skb, len - tcp_header_len);
 			eaten = tcp_queue_rcv(sk, skb, &fragstolen);
 
 			tcp_event_data_recv(sk, skb);
@@ -5888,7 +5893,7 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb)
 		return;
 
 step5:
-	tcp_ecn_received_counters(sk, skb);
+	tcp_ecn_received_counters(sk, skb, len - th->doff * 4);
 
 	if (tcp_ack(sk, skb, FLAG_SLOWPATH | FLAG_UPDATE_TS_RECENT) < 0)
 		goto discard;
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index 57b7cf4658fc..668edd00e377 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -433,10 +433,11 @@ static void tcp_ecn_openreq_child(struct sock *sk,
 	const struct tcp_request_sock *treq = tcp_rsk(req);
 
 	if (treq->accecn_ok) {
+		const struct tcphdr *th = (const struct tcphdr *)skb->data;
 		tcp_ecn_mode_set(tp, TCP_ECN_MODE_ACCECN);
 		tp->syn_ect_snt = treq->syn_ect_snt;
 		tcp_accecn_third_ack(sk, skb, treq->syn_ect_snt);
-		tcp_ecn_received_counters(sk, skb);
+		tcp_ecn_received_counters(sk, skb, skb->len - th->doff * 4);
 	} else {
 		tcp_ecn_mode_set(tp, inet_rsk(req)->ecn_ok ?
 				     TCP_ECN_MODE_RFC3168 :
-- 
2.20.1


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

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-18  9:43 [RFC PATCH 00/28]: Accurate ECN for TCP Ilpo Järvinen
2020-03-18  9:43 ` [RFC PATCH 01/28] tcp: add tp to prepare for AccECN code Ilpo Järvinen
2020-03-18  9:43 ` [RFC PATCH 02/28] tcp: fast path functions later Ilpo Järvinen
2020-03-18  9:43 ` [RFC PATCH 03/28] tcp: move tcp_in_ack_event later Ilpo Järvinen
2020-03-18  9:43 ` [RFC PATCH 04/28] tcp: create FLAG_TS_PROGRESS Ilpo Järvinen
2020-03-18  9:43 ` [RFC PATCH 05/28] tcp: extend TCP flags to allow AE bit/ACE field Ilpo Järvinen
2020-03-18  9:43 ` [RFC PATCH 06/28] tcp: reorganize SYN ECN code Ilpo Järvinen
2020-03-18  9:43 ` [RFC PATCH 07/28] tcp: rework {__,}tcp_ecn_check_ce() -> tcp_data_ecn_check() Ilpo Järvinen
2020-03-18  9:43 ` [RFC PATCH 08/28] tcp: helpers for ECN mode handling Ilpo Järvinen
2020-03-18  9:43 ` [RFC PATCH 09/28] gso: AccECN support Ilpo Järvinen
2020-03-19  3:44   ` Eric Dumazet
2020-03-19 22:36     ` Ilpo Järvinen
2020-03-18  9:43 ` [RFC PATCH 10/28] gro: prevent ACE field corruption & better AccECN handling Ilpo Järvinen
2020-03-18  9:43 ` [RFC PATCH 11/28] tcp: AccECN support to tcp_add_backlog Ilpo Järvinen
2020-03-18  9:43 ` [RFC PATCH 12/28] tcp: AccECN core Ilpo Järvinen
2020-03-18  9:43 ` [RFC PATCH 13/28] tcp: Pass flags to tcp_send_ack Ilpo Järvinen
2020-03-18  9:43 ` [RFC PATCH 14/28] tcp: AccECN negotiation Ilpo Järvinen
2020-03-18  9:43 ` Ilpo Järvinen [this message]
2020-03-19  3:36   ` [RFC PATCH 15/28] tcp: add AccECN rx byte counters Eric Dumazet
2020-03-18  9:43 ` [RFC PATCH 16/28] tcp: allow embedding leftover into option padding Ilpo Järvinen
2020-03-18  9:43 ` [RFC PATCH 17/28] tcp: AccECN needs to know delivered bytes Ilpo Järvinen
2020-03-18  9:43 ` [RFC PATCH 18/28] tcp: don't early return when sack doesn't fit Ilpo Järvinen
2020-03-18  9:43 ` [RFC PATCH 19/28] tcp: AccECN option Ilpo Järvinen
2020-03-18  9:43 ` [RFC PATCH 20/28] tcp: AccECN option send control Ilpo Järvinen
2020-03-18  9:43 ` [RFC PATCH 21/28] tcp: AccECN option beacon Ilpo Järvinen
2020-03-18  9:43 ` [RFC PATCH 22/28] tcp: AccECN option order bit & failure handling Ilpo Järvinen
2020-03-18  9:43 ` [RFC PATCH 23/28] tcp: AccECN option ceb/cep heuristic Ilpo Järvinen
2020-03-18  9:43 ` [RFC PATCH 24/28] tcp: try to fit AccECN option with SACK Ilpo Järvinen
2020-03-19  3:29   ` Eric Dumazet
2020-03-19 20:33     ` Ilpo Järvinen
2020-03-18  9:43 ` [RFC PATCH 25/28] tcp: try to avoid safer when ACKs are thinned Ilpo Järvinen
2020-03-18  9:43 ` [RFC PATCH 26/28] tcp: to prevent runaway AccECN cep/ACE deficit, limit GSO size Ilpo Järvinen
2020-03-18  9:43 ` [RFC PATCH 27/28] gro: flushing when CWR is set negatively affects AccECN Ilpo Järvinen
2020-03-18  9:43 ` [RFC PATCH 28/28] tcp: AccECN sysctl documentation Ilpo Järvinen
2020-03-19 23:02   ` Dave Taht
2020-03-20 22:40     ` Ilpo Järvinen
2020-03-20 23:22       ` Yuchung Cheng
2020-03-23 13:34         ` Ilpo Järvinen
2020-03-23 19:03           ` Yuchung Cheng
2020-03-24 12:50             ` Ilpo Järvinen
2020-03-24 17:05               ` Yuchung Cheng
2020-03-18 23:29 ` [RFC PATCH 00/28]: Accurate ECN for TCP David Miller
2020-03-19 20:25   ` Ilpo Järvinen
2020-03-20  4:38     ` David Miller
  -- strict thread matches above, loose matches on Subject: below --
2020-03-18  9:37 [RFC PATCH 02/28] tcp: fast path functions later Ilpo Järvinen
2020-03-18  9:37 ` [RFC PATCH 15/28] tcp: add AccECN rx byte counters 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=1584524612-24470-16-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.