git: 4c4633fdffbe - stable/13 - if_tuntap: fix NOIP build

From: Michael Tuexen <tuexen_at_FreeBSD.org>
Date: Fri, 12 Jan 2024 21:10:22 UTC
The branch stable/13 has been updated by tuexen:

URL: https://cgit.FreeBSD.org/src/commit/?id=4c4633fdffbe8e4b6d328c2bc9bb3edacc9ab50a

commit 4c4633fdffbe8e4b6d328c2bc9bb3edacc9ab50a
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2023-12-04 18:18:56 +0000
Commit:     Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2024-01-12 21:09:27 +0000

    if_tuntap: fix NOIP build
    
    Note: this removes one TUNDEBUG() for the sake of not having one more
    ifdefed variable declaration and for the overall code brevity.  The call
    from tuntap into LRO can be so easily traced with dtrace(1) that an
    80-ish printf(9)-based debugging can be omitted.
    
    Fixes:  99c79cab422705f92f05a2924a29bdf823372ebf
    (cherry picked from commit 5b0010b4678d778967a5a82fb38507e46a071e38)
---
 sys/net/if_tuntap.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/sys/net/if_tuntap.c b/sys/net/if_tuntap.c
index a2eecd31723d..a6695adc93c5 100644
--- a/sys/net/if_tuntap.c
+++ b/sys/net/if_tuntap.c
@@ -1171,13 +1171,13 @@ tundtor(void *data)
 	if ((tp->tun_flags & TUN_VMNET) != 0 ||
 	    (l2tun && (ifp->if_flags & IFF_LINK0) != 0))
 		goto out;
-
+#if defined(INET) || defined(INET6)
 	if (l2tun && tp->tun_lro_ready) {
 		TUNDEBUG (ifp, "LRO disabled\n");
 		tcp_lro_free(&tp->tun_lro);
 		tp->tun_lro_ready = false;
 	}
-
+#endif
 	if (ifp->if_flags & IFF_UP) {
 		TUN_UNLOCK(tp);
 		if_down(ifp);
@@ -1222,6 +1222,7 @@ tuninit(struct ifnet *ifp)
 		getmicrotime(&ifp->if_lastchange);
 		TUN_UNLOCK(tp);
 	} else {
+#if defined(INET) || defined(INET6)
 		if (tcp_lro_init(&tp->tun_lro) == 0) {
 			TUNDEBUG(ifp, "LRO enabled\n");
 			tp->tun_lro.ifp = ifp;
@@ -1230,6 +1231,7 @@ tuninit(struct ifnet *ifp)
 			TUNDEBUG(ifp, "Could not enable LRO\n");
 			tp->tun_lro_ready = false;
 		}
+#endif
 		ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
 		TUN_UNLOCK(tp);
 		/* attempt to start output */
@@ -1776,7 +1778,6 @@ 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);
 
@@ -1832,14 +1833,12 @@ tunwrite_l2(struct tuntap_softc *tp, struct mbuf *m,
 	/* Pass packet up to parent. */
 	CURVNET_SET(ifp->if_vnet);
 	NET_EPOCH_ENTER(et);
-	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)
+#if defined(INET) || defined(INET6)
+	if (tp->tun_lro_ready && ifp->if_capenable & IFCAP_LRO &&
+	    tcp_lro_rx(&tp->tun_lro, m, 0) == 0)
 		tcp_lro_flush_all(&tp->tun_lro);
 	else
+#endif
 		(*ifp->if_input)(ifp, m);
 	NET_EPOCH_EXIT(et);
 	CURVNET_RESTORE();