* bridge_clone_create: * * Create a new bridge instance. */
| 676 | * Create a new bridge instance. |
| 677 | */ |
| 678 | static int |
| 679 | bridge_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 | |
| 727 | static void |
| 728 | bridge_clone_destroy_cb(struct epoch_context *ctx) |
nothing calls this directly
no test coverage detected