| 406 | } |
| 407 | |
| 408 | struct if_clone * |
| 409 | if_clone_simple(const char *name, ifcs_create_t create, ifcs_destroy_t destroy, |
| 410 | u_int minifs) |
| 411 | { |
| 412 | struct if_clone *ifc; |
| 413 | u_int unit; |
| 414 | |
| 415 | ifc = if_clone_alloc(name, 0); |
| 416 | ifc->ifc_type = SIMPLE; |
| 417 | ifc->ifcs_create = create; |
| 418 | ifc->ifcs_destroy = destroy; |
| 419 | ifc->ifcs_minifs = minifs; |
| 420 | |
| 421 | if (if_clone_attach(ifc) != 0) |
| 422 | return (NULL); |
| 423 | |
| 424 | for (unit = 0; unit < minifs; unit++) { |
| 425 | char name[IFNAMSIZ]; |
| 426 | int error __unused; |
| 427 | |
| 428 | snprintf(name, IFNAMSIZ, "%s%d", ifc->ifc_name, unit); |
| 429 | error = if_clone_createif(ifc, name, IFNAMSIZ, NULL); |
| 430 | KASSERT(error == 0, |
| 431 | ("%s: failed to create required interface %s", |
| 432 | __func__, name)); |
| 433 | } |
| 434 | |
| 435 | EVENTHANDLER_INVOKE(if_clone_event, ifc); |
| 436 | |
| 437 | return (ifc); |
| 438 | } |
| 439 | |
| 440 | /* |
| 441 | * Unregister a network interface cloner. |
no test coverage detected