git: 126767e314cc - stable/13 - if_vtnet: improve dumping a kernel

From: Michael Tuexen <tuexen_at_FreeBSD.org>
Date: Wed, 01 Feb 2023 22:44:11 UTC
The branch stable/13 has been updated by tuexen:

URL: https://cgit.FreeBSD.org/src/commit/?id=126767e314ccdc77c82b6f29aeda3b715b31683a

commit 126767e314ccdc77c82b6f29aeda3b715b31683a
Author:     Michael Tuexen <tuexen@FreeBSD.org>
AuthorDate: 2022-04-18 22:40:31 +0000
Commit:     Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2023-02-01 22:43:44 +0000

    if_vtnet: improve dumping a kernel
    
    Disable software LRO during kernel dumping, because having it enabled
    requires to be in a network epoch, which might or might not be the
    case depending on the code path resulting in the panic.
    
    Reviewed by:            markj
    Sponsored by:           Netflix, Inc.
    Differential Revision:  https://reviews.freebsd.org/D34787
    
    (cherry picked from commit 53236f905dbf4f3d58b1d5eff5c9b14f100d0c5d)
---
 sys/dev/virtio/network/if_vtnet.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/sys/dev/virtio/network/if_vtnet.c b/sys/dev/virtio/network/if_vtnet.c
index 2b25fbfb6b93..79011a2abfb8 100644
--- a/sys/dev/virtio/network/if_vtnet.c
+++ b/sys/dev/virtio/network/if_vtnet.c
@@ -4388,8 +4388,27 @@ vtnet_debugnet_init(struct ifnet *ifp, int *nrxr, int *ncl, int *clsize)
 }
 
 static void
-vtnet_debugnet_event(struct ifnet *ifp __unused, enum debugnet_ev event __unused)
+vtnet_debugnet_event(struct ifnet *ifp, enum debugnet_ev event)
 {
+	struct vtnet_softc *sc;
+	static bool sw_lro_enabled = false;
+
+	/*
+	 * Disable software LRO, since it would require entering the network
+	 * epoch when calling vtnet_txq_eof() in vtnet_debugnet_poll().
+	 */
+	sc = if_getsoftc(ifp);
+	switch (event) {
+	case DEBUGNET_START:
+		sw_lro_enabled = (sc->vtnet_flags & VTNET_FLAG_SW_LRO) != 0;
+		if (sw_lro_enabled)
+			sc->vtnet_flags &= ~VTNET_FLAG_SW_LRO;
+		break;
+	case DEBUGNET_END:
+		if (sw_lro_enabled)
+			sc->vtnet_flags |= VTNET_FLAG_SW_LRO;
+		break;
+	}
 }
 
 static int