git: 97ecdc00ac5a - main - neta: Fix MTU change sequence

From: Kornel Dulęba <kd_at_FreeBSD.org>
Date: Thu, 18 Aug 2022 16:57:06 UTC
The branch main has been updated by kd:

URL: https://cgit.FreeBSD.org/src/commit/?id=97ecdc00ac5ac506f4119be9570d13de2d3a003a

commit 97ecdc00ac5ac506f4119be9570d13de2d3a003a
Author:     Kornel Dulęba <kd@FreeBSD.org>
AuthorDate: 2022-08-18 16:53:14 +0000
Commit:     Kornel Dulęba <kd@FreeBSD.org>
CommitDate: 2022-08-18 16:53:14 +0000

    neta: Fix MTU change sequence
    
    The IFF_DRV_RUNNING flag is used to see if the interface needs
    to be temporarily brought down during MTU change sequence.
    The problem here is that this flag is cleared in mvneta_stop_locked,
    resulting in the reinitialization logic never being executed after
    MTU has been changed.
    Fix that by saving the flag value before the interface is brought down.
    
    Reported by:    Jérôme Tomczyk <jerome.tomczyk@stormshield.eu>
    Approved by:    mw(mentor)
    Obtained from:  Semihalf
    Sponsored by:   Stormshield
    MFC after:      2 weeks
---
 sys/dev/neta/if_mvneta.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/sys/dev/neta/if_mvneta.c b/sys/dev/neta/if_mvneta.c
index c2eb32947716..eb6c9eec74ce 100644
--- a/sys/dev/neta/if_mvneta.c
+++ b/sys/dev/neta/if_mvneta.c
@@ -2054,9 +2054,11 @@ mvneta_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
 	struct ifreq *ifr;
 	int error, mask;
 	uint32_t flags;
+	bool reinit;
 	int q;
 
 	error = 0;
+	reinit = false;
 	sc = ifp->if_softc;
 	ifr = (struct ifreq *)data;
 	switch (cmd) {
@@ -2157,8 +2159,10 @@ mvneta_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
 			 * Reinitialize RX queues.
 			 * We need to update RX descriptor size.
 			 */
-			if (ifp->if_drv_flags & IFF_DRV_RUNNING)
+			if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
+				reinit = true;
 				mvneta_stop_locked(sc);
+			}
 
 			for (q = 0; q < MVNETA_RX_QNUM_MAX; q++) {
 				mvneta_rx_lockq(sc, q);
@@ -2172,7 +2176,7 @@ mvneta_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
 				}
 				mvneta_rx_unlockq(sc, q);
 			}
-			if (ifp->if_drv_flags & IFF_DRV_RUNNING)
+			if (reinit)
 				mvneta_init_locked(sc);
 
 			mvneta_sc_unlock(sc);