From nobody Fri Jan 12 17:53:43 2024 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 4TBTfv5v13z57FY8; Fri, 12 Jan 2024 17:53:43 +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 4TBTfv4Ncbz4l0k; Fri, 12 Jan 2024 17:53:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705082023; 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=dX3nAgSXhrgb/S/zA9DLpRhYqZPIRJNojMiql8ZfOSY=; b=oR5MSnEX+smZXBZrhsWPZ4mP3jqYYI5bDayMko4svHllv9lioE8hrDnPk/LWZ3nrMjhSAT paRv7rSQ6IMDXztVTg56UgNKiE0aXTcKoXlfyEr9nZ8RTEAaV79sWMezCzxPy57OC7VuxI uAbkcVVdGVgnVusqsafRmVYhAzLVfuv0asa0FzUlSyTMCKLN5xR19FuLbAMDQUirG13hcG SH5um6eNRXKPDV9XX5gSmPK3slLk4BvsYEUOVLp7SlQKxrlilPvgOTfsjBe48hJFaOAa78 H/oiAF6d2ITNEcvOiO8RFoABH/EuXijSV0HF/YTt8wViIXIrAWQWkFJHoCAqpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705082023; 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=dX3nAgSXhrgb/S/zA9DLpRhYqZPIRJNojMiql8ZfOSY=; b=MkF0ERAy5zF7CO3BXtvzvEvg5jds3Ho/BbrVjlVn3r+0UumP5Qu99K8+VsDCQXfybagTOb VsYC4+oulQsadYPLAwWSxDa9eQI/dTpGAu83lPzWKkWe7V2mgzLEt1hPf6IAoh0yUz7SiX LW14GeDmKkyAppK8a3f4lU4W3jcfuWdCvxIb5wz65YeovFPSl6/T23iveNZ1uKr8iVevX4 C+YIQ3lBUmCJFMbmVcXDxPhehmY31uulu5F+0GJ48rv28aXBXgftQ4ktcKelcO/Rh/Ep3z a8F7AbB7EuhUxaT0xThhYNtYJsNLopCgcZHh9Idf5GPfGxdRzcl5UFRDxO1JNw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1705082023; a=rsa-sha256; cv=none; b=veZz/DiuDNJT/iVSniYhsVXGAyUi9MxJPsaFtVcAFuZ/N/aSYmrZ7r2J7THo1K2cnG5Ie2 To/24E0M3+KMdGDvMpSgC8mgqiFLJ9HyTCfp2Hu7JrgNknRoBarlU+0P+ef4Hn9vnODYM3 lKaXUkh5EHVgiDnhvU3OQLzlPNyGCIKDJBbZwzlfgtNh1mGiByYII5lWMQ6p/1ihHVeP0l kFvcwOHdNlt8jifmOw9PCx90Ushf85yAWks2CirLp+W5KhB14VZdLiBdzVE1JmXhb4/61/ w5UPmW6+9ZSGEqc9uYq4U4q1ViQrni1cYxy+xtAe3UsduEgyTxmN6Mqf8Pj/ZA== 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 4TBTfv3SRPz1BlD; Fri, 12 Jan 2024 17:53:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 40CHrhHx099693; Fri, 12 Jan 2024 17:53:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40CHrhhv099690; Fri, 12 Jan 2024 17:53:43 GMT (envelope-from git) Date: Fri, 12 Jan 2024 17:53:43 GMT Message-Id: <202401121753.40CHrhhv099690@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Michael Tuexen Subject: git: 41988a137d55 - stable/13 - if_tuntap: support receive checksum offloading for tap interfaces 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: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 41988a137d556b0e4bd6259bc7af0c63f6975596 Auto-Submitted: auto-generated The branch stable/13 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=41988a137d556b0e4bd6259bc7af0c63f6975596 commit 41988a137d556b0e4bd6259bc7af0c63f6975596 Author: Michael Tuexen AuthorDate: 2023-11-09 10:37:27 +0000 Commit: Michael Tuexen CommitDate: 2024-01-12 17:53:19 +0000 if_tuntap: support receive checksum offloading for tap interfaces When enabled, pretend that the IPv4 and transport layer checksum is correct for packets injected via the character device. This is a prerequisite for adding support for LRO, which will be added next. Then packetdrill can be used to test the LRO code in local mode. Reviewed by: rscheff, zlei Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D42477 (cherry picked from commit ff69d13a50d1d07601de0885fd94f6a09a7ba383) --- sys/net/if_tuntap.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/sys/net/if_tuntap.c b/sys/net/if_tuntap.c index 29e9c05e52bc..9cadd971eb37 100644 --- a/sys/net/if_tuntap.c +++ b/sys/net/if_tuntap.c @@ -970,6 +970,8 @@ tuncreate(struct cdev *dev) ifp->if_flags = iflags; IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen); ifp->if_capabilities |= IFCAP_LINKSTATE; + if ((tp->tun_flags & TUN_L2) != 0) + ifp->if_capabilities |= IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6; ifp->if_capenable |= IFCAP_LINKSTATE; if ((tp->tun_flags & TUN_L2) != 0) { @@ -1777,9 +1779,35 @@ tunwrite_l2(struct tuntap_softc *tp, struct mbuf *m, return (0); } - if (vhdr != NULL && virtio_net_rx_csum(m, &vhdr->hdr)) { - m_freem(m); - return (0); + if (vhdr != NULL) { + if (virtio_net_rx_csum(m, &vhdr->hdr)) { + m_freem(m); + return (0); + } + } else { + switch (ntohs(eh->ether_type)) { +#ifdef INET + case ETHERTYPE_IP: + if (ifp->if_capenable & IFCAP_RXCSUM) { + m->m_pkthdr.csum_flags |= + CSUM_IP_CHECKED | CSUM_IP_VALID | + CSUM_DATA_VALID | CSUM_SCTP_VALID | + CSUM_PSEUDO_HDR; + m->m_pkthdr.csum_data = 0xffff; + } + break; +#endif +#ifdef INET6 + case ETHERTYPE_IPV6: + if (ifp->if_capenable & IFCAP_RXCSUM_IPV6) { + m->m_pkthdr.csum_flags |= + CSUM_DATA_VALID_IPV6 | CSUM_SCTP_VALID | + CSUM_PSEUDO_HDR; + m->m_pkthdr.csum_data = 0xffff; + } + break; +#endif + } } /* Pass packet up to parent. */