From nobody Thu Nov 09 14:46:18 2023 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 4SR4XC1Hksz4yxhc; Thu, 9 Nov 2023 14:46:19 +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 4SR4XC0csqz3Sps; Thu, 9 Nov 2023 14:46:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699541179; 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=4OLyJitw3DU4pq/ekFs04Oth3op7xM+dOmPVgNX0NXk=; b=pmYVNO4GWC37Zn0xKdZjliyBWykQhoVk2ekCVMzqE8g0ghsnGzj39mfnwg292FvsiSnRwI 3YNiw3TNPyMQfuPd6muNmY3voycTrZWbNL3QX/dIpFSCpup+LHiHbN3oSwH8OB047H+Xxm aAPc26cdZMjpL1otL7sc0pU7lZZcnjJv72hsDAYhlje4uNUyqxRQM9GONYH4+vg0gtsqUs rDV5Io9G8xx+puJZ0FEIPwlQ/YPdZUl3aQR7gBFLKWSQhILM7G1o3m8KHd0Pa88QbbZ9vx 37lNuJ2Sv6l1tSY/EknEKXXVfc0c54fKmdzealZR+BcjvAhD115EPPg0Vpue5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699541179; 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=4OLyJitw3DU4pq/ekFs04Oth3op7xM+dOmPVgNX0NXk=; b=f7igk8sD5JnF5gBiAxpsig4u0gNXXmfssCErPvXaFpynSJ4F1Y/m9AWcAykOLz6iXAoLiK /uWuUL3UrbgLY+leIOMY7KB+xbS+1oTVWRnYPNdK25fu5m4GaK4+Z0X1pyayxSmsR4HaFa ZlmZfyocV3LoOu51qiIiRNbJW6tr41B/FqbAunXS3tOP06sz+J+xtQUcCX3yX3tawtavEH FJ1oQ6S3mRPYuZja+Ig4YrmSvsMXjvKsN0rkrw0o3ZwywI45aV4x8N6J2639NohjtO+BHs sOVGnLT41Nm/SHn68KWQyTpH/SYxijHfQ806MuDHlvktl57JcEEP/CX9JJKeWw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1699541179; a=rsa-sha256; cv=none; b=EumeGsIhWrJELARHeWTn1ouZwMP2fXyREZQT44AG3aIPCo8JlQihbDoDn5bI5qz8x1YYuY KG1r9YZyHuxjwxeGkXVEwjh8H+Nsq1z3OBUPxW1SUHakJp/8VGfysCz87YI/iyHGi9E45E rEu/Bewyw38Idp5lEA9KBQZoRYS2mG7V7rml1kJOZLZd895dyp4woKqzedqgzN9wO0AgwJ 8Z1qm+d+SdcG1lS5jHo1gNhweDe3Kdh6CCPIuPep3YT8epLXrZkEx/Os0e4ZQVNEcgp4oO uKjGEm+RCkdeJgxfN7YER/UPHL9WSrJjLjniGqWgu92toHWSqnrAwXNUTfLX8w== 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 4SR4XB6g2yz4qJ; Thu, 9 Nov 2023 14:46:18 +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 3A9EkIVA081784; Thu, 9 Nov 2023 14:46:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3A9EkIMG081781; Thu, 9 Nov 2023 14:46:18 GMT (envelope-from git) Date: Thu, 9 Nov 2023 14:46:18 GMT Message-Id: <202311091446.3A9EkIMG081781@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michael Tuexen Subject: git: ff69d13a50d1 - main - 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/main X-Git-Reftype: branch X-Git-Commit: ff69d13a50d1d07601de0885fd94f6a09a7ba383 Auto-Submitted: auto-generated The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=ff69d13a50d1d07601de0885fd94f6a09a7ba383 commit ff69d13a50d1d07601de0885fd94f6a09a7ba383 Author: Michael Tuexen AuthorDate: 2023-11-09 10:37:27 +0000 Commit: Michael Tuexen CommitDate: 2023-11-09 10:37:27 +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 MFC after: 1 week Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D42477 --- 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 a865c23cb372..30d1d84b2f59 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. */