lagg: Use promiscuous mode instead of if_init() to avoid panic

when the interface has no if_init()
This commit is contained in:
yamaguchi 2021-11-11 01:10:09 +00:00
parent a18d86b7be
commit da8dae575e
1 changed files with 30 additions and 18 deletions

View File

@ -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>
@ -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_port_setsadl(struct lagg_port *lp, uint8_t *lladdr,
lagg_chg_sadl(ifp_port,
lladdr, ETHER_ADDR_LEN);
if (!ISSET(ifp_port->if_flags, IFF_RUNNING)) {
break;
}
if (ifp_port->if_init != NULL) {
error = 0;
if (ISSET(ifp_port->if_flags, IFF_RUNNING))
error = ifp_port->if_init(ifp_port);
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 (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_port_unsetsadl(struct lagg_port *lp)
lagg_chg_sadl(ifp_port,
lp->lp_lladdr, ETHER_ADDR_LEN);
if (!ISSET(ifp_port->if_flags, IFF_RUNNING)) {
break;
}
if (ifp_port->if_init != NULL) {
error = 0;
if (ISSET(ifp_port->if_flags, IFF_RUNNING))
error = ifp_port->if_init(ifp_port);
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 (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;