* 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. */
| 175 | * Returns 0 on success, EAFNOSUPPORT if the jail doesn't allow IPv6. |
| 176 | */ |
| 177 | int |
| 178 | prison_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. |
no test coverage detected