Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/net/lagg lagg(4): Need to take IFNET_LOCK around if_init.



details:   https://anonhg.NetBSD.org/src/rev/2dfa450efd77
branches:  trunk
changeset: 359593:2dfa450efd77
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Wed Jan 12 01:21:36 2022 +0000

description:
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.

diffstat:

 sys/net/lagg/if_lagg.c |  16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diffs (48 lines):

diff -r 42274e01052a -r 2dfa450efd77 sys/net/lagg/if_lagg.c
--- a/sys/net/lagg/if_lagg.c    Tue Jan 11 22:55:54 2022 +0000
+++ b/sys/net/lagg/if_lagg.c    Wed Jan 12 01:21:36 2022 +0000
@@ -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 <reyk%openbsd.org@localhost>
@@ -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_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 @@
                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);



Home | Main Index | Thread Index | Old Index