if (i < 0 || i > AF_MAX) { error = EINVAL; goto out; }
vfs_hang_addrlist(mp, nep, argp)	struct mount *mp;	struct netexport *nep;	struct export_args *argp;{	register struct netcred *np;	register struct radix_node_head *rnh;	register int i;	struct radix_node *rn;	struct sockaddr *saddr, *smask = 0;	struct domain *dom;	int error;	if (argp->ex_addrlen == 0) {		if (mp->mnt_flag & MNT_DEFEXPORTED)			return (EPERM);		np = &nep->ne_defexported;		np->netc_exflags = argp->ex_flags;		np->netc_anon = argp->ex_anon;		np->netc_anon.cr_ref = 1;		mp->mnt_flag |= MNT_DEFEXPORTED;		return (0);	}	if (argp->ex_addrlen > MLEN)		return (EINVAL);	i = sizeof(struct netcred) + argp->ex_addrlen + argp->ex_masklen;	np = (struct netcred *)malloc(i, M_NETADDR, M_WAITOK);	bzero((caddr_t)np, i);	saddr = (struct sockaddr *)(np + 1);	error = copyin(argp->ex_addr, (caddr_t)saddr, argp->ex_addrlen);	if (error)		goto out;	if (saddr->sa_len > argp->ex_addrlen)		saddr->sa_len = argp->ex_addrlen;	if (argp->ex_masklen) {		smask = (struct sockaddr *)((caddr_t)saddr + argp->ex_addrlen);		error = copyin(argp->ex_mask, (caddr_t)smask, argp->ex_masklen);		if (error)			goto out;		if (smask->sa_len > argp->ex_masklen)			smask->sa_len = argp->ex_masklen;	}	i = saddr->sa_family;	if ((rnh = nep->ne_rtable[i]) == 0) {		/*		 * Seems silly to initialize every AF when most are not		 * used, do so on demand here		 */		for (dom = domains; dom; dom = dom->dom_next)			if (dom->dom_family == i && dom->dom_rtattach) {				dom->dom_rtattach((void **)&nep->ne_rtable[i],					dom->dom_rtoffset);				break;			}		if ((rnh = nep->ne_rtable[i]) == 0) {			error = ENOBUFS;			goto out;		}	}	rn = (*rnh->rnh_addaddr)((caddr_t)saddr, (caddr_t)smask, rnh,		np->netc_rnodes);	if (rn == 0 || np != (struct netcred *)rn) { /* already exists */		error = EPERM;		goto out;	}	np->netc_exflags = argp->ex_flags;	np->netc_anon = argp->ex_anon;	np->netc_anon.cr_ref = 1;	return (0);out:	free(np, M_NETADDR);	return (error);}