FreeBSD/sys/dev/netmap/netmap_vale.c
/*
 * Create a virtual interface registered to the system.
 * The interface will be attached to a bridge later.
 */
Create a virtual interface registered to the system.
The interface will be attached to a bridge later.
Create a virtual interface registered to the system . The interface will be attached to a bridge later .
static int
nm_vi_create(struct nmreq *nmr)
{
	struct ifnet *ifp;
	struct netmap_vp_adapter *vpna;
	int error;
	if (!strncmp(nmr->nr_name, NM_NAME, strlen(NM_NAME)))
		return EINVAL;
	ifp = ifunit_ref(nmr->nr_name);
	if (ifp) { 
		if_rele(ifp);
		return EEXIST;
	}
	error = nm_vi_persist(nmr->nr_name, &ifp);
	if (error)
		return error;
	NMG_LOCK();
	error = netmap_vp_create(nmr, ifp, &vpna);
	if (error) {
		D("error %d", error);
		nm_vi_detach(ifp);
		return error;
	}
	vpna->up.nm_bdg_ctl = netmap_vp_bdg_ctl;
	netmap_adapter_get(&vpna->up);
	NMG_UNLOCK();
	D("created %s", ifp->if_xname);
	return 0;
}
static int nm_vi_create ( struct nmreq * nmr ) { struct ifnet * ifp ; struct netmap_vp_adapter * vpna ; int error ; if ( ! strncmp ( nmr -> nr_name , NM_NAME , strlen ( NM_NAME ) ) ) return EINVAL ; ifp = ifunit_ref ( nmr -> nr_name ) ; if ( ifp ) { if_rele ( ifp ) ; return EEXIST ; } error = nm_vi_persist ( nmr -> nr_name , & ifp ) ; if ( error ) return error ; NMG_LOCK ( ) ; error = netmap_vp_create ( nmr , ifp , & vpna ) ; if ( error ) { D ( " " , error ) ; nm_vi_detach ( ifp ) ; return error ; } vpna -> up . nm_bdg_ctl = netmap_vp_bdg_ctl ; netmap_adapter_get ( & vpna -> up ) ; NMG_UNLOCK ( ) ; D ( " " , ifp -> if_xname ) ; return 0 ; }
Create a virtual interface registered to the system.
Create a virtual interface registered to the system .
/* don't include VALE prefix */ /* already exist, cannot create new one */ /* netmap_vp_create creates a struct netmap_vp_adapter */ /* persist-specific routines */