Date: Tue, 2 May 2017 19:30:05 +0000 (UTC) From: Alexander Motin <mav@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r317698 - stable/11/sys/net Message-ID: <201705021930.v42JU5iN025120@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mav Date: Tue May 2 19:30:05 2017 New Revision: 317698 URL: https://svnweb.freebsd.org/changeset/base/317698 Log: MFC r317253: Add interface reference counting to if_lagg. Using plain ifunit() looks like request for troubles. Modified: stable/11/sys/net/if_lagg.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/net/if_lagg.c ============================================================================== --- stable/11/sys/net/if_lagg.c Tue May 2 19:29:31 2017 (r317697) +++ stable/11/sys/net/if_lagg.c Tue May 2 19:30:05 2017 (r317698) @@ -672,6 +672,7 @@ lagg_port_lladdr(struct lagg_port *lp, u if (llq == NULL) /* XXX what to do */ return; + if_ref(ifp); llq->llq_ifp = ifp; llq->llq_type = llq_type; bcopy(lladdr, llq->llq_lladdr, ETHER_ADDR_LEN); @@ -720,6 +721,7 @@ lagg_port_setlladdr(void *arg, int pendi EVENTHANDLER_INVOKE(iflladdr_event, ifp); CURVNET_RESTORE(); head = SLIST_NEXT(llq, llq_entries); + if_rele(ifp); free(llq, M_DEVBUF); } } @@ -794,6 +796,7 @@ lagg_port_create(struct lagg_softc *sc, lp->lp_output = ifp->if_output; ifp->if_output = lagg_port_output; + if_ref(ifp); lp->lp_ifp = ifp; lp->lp_softc = sc; @@ -947,6 +950,7 @@ lagg_port_destroy(struct lagg_port *lp, if (llq->llq_ifp == ifp) { SLIST_REMOVE(&sc->sc_llq_head, llq, lagg_llq, llq_entries); + if_rele(llq->llq_ifp); free(llq, M_DEVBUF); break; /* Only appears once */ } @@ -956,6 +960,7 @@ lagg_port_destroy(struct lagg_port *lp, if (lp->lp_ifflags) if_printf(ifp, "%s: lp_ifflags unclean\n", __func__); + if_rele(ifp); free(lp, M_DEVBUF); /* Update lagg capabilities */ @@ -1432,7 +1437,7 @@ lagg_ioctl(struct ifnet *ifp, u_long cmd break; case SIOCGLAGGPORT: if (rp->rp_portname[0] == '\0' || - (tpif = ifunit(rp->rp_portname)) == NULL) { + (tpif = ifunit_ref(rp->rp_portname)) == NULL) { error = EINVAL; break; } @@ -1442,18 +1447,20 @@ lagg_ioctl(struct ifnet *ifp, u_long cmd lp->lp_softc != sc) { error = ENOENT; LAGG_RUNLOCK(sc, &tracker); + if_rele(tpif); break; } lagg_port2req(lp, rp); LAGG_RUNLOCK(sc, &tracker); + if_rele(tpif); break; case SIOCSLAGGPORT: error = priv_check(td, PRIV_NET_LAGG); if (error) break; if (rp->rp_portname[0] == '\0' || - (tpif = ifunit(rp->rp_portname)) == NULL) { + (tpif = ifunit_ref(rp->rp_portname)) == NULL) { error = EINVAL; break; } @@ -1480,13 +1487,14 @@ lagg_ioctl(struct ifnet *ifp, u_long cmd LAGG_WLOCK(sc); error = lagg_port_create(sc, tpif); LAGG_WUNLOCK(sc); + if_rele(tpif); break; case SIOCSLAGGDELPORT: error = priv_check(td, PRIV_NET_LAGG); if (error) break; if (rp->rp_portname[0] == '\0' || - (tpif = ifunit(rp->rp_portname)) == NULL) { + (tpif = ifunit_ref(rp->rp_portname)) == NULL) { error = EINVAL; break; } @@ -1496,11 +1504,13 @@ lagg_ioctl(struct ifnet *ifp, u_long cmd lp->lp_softc != sc) { error = ENOENT; LAGG_WUNLOCK(sc); + if_rele(tpif); break; } error = lagg_port_destroy(lp, 1); LAGG_WUNLOCK(sc); + if_rele(tpif); break; case SIOCSIFFLAGS: /* Set flags on ports too */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201705021930.v42JU5iN025120>