diff options
| author | yamaguchi <yamaguchi@NetBSD.org> | 2022-03-31 03:10:59 +0000 |
|---|---|---|
| committer | yamaguchi <yamaguchi@NetBSD.org> | 2022-03-31 03:10:59 +0000 |
| commit | ffbf1fb7f8afbbbd83cd37596e5a94188a29d7e4 (patch) | |
| tree | 1ae13537b3d145f1dfaf3a676cf0001bd3fe808b /sys | |
| parent | 52e4cf0d9b7d6572edf916af77488f23243408f2 (diff) | |
added log when ifpromisc is failed
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/net/lagg/if_lagg.c | 77 | ||||
| -rw-r--r-- | sys/net/lagg/if_laggproto.h | 3 |
2 files changed, 48 insertions, 32 deletions
diff --git a/sys/net/lagg/if_lagg.c b/sys/net/lagg/if_lagg.c index b57b5001650..b9eb1ba4cb2 100644 --- a/sys/net/lagg/if_lagg.c +++ b/sys/net/lagg/if_lagg.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_lagg.c,v 1.39 2022/03/31 03:07:05 yamaguchi Exp $ */ +/* $NetBSD: if_lagg.c,v 1.40 2022/03/31 03:10:59 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.39 2022/03/31 03:07:05 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.40 2022/03/31 03:10:59 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -181,7 +181,7 @@ static int lagg_delport_all(struct lagg_softc *); static int lagg_port_ioctl(struct ifnet *, u_long, void *); static int lagg_port_output(struct ifnet *, struct mbuf *, const struct sockaddr *, const struct rtentry *); -static int lagg_config_promisc(struct lagg_softc *, struct lagg_port *); +static void lagg_config_promisc(struct lagg_softc *, struct lagg_port *); static void lagg_unconfig_promisc(struct lagg_softc *, struct lagg_port *); static struct lagg_variant * lagg_variant_getref(struct lagg_softc *, struct psref *); @@ -2130,10 +2130,6 @@ lagg_port_setsadl(struct lagg_port *lp, uint8_t *lladdr, break; default: if_alloc_sadl(ifp_port); - if (lp->lp_promisc == false) { - ifpromisc_locked(ifp_port, 1); - lp->lp_promisc = true; - } break; } } @@ -2179,11 +2175,6 @@ lagg_port_unsetsadl(struct lagg_port *lp) /* reset if_type before if_alloc_sadl */ ifp_port->if_type = lp->lp_iftype; if_alloc_sadl(ifp_port); - - if (lp->lp_promisc == true) { - ifpromisc_locked(ifp_port, 0); - lp->lp_promisc = false; - } break; } } @@ -2647,39 +2638,65 @@ lagg_get_stats(struct lagg_softc *sc, struct lagg_req *resp, return 0; } -static int +static void lagg_config_promisc(struct lagg_softc *sc, struct lagg_port *lp) { - struct ifnet *ifp; - uint64_t chg_flags; + struct ifnet *ifp, *ifp_port; int error; + bool promisc; + + KASSERT(LAGG_LOCKED(sc)); - error = 0; ifp = &sc->sc_if; - chg_flags = ifp->if_flags ^ lp->lp_ifflags; + ifp_port = lp->lp_ifp; - if (ISSET(chg_flags, IFF_PROMISC)) { - error = ifpromisc(lp->lp_ifp, - ISSET(ifp->if_flags, IFF_PROMISC) ? 1 : 0); - if (error == 0) { - lp->lp_ifflags ^= IFF_PROMISC; - } + if (lp->lp_iftype == IFT_ETHER) { + promisc = ISSET(ifp->if_flags, IFF_PROMISC) ? + true : false; + } else { + promisc = true; } - return error; + if (lp->lp_promisc == promisc) + return; + + error = ifpromisc(ifp_port, promisc ? 1 : 0); + if (error == ENETRESET) { + error = ifp_port->if_init(ifp_port); + } + + if (error == 0) { + lp->lp_promisc = promisc; + } else { + lagg_log(sc, LOG_WARNING, + "couldn't %s promisc on %s\n", + promisc ? "set" : "unset", + ifp_port->if_xname); + } } static void lagg_unconfig_promisc(struct lagg_softc *sc, struct lagg_port *lp) { + struct ifnet *ifp_port; int error; - if (ISSET(lp->lp_ifflags, IFF_PROMISC)) { - error = ifpromisc(lp->lp_ifp, 0); - if (error != 0) { - lagg_log(sc, LOG_DEBUG, - "couldn't unset promiscuous mode"); - } + KASSERT(LAGG_LOCKED(sc)); + + ifp_port = lp->lp_ifp; + + if (lp->lp_promisc == false) + return; + + error = ifpromisc(ifp_port, 0); + if (error == ENETRESET) { + error = ifp_port->if_init(ifp_port); + } + + if (error != 0) { + lagg_log(sc, LOG_WARNING, + "couldn't unset promisc on %s\n", + ifp_port->if_xname); } } diff --git a/sys/net/lagg/if_laggproto.h b/sys/net/lagg/if_laggproto.h index 4fefd1db10f..4678c5faf0f 100644 --- a/sys/net/lagg/if_laggproto.h +++ b/sys/net/lagg/if_laggproto.h @@ -1,4 +1,4 @@ -/* $NetBSD: if_laggproto.h,v 1.11 2022/03/31 02:00:27 yamaguchi Exp $ */ +/* $NetBSD: if_laggproto.h,v 1.12 2022/03/31 03:10:59 yamaguchi Exp $ */ /* * Copyright (c) 2021 Internet Initiative Japan Inc. @@ -77,7 +77,6 @@ struct lagg_port { u_char lp_iftype; uint8_t lp_lladdr[ETHER_ADDR_LEN]; - unsigned short lp_ifflags; int lp_eccapenable; uint64_t lp_ifcapenable; uint64_t lp_mtu; |
