diff options
author | jamie <jamie@FreeBSD.org> | 2009-02-05 14:06:09 +0000 |
---|---|---|
committer | jamie <jamie@FreeBSD.org> | 2009-02-05 14:06:09 +0000 |
commit | 12bbe1869f5926ca7e3457f5424afdca31a1189b (patch) | |
tree | 71fe0b10296684e7094a545ca78ed6f72789d82d /sys/netinet6/in6.c | |
parent | 2926f8fa435de3f0b595eb5309b2a0c364703371 (diff) | |
download | FreeBSD-src-12bbe1869f5926ca7e3457f5424afdca31a1189b.zip FreeBSD-src-12bbe1869f5926ca7e3457f5424afdca31a1189b.tar.gz |
Standardize the various prison_foo_ip[46] functions and prison_if to
return zero on success and an error code otherwise. The possible errors
are EADDRNOTAVAIL if an address being checked for doesn't match the
prison, and EAFNOSUPPORT if the prison doesn't have any addresses in
that address family. For most callers of these functions, use the
returned error code instead of e.g. a hard-coded EADDRNOTAVAIL or
EINVAL.
Always include a jailed() check in these functions, where a non-jailed
cred always returns success (and makes no changes). Remove the explicit
jailed() checks that preceded many of the function calls.
Approved by: bz (mentor)
Diffstat (limited to 'sys/netinet6/in6.c')
-rw-r--r-- | sys/netinet6/in6.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c index 693a2f9..81a37f8 100644 --- a/sys/netinet6/in6.c +++ b/sys/netinet6/in6.c @@ -330,9 +330,9 @@ in6_control(struct socket *so, u_long cmd, caddr_t data, error = in6_setscope(&sa6->sin6_addr, ifp, NULL); if (error != 0) return (error); - if (td != NULL && !prison_check_ip6(td->td_ucred, - &sa6->sin6_addr)) - return (EADDRNOTAVAIL); + if (td != NULL && (error = prison_check_ip6(td->td_ucred, + &sa6->sin6_addr)) != 0) + return (error); ia = in6ifa_ifpwithaddr(ifp, &sa6->sin6_addr); } else ia = NULL; @@ -2241,8 +2241,7 @@ in6_lltable_dump(struct lltable *llt, struct sysctl_req *wr) if ((lle->la_flags & (LLE_DELETED|LLE_VALID)) != LLE_VALID) continue; /* Skip if jailed and not a valid IP of the prison. */ - if (jailed(wr->td->td_ucred) && - !prison_if(wr->td->td_ucred, L3_ADDR(lle))) + if (prison_if(wr->td->td_ucred, L3_ADDR(lle)) != 0) continue; /* * produce a msg made of: |