Module Name: src Committed By: yamaguchi Date: Thu Mar 31 02:00:28 UTC 2022
Modified Files: src/sys/net/lagg: if_lagg.c if_lagg_lacp.c if_laggproto.h if_laggvar.h Log Message: fix coding style To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/sys/net/lagg/if_lagg.c cvs rdiff -u -r1.16 -r1.17 src/sys/net/lagg/if_lagg_lacp.c cvs rdiff -u -r1.10 -r1.11 src/sys/net/lagg/if_laggproto.h cvs rdiff -u -r1.4 -r1.5 src/sys/net/lagg/if_laggvar.h 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.37 src/sys/net/lagg/if_lagg.c:1.38 --- src/sys/net/lagg/if_lagg.c:1.37 Thu Mar 31 01:57:13 2022 +++ src/sys/net/lagg/if_lagg.c Thu Mar 31 02:00:27 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: if_lagg.c,v 1.37 2022/03/31 01:57:13 yamaguchi Exp $ */ +/* $NetBSD: if_lagg.c,v 1.38 2022/03/31 02:00:27 yamaguchi 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.37 2022/03/31 01:57:13 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.38 2022/03/31 02:00:27 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -283,9 +283,8 @@ lagg_in6_ifdetach(struct ifnet *ifp) #ifdef INET6 KERNEL_LOCK_UNLESS_NET_MPSAFE(); - if (in6_present) { + if (in6_present) in6_ifdetach(ifp); - } KERNEL_UNLOCK_UNLESS_NET_MPSAFE(); #endif } @@ -761,9 +760,8 @@ lagg_ioctl(struct ifnet *ifp, u_long cmd /* set every port back to the original MTU */ ifr->ifr_mtu = ifp->if_mtu; LAGG_PORTS_FOREACH(sc, lp) { - if (lp->lp_ioctl != NULL) { + if (lp->lp_ioctl != NULL) lagg_lp_ioctl(lp, cmd, (void *)ifr); - } } } LAGG_UNLOCK(sc); @@ -907,17 +905,16 @@ lagg_hashmbuf(struct lagg_softc *sc, str } while(0) eh = lagg_m_extract(m, 0, sizeof(*eh), &buf); - if (eh == NULL) { + if (eh == NULL) goto out; - } + off = ETHER_HDR_LEN; etype = ntohs(eh->ether_type); if (etype == ETHERTYPE_VLAN) { evl = lagg_m_extract(m, 0, sizeof(*evl), &buf); - if (evl == NULL) { + if (evl == NULL) goto out; - } vlantag = ntohs(evl->evl_tag); etype = ntohs(evl->evl_proto); @@ -937,9 +934,8 @@ lagg_hashmbuf(struct lagg_softc *sc, str switch (etype) { case ETHERTYPE_IP: ip = lagg_m_extract(m, off, sizeof(*ip), &buf); - if (ip == NULL) { + if (ip == NULL) goto out; - } if (sc->sc_hash_ipaddr) { LAGG_HASH_ADD(&hash_src, ip->ip_src); @@ -951,9 +947,8 @@ lagg_hashmbuf(struct lagg_softc *sc, str break; case ETHERTYPE_IPV6: ip6 = lagg_m_extract(m, off, sizeof(*ip6), &buf); - if (ip6 == NULL) { + if (ip6 == NULL) goto out; - } if (sc->sc_hash_ip6addr) { LAGG_HASH_ADD(&hash_src, ip6->ip6_src); @@ -972,9 +967,8 @@ lagg_hashmbuf(struct lagg_softc *sc, str switch (proto) { case IPPROTO_TCP: th = lagg_m_extract(m, off, sizeof(*th), &buf); - if (th == NULL) { + if (th == NULL) goto out; - } if (sc->sc_hash_tcp) { LAGG_HASH_ADD(&hash_src, th->th_sport); @@ -983,9 +977,8 @@ lagg_hashmbuf(struct lagg_softc *sc, str break; case IPPROTO_UDP: uh = lagg_m_extract(m, off, sizeof(*uh), &buf); - if (uh == NULL) { + if (uh == NULL) goto out; - } if (sc->sc_hash_udp) { LAGG_HASH_ADD(&hash_src, uh->uh_sport); @@ -1149,9 +1142,8 @@ lagg_input_ethernet(struct ifnet *ifp_po } if (pfil_run_hooks(ifp_port->if_pfil, &m, - ifp_port, PFIL_IN) != 0) { + ifp_port, PFIL_IN) != 0) goto out; - } m = lagg_proto_input(lp->lp_softc, lp, m); if (m != NULL) { @@ -2036,9 +2028,8 @@ lagg_setup_mtu(struct lagg_softc *sc, st ifr.ifr_mtu = sc->sc_if.if_mtu; } - if (sc->sc_if.if_mtu != (uint64_t)ifr.ifr_mtu) { + if (sc->sc_if.if_mtu != (uint64_t)ifr.ifr_mtu) sc->sc_if.if_mtu = ifr.ifr_mtu; - } if (lp->lp_mtu != (uint64_t)ifr.ifr_mtu) { if (lp->lp_ioctl == NULL) { @@ -2072,9 +2063,8 @@ lagg_teardown_mtu(struct lagg_softc *sc, ifp_port = lp->lp_ifp; KASSERT(IFNET_LOCKED(ifp_port)); - if (SIMPLEQ_EMPTY(&sc->sc_ports)) { + if (SIMPLEQ_EMPTY(&sc->sc_ports)) sc->sc_if.if_mtu = 0; - } if (ifp_port->if_mtu != lp->lp_mtu) { memset(&ifr, 0, sizeof(ifr)); @@ -2198,9 +2188,8 @@ lagg_setup_lladdr(struct lagg_softc *sc, KASSERT(LAGG_LOCKED(sc)); - if (lagg_lladdr_equal(sc->sc_lladdr, sc->sc_lladdr_rand)) { + if (lagg_lladdr_equal(sc->sc_lladdr, sc->sc_lladdr_rand)) lagg_lladdr_cpy(sc->sc_lladdr, lp->lp_lladdr); - } } static void @@ -2305,9 +2294,8 @@ lagg_port_setup(struct lagg_softc *sc, return EINVAL; } - if (sc->sc_nports > LAGG_MAX_PORTS) { + if (sc->sc_nports > LAGG_MAX_PORTS) return ENOSPC; - } if (ifp_port->if_lagg != NULL) { lp = (struct lagg_port *)ifp_port->if_lagg; @@ -2364,13 +2352,12 @@ lagg_port_setup(struct lagg_softc *sc, lagg_in6_ifdetach(ifp_port); error = lagg_setup_mtu(sc, lp); - if (error != 0) { + if (error != 0) goto restore_ipv6lla; - } - if (lp->lp_iftype == IFT_ETHER) { + if (lp->lp_iftype == IFT_ETHER) lagg_setup_lladdr(sc, lp); - } + lagg_port_setsadl(lp, sc->sc_lladdr, iftype_changed); IFNET_UNLOCK(ifp_port); @@ -2419,9 +2406,8 @@ teardown_lladdr: IFNET_LOCK(ifp_port); lagg_teardown_mtu(sc, lp); lagg_port_unsetsadl(lp); - if (lp->lp_iftype == IFT_ETHER) { + if (lp->lp_iftype == IFT_ETHER) lagg_teardown_lladdr(sc, lp); - } restore_ipv6lla: KASSERT(IFNET_LOCKED(ifp_port)); lagg_in6_ifdetach(ifp_port); @@ -2498,9 +2484,8 @@ lagg_port_teardown(struct lagg_softc *sc ifp_port->if_ioctl = lp->lp_ioctl; lagg_teardown_mtu(sc, lp); - if (stopped) { + if (stopped) if_init(ifp_port); - } IFNET_UNLOCK(ifp_port); if (is_ifdetach == false) { @@ -2719,9 +2704,8 @@ lagg_port_ioctl(struct ifnet *ifp, u_lon error = LAGG_PORT_IOCTL(lp, cmd, data); ifflags ^= ifp->if_flags; - if ((ifflags & (IFF_UP | IFF_RUNNING)) != 0) { + if ((ifflags & (IFF_UP | IFF_RUNNING)) != 0) lagg_proto_linkstate(sc, lp); - } break; default: goto fallback; Index: src/sys/net/lagg/if_lagg_lacp.c diff -u src/sys/net/lagg/if_lagg_lacp.c:1.16 src/sys/net/lagg/if_lagg_lacp.c:1.17 --- src/sys/net/lagg/if_lagg_lacp.c:1.16 Thu Mar 31 01:59:05 2022 +++ src/sys/net/lagg/if_lagg_lacp.c Thu Mar 31 02:00:27 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: if_lagg_lacp.c,v 1.16 2022/03/31 01:59:05 yamaguchi Exp $ */ +/* $NetBSD: if_lagg_lacp.c,v 1.17 2022/03/31 02:00:27 yamaguchi Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-NetBSD @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.16 2022/03/31 01:59:05 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.17 2022/03/31 02:00:27 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "opt_lagg.h" @@ -2105,9 +2105,8 @@ lacp_set_mux(struct lacp_softc *lsc, str sc = lacpp->lp_laggport->lp_softc; ifp = &sc->sc_if; - if (lacpp->lp_mux_state == new_state) { + if (lacpp->lp_mux_state == new_state) return -1; - } switch (new_state) { case LACP_MUX_DETACHED: @@ -2304,7 +2303,6 @@ lacp_select(struct lacp_softc *lsc, stru struct lacp_aggregator_systemid *sid; struct lacp_port *lacpp0; char buf[LACP_SYSTEMIDSTR_LEN] __LACPDEBUGUSED; - bool insert_after; if (lacpp->lp_aggregator != NULL) return; @@ -2346,25 +2344,20 @@ lacp_select(struct lacp_softc *lsc, stru lacpp->lp_aggregator = la; lacpp->lp_selected = LACP_STANDBY; - insert_after = false; - LIST_FOREACH(lacpp0, &la->la_ports, lp_entry_la) { - if (lacp_port_priority_max(lacpp0, lacpp) == lacpp) + if (lacp_port_priority_max(lacpp0, lacpp) == lacpp) { + LIST_INSERT_BEFORE(lacpp0, lacpp, lp_entry_la); break; + } if (LIST_NEXT(lacpp0, lp_entry_la) == NULL) { - insert_after = true; + LIST_INSERT_AFTER(lacpp0, lacpp, lp_entry_la); break; } } - if (lacpp0 == NULL) { + if (lacpp0 == NULL) LIST_INSERT_HEAD(&la->la_ports, lacpp, lp_entry_la); - } else if (insert_after) { - LIST_INSERT_AFTER(lacpp0, lacpp, lp_entry_la); - } else { - LIST_INSERT_BEFORE(lacpp0, lacpp, lp_entry_la); - } lacp_selected_update(lsc, la); } @@ -2405,9 +2398,8 @@ lacp_unselect(struct lacp_softc *lsc, st TAILQ_REMOVE(&lsc->lsc_aggregators, la, la_q); kmem_free(la, sizeof(*la)); - if (remove_actaggr) { + if (remove_actaggr) lacp_select_active_aggregator(lsc); - } } else { lacp_selected_update(lsc, la); } @@ -2590,7 +2582,6 @@ lacp_dump_markertlv(const struct markerd ntohs(mi_res->mi_rq_port), ether_sprintf(mi_res->mi_rq_system), ntohl(mi_res->mi_rq_xid)); - } } Index: src/sys/net/lagg/if_laggproto.h diff -u src/sys/net/lagg/if_laggproto.h:1.10 src/sys/net/lagg/if_laggproto.h:1.11 --- src/sys/net/lagg/if_laggproto.h:1.10 Wed Jan 12 08:23:53 2022 +++ src/sys/net/lagg/if_laggproto.h Thu Mar 31 02:00:27 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: if_laggproto.h,v 1.10 2022/01/12 08:23:53 yamaguchi Exp $ */ +/* $NetBSD: if_laggproto.h,v 1.11 2022/03/31 02:00:27 yamaguchi Exp $ */ /* * Copyright (c) 2021 Internet Initiative Japan Inc. @@ -26,7 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _NET_LAGG_IF_LAGGPROTO_H_ +#ifndef _NET_LAGG_IF_LAGGPROTO_H_ #define _NET_LAGG_IF_LAGGPROTO_H_ struct lagg_softc; @@ -208,9 +208,9 @@ struct lagg_softc { #define LAGG_LOCKED(_sc) mutex_owned(&(_sc)->sc_lock) #define LAGG_CLLADDR(_sc) CLLADDR((_sc)->sc_if.if_sadl) -#define LAGG_PORTS_FOREACH(_sc, _lp) \ +#define LAGG_PORTS_FOREACH(_sc, _lp) \ SIMPLEQ_FOREACH((_lp), &(_sc)->sc_ports, lp_entry) -#define LAGG_PORTS_FIRST(_sc) SIMPLEQ_FIRST(&(_sc)->sc_ports) +#define LAGG_PORTS_FIRST(_sc) SIMPLEQ_FIRST(&(_sc)->sc_ports) #define LAGG_PORTS_EMPTY(_sc) SIMPLEQ_EMPTY(&(_sc)->sc_ports) #define LAGG_PORT_IOCTL(_lp, _cmd, _data) \ (_lp)->lp_ioctl == NULL ? ENOTTY : \ Index: src/sys/net/lagg/if_laggvar.h diff -u src/sys/net/lagg/if_laggvar.h:1.4 src/sys/net/lagg/if_laggvar.h:1.5 --- src/sys/net/lagg/if_laggvar.h:1.4 Thu Sep 30 04:29:17 2021 +++ src/sys/net/lagg/if_laggvar.h Thu Mar 31 02:00:27 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: if_laggvar.h,v 1.4 2021/09/30 04:29:17 yamaguchi Exp $ */ +/* $NetBSD: if_laggvar.h,v 1.5 2022/03/31 02:00:27 yamaguchi Exp $ */ /* * Copyright (c) 2021 Internet Initiative Japan Inc. @@ -26,7 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _NET_LAGG_IF_LAGGVAR_H_ +#ifndef _NET_LAGG_IF_LAGGVAR_H_ #define _NET_LAGG_IF_LAGGVAR_H_ extern struct mbuf *