Module Name:    src
Committed By:   riastradh
Date:           Wed Jan 12 01:21:36 UTC 2022

Modified Files:
        src/sys/net/lagg: if_lagg.c

Log Message:
lagg(4): Need to take IFNET_LOCK around if_init.

This should really just avoid dropping IFNET_LOCK before it's done
changing the port interface's configuration, but this stop-gap change
will serve provisionally to reduce crashes until we can confirm that
there's no deadlock lurking in the time this logic drops IFNET_LOCK.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/net/lagg/if_lagg.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net/lagg/if_lagg.c
diff -u src/sys/net/lagg/if_lagg.c:1.28 src/sys/net/lagg/if_lagg.c:1.29
--- src/sys/net/lagg/if_lagg.c:1.28	Fri Dec 31 14:25:24 2021
+++ src/sys/net/lagg/if_lagg.c	Wed Jan 12 01:21:36 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg.c,v 1.28 2021/12/31 14:25:24 riastradh Exp $	*/
+/*	$NetBSD: if_lagg.c,v 1.29 2022/01/12 01:21:36 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter <r...@openbsd.org>
@@ -20,7 +20,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.28 2021/12/31 14:25:24 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.29 2022/01/12 01:21:36 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -2385,9 +2385,13 @@ lagg_port_setup(struct lagg_softc *sc,
 	lagg_port_syncvlan(sc, lp);
 
 	if (stopped) {
-		error = if_init(ifp_port);
-		if (error != 0)
-			goto remove_port;
+		IFNET_LOCK(ifp_port);
+		if (!ISSET(ifp_port->if_flags, IFF_RUNNING)) {
+			error = if_init(ifp_port);
+			if (error != 0)
+				goto remove_port;
+		}
+		IFNET_UNLOCK(ifp_port);
 	}
 
 	lagg_config_promisc(sc, lp);
@@ -2484,11 +2488,11 @@ lagg_port_teardown(struct lagg_softc *sc
 		ifp_port->if_ioctl = lp->lp_ioctl;
 	ifp_port->if_output = lp->lp_output;
 	lagg_teardown_mtu(sc, lp);
-	IFNET_UNLOCK(ifp_port);
 
 	if (stopped) {
 		if_init(ifp_port);
 	}
+	IFNET_UNLOCK(ifp_port);
 
 	if (is_ifdetach == false) {
 		lagg_unconfig_promisc(sc, lp);

Reply via email to