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

Function tun_create_device

freebsd/net/if_tuntap.c:795–833  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

793MODULE_VERSION(if_tap, 1);
794
795static int
796tun_create_device(struct tuntap_driver *drv, int unit, struct ucred *cr,
797 struct cdev **dev, const char *name)
798{
799 struct make_dev_args args;
800 struct tuntap_softc *tp;
801 int error;
802
803 tp = malloc(sizeof(*tp), M_TUN, M_WAITOK | M_ZERO);
804 mtx_init(&tp->tun_mtx, "tun_mtx", NULL, MTX_DEF);
805 cv_init(&tp->tun_cv, "tun_condvar");
806 tp->tun_flags = drv->ident_flags;
807 tp->tun_drv = drv;
808
809 make_dev_args_init(&args);
810 if (cr != NULL)
811 args.mda_flags = MAKEDEV_REF;
812 args.mda_devsw = &drv->cdevsw;
813 args.mda_cr = cr;
814 args.mda_uid = UID_UUCP;
815 args.mda_gid = GID_DIALER;
816 args.mda_mode = 0600;
817 args.mda_unit = unit;
818 args.mda_si_drv1 = tp;
819 error = make_dev_s(&args, dev, "%s", name);
820 if (error != 0) {
821 free(tp, M_TUN);
822 return (error);
823 }
824
825 KASSERT((*dev)->si_drv1 != NULL,
826 ("Failed to set si_drv1 at %s creation", name));
827 tp->tun_dev = *dev;
828 knlist_init_mtx(&tp->tun_rsel.si_note, &tp->tun_mtx);
829 mtx_lock(&tunmtx);
830 TAILQ_INSERT_TAIL(&tunhead, tp, tun_list);
831 mtx_unlock(&tunmtx);
832 return (0);
833}
834
835static void
836tunstart(struct ifnet *ifp)

Callers 2

tun_clone_createFunction · 0.85
tuncloneFunction · 0.85

Calls 8

mallocFunction · 0.85
mtx_initFunction · 0.85
make_dev_sFunction · 0.85
knlist_init_mtxFunction · 0.85
cv_initFunction · 0.50
freeFunction · 0.50
mtx_lockFunction · 0.50
mtx_unlockFunction · 0.50

Tested by

no test coverage detected