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

Function prison_get_ip4

freebsd/netinet/in_jail.c:186–210  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

184 * Address returned in NBO.
185 */
186int
187prison_get_ip4(struct ucred *cred, struct in_addr *ia)
188{
189 struct prison *pr;
190
191 KASSERT(cred != NULL, ("%s: cred is NULL", __func__));
192 KASSERT(ia != NULL, ("%s: ia is NULL", __func__));
193
194 pr = cred->cr_prison;
195 if (!(pr->pr_flags & PR_IP4))
196 return (0);
197 mtx_lock(&pr->pr_mtx);
198 if (!(pr->pr_flags & PR_IP4)) {
199 mtx_unlock(&pr->pr_mtx);
200 return (0);
201 }
202 if (pr->pr_ip4 == NULL) {
203 mtx_unlock(&pr->pr_mtx);
204 return (EAFNOSUPPORT);
205 }
206
207 ia->s_addr = pr->pr_ip4[0].s_addr;
208 mtx_unlock(&pr->pr_mtx);
209 return (0);
210}
211
212/*
213 * Return 1 if we should do proper source address selection or are not jailed.

Callers 4

in_pcbladdrFunction · 0.70
in_pcbconnect_setupFunction · 0.70
prison_saddrsel_ip4Function · 0.70
rtm_get_jailedFunction · 0.50

Calls 2

mtx_lockFunction · 0.50
mtx_unlockFunction · 0.50

Tested by

no test coverage detected