From nobody Fri Jan 12 17:55:25 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 4TBThs2qF4z57FwZ; Fri, 12 Jan 2024 17:55:25 +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 4TBThs1wX6z4lQy; Fri, 12 Jan 2024 17:55:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705082125; 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=Z2H1F9JxYrxtUrWHhfDEXQmbndL6Zs+zD/0B+lXHjlQ=; b=M57J4Zo3WMkH1jljvjlrL4T26oPhRzXHqEAXs/VT0OnVRvujo84lkFyEjnV/+VKr6WjBGw 8mWooXpz9wS50oAxVoH2cDLX9Q1RwHfjtYzH2DlFEqwiZIviQhnLrhuH2T5I+zVk2A9O44 QHXTbVsVZ0PG+1za+nVQhxXN6T2g6oa288L4RPLphCBV5jEjI9WXuH73o64UIMnGdst84a iSLiynUN1ODEaYlNVJGJebjkJrV+SLl20DJR0V303SRmtybfS8lxFMfLTzErsvixcyOfrj 4NO9C7dLicW4kbqiH42h41wHgA5e2j2A7wEEnFuvcOcnMKRkWlWAjBnfs1rCVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705082125; 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=Z2H1F9JxYrxtUrWHhfDEXQmbndL6Zs+zD/0B+lXHjlQ=; b=LYhMYx0z/O1hIl3sxWLWSLUhrqsxlh311Cnj4bgfhO5eRE7q8UjEDrwvyVSXjiDwMpsjqK AHXxfR85tQlcUQE1Ky/iunrUz8FiPP7ZVTHZMbVNWA0quBB8fet5/WAyH+2JueNIKP4T6I 3e9J3a5EJyrEhGqqT8Fg8WVX00xI9a8c2XE6RL8rZuUXH7gsAT5hYXaCtgrorRo1CG0D88 NY+6jEJAdrC3ld6LFGGpyBsBUUEXRk+zvUd+0tpY2epYvs2fQ0862mtkzsCS+jqENAKq4A MdFD+lM3IvuX17sPqc6My4tuO9NBFNipsBt+8RAStDrDJy0TZPMudZ6S13+Jfw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1705082125; a=rsa-sha256; cv=none; b=I51cHv/ViEgXAlgudpIgDBPd1asG8gwDdYRlEqpEz0aBXR97uHjBF0rGr9yi3LTOero5/Z TLqO/s0PGSCG9qMd8uAtdSWsr81E1dzI1yfn08YJrbWOBaInVsSFA8/TCgeFsQLZrXZcxY Q+wuM/Yrh6QQP63MeLmkqc2W3QeYYxOMkrVmJjem2D9Rbitehy9G7PcYEhOdFk7L5/SkXd POg6cIdwectN5osrA+S2tS4pp4s1B9dqOxN0GthsOqbQ0m5swXhD83CcEmdosSioU7rnLN teAzMQVlma/2YyySmp28Eo525sLML/k6Mx6LR7038kEeE80rqwMYj14Bp5aG9g== 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 4TBThs0zcfz1BBX; Fri, 12 Jan 2024 17:55:25 +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 40CHtP8n000380; Fri, 12 Jan 2024 17:55:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40CHtPiW000377; Fri, 12 Jan 2024 17:55:25 GMT (envelope-from git) Date: Fri, 12 Jan 2024 17:55:25 GMT Message-Id: <202401121755.40CHtPiW000377@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: 73e955d3ea57 - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 73e955d3ea57f05fb3ae353bc01eec1e6f2e2397 Auto-Submitted: auto-generated The branch stable/13 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=73e955d3ea57f05fb3ae353bc01eec1e6f2e2397 commit 73e955d3ea57f05fb3ae353bc01eec1e6f2e2397 Author: Michael Tuexen AuthorDate: 2023-11-19 14:57:53 +0000 Commit: Michael Tuexen CommitDate: 2024-01-12 17:54:43 +0000 if_tuntap: add LRO support to tap devices This allows testing the LRO code with packetdrill in local mode. Reviewed by: rscheff Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D42548 (cherry picked from commit 99c79cab422705f92f05a2924a29bdf823372ebf) --- 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 28b8454c2894..a2eecd31723d 100644 --- a/sys/net/if_tuntap.c +++ b/sys/net/if_tuntap.c @@ -96,6 +96,7 @@ #endif #include #include +#include #include #include #include @@ -143,6 +144,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) @@ -971,7 +974,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) { @@ -1168,6 +1172,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); @@ -1212,6 +1222,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 */ @@ -1758,6 +1776,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); @@ -1813,7 +1832,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 */