From nobody Sun Jun 28 10:57:58 2026 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 4gp5wr2tPWz6k1Qt for ; Sun, 28 Jun 2026 10:58:04 +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 "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gp5wr0f12z3nxm for ; Sun, 28 Jun 2026 10:58:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782644284; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=dlBxvcWbyGRBeZ3vCJQCvMD4ETRz/AXzfyF7tWi+Q3c=; b=ERYDZaPZP7Fx62jyf7XcXBdbVT11dpY/0QDM+lifZ9p+PoBKHeQUv+1p+xQlW8g7w/dmRg rCWMq6tQ6IpaNyL5LRFOZJtCPix6e+S6U05YiKi5dNRxWQXXgRPYYzawyEJzHwnVnLy44W /N4L4SDabK20Jzeg0nYC7F1p73g8k6Cr46pZBug3rAc7sGnACAr0KDm0H9TMlmiqHQew0q Mvm1m4twsBQ3DCO7Dnboh4j9ql2kboiAm5gQcme9zWqO+MGchboRN1aSOpfbMMYFU3e6k3 /R3/G15rt1PquVlHdoVDvL8i0+cIii8TKfpGjDlidwes0SfB7Du2V7KT8OYkyw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1782644284; a=rsa-sha256; cv=none; b=Po6TOTHqnsDVruAVScc1Gvg7EdjOMHs2B3muhiDW3EBcsHgMTk5OOLszGaB6+IXbVyxMpW h3XBsJYGsbOobQm1YetlD1UTzGKyDc9AHZaSj6Bs/v3mWh8pAAToskfMbzjwKesx7vrOtw ASjoUnwZ12bc0UXhV6IW4mEg8q0TIYePRViUHERfryl+7U8himm1/vCJSgXV23YODRtcxq gnhny0gb8m9vJaLkeDVJBo/6VRfrOWEPgO3rLIb7SDVc5ot3L4/uS7UFoHfQoY8Ii2qWzz 5X4Maxiken5peN27uLDoM258PH6sqRN7wuvthhCGaKcGQO6nn7CkTOYkcKNnOA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782644284; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=dlBxvcWbyGRBeZ3vCJQCvMD4ETRz/AXzfyF7tWi+Q3c=; b=m4vIZlaWTpNSPCkwjmJFQFYoym7LgW5lKt102l1SnzgJq+VGstshjedTdSLJ1+fvG6Bdqe sMccKZFW4d8n5J4OGuwddgdyyIDz44AQKiPHnbmQbHd++vkq9D19q210fUnsYFVOkAI5jX PRfCpPanuacwVtglNzd6KaJx3R/6pgrYo1jhJi2b36Ta3N4SKm+LQJw7LDpw+iOlKRR0Pn h1HPhqYICiSjrINPB1u9UPa8NisD8LOOCVlfZXRPviln3MYhj/qcCm5RBb42OJYXZpVkOz Sh61FgsMsK2vB9b0j7Uh7TVgdGh94FXpmeO8GkEEeNNwOJRZJIt1t50UiQMuBA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gp5wq69ssz166B for ; Sun, 28 Jun 2026 10:58:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 39b1d by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 28 Jun 2026 10:57:58 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Timo =?utf-8?Q?V=C3=B6lker?= From: Michael Tuexen Subject: git: d6c4cea7740d - main - loopback: improve checksum offloading 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d6c4cea7740d5c5c673a06ba37e4f1bdcddb2ece Auto-Submitted: auto-generated Date: Sun, 28 Jun 2026 10:57:58 +0000 Message-Id: <6a40fe36.39b1d.3aea7fb1@gitrepo.freebsd.org> The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=d6c4cea7740d5c5c673a06ba37e4f1bdcddb2ece commit d6c4cea7740d5c5c673a06ba37e4f1bdcddb2ece Author: Timo Völker AuthorDate: 2026-06-28 10:50:15 +0000 Commit: Michael Tuexen CommitDate: 2026-06-28 10:50:15 +0000 loopback: improve checksum offloading * Allow disabling IFCAP_RXCSUM_IPV6 or IFCAP_TXCSUM_IPV6. * Do not pretend the checksum is correct by setting the LO_CSUM_SET flags if IFCAP_RXCSUM_IPV6 or IFCAP_RXCSUM is enabled. Instead, remove the LO_CSUM_SET flags (in case they have been set somehow) if IFCAP_RXCSUM_IPV6 or IFCAP_RXCSUM is disabled. * Do not unset the transmit checksum offload flags LO_CSUM_FEATURES or LO_CSUM_FEATURES6 since they now have a meaning for the receive path. Reviewed by: glebius, pouria, tuexen Okayed by: bz MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D57518 --- share/man/man4/lo.4 | 23 ++++++++++------------- sys/net/if_loop.c | 42 ++++++------------------------------------ 2 files changed, 16 insertions(+), 49 deletions(-) diff --git a/share/man/man4/lo.4 b/share/man/man4/lo.4 index 7bad739eec41..c0c39093473e 100644 --- a/share/man/man4/lo.4 +++ b/share/man/man4/lo.4 @@ -27,7 +27,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd June 23, 2024 +.Dd June 28, 2026 .Dt LO 4 .Os .Sh NAME @@ -54,19 +54,16 @@ The loopback should be configured first unless no hardware interfaces exist. .Pp -If the transmit checksum offload capability flag is enabled on a loopback -interface, checksums will not be generated by IP, UDP, TCP, or SCTP for packets -sent on the interface. +If the transmit checksum offload capability is enabled on a loopback interface, +checksums will not be generated by IP, UDP, TCP, or SCTP for packets sent on the +interface. +By default, this capability is enabled to avoid the overhead of checksumming for +local communication where data corruption is unlikely. .Pp -If the receive checksum offload capability flag is enabled on a loopback -interface, checksums will not be validated by IP, UDP, TCP, or SCTP for packets -received on the interface. -.Pp -By default, both receive and transmit checksum flags will be enabled, in -order to avoid the overhead of checksumming for local communication where -data corruption is unlikely. -If transmit checksum generation is disabled, then validation should also be -disabled in order to avoid packets being dropped due to invalid checksums. +If the receive checksum offload capability is disabled on a loopback interface, +the flags that indicate a valid checksum will be unset if set previously. +By default, this capability is enabled to avoid another checksum validation if +it has already been validated. .Sh DIAGNOSTICS .Bl -diag .It lo%d: can't handle af%d. diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c index fc5ce9548bcc..69108e9f332a 100644 --- a/sys/net/if_loop.c +++ b/sys/net/if_loop.c @@ -229,38 +229,22 @@ looutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, else af = RO_GET_FAMILY(ro, dst); -#if 1 /* XXX */ switch (af) { case AF_INET: - if (ifp->if_capenable & IFCAP_RXCSUM) { - m->m_pkthdr.csum_data = 0xffff; - m->m_pkthdr.csum_flags = LO_CSUM_SET; + if ((ifp->if_capenable & IFCAP_RXCSUM) == 0) { + m->m_pkthdr.csum_flags &= ~LO_CSUM_SET; } - m->m_pkthdr.csum_flags &= ~LO_CSUM_FEATURES; break; case AF_INET6: -#if 0 - /* - * XXX-BZ for now always claim the checksum is good despite - * any interface flags. This is a workaround for 9.1-R and - * a proper solution ought to be sought later. - */ - if (ifp->if_capenable & IFCAP_RXCSUM_IPV6) { - m->m_pkthdr.csum_data = 0xffff; - m->m_pkthdr.csum_flags = LO_CSUM_SET; + if ((ifp->if_capenable & IFCAP_RXCSUM_IPV6) == 0) { + m->m_pkthdr.csum_flags &= ~LO_CSUM_SET; } -#else - m->m_pkthdr.csum_data = 0xffff; - m->m_pkthdr.csum_flags = LO_CSUM_SET; -#endif - m->m_pkthdr.csum_flags &= ~LO_CSUM_FEATURES6; break; default: printf("looutput: af=%d unexpected\n", af); m_freem(m); return (EAFNOSUPPORT); } -#endif return (if_simloop(ifp, m, af, 0)); } @@ -420,29 +404,15 @@ loioctl(struct ifnet *ifp, u_long cmd, caddr_t data) ifp->if_capenable ^= IFCAP_RXCSUM; if ((mask & IFCAP_TXCSUM) != 0) ifp->if_capenable ^= IFCAP_TXCSUM; - if ((mask & IFCAP_RXCSUM_IPV6) != 0) { -#if 0 + if ((mask & IFCAP_RXCSUM_IPV6) != 0) ifp->if_capenable ^= IFCAP_RXCSUM_IPV6; -#else - error = EOPNOTSUPP; - break; -#endif - } - if ((mask & IFCAP_TXCSUM_IPV6) != 0) { -#if 0 + if ((mask & IFCAP_TXCSUM_IPV6) != 0) ifp->if_capenable ^= IFCAP_TXCSUM_IPV6; -#else - error = EOPNOTSUPP; - break; -#endif - } ifp->if_hwassist = 0; if (ifp->if_capenable & IFCAP_TXCSUM) ifp->if_hwassist = LO_CSUM_FEATURES; -#if 0 if (ifp->if_capenable & IFCAP_TXCSUM_IPV6) ifp->if_hwassist |= LO_CSUM_FEATURES6; -#endif break; default: