MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ifc_simple_create

Function ifc_simple_create

freebsd/net/if_clone.c:689–728  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

687}
688
689static int
690ifc_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
730static int
731ifc_simple_destroy(struct if_clone *ifc, struct ifnet *ifp)

Callers 1

if_clone_createifFunction · 0.85

Calls 5

ifc_name2unitFunction · 0.85
ifc_alloc_unitFunction · 0.85
ifc_free_unitFunction · 0.85
snprintfFunction · 0.85
panicFunction · 0.50

Tested by

no test coverage detected