Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/vfs_export.c
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | |||||
#include <netinet/in.h> | #include <netinet/in.h> | ||||
#include <net/radix.h> | #include <net/radix.h> | ||||
static MALLOC_DEFINE(M_NETADDR, "export_host", "Export host address structure"); | static MALLOC_DEFINE(M_NETADDR, "export_host", "Export host address structure"); | ||||
#if defined(INET) || defined(INET6) | #if defined(INET) || defined(INET6) | ||||
static struct radix_node_head *vfs_create_addrlist_af( | static struct radix_node_head *vfs_create_addrlist_af( | ||||
struct radix_node_head **prnh, int off); | struct radix_node_head **prnh, int off, int salen); | ||||
#endif | #endif | ||||
static void vfs_free_addrlist(struct netexport *nep); | static void vfs_free_addrlist(struct netexport *nep); | ||||
static int vfs_free_netcred(struct radix_node *rn, void *w); | static int vfs_free_netcred(struct radix_node *rn, void *w); | ||||
static void vfs_free_addrlist_af(struct radix_node_head **prnh); | static void vfs_free_addrlist_af(struct radix_node_head **prnh); | ||||
static int vfs_hang_addrlist(struct mount *mp, struct netexport *nep, | static int vfs_hang_addrlist(struct mount *mp, struct netexport *nep, | ||||
struct export_args *argp); | struct export_args *argp); | ||||
static struct netcred *vfs_export_lookup(struct mount *, struct sockaddr *); | static struct netcred *vfs_export_lookup(struct mount *, struct sockaddr *); | ||||
Show All 26 Lines | vfs_hang_addrlist(struct mount *mp, struct netexport *nep, | ||||
struct export_args *argp) | struct export_args *argp) | ||||
{ | { | ||||
struct netcred *np; | struct netcred *np; | ||||
struct radix_node_head *rnh; | struct radix_node_head *rnh; | ||||
int i; | int i; | ||||
struct radix_node *rn; | struct radix_node *rn; | ||||
struct sockaddr *saddr, *smask = NULL; | struct sockaddr *saddr, *smask = NULL; | ||||
#if defined(INET6) || defined(INET) | #if defined(INET6) || defined(INET) | ||||
int off; | int off, salen; | ||||
#endif | #endif | ||||
int error; | int error; | ||||
/* | /* | ||||
* XXX: This routine converts from a `struct xucred' | * XXX: This routine converts from a `struct xucred' | ||||
* (argp->ex_anon) to a `struct ucred' (np->netc_anon). This | * (argp->ex_anon) to a `struct ucred' (np->netc_anon). This | ||||
* operation is questionable; for example, what should be done | * operation is questionable; for example, what should be done | ||||
* with fields like cr_uidinfo and cr_prison? Currently, this | * with fields like cr_uidinfo and cr_prison? Currently, this | ||||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | if (argp->ex_masklen) { | ||||
if (smask->sa_len > argp->ex_masklen) | if (smask->sa_len > argp->ex_masklen) | ||||
smask->sa_len = argp->ex_masklen; | smask->sa_len = argp->ex_masklen; | ||||
} | } | ||||
rnh = NULL; | rnh = NULL; | ||||
switch (saddr->sa_family) { | switch (saddr->sa_family) { | ||||
#ifdef INET | #ifdef INET | ||||
case AF_INET: | case AF_INET: | ||||
if ((rnh = nep->ne4) == NULL) { | if ((rnh = nep->ne4) == NULL) { | ||||
salen = sizeof(struct sockaddr_in); | |||||
off = offsetof(struct sockaddr_in, sin_addr) << 3; | off = offsetof(struct sockaddr_in, sin_addr) << 3; | ||||
rnh = vfs_create_addrlist_af(&nep->ne4, off); | rnh = vfs_create_addrlist_af(&nep->ne4, off, salen); | ||||
} | } | ||||
break; | break; | ||||
#endif | #endif | ||||
#ifdef INET6 | #ifdef INET6 | ||||
case AF_INET6: | case AF_INET6: | ||||
if ((rnh = nep->ne6) == NULL) { | if ((rnh = nep->ne6) == NULL) { | ||||
salen = sizeof(struct sockaddr_in6); | |||||
off = offsetof(struct sockaddr_in6, sin6_addr) << 3; | off = offsetof(struct sockaddr_in6, sin6_addr) << 3; | ||||
rnh = vfs_create_addrlist_af(&nep->ne6, off); | rnh = vfs_create_addrlist_af(&nep->ne6, off, salen); | ||||
} | } | ||||
break; | break; | ||||
#endif | #endif | ||||
} | } | ||||
if (rnh == NULL) { | if (rnh == NULL) { | ||||
error = ENOBUFS; | error = ENOBUFS; | ||||
vfs_mount_error(mp, "%s %s %d", | vfs_mount_error(mp, "%s %s %d", | ||||
"Unable to initialize radix node head ", | "Unable to initialize radix node head ", | ||||
Show All 38 Lines | vfs_free_netcred(struct radix_node *rn, void *w) | ||||
if (cred != NULL) | if (cred != NULL) | ||||
crfree(cred); | crfree(cred); | ||||
free(rn, M_NETADDR); | free(rn, M_NETADDR); | ||||
return (0); | return (0); | ||||
} | } | ||||
#if defined(INET) || defined(INET6) | #if defined(INET) || defined(INET6) | ||||
static struct radix_node_head * | static struct radix_node_head * | ||||
vfs_create_addrlist_af(struct radix_node_head **prnh, int off) | vfs_create_addrlist_af(struct radix_node_head **prnh, int off, int salen) | ||||
{ | { | ||||
if (rn_inithead((void **)prnh, off) == 0) | if (rn_inithead((void **)prnh, off, salen) == 0) | ||||
return (NULL); | return (NULL); | ||||
RADIX_NODE_HEAD_LOCK_INIT(*prnh); | RADIX_NODE_HEAD_LOCK_INIT(*prnh); | ||||
return (*prnh); | return (*prnh); | ||||
} | } | ||||
#endif | #endif | ||||
static void | static void | ||||
vfs_free_addrlist_af(struct radix_node_head **prnh) | vfs_free_addrlist_af(struct radix_node_head **prnh) | ||||
▲ Show 20 Lines • Show All 269 Lines • Show Last 20 Lines |