git: 108b6eb670ec - stable/13 - neta: Fix MTU change sequence

From: Kornel Dulęba <kd_at_FreeBSD.org>
Date: Thu, 01 Sep 2022 07:21:27 UTC
The branch stable/13 has been updated by kd:

URL: https://cgit.FreeBSD.org/src/commit/?id=108b6eb670ecced4674747fbec26c39fc8df0a55

commit 108b6eb670ecced4674747fbec26c39fc8df0a55
Author:     Kornel Dulęba <kd@FreeBSD.org>
AuthorDate: 2022-08-18 16:53:14 +0000
Commit:     Kornel Dulęba <kd@FreeBSD.org>
CommitDate: 2022-09-01 07:14:43 +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
    
    (cherry picked from commit 97ecdc00ac5ac506f4119be9570d13de2d3a003a)
---
 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 215d35b1141a..4520680dc96b 100644
--- a/sys/dev/neta/if_mvneta.c
+++ b/sys/dev/neta/if_mvneta.c
@@ -2067,9 +2067,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) {
@@ -2170,8 +2172,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);
@@ -2185,7 +2189,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);