From nobody Fri Jan 12 16:58:44 2024 X-Original-To: dev-commits-src-all@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 4TBSRS56WFz579BC; Fri, 12 Jan 2024 16:58:44 +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 4TBSRS4Z6cz4Xtd; Fri, 12 Jan 2024 16:58:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705078724; 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=so4dI3Fl7ypfsbV5WDnU5CWeX85icpMVi2zTOzOQxyw=; b=QAC/mlFkQZZnJuCeTwikWta+/mJi7iMtGiF3j0wac3oi2Ga87tzr3rO8+XYhGVK09HHRhm lNuE5S01w7TptLUEyn1P/gIlUi0mPGzkdRNsh9uQr4e94tbngdXuRfHCaOppDUDfNCU5uY GVu9Gekda23Eh/BgRIXJ85T3IXA8Bi0Slx51Eaz9rHH1/BUeG0Mlsg7RJvoTaFSzkfFTfs Ocr3B7/T/NvGjF/A0H7ZfilU4GXxXftnGfP+jbd254WoQXoG60LSqxXVXOHpkWrQ5xRUOh d4j3KVxlRWPmjHwzbGd6kYetkXhXGIH94BkV8ACQMwpXn1JC1W5cKso22GuBGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705078724; 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=so4dI3Fl7ypfsbV5WDnU5CWeX85icpMVi2zTOzOQxyw=; b=uix76mwRMSDSq2IsWd6j9jhyBJ10Bre35m0GVfWk91utXS70NgfX7VFhscLeCNFyutGe4x 1LuiDB7uVpYyeTEAWMWFimO4wKZFpotA1S0uCs74cba9dddHCt6r+afCrg+waxYvLeClOu 4CHY+FyLWeGK3KWAZItHN38EoK7LRO9K9xbcoCQPc+dqurzOXBF6aZAYlO5eLtcx6ALm+p KECeMghptzw07haqKmLytGo1tXB96EKIZqLCn7h+3A86ZdB+Hd2PwwkGx4ohSx60n/5w+P v1ISu/tGQlJfzMH2VLY2WSv/DYYq4t/+S8iA5BWbeQctnhILPG2nNW0ltcNr/Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1705078724; a=rsa-sha256; cv=none; b=CcxT2FHbGmhu7DcRf/D6O/2mo4hIBud46Xk80YEzZbkDzwyi6qRylraN2oTY19ENZDF9G+ JvlRCtfWw44xiuHDW2Kby6ZU4PO0SQbKIRpcdSf3ykLX/+nhRB79LIMkSCzPCIuID8B66l 3JBZgWDMTGcZJxZKHLcRozLHq3GHeP3R6gyBXMsM27ZPiZ7L5zPhQsFix8ET//AnpK2drb 1dhItNC3BvWUwNjmE9kAYdA0TUxk7nlgpVp8NEx80i8W5+PmsDDw9GSKXenRtTi5ZB1KnY YqNo34GAbsfb/IZWYuEHg8lD4Jb9HjHHfOye+luxENH0KafhrxhnWDAJik2txQ== 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 4TBSRS3bqmz19NJ; Fri, 12 Jan 2024 16:58:44 +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 40CGwign096857; Fri, 12 Jan 2024 16:58:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40CGwi3k096854; Fri, 12 Jan 2024 16:58:44 GMT (envelope-from git) Date: Fri, 12 Jan 2024 16:58:44 GMT Message-Id: <202401121658.40CGwi3k096854@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: 002829ea6139 - stable/14 - if_tuntap: support receive checksum offloading for tap interfaces List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/14 X-Git-Reftype: branch X-Git-Commit: 002829ea6139fcbfc295790c97aed811535736fa Auto-Submitted: auto-generated The branch stable/14 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=002829ea6139fcbfc295790c97aed811535736fa commit 002829ea6139fcbfc295790c97aed811535736fa Author: Michael Tuexen AuthorDate: 2023-11-09 10:37:27 +0000 Commit: Michael Tuexen CommitDate: 2024-01-12 16:55:40 +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 f273e4993dfd..738e6b997ace 100644 --- a/sys/net/if_tuntap.c +++ b/sys/net/if_tuntap.c @@ -977,6 +977,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) { @@ -1784,9 +1786,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. */