From nobody Sun Nov 19 21:33:31 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 4SYP5R72tyz51NCc; Sun, 19 Nov 2023 21:33:31 +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 4SYP5R6LyMz3P7C; Sun, 19 Nov 2023 21:33:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700429611; 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=BMjRpiToPrP6fKeWsuiEThirW+crKQWXeZv14g4PCpw=; b=AutxSK+9f4xfDzyE3VhvVK79mdiHTcr5gcM/s4CuweY8XJ8IHeq7/5GJNmMvXf2VfoIAGR Yu9YQgJziJCMPvI39UFt2eoJYr47jHknz4vXeN+CZDScwfgzNHX3E2UJGsM3jKCeydmahu vdaNJyoUtjNr8YFhal3AJbvz6/VKtN/qhqQRaE2JGUgFxQ0UO57qinf33qRVi5aMcYGGkU EsfQqLymh8vxklF8FwHw8g+79lk1vuahpznvViU+WCrUUaSfI+H5joAZ7T58szIRYVH+ry 3Xl8XFmEuG+YDdgW15Es4Dh4PmdeIinJ5c5NMuE5ubNpVSd/Vu6rgWCEM+CxZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700429611; 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=BMjRpiToPrP6fKeWsuiEThirW+crKQWXeZv14g4PCpw=; b=PH74IAGuCklM6wkvtiDJse0sNeuJDIjnmDPk3W+Ub9mfMGns3qkgBSVv8iY7P4qJ26W/P4 2xpkQ9dUuYYidTN+3wAr6e8RTJP8VNbxVRd+OW0ynqKEfifBnrkf4QRHlyETd9t9KjAu99 XNbKn9dbwmND6uuLSU2K9Zc43DGVK6WOf+/wBVkIqNfhs8DG9xXGtdaR9UrG2o9OVRRWu0 Np5OlZc8/0SkqSfj+JkSzbHprbCtjQptDFXlAizZtuO3nBYbKiHg52K/1mKBUg5jZ5MkKq 0FQ5+00HsxUvSWrun5pZme6r8QMVUPQ+7Gq1JuSpm/zO+w0nPiVgDksY5t91gw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1700429611; a=rsa-sha256; cv=none; b=cPBjzRj1H5AzSfILmuZ/MSHTdNp1Mc6ETBTi9+dk1kAX0rN030RnMO4c+EVFHyfnWjYXiY ooksamXPAuMCmvM8kBTknY0oHhqDhWlXQ3NhVpqQzgamqaNgDSiAqx57sltGSNx7v9tPxH /aDAFnt0AfCcE5dFz1z+SIKwWhlT/k7JpAOTzKb510IvmbkEKCp2kvXJRI5+opum7JvZVV oC1mHdZJmJZLxnX9l24CGYidaMrT4/Tn3ndG+uNoXtae1pdgIDa+7ZnQFjYrUu0+tbunRW 8Z/lw6vlsZ2Pm34cCDWAy+EC6L8+aDUaKg+xa/jobHoKWZ5W6OCZO7La3UN7bw== 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 4SYP5R5PQfzB89; Sun, 19 Nov 2023 21:33:31 +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 3AJLXVvo034873; Sun, 19 Nov 2023 21:33:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3AJLXVQe034870; Sun, 19 Nov 2023 21:33:31 GMT (envelope-from git) Date: Sun, 19 Nov 2023 21:33:31 GMT Message-Id: <202311192133.3AJLXVQe034870@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: 99c79cab4227 - main - if_tuntap: add LRO support to tap devices 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: 99c79cab422705f92f05a2924a29bdf823372ebf Auto-Submitted: auto-generated The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=99c79cab422705f92f05a2924a29bdf823372ebf commit 99c79cab422705f92f05a2924a29bdf823372ebf Author: Michael Tuexen AuthorDate: 2023-11-19 14:57:53 +0000 Commit: Michael Tuexen CommitDate: 2023-11-19 14:57:53 +0000 if_tuntap: add LRO support to tap devices This allows testing the LRO code with packetdrill in local mode. Reviewed by: rscheff MFC after: 1 week Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D42548 --- sys/net/if_tuntap.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/sys/net/if_tuntap.c b/sys/net/if_tuntap.c index 8881bbaec070..5a4231604f5a 100644 --- a/sys/net/if_tuntap.c +++ b/sys/net/if_tuntap.c @@ -97,6 +97,7 @@ #endif #include #include +#include #include #include #include @@ -144,6 +145,8 @@ struct tuntap_softc { struct ether_addr tun_ether; /* remote address */ int tun_busy; /* busy count */ int tun_vhdrlen; /* virtio-net header length */ + struct lro_ctrl tun_lro; /* for TCP LRO */ + bool tun_lro_ready; /* TCP LRO initialized */ }; #define TUN2IFP(sc) ((sc)->tun_ifp) @@ -978,7 +981,8 @@ tuncreate(struct cdev *dev) 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_capabilities |= + IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6 | IFCAP_LRO; ifp->if_capenable |= IFCAP_LINKSTATE; if ((tp->tun_flags & TUN_L2) != 0) { @@ -1175,6 +1179,12 @@ tundtor(void *data) (l2tun && (ifp->if_flags & IFF_LINK0) != 0)) goto out; + if (l2tun && tp->tun_lro_ready) { + TUNDEBUG (ifp, "LRO disabled\n"); + tcp_lro_free(&tp->tun_lro); + tp->tun_lro_ready = false; + } + if (ifp->if_flags & IFF_UP) { TUN_UNLOCK(tp); if_down(ifp); @@ -1219,6 +1229,14 @@ tuninit(struct ifnet *ifp) getmicrotime(&ifp->if_lastchange); TUN_UNLOCK(tp); } else { + if (tcp_lro_init(&tp->tun_lro) == 0) { + TUNDEBUG(ifp, "LRO enabled\n"); + tp->tun_lro.ifp = ifp; + tp->tun_lro_ready = true; + } else { + TUNDEBUG(ifp, "Could not enable LRO\n"); + tp->tun_lro_ready = false; + } ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; TUN_UNLOCK(tp); /* attempt to start output */ @@ -1765,6 +1783,7 @@ tunwrite_l2(struct tuntap_softc *tp, struct mbuf *m, struct epoch_tracker et; struct ether_header *eh; struct ifnet *ifp; + int result; ifp = TUN2IFP(tp); @@ -1820,7 +1839,15 @@ tunwrite_l2(struct tuntap_softc *tp, struct mbuf *m, /* Pass packet up to parent. */ CURVNET_SET(ifp->if_vnet); NET_EPOCH_ENTER(et); - (*ifp->if_input)(ifp, m); + if (tp->tun_lro_ready && ifp->if_capenable & IFCAP_LRO) { + result = tcp_lro_rx(&tp->tun_lro, m, 0); + TUNDEBUG(ifp, "tcp_lro_rx() returned %d\n", result); + } else + result = TCP_LRO_CANNOT; + if (result == 0) + tcp_lro_flush_all(&tp->tun_lro); + else + (*ifp->if_input)(ifp, m); NET_EPOCH_EXIT(et); CURVNET_RESTORE(); /* ibytes are counted in parent */