Changeset View
Changeset View
Standalone View
Standalone View
head/sys/net/if_clone.c
Show First 20 Lines • Show All 381 Lines • ▼ Show 20 Lines | if_clone_advanced(const char *name, u_int maxunit, ifc_match_t match, | ||||
struct if_clone *ifc; | struct if_clone *ifc; | ||||
ifc = if_clone_alloc(name, maxunit); | ifc = if_clone_alloc(name, maxunit); | ||||
ifc->ifc_type = ADVANCED; | ifc->ifc_type = ADVANCED; | ||||
ifc->ifc_match = match; | ifc->ifc_match = match; | ||||
ifc->ifc_create = create; | ifc->ifc_create = create; | ||||
ifc->ifc_destroy = destroy; | ifc->ifc_destroy = destroy; | ||||
if (if_clone_attach(ifc) != 0) { | if (if_clone_attach(ifc) != 0) | ||||
if_clone_free(ifc); | |||||
return (NULL); | return (NULL); | ||||
} | |||||
EVENTHANDLER_INVOKE(if_clone_event, ifc); | EVENTHANDLER_INVOKE(if_clone_event, ifc); | ||||
return (ifc); | return (ifc); | ||||
} | } | ||||
struct if_clone * | struct if_clone * | ||||
if_clone_simple(const char *name, ifcs_create_t create, ifcs_destroy_t destroy, | if_clone_simple(const char *name, ifcs_create_t create, ifcs_destroy_t destroy, | ||||
u_int minifs) | u_int minifs) | ||||
{ | { | ||||
struct if_clone *ifc; | struct if_clone *ifc; | ||||
u_int unit; | u_int unit; | ||||
ifc = if_clone_alloc(name, 0); | ifc = if_clone_alloc(name, 0); | ||||
ifc->ifc_type = SIMPLE; | ifc->ifc_type = SIMPLE; | ||||
ifc->ifcs_create = create; | ifc->ifcs_create = create; | ||||
ifc->ifcs_destroy = destroy; | ifc->ifcs_destroy = destroy; | ||||
ifc->ifcs_minifs = minifs; | ifc->ifcs_minifs = minifs; | ||||
if (if_clone_attach(ifc) != 0) { | if (if_clone_attach(ifc) != 0) | ||||
if_clone_free(ifc); | |||||
return (NULL); | return (NULL); | ||||
} | |||||
for (unit = 0; unit < minifs; unit++) { | for (unit = 0; unit < minifs; unit++) { | ||||
char name[IFNAMSIZ]; | char name[IFNAMSIZ]; | ||||
int error; | int error; | ||||
snprintf(name, IFNAMSIZ, "%s%d", ifc->ifc_name, unit); | snprintf(name, IFNAMSIZ, "%s%d", ifc->ifc_name, unit); | ||||
error = if_clone_createif(ifc, name, IFNAMSIZ, NULL); | error = if_clone_createif(ifc, name, IFNAMSIZ, NULL); | ||||
KASSERT(error == 0, | KASSERT(error == 0, | ||||
▲ Show 20 Lines • Show All 314 Lines • Show Last 20 Lines |