From nobody Tue Feb 08 15:13:40 2022 X-Original-To: dev-commits-src-branches@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 633D319C2ABB; Tue, 8 Feb 2022 15:13:41 +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 4JtRNh6tkcz4dZW; Tue, 8 Feb 2022 15:13:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644333221; 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=9B3V/JOxaepmyytGeqjPmaebeO5+kwsFxsB4kJIrJLM=; b=EeYC7RUVMtJwT3aNpRJtnNOt0xE5lBnsopAF7Lc6h0eseEikVsGKSITMeuFY/b72wsdUie sR6xLbWQwdkGgwZwnjMEeGGbK0V7h9pxtI6b+o1EAoEXr9LPXnkuBLg/GWZnRoaEttrWte e82O4bCknXLXStPN4FEK8qGFQAIGtKOjaxACy8zz7cC7K2Y2eFi4mcbEYXGwG/SGzFQa2/ fKf6zDAj/Ex1M2elm4XUhREfEvXq9+otAwxWQh/SS/mEUOYr+TfxXt0Hy/fgB+wzvunJM+ QRwOB2oR7LzcvkE2uZDQZd7U090hpvP408S87gnZsoIjdw8o73Env5bQg85RJg== 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 462261BA6E; Tue, 8 Feb 2022 15:13:40 +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 218FDegc020257; Tue, 8 Feb 2022 15:13:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 218FDeAJ020256; Tue, 8 Feb 2022 15:13:40 GMT (envelope-from git) Date: Tue, 8 Feb 2022 15:13:40 GMT Message-Id: <202202081513.218FDeAJ020256@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Hans Petter Selasky Subject: git: 22b24dc1abb3 - stable/13 - LRO: Fix lost packets when merging 1 payload with an ACK List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 22b24dc1abb3bc41c9b54054c2242b525daa5bfc Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644333221; 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=9B3V/JOxaepmyytGeqjPmaebeO5+kwsFxsB4kJIrJLM=; b=Y6pfnZtm/+USNMPGkzQ5IgHLOTukC7SQYY60k2IdLepafgQRY0SKYm1O0qkpOmKkezKqH4 KB+1L58qwOBtbbsB8FubZS94lMKXgCpJ8nVE1pgMKxHVWMpV8a7PEhhR+iGHFMrqSjlaNT +ExRBMeej16gt+Br4VRP4cdt5kuEWgUKl2TUGy9/e54ai8J9bANPP4AW6FAuFvqNbXSVgK S+VMqS8/AhfpetVqHFlnSNgAVIGt/qbNclrjo4gjJyyBZWenDLmwkwwDTLJmOWlsq3J+aJ +hO1GsUmfH263OgkoBW1TboATGTY2qjMBrktZH3P5F92pWPLLVbwhIOpNqnYrQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1644333221; a=rsa-sha256; cv=none; b=MP+rN0VxruOo2M64lGBF+BIHCBhzP60BdWsHvKHOZ94AWuTncZTYTdHIv2WtD8mERvQgxM kuj9ER2KUo/2ARAp2CjzCtJQQnqLyEcSxd2UZK0EM/aUxPJ5ihtILKb6QI7MP31H8Xz9FD f3df9wnHWsIoX9Dte/NzuhWHgcdK9rGnS3mYTAtodb1j0378K69Ga3evWDIKk4VktlOoWT EEQqvJVBoonATHC5EfgMtkljC73Y/I9OboRgvJrSbsOFRu9RJnVc5WYae+xpCFxEwuK3N3 bTAdFfNhnePhvKnMMo0mRA0goN08BgLPxZ7DHV0hvEW94stntCP47OvHxfkfzA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=22b24dc1abb3bc41c9b54054c2242b525daa5bfc commit 22b24dc1abb3bc41c9b54054c2242b525daa5bfc Author: Ryan Stone AuthorDate: 2022-02-08 15:08:50 +0000 Commit: Hans Petter Selasky CommitDate: 2022-02-08 15:08:50 +0000 LRO: Fix lost packets when merging 1 payload with an ACK To check if it needed to regenerate a packet's header before sending it up the stack, LRO was checking if more than one payload had been merged into the packet. This failed in the case where a single payload was merged with one or more pure ACKs. This results in lost ACKs. Fix this by precisely tracking whether header regeneration is required instead of using an incorrect heuristic. Found with: Sysunit test Differential Revision: https://reviews.freebsd.org/D33774 Reviewed by: rrs (cherry picked from commit 24fe6643dac0780dc02676626f70052e525b9b22) --- sys/netinet/tcp_lro.c | 16 ++++++++++++---- sys/netinet/tcp_lro.h | 3 ++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/sys/netinet/tcp_lro.c b/sys/netinet/tcp_lro.c index 4d735f41d84d..feec8c36ab69 100644 --- a/sys/netinet/tcp_lro.c +++ b/sys/netinet/tcp_lro.c @@ -794,7 +794,7 @@ static void tcp_flush_out_entry(struct lro_ctrl *lc, struct lro_entry *le) { /* Check if we need to recompute any checksums. */ - if (le->m_head->m_pkthdr.lro_nsegs > 1) { + if (le->needs_merge) { uint16_t csum; switch (le->inner.data.lro_type) { @@ -895,6 +895,7 @@ tcp_set_entry_to_mbuf(struct lro_ctrl *lc, struct lro_entry *le, le->next_seq = ntohl(th->th_seq) + tcp_data_len; le->ack_seq = th->th_ack; le->window = th->th_win; + le->needs_merge = 0; /* Setup new data pointers. */ le->m_head = m; @@ -936,10 +937,12 @@ tcp_push_and_replace(struct lro_ctrl *lc, struct lro_entry *le, struct mbuf *m) } static void -tcp_lro_mbuf_append_pkthdr(struct mbuf *m, const struct mbuf *p) +tcp_lro_mbuf_append_pkthdr(struct lro_entry *le, const struct mbuf *p) { + struct mbuf *m; uint32_t csum; + m = le->m_head; if (m->m_pkthdr.lro_nsegs == 1) { /* Compute relative checksum. */ csum = p->m_pkthdr.lro_tcp_d_csum; @@ -956,6 +959,7 @@ tcp_lro_mbuf_append_pkthdr(struct mbuf *m, const struct mbuf *p) m->m_pkthdr.lro_tcp_d_csum = csum; m->m_pkthdr.lro_tcp_d_len += p->m_pkthdr.lro_tcp_d_len; m->m_pkthdr.lro_nsegs += p->m_pkthdr.lro_nsegs; + le->needs_merge = 1; } static void @@ -1074,8 +1078,12 @@ again: le->next_seq += tcp_data_len; le->ack_seq = th->th_ack; le->window = th->th_win; + le->needs_merge = 1; } else if (th->th_ack == le->ack_seq) { - le->window = WIN_MAX(le->window, th->th_win); + if (WIN_GT(th->th_win, le->window)) { + le->window = th->th_win; + le->needs_merge = 1; + } } if (tcp_data_len == 0) { @@ -1084,7 +1092,7 @@ again: } /* Merge TCP data checksum and length to head mbuf. */ - tcp_lro_mbuf_append_pkthdr(le->m_head, m); + tcp_lro_mbuf_append_pkthdr(le, m); /* * Adjust the mbuf so that m_data points to the first byte of diff --git a/sys/netinet/tcp_lro.h b/sys/netinet/tcp_lro.h index 3eefd4f0537c..97819596231e 100644 --- a/sys/netinet/tcp_lro.h +++ b/sys/netinet/tcp_lro.h @@ -146,7 +146,8 @@ struct lro_entry { uint16_t compressed; uint16_t uncompressed; uint16_t window; - uint16_t timestamp; /* flag, not a TCP hdr field. */ + uint16_t timestamp : 1; + uint16_t needs_merge : 1; struct bintime alloc_time; /* time when entry was allocated */ };