From 0bb9541b3cb54295e815b754e611ed775fecbc58 Mon Sep 17 00:00:00 2001 From: mpi Date: Wed, 19 Sep 2018 13:17:21 +0000 Subject: [PATCH] Always call bridge_iflist `bif'. ok bluhm@, visa@ --- sys/net/if_bridge.c | 222 ++++++++++++++++++++++---------------------- 1 file changed, 111 insertions(+), 111 deletions(-) diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c index 6374fa20495..38e2509c9fa 100644 --- a/sys/net/if_bridge.c +++ b/sys/net/if_bridge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bridge.c,v 1.308 2018/04/19 22:31:25 dlg Exp $ */ +/* $OpenBSD: if_bridge.c,v 1.309 2018/09/19 13:17:21 mpi Exp $ */ /* * Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net) @@ -233,22 +233,22 @@ bridge_clone_destroy(struct ifnet *ifp) } int -bridge_delete(struct bridge_softc *sc, struct bridge_iflist *p) +bridge_delete(struct bridge_softc *sc, struct bridge_iflist *bif) { int error; - if (p->bif_flags & IFBIF_STP) - bstp_delete(p->bif_stp); + if (bif->bif_flags & IFBIF_STP) + bstp_delete(bif->bif_stp); - p->ifp->if_bridgeport = NULL; - error = ifpromisc(p->ifp, 0); - hook_disestablish(p->ifp->if_detachhooks, p->bif_dhcookie); + bif->ifp->if_bridgeport = NULL; + error = ifpromisc(bif->ifp, 0); + hook_disestablish(bif->ifp->if_detachhooks, bif->bif_dhcookie); - if_ih_remove(p->ifp, bridge_input, NULL); - TAILQ_REMOVE(&sc->sc_iflist, p, next); - bridge_rtdelete(sc, p->ifp, 0); - bridge_flushrule(p); - free(p, M_DEVBUF, sizeof *p); + if_ih_remove(bif->ifp, bridge_input, NULL); + TAILQ_REMOVE(&sc->sc_iflist, bif, next); + bridge_rtdelete(sc, bif->ifp, 0); + bridge_flushrule(bif); + free(bif, M_DEVBUF, sizeof *bif); return (error); } @@ -260,7 +260,7 @@ bridge_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) struct ifbreq *req = (struct ifbreq *)data; struct ifbropreq *brop = (struct ifbropreq *)data; struct ifnet *ifs; - struct bridge_iflist *p; + struct bridge_iflist *bif; struct bstp_port *bp; struct bstp_state *bs = sc->sc_stp; int error = 0; @@ -284,8 +284,8 @@ bridge_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) } if (ifs->if_bridgeport != NULL) { - p = (struct bridge_iflist *)ifs->if_bridgeport; - if (p->bridge_sc == sc) + bif = (struct bridge_iflist *)ifs->if_bridgeport; + if (bif->bridge_sc == sc) error = EEXIST; else error = EBUSY; @@ -293,10 +293,10 @@ bridge_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) } /* If it's in the span list, it can't be a member. */ - TAILQ_FOREACH(p, &sc->sc_spanlist, next) - if (p->ifp == ifs) + TAILQ_FOREACH(bif, &sc->sc_spanlist, next) + if (bif->ifp == ifs) break; - if (p != NULL) { + if (bif != NULL) { error = EBUSY; break; } @@ -316,24 +316,24 @@ bridge_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) break; } - p = malloc(sizeof(*p), M_DEVBUF, M_NOWAIT|M_ZERO); - if (p == NULL) { + bif = malloc(sizeof(*bif), M_DEVBUF, M_NOWAIT|M_ZERO); + if (bif == NULL) { if (ifs->if_type == IFT_ETHER) ifpromisc(ifs, 0); error = ENOMEM; break; } - p->bridge_sc = sc; - p->ifp = ifs; - p->bif_flags = IFBIF_LEARNING | IFBIF_DISCOVER; - SIMPLEQ_INIT(&p->bif_brlin); - SIMPLEQ_INIT(&p->bif_brlout); - ifs->if_bridgeport = (caddr_t)p; - p->bif_dhcookie = hook_establish(ifs->if_detachhooks, 0, + bif->bridge_sc = sc; + bif->ifp = ifs; + bif->bif_flags = IFBIF_LEARNING | IFBIF_DISCOVER; + SIMPLEQ_INIT(&bif->bif_brlin); + SIMPLEQ_INIT(&bif->bif_brlout); + ifs->if_bridgeport = (caddr_t)bif; + bif->bif_dhcookie = hook_establish(ifs->if_detachhooks, 0, bridge_ifdetach, ifs); - if_ih_insert(p->ifp, bridge_input, NULL); - TAILQ_INSERT_TAIL(&sc->sc_iflist, p, next); + if_ih_insert(bif->ifp, bridge_input, NULL); + TAILQ_INSERT_TAIL(&sc->sc_iflist, bif, next); break; case SIOCBRDGDEL: if ((error = suser(curproc)) != 0) @@ -343,12 +343,12 @@ bridge_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) error = ENOENT; break; } - p = (struct bridge_iflist *)ifs->if_bridgeport; - if (p == NULL || p->bridge_sc != sc) { + bif = (struct bridge_iflist *)ifs->if_bridgeport; + if (bif == NULL || bif->bridge_sc != sc) { error = ESRCH; break; } - error = bridge_delete(sc, p); + error = bridge_delete(sc, bif); break; case SIOCBRDGIFS: error = bridge_bifconf(sc, (struct ifbifconf *)data); @@ -370,39 +370,39 @@ bridge_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) error = EBUSY; break; } - TAILQ_FOREACH(p, &sc->sc_spanlist, next) { - if (p->ifp == ifs) + TAILQ_FOREACH(bif, &sc->sc_spanlist, next) { + if (bif->ifp == ifs) break; } - if (p != NULL) { + if (bif != NULL) { error = EEXIST; break; } - p = malloc(sizeof(*p), M_DEVBUF, M_NOWAIT|M_ZERO); - if (p == NULL) { + bif = malloc(sizeof(*bif), M_DEVBUF, M_NOWAIT|M_ZERO); + if (bif == NULL) { error = ENOMEM; break; } - p->ifp = ifs; - p->bif_flags = IFBIF_SPAN; - p->bridge_sc = sc; - p->bif_dhcookie = hook_establish(ifs->if_detachhooks, 0, - bridge_spandetach, p); - SIMPLEQ_INIT(&p->bif_brlin); - SIMPLEQ_INIT(&p->bif_brlout); - TAILQ_INSERT_TAIL(&sc->sc_spanlist, p, next); + bif->ifp = ifs; + bif->bif_flags = IFBIF_SPAN; + bif->bridge_sc = sc; + bif->bif_dhcookie = hook_establish(ifs->if_detachhooks, 0, + bridge_spandetach, bif); + SIMPLEQ_INIT(&bif->bif_brlin); + SIMPLEQ_INIT(&bif->bif_brlout); + TAILQ_INSERT_TAIL(&sc->sc_spanlist, bif, next); break; case SIOCBRDGDELS: if ((error = suser(curproc)) != 0) break; - TAILQ_FOREACH(p, &sc->sc_spanlist, next) { - if (strncmp(p->ifp->if_xname, req->ifbr_ifsname, - sizeof(p->ifp->if_xname)) == 0) { - bridge_spandetach(p); + TAILQ_FOREACH(bif, &sc->sc_spanlist, next) { + if (strncmp(bif->ifp->if_xname, req->ifbr_ifsname, + sizeof(bif->ifp->if_xname)) == 0) { + bridge_spandetach(bif); break; } } - if (p == NULL) { + if (bif == NULL) { error = ENOENT; break; } @@ -413,16 +413,16 @@ bridge_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) error = ENOENT; break; } - p = (struct bridge_iflist *)ifs->if_bridgeport; - if (p == NULL || p->bridge_sc != sc) { + bif = (struct bridge_iflist *)ifs->if_bridgeport; + if (bif == NULL || bif->bridge_sc != sc) { error = ESRCH; break; } - req->ifbr_ifsflags = p->bif_flags; - req->ifbr_portno = p->ifp->if_index & 0xfff; - req->ifbr_protected = p->bif_protected; - if (p->bif_flags & IFBIF_STP) { - bp = p->bif_stp; + req->ifbr_ifsflags = bif->bif_flags; + req->ifbr_portno = bif->ifp->if_index & 0xfff; + req->ifbr_protected = bif->bif_protected; + if (bif->bif_flags & IFBIF_STP) { + bp = bif->bif_stp; req->ifbr_state = bstp_getstate(bs, bp); req->ifbr_priority = bp->bp_priority; req->ifbr_path_cost = bp->bp_path_cost; @@ -455,8 +455,8 @@ bridge_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) error = ENOENT; break; } - p = (struct bridge_iflist *)ifs->if_bridgeport; - if (p == NULL || p->bridge_sc != sc) { + bif = (struct bridge_iflist *)ifs->if_bridgeport; + if (bif == NULL || bif->bridge_sc != sc) { error = ESRCH; break; } @@ -465,22 +465,22 @@ bridge_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) break; } if (req->ifbr_ifsflags & IFBIF_STP) { - if ((p->bif_flags & IFBIF_STP) == 0) { + if ((bif->bif_flags & IFBIF_STP) == 0) { /* Enable STP */ - if ((p->bif_stp = bstp_add(sc->sc_stp, - p->ifp)) == NULL) { + if ((bif->bif_stp = bstp_add(sc->sc_stp, + bif->ifp)) == NULL) { error = ENOMEM; break; } } else { /* Update STP flags */ - bstp_ifsflags(p->bif_stp, req->ifbr_ifsflags); + bstp_ifsflags(bif->bif_stp, req->ifbr_ifsflags); } - } else if (p->bif_flags & IFBIF_STP) { - bstp_delete(p->bif_stp); - p->bif_stp = NULL; + } else if (bif->bif_flags & IFBIF_STP) { + bstp_delete(bif->bif_stp); + bif->bif_stp = NULL; } - p->bif_flags = req->ifbr_ifsflags; + bif->bif_flags = req->ifbr_ifsflags; break; case SIOCSIFFLAGS: if ((ifp->if_flags & IFF_UP) == IFF_UP) @@ -514,12 +514,12 @@ bridge_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) error = ENOENT; break; } - p = (struct bridge_iflist *)ifs->if_bridgeport; - if (p == NULL || p->bridge_sc != sc) { + bif = (struct bridge_iflist *)ifs->if_bridgeport; + if (bif == NULL || bif->bridge_sc != sc) { error = ESRCH; break; } - p->bif_protected = req->ifbr_protected; + bif->bif_protected = req->ifbr_protected; break; case SIOCBRDGRTS: case SIOCBRDGGCACHE: @@ -578,28 +578,28 @@ bridge_ifdetach(void *arg) void bridge_spandetach(void *arg) { - struct bridge_iflist *p = (struct bridge_iflist *)arg; - struct bridge_softc *sc = p->bridge_sc; + struct bridge_iflist *bif = (struct bridge_iflist *)arg; + struct bridge_softc *sc = bif->bridge_sc; - hook_disestablish(p->ifp->if_detachhooks, p->bif_dhcookie); - TAILQ_REMOVE(&sc->sc_spanlist, p, next); - free(p, M_DEVBUF, sizeof(*p)); + hook_disestablish(bif->ifp->if_detachhooks, bif->bif_dhcookie); + TAILQ_REMOVE(&sc->sc_spanlist, bif, next); + free(bif, M_DEVBUF, sizeof(*bif)); } int bridge_bifconf(struct bridge_softc *sc, struct ifbifconf *bifc) { - struct bridge_iflist *p; + struct bridge_iflist *bif; struct bstp_port *bp; struct bstp_state *bs = sc->sc_stp; u_int32_t total = 0, i = 0; int error = 0; struct ifbreq *breq = NULL; - TAILQ_FOREACH(p, &sc->sc_iflist, next) + TAILQ_FOREACH(bif, &sc->sc_iflist, next) total++; - TAILQ_FOREACH(p, &sc->sc_spanlist, next) + TAILQ_FOREACH(bif, &sc->sc_spanlist, next) total++; if (bifc->ifbic_len == 0) { @@ -611,17 +611,17 @@ bridge_bifconf(struct bridge_softc *sc, struct ifbifconf *bifc) malloc(sizeof(*breq), M_DEVBUF, M_NOWAIT)) == NULL) goto done; - TAILQ_FOREACH(p, &sc->sc_iflist, next) { + TAILQ_FOREACH(bif, &sc->sc_iflist, next) { bzero(breq, sizeof(*breq)); if (bifc->ifbic_len < sizeof(*breq)) break; strlcpy(breq->ifbr_name, sc->sc_if.if_xname, IFNAMSIZ); - strlcpy(breq->ifbr_ifsname, p->ifp->if_xname, IFNAMSIZ); - breq->ifbr_ifsflags = p->bif_flags; - breq->ifbr_portno = p->ifp->if_index & 0xfff; - breq->ifbr_protected = p->bif_protected; - if (p->bif_flags & IFBIF_STP) { - bp = p->bif_stp; + strlcpy(breq->ifbr_ifsname, bif->ifp->if_xname, IFNAMSIZ); + breq->ifbr_ifsflags = bif->bif_flags; + breq->ifbr_portno = bif->ifp->if_index & 0xfff; + breq->ifbr_protected = bif->bif_protected; + if (bif->bif_flags & IFBIF_STP) { + bp = bif->bif_stp; breq->ifbr_state = bstp_getstate(sc->sc_stp, bp); breq->ifbr_priority = bp->bp_priority; breq->ifbr_path_cost = bp->bp_path_cost; @@ -652,14 +652,14 @@ bridge_bifconf(struct bridge_softc *sc, struct ifbifconf *bifc) i++; bifc->ifbic_len -= sizeof(*breq); } - TAILQ_FOREACH(p, &sc->sc_spanlist, next) { + TAILQ_FOREACH(bif, &sc->sc_spanlist, next) { bzero(breq, sizeof(*breq)); if (bifc->ifbic_len < sizeof(*breq)) break; strlcpy(breq->ifbr_name, sc->sc_if.if_xname, IFNAMSIZ); - strlcpy(breq->ifbr_ifsname, p->ifp->if_xname, IFNAMSIZ); - breq->ifbr_ifsflags = p->bif_flags | IFBIF_SPAN; - breq->ifbr_portno = p->ifp->if_index & 0xfff; + strlcpy(breq->ifbr_ifsname, bif->ifp->if_xname, IFNAMSIZ); + breq->ifbr_ifsflags = bif->bif_flags | IFBIF_SPAN; + breq->ifbr_portno = bif->ifp->if_index & 0xfff; error = copyout((caddr_t)breq, (caddr_t)(bifc->ifbic_req + i), sizeof(*breq)); if (error) @@ -767,14 +767,14 @@ bridge_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *sa, if ((dst_p = bridge_rtlookup(sc, dst)) != NULL) dst_if = dst_p->brt_if; if (dst_if == NULL || ETHER_IS_MULTICAST(eh->ether_dhost)) { - struct bridge_iflist *p; + struct bridge_iflist *bif; struct mbuf *mc; int used = 0; bridge_span(sc, m); - TAILQ_FOREACH(p, &sc->sc_iflist, next) { - dst_if = p->ifp; + TAILQ_FOREACH(bif, &sc->sc_iflist, next) { + dst_if = bif->ifp; if ((dst_if->if_flags & IFF_RUNNING) == 0) continue; @@ -785,8 +785,8 @@ bridge_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *sa, * allows forwarding. */ if (dst_if != ifp && - (p->bif_flags & IFBIF_STP) && - (p->bif_state == BSTP_IFSTATE_DISCARDING)) + (bif->bif_flags & IFBIF_STP) && + (bif->bif_state == BSTP_IFSTATE_DISCARDING)) continue; #if NMPW > 0 /* @@ -797,11 +797,11 @@ bridge_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *sa, dst_if->if_type == IFT_MPLSTUNNEL) continue; #endif /* NMPW */ - if ((p->bif_flags & IFBIF_DISCOVER) == 0 && + if ((bif->bif_flags & IFBIF_DISCOVER) == 0 && (m->m_flags & (M_BCAST | M_MCAST)) == 0) continue; - if (TAILQ_NEXT(p, next) == NULL) { + if (TAILQ_NEXT(bif, next) == NULL) { used = 1; mc = m; } else { @@ -1205,31 +1205,31 @@ void bridge_broadcast(struct bridge_softc *sc, struct ifnet *ifp, struct ether_header *eh, struct mbuf *m) { - struct bridge_iflist *p; + struct bridge_iflist *bif; struct mbuf *mc; struct ifnet *dst_if; int len, used = 0; u_int32_t protected; - p = (struct bridge_iflist *)ifp->if_bridgeport; - protected = p->bif_protected; + bif = (struct bridge_iflist *)ifp->if_bridgeport; + protected = bif->bif_protected; - TAILQ_FOREACH(p, &sc->sc_iflist, next) { - dst_if = p->ifp; + TAILQ_FOREACH(bif, &sc->sc_iflist, next) { + dst_if = bif->ifp; if ((dst_if->if_flags & IFF_RUNNING) == 0) continue; - if ((p->bif_flags & IFBIF_STP) && - (p->bif_state == BSTP_IFSTATE_DISCARDING)) + if ((bif->bif_flags & IFBIF_STP) && + (bif->bif_state == BSTP_IFSTATE_DISCARDING)) continue; - if ((p->bif_flags & IFBIF_DISCOVER) == 0 && + if ((bif->bif_flags & IFBIF_DISCOVER) == 0 && (m->m_flags & (M_BCAST | M_MCAST)) == 0) continue; /* Drop non-IP frames if the appropriate flag is set. */ - if (p->bif_flags & IFBIF_BLOCKNONIP && + if (bif->bif_flags & IFBIF_BLOCKNONIP && bridge_blocknonip(eh, m)) continue; @@ -1237,10 +1237,10 @@ bridge_broadcast(struct bridge_softc *sc, struct ifnet *ifp, * Do not transmit if both ports are part of the same * protected domain. */ - if (protected != 0 && (protected & p->bif_protected)) + if (protected != 0 && (protected & bif->bif_protected)) continue; - if (bridge_filterrule(&p->bif_brlout, eh, m) == BRL_ACTION_BLOCK) + if (bridge_filterrule(&bif->bif_brlout, eh, m) == BRL_ACTION_BLOCK) continue; /* @@ -1263,7 +1263,7 @@ bridge_broadcast(struct bridge_softc *sc, struct ifnet *ifp, #endif /* NMPW */ /* If last one, reuse the passed-in mbuf */ - if (TAILQ_NEXT(p, next) == NULL) { + if (TAILQ_NEXT(bif, next) == NULL) { mc = m; used = 1; } else { @@ -1333,13 +1333,13 @@ bridge_localbroadcast(struct bridge_softc *sc, struct ifnet *ifp, void bridge_span(struct bridge_softc *sc, struct mbuf *m) { - struct bridge_iflist *p; + struct bridge_iflist *bif; struct ifnet *ifp; struct mbuf *mc; int error; - TAILQ_FOREACH(p, &sc->sc_spanlist, next) { - ifp = p->ifp; + TAILQ_FOREACH(bif, &sc->sc_spanlist, next) { + ifp = bif->ifp; if ((ifp->if_flags & IFF_RUNNING) == 0) continue; -- 2.20.1