MCPcopy Create free account
hub / github.com/F-Stack/f-stack / bridge_clone_create

Function bridge_clone_create

freebsd/net/if_bridge.c:678–725  ·  view source on GitHub ↗

* bridge_clone_create: * * Create a new bridge instance. */

Source from the content-addressed store, hash-verified

676 * Create a new bridge instance.
677 */
678static int
679bridge_clone_create(struct if_clone *ifc, int unit, caddr_t params)
680{
681 struct bridge_softc *sc;
682 struct ifnet *ifp;
683
684 sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK|M_ZERO);
685 ifp = sc->sc_ifp = if_alloc(IFT_ETHER);
686 if (ifp == NULL) {
687 free(sc, M_DEVBUF);
688 return (ENOSPC);
689 }
690
691 BRIDGE_LOCK_INIT(sc);
692 sc->sc_brtmax = BRIDGE_RTABLE_MAX;
693 sc->sc_brttimeout = BRIDGE_RTABLE_TIMEOUT;
694
695 /* Initialize our routing table. */
696 bridge_rtable_init(sc);
697
698 callout_init_mtx(&sc->sc_brcallout, &sc->sc_rt_mtx, 0);
699
700 CK_LIST_INIT(&sc->sc_iflist);
701 CK_LIST_INIT(&sc->sc_spanlist);
702
703 ifp->if_softc = sc;
704 if_initname(ifp, bridge_name, unit);
705 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
706 ifp->if_ioctl = bridge_ioctl;
707 ifp->if_transmit = bridge_transmit;
708 ifp->if_qflush = bridge_qflush;
709 ifp->if_init = bridge_init;
710 ifp->if_type = IFT_BRIDGE;
711
712 ether_gen_addr(ifp, &sc->sc_defaddr);
713
714 bstp_attach(&sc->sc_stp, &bridge_ops);
715 ether_ifattach(ifp, sc->sc_defaddr.octet);
716 /* Now undo some of the damage... */
717 ifp->if_baudrate = 0;
718 ifp->if_type = IFT_BRIDGE;
719
720 BRIDGE_LIST_LOCK();
721 LIST_INSERT_HEAD(&V_bridge_list, sc, sc_list);
722 BRIDGE_LIST_UNLOCK();
723
724 return (0);
725}
726
727static void
728bridge_clone_destroy_cb(struct epoch_context *ctx)

Callers

nothing calls this directly

Calls 8

mallocFunction · 0.85
if_allocFunction · 0.85
bridge_rtable_initFunction · 0.85
if_initnameFunction · 0.85
ether_gen_addrFunction · 0.85
bstp_attachFunction · 0.85
ether_ifattachFunction · 0.85
freeFunction · 0.50

Tested by

no test coverage detected