From nobody Thu Nov 10 11:09:50 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4N7JyQ70N3z4cJ8L; Thu, 10 Nov 2022 11:09:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4N7JyQ6Sw6z3sPZ; Thu, 10 Nov 2022 11:09:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668078590; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=srIU8FsvwxaVmCzkki5C0KYQoFzI/sg+LJlapqwHapM=; b=vFUgi1zpIQiwyafnNMtQo9Wq5fhTEo3BTcfEtijrfhkAS7B9A6hw10jMRS/gLSyHDQyiMu 8rLU724dzZnQ1vEXGQT8qrhCxBmtkjBeKpffGl37GHiDltKewUMkN6uXXKPg+UU0GJQAln tvI5ssTSJ7G3Ir33s2fSCHff0is5S5kWsHpsST21uLONw5VeUC1VoF1NIrr8yb2VSqiwB2 zj9MvwUAiDWmwZk/IKTO68Xhj8CPZPtmK+MF/hf4+eaMsmWrBK2pUxDxUTzl8gPKw3DfM8 JCr3izdbgqR07kwvhPW0NL8FEHOzHXkgReDrJpIzFV3Gg9UJ1jp+5g+/ql1c4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668078590; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=srIU8FsvwxaVmCzkki5C0KYQoFzI/sg+LJlapqwHapM=; b=MY2jcaVaSWmV0r9rXVmi/DLOSFWrRCExGbMDwGOBqfwMWaF9K/+n8YANyhJpk7WCB0GH3i i/RmuxufL8D1+GZC3Mjxr0TbVEQD+Q2WA/tbz+KASU3O2Q5CdQct7bjZgoTAYaiGqwkP0/ eubYP747js7p/y5KM9oGaqOiL01j0BanvHscSYPEENf2Pso1RADUn2ZYXxgERuTk+nT0JS 2DQfPgZGtZT7QO7Qq5RpTyHP3VQ6ltHJ3UYP4FiKvHAGTduPkD6CVux2p9qjodCAXwDxW4 gwyLIa3Ye2jnhaSyuw8qBYyqLZyePfyhkz/8Rhd8eUeukSlH4vpw4fSEX+2XSg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1668078590; a=rsa-sha256; cv=none; b=n/LB/50/ZK2ATxnreNAF1cAhh4nwLygJntno1uVYCE8EJ02eLsYEV1Kti7XI+pBmTDa/BX ckBlIXjT0KeIxUUkWSWk2voKic47JoGWuleC0MSgwGkc5Mp9y/8roHuIzpjYLaO+/BnCLE ZCNGOU+Qigmv1EqJU1n8L70xELm2KxFZc1bZQHMhzvEHvKg+OFUfIbCQHZreRdmOIb7R23 nq46T1gFjkBn9h7nPQlZqgd+MwkHaebCP9f5qEZyoLADrTxVaIFxo70UL4DxNX4xWc5xLO JFAx9jprNo+zbDzOUlZaRmWjDwK7FPVi1uqV2iSmowZ81bHWeH2c6uR/kjILog== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4N7JyQ5V7yzybh; Thu, 10 Nov 2022 11:09:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2AAB9okT005140; Thu, 10 Nov 2022 11:09:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2AAB9ofG005139; Thu, 10 Nov 2022 11:09:50 GMT (envelope-from git) Date: Thu, 10 Nov 2022 11:09:50 GMT Message-Id: <202211101109.2AAB9ofG005139@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Richard Scheffenegger Subject: git: 1a70101a8700 - main - tcp: account sent/received IP ECN markings independently List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rscheff X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1a70101a870015304d5b2446b480d8677d8aad36 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rscheff: URL: https://cgit.FreeBSD.org/src/commit/?id=1a70101a870015304d5b2446b480d8677d8aad36 commit 1a70101a870015304d5b2446b480d8677d8aad36 Author: Richard Scheffenegger AuthorDate: 2022-11-10 10:35:02 +0000 Commit: Richard Scheffenegger CommitDate: 2022-11-10 10:35:35 +0000 tcp: account sent/received IP ECN markings independently Have tcpstats (netstat -s) differentiate between received and sent ECN-marked packets. Also account for IP ECN bits (on TCP packets) even when the tcp session has not negotiated ECN support. Event: IETF 115 Hackathon Reviewed By: glebius, tuexen, #transport Sponsored by: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D37314 --- sys/netinet/tcp_ecn.c | 40 ++++++++++++++++++++++++++-------------- sys/netinet/tcp_var.h | 12 ++++++++---- usr.bin/netstat/inet.c | 16 ++++++++++------ 3 files changed, 44 insertions(+), 24 deletions(-) diff --git a/sys/netinet/tcp_ecn.c b/sys/netinet/tcp_ecn.c index 8e3e38ddabfc..5b19ed93225f 100644 --- a/sys/netinet/tcp_ecn.c +++ b/sys/netinet/tcp_ecn.c @@ -288,19 +288,19 @@ tcp_ecn_input_segment(struct tcpcb *tp, uint16_t thflags, int tlen, int pkts, in { int delta_cep = 0; - if (tp->t_flags2 & (TF2_ECN_PERMIT | TF2_ACE_PERMIT)) { - switch (iptos & IPTOS_ECN_MASK) { - case IPTOS_ECN_CE: - TCPSTAT_INC(tcps_ecn_ce); - break; - case IPTOS_ECN_ECT0: - TCPSTAT_INC(tcps_ecn_ect0); - break; - case IPTOS_ECN_ECT1: - TCPSTAT_INC(tcps_ecn_ect1); - break; - } + switch (iptos & IPTOS_ECN_MASK) { + case IPTOS_ECN_CE: + TCPSTAT_INC(tcps_ecn_rcvce); + break; + case IPTOS_ECN_ECT0: + TCPSTAT_INC(tcps_ecn_rcvect0); + break; + case IPTOS_ECN_ECT1: + TCPSTAT_INC(tcps_ecn_rcvect1); + break; + } + if (tp->t_flags2 & (TF2_ECN_PERMIT | TF2_ACE_PERMIT)) { if (tp->t_flags2 & TF2_ACE_PERMIT) { if ((iptos & IPTOS_ECN_MASK) == IPTOS_ECN_CE) tp->t_rcep += 1; @@ -413,10 +413,10 @@ tcp_ecn_output_established(struct tcpcb *tp, uint16_t *thflags, int len, bool rx if (newdata) { if (tp->t_flags2 & TF2_ECN_USE_ECT1) { ipecn = IPTOS_ECN_ECT1; - TCPSTAT_INC(tcps_ecn_ect1); + TCPSTAT_INC(tcps_ecn_sndect1); } else { ipecn = IPTOS_ECN_ECT0; - TCPSTAT_INC(tcps_ecn_ect0); + TCPSTAT_INC(tcps_ecn_sndect0); } } /* @@ -497,6 +497,18 @@ tcp_ecn_syncache_add(uint16_t thflags, int iptos) { int scflags = 0; + switch (iptos & IPTOS_ECN_MASK) { + case IPTOS_ECN_CE: + TCPSTAT_INC(tcps_ecn_rcvce); + break; + case IPTOS_ECN_ECT0: + TCPSTAT_INC(tcps_ecn_rcvect0); + break; + case IPTOS_ECN_ECT1: + TCPSTAT_INC(tcps_ecn_rcvect1); + break; + } + switch (thflags & (TH_AE|TH_CWR|TH_ECE)) { /* no ECN */ case (0|0|0): diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index 2cfc1ff3f21a..3cfbad75085d 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -787,9 +787,9 @@ struct tcpstat { uint64_t tcps_sack_sboverflow; /* times scoreboard overflowed */ /* ECN related stats */ - uint64_t tcps_ecn_ce; /* ECN Congestion Experienced */ - uint64_t tcps_ecn_ect0; /* ECN Capable Transport */ - uint64_t tcps_ecn_ect1; /* ECN Capable Transport */ + uint64_t tcps_ecn_rcvce; /* ECN Congestion Experienced */ + uint64_t tcps_ecn_rcvect0; /* ECN Capable Transport */ + uint64_t tcps_ecn_rcvect1; /* ECN Capable Transport */ uint64_t tcps_ecn_shs; /* ECN successful handshakes */ uint64_t tcps_ecn_rcwnd; /* # times ECN reduced the cwnd */ @@ -824,7 +824,11 @@ struct tcpstat { uint64_t tcps_ace_ect0; /* ACE SYN packet with ECT0 */ uint64_t tcps_ace_ce; /* ACE SYN packet with CE */ - uint64_t _pad[6]; /* 6 TBD placeholder for STABLE */ + /* ECN related stats */ + uint64_t tcps_ecn_sndect0; /* ECN Capable Transport */ + uint64_t tcps_ecn_sndect1; /* ECN Capable Transport */ + + uint64_t _pad[4]; /* 4 TBD placeholder for STABLE */ }; #define tcps_rcvmemdrop tcps_rcvreassfull /* compat */ diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c index c295f34a96c6..a16f09d391fb 100644 --- a/usr.bin/netstat/inet.c +++ b/usr.bin/netstat/inet.c @@ -818,12 +818,16 @@ tcp_stats(u_long off, const char *name, int af1 __unused, int proto __unused) xo_close_container("sack"); xo_open_container("ecn"); - p(tcps_ecn_ce, "\t{:ce-packets/%ju} " - "{N:/packet%s with ECN CE bit set}\n"); - p(tcps_ecn_ect0, "\t{:ect0-packets/%ju} " - "{N:/packet%s with ECN ECT(0) bit set}\n"); - p(tcps_ecn_ect1, "\t{:ect1-packets/%ju} " - "{N:/packet%s with ECN ECT(1) bit set}\n"); + p(tcps_ecn_rcvce, "\t{:received-ce-packets/%ju} " + "{N:/packet%s received with ECN CE bit set}\n"); + p(tcps_ecn_rcvect0, "\t{:received-ect0-packets/%ju} " + "{N:/packet%s received with ECN ECT(0) bit set}\n"); + p(tcps_ecn_rcvect1, "\t{:received-ect1-packets/%ju} " + "{N:/packet%s received with ECN ECT(1) bit set}\n"); + p(tcps_ecn_sndect0, "\t{:sent-ect0-packets/%ju} " + "{N:/packet%s sent with ECN ECT(0) bit set}\n"); + p(tcps_ecn_sndect1, "\t{:sent-ect1-packets/%ju} " + "{N:/packet%s sent with ECN ECT(1) bit set}\n"); p(tcps_ecn_shs, "\t{:handshakes/%ju} " "{N:/successful ECN handshake%s}\n"); p(tcps_ecn_rcwnd, "\t{:congestion-reductions/%ju} "