| 503 | } |
| 504 | |
| 505 | static int |
| 506 | lagg_clone_create(struct if_clone *ifc, int unit, caddr_t params) |
| 507 | { |
| 508 | struct iflaggparam iflp; |
| 509 | struct lagg_softc *sc; |
| 510 | struct ifnet *ifp; |
| 511 | int if_type; |
| 512 | int error; |
| 513 | static const uint8_t eaddr[LAGG_ADDR_LEN]; |
| 514 | |
| 515 | if (params != NULL) { |
| 516 | error = copyin(params, &iflp, sizeof(iflp)); |
| 517 | if (error) |
| 518 | return (error); |
| 519 | |
| 520 | switch (iflp.lagg_type) { |
| 521 | case LAGG_TYPE_ETHERNET: |
| 522 | if_type = IFT_ETHER; |
| 523 | break; |
| 524 | case LAGG_TYPE_INFINIBAND: |
| 525 | if_type = IFT_INFINIBAND; |
| 526 | break; |
| 527 | default: |
| 528 | return (EINVAL); |
| 529 | } |
| 530 | } else { |
| 531 | if_type = IFT_ETHER; |
| 532 | } |
| 533 | |
| 534 | sc = malloc(sizeof(*sc), M_LAGG, M_WAITOK|M_ZERO); |
| 535 | ifp = sc->sc_ifp = if_alloc(if_type); |
| 536 | if (ifp == NULL) { |
| 537 | free(sc, M_LAGG); |
| 538 | return (ENOSPC); |
| 539 | } |
| 540 | LAGG_SX_INIT(sc); |
| 541 | |
| 542 | mtx_init(&sc->sc_mtx, "lagg-mtx", NULL, MTX_DEF); |
| 543 | callout_init_mtx(&sc->sc_watchdog, &sc->sc_mtx, 0); |
| 544 | |
| 545 | LAGG_XLOCK(sc); |
| 546 | if (V_def_use_flowid) |
| 547 | sc->sc_opts |= LAGG_OPT_USE_FLOWID; |
| 548 | if (V_def_use_numa) |
| 549 | sc->sc_opts |= LAGG_OPT_USE_NUMA; |
| 550 | sc->flowid_shift = V_def_flowid_shift; |
| 551 | |
| 552 | /* Hash all layers by default */ |
| 553 | sc->sc_flags = MBUF_HASHFLAG_L2|MBUF_HASHFLAG_L3|MBUF_HASHFLAG_L4; |
| 554 | |
| 555 | lagg_proto_attach(sc, LAGG_PROTO_DEFAULT); |
| 556 | |
| 557 | CK_SLIST_INIT(&sc->sc_ports); |
| 558 | |
| 559 | switch (if_type) { |
| 560 | case IFT_ETHER: |
| 561 | /* Initialise pseudo media types */ |
| 562 | ifmedia_init(&sc->sc_media, 0, lagg_media_change, |
nothing calls this directly
no test coverage detected