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

Function tun_clone_create

freebsd/net/if_tuntap.c:516–553  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

514}
515
516static int
517tun_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params)
518{
519 struct tuntap_driver *drv;
520 struct cdev *dev;
521 int err, i, tunflags, unit;
522
523 tunflags = 0;
524 /* The name here tells us exactly what we're creating */
525 err = tuntap_name2info(name, &unit, &tunflags);
526 if (err != 0)
527 return (err);
528
529 drv = tuntap_driver_from_flags(tunflags);
530 if (drv == NULL)
531 return (ENXIO);
532
533 if (unit != -1) {
534 /* If this unit number is still available that's okay. */
535 if (alloc_unr_specific(drv->unrhdr, unit) == -1)
536 return (EEXIST);
537 } else {
538 unit = alloc_unr(drv->unrhdr);
539 }
540
541 snprintf(name, IFNAMSIZ, "%s%d", drv->cdevsw.d_name, unit);
542
543 /* find any existing device, or allocate new unit number */
544 dev = NULL;
545 i = clone_create(&drv->clones, &drv->cdevsw, &unit, &dev, 0);
546 /* No preexisting struct cdev *, create one */
547 if (i != 0)
548 i = tun_create_device(drv, unit, NULL, &dev, name);
549 if (i == 0)
550 tuncreate(dev);
551
552 return (i);
553}
554
555static void
556tunclone(void *arg, struct ucred *cred, char *name, int namelen,

Callers

nothing calls this directly

Calls 8

tuntap_name2infoFunction · 0.85
tuntap_driver_from_flagsFunction · 0.85
alloc_unr_specificFunction · 0.85
alloc_unrFunction · 0.85
snprintfFunction · 0.85
clone_createFunction · 0.85
tun_create_deviceFunction · 0.85
tuncreateFunction · 0.85

Tested by

no test coverage detected