MCPcopy Create free account
hub / github.com/F-Stack/f-stack / prison_get_ip6

Function prison_get_ip6

freebsd/netinet6/in6_jail.c:177–201  ·  view source on GitHub ↗

* Pass back primary IPv6 address for this jail. * * If not restricted return success but do not alter the address. Caller has * to make sure to initialize it correctly (e.g. IN6ADDR_ANY_INIT). * * Returns 0 on success, EAFNOSUPPORT if the jail doesn't allow IPv6. */

Source from the content-addressed store, hash-verified

175 * Returns 0 on success, EAFNOSUPPORT if the jail doesn't allow IPv6.
176 */
177int
178prison_get_ip6(struct ucred *cred, struct in6_addr *ia6)
179{
180 struct prison *pr;
181
182 KASSERT(cred != NULL, ("%s: cred is NULL", __func__));
183 KASSERT(ia6 != NULL, ("%s: ia6 is NULL", __func__));
184
185 pr = cred->cr_prison;
186 if (!(pr->pr_flags & PR_IP6))
187 return (0);
188 mtx_lock(&pr->pr_mtx);
189 if (!(pr->pr_flags & PR_IP6)) {
190 mtx_unlock(&pr->pr_mtx);
191 return (0);
192 }
193 if (pr->pr_ip6 == NULL) {
194 mtx_unlock(&pr->pr_mtx);
195 return (EAFNOSUPPORT);
196 }
197
198 bcopy(&pr->pr_ip6[0], ia6, sizeof(struct in6_addr));
199 mtx_unlock(&pr->pr_mtx);
200 return (0);
201}
202
203/*
204 * Return 1 if we should do proper source address selection or are not jailed.

Callers 2

prison_saddrsel_ip6Function · 0.70
rtm_get_jailedFunction · 0.50

Calls 2

mtx_lockFunction · 0.50
mtx_unlockFunction · 0.50

Tested by

no test coverage detected