| 687 | } |
| 688 | |
| 689 | static int |
| 690 | ifc_simple_create(struct if_clone *ifc, char *name, size_t len, caddr_t params) |
| 691 | { |
| 692 | char *dp; |
| 693 | int wildcard; |
| 694 | int unit; |
| 695 | int err; |
| 696 | |
| 697 | err = ifc_name2unit(name, &unit); |
| 698 | if (err != 0) |
| 699 | return (err); |
| 700 | |
| 701 | wildcard = (unit < 0); |
| 702 | |
| 703 | err = ifc_alloc_unit(ifc, &unit); |
| 704 | if (err != 0) |
| 705 | return (err); |
| 706 | |
| 707 | err = ifc->ifcs_create(ifc, unit, params); |
| 708 | if (err != 0) { |
| 709 | ifc_free_unit(ifc, unit); |
| 710 | return (err); |
| 711 | } |
| 712 | |
| 713 | /* In the wildcard case, we need to update the name. */ |
| 714 | if (wildcard) { |
| 715 | for (dp = name; *dp != '\0'; dp++); |
| 716 | if (snprintf(dp, len - (dp-name), "%d", unit) > |
| 717 | len - (dp-name) - 1) { |
| 718 | /* |
| 719 | * This can only be a programmer error and |
| 720 | * there's no straightforward way to recover if |
| 721 | * it happens. |
| 722 | */ |
| 723 | panic("if_clone_create(): interface name too long"); |
| 724 | } |
| 725 | } |
| 726 | |
| 727 | return (0); |
| 728 | } |
| 729 | |
| 730 | static int |
| 731 | ifc_simple_destroy(struct if_clone *ifc, struct ifnet *ifp) |
no test coverage detected