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

Function prison_remote_ip6

freebsd/netinet6/in6_jail.c:321–354  ·  view source on GitHub ↗

* Rewrite destination address in case we will connect to loopback address. * * Returns 0 on success, EAFNOSUPPORT if the jail doesn't allow IPv6. */

Source from the content-addressed store, hash-verified

319 * Returns 0 on success, EAFNOSUPPORT if the jail doesn't allow IPv6.
320 */
321int
322prison_remote_ip6(struct ucred *cred, struct in6_addr *ia6)
323{
324 struct prison *pr;
325
326 KASSERT(cred != NULL, ("%s: cred is NULL", __func__));
327 KASSERT(ia6 != NULL, ("%s: ia6 is NULL", __func__));
328
329 pr = cred->cr_prison;
330 if (!(pr->pr_flags & PR_IP6))
331 return (0);
332 mtx_lock(&pr->pr_mtx);
333 if (!(pr->pr_flags & PR_IP6)) {
334 mtx_unlock(&pr->pr_mtx);
335 return (0);
336 }
337 if (pr->pr_ip6 == NULL) {
338 mtx_unlock(&pr->pr_mtx);
339 return (EAFNOSUPPORT);
340 }
341
342 if (IN6_IS_ADDR_LOOPBACK(ia6) &&
343 prison_check_ip6_locked(pr, ia6) == EADDRNOTAVAIL) {
344 bcopy(&pr->pr_ip6[0], ia6, sizeof(struct in6_addr));
345 mtx_unlock(&pr->pr_mtx);
346 return (0);
347 }
348
349 /*
350 * Return success because nothing had to be changed.
351 */
352 mtx_unlock(&pr->pr_mtx);
353 return (0);
354}
355
356/*
357 * Check if given address belongs to the jail referenced by cred/prison.

Callers 5

in6_pcbladdrFunction · 0.70
udp6_connectFunction · 0.70
sctp_connectFunction · 0.50
tcp6_usr_connectFunction · 0.50
tcp_usr_sendFunction · 0.50

Calls 3

prison_check_ip6_lockedFunction · 0.85
mtx_lockFunction · 0.50
mtx_unlockFunction · 0.50

Tested by

no test coverage detected