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: Use promiscuous mode instead of if_init()...



details:   https://anonhg.NetBSD.org/src/rev/d630a613b840
branches:  trunk
changeset: 1025536:d630a613b840
user:      yamaguchi <yamaguchi%NetBSD.org@localhost>
date:      Thu Nov 11 01:10:09 2021 +0000

description:
lagg: Use promiscuous mode instead of if_init() to avoid panic
when the interface has no if_init()

diffstat:

 sys/net/lagg/if_lagg.c |  52 ++++++++++++++++++++++++++++++-------------------
 1 files changed, 32 insertions(+), 20 deletions(-)

diffs (80 lines):

diff -r 54c5668e0c4e -r d630a613b840 sys/net/lagg/if_lagg.c
--- a/sys/net/lagg/if_lagg.c    Wed Nov 10 18:25:52 2021 +0000
+++ b/sys/net/lagg/if_lagg.c    Thu Nov 11 01:10:09 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_lagg.c,v 1.20 2021/11/08 06:29:16 yamaguchi Exp $   */
+/*     $NetBSD: if_lagg.c,v 1.21 2021/11/11 01:10:09 yamaguchi 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.20 2021/11/08 06:29:16 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.21 2021/11/11 01:10:09 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -2091,15 +2091,21 @@
                lagg_chg_sadl(ifp_port,
                    lladdr, ETHER_ADDR_LEN);
 
-               if (!ISSET(ifp_port->if_flags, IFF_RUNNING)) {
-                       break;
-               }
-
-               error = ifp_port->if_init(ifp_port);
-               if (error != 0) {
-                       lagg_log(lp->lp_softc, LOG_WARNING,
-                           "%s failed to if_init() on %d\n",
-                           ifp_port->if_xname, error);
+               if (ifp_port->if_init != NULL) {
+                       error = 0;
+                       if (ISSET(ifp_port->if_flags, IFF_RUNNING))
+                               error = ifp_port->if_init(ifp_port);
+
+                       if (error != 0) {
+                               lagg_log(lp->lp_softc, LOG_WARNING,
+                                   "%s failed to if_init() on %d\n",
+                                   ifp_port->if_xname, error);
+                       }
+               } else {
+                       if (lp->lp_promisc == false) {
+                               ifpromisc_locked(ifp_port, 1);
+                               lp->lp_promisc = true;
+                       }
                }
                break;
        default:
@@ -2131,15 +2137,21 @@
                lagg_chg_sadl(ifp_port,
                    lp->lp_lladdr, ETHER_ADDR_LEN);
 
-               if (!ISSET(ifp_port->if_flags, IFF_RUNNING)) {
-                       break;
-               }
-
-               error = ifp_port->if_init(ifp_port);
-               if (error != 0) {
-                       lagg_log(lp->lp_softc, LOG_WARNING,
-                           "%s failed to if_init() on %d\n",
-                           ifp_port->if_xname, error);
+               if (ifp_port->if_init != NULL) {
+                       error = 0;
+                       if (ISSET(ifp_port->if_flags, IFF_RUNNING))
+                               error = ifp_port->if_init(ifp_port);
+
+                       if (error != 0) {
+                               lagg_log(lp->lp_softc, LOG_WARNING,
+                                   "%s failed to if_init() on %d\n",
+                                   ifp_port->if_xname, error);
+                       }
+               } else {
+                       if (lp->lp_promisc == true) {
+                               ifpromisc_locked(ifp_port, 0);
+                               lp->lp_promisc = false;
+                       }
                }
                break;
 



Home | Main Index | Thread Index | Old Index