vfs_export: Simplify vfs_export_lookup
If the filesystem is not exported directly return NULL. If no address is given and filesystem is exported using some default one return it directly, if it doesn't have a default one directly return NULL. Reviewed by: kib, bapt MFC after: 1 week Sponsored by: Gandi.net Differential Revision: https://reviews.freebsd.org/D12505
This commit is contained in:
parent
04335d9414
commit
444f0ddd90
@ -448,44 +448,46 @@ static struct netcred *
|
||||
vfs_export_lookup(struct mount *mp, struct sockaddr *nam)
|
||||
{
|
||||
struct netexport *nep;
|
||||
struct netcred *np;
|
||||
struct netcred *np = NULL;
|
||||
struct radix_node_head *rnh;
|
||||
struct sockaddr *saddr;
|
||||
|
||||
nep = mp->mnt_export;
|
||||
if (nep == NULL)
|
||||
return (NULL);
|
||||
np = NULL;
|
||||
if (mp->mnt_flag & MNT_EXPORTED) {
|
||||
/*
|
||||
* Lookup in the export list first.
|
||||
*/
|
||||
if (nam != NULL) {
|
||||
saddr = nam;
|
||||
rnh = NULL;
|
||||
switch (saddr->sa_family) {
|
||||
case AF_INET:
|
||||
rnh = nep->ne4;
|
||||
break;
|
||||
case AF_INET6:
|
||||
rnh = nep->ne6;
|
||||
break;
|
||||
}
|
||||
if (rnh != NULL) {
|
||||
RADIX_NODE_HEAD_RLOCK(rnh);
|
||||
np = (struct netcred *)
|
||||
(*rnh->rnh_matchaddr)(saddr, &rnh->rh);
|
||||
RADIX_NODE_HEAD_RUNLOCK(rnh);
|
||||
if (np && np->netc_rnodes->rn_flags & RNF_ROOT)
|
||||
np = NULL;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* If no address match, use the default if it exists.
|
||||
*/
|
||||
if (np == NULL && mp->mnt_flag & MNT_DEFEXPORTED)
|
||||
np = &nep->ne_defexported;
|
||||
if ((mp->mnt_flag & MNT_EXPORTED) == 0)
|
||||
return (NULL);
|
||||
|
||||
/*
|
||||
* If no address is provided, use the default if it exists.
|
||||
*/
|
||||
if (nam == NULL) {
|
||||
if ((mp->mnt_flag & MNT_DEFEXPORTED) != 0)
|
||||
return (&nep->ne_defexported);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Lookup in the export list
|
||||
*/
|
||||
saddr = nam;
|
||||
rnh = NULL;
|
||||
switch (saddr->sa_family) {
|
||||
case AF_INET:
|
||||
rnh = nep->ne4;
|
||||
break;
|
||||
case AF_INET6:
|
||||
rnh = nep->ne6;
|
||||
break;
|
||||
}
|
||||
if (rnh != NULL) {
|
||||
RADIX_NODE_HEAD_RLOCK(rnh);
|
||||
np = (struct netcred *) (*rnh->rnh_matchaddr)(saddr, &rnh->rh);
|
||||
RADIX_NODE_HEAD_RUNLOCK(rnh);
|
||||
if (np != NULL && (np->netc_rnodes->rn_flags & RNF_ROOT) != 0)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
return (np);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user