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

Function prison_saddrsel_ip4

freebsd/netinet/in_jail.c:219–245  ·  view source on GitHub ↗

* Return 1 if we should do proper source address selection or are not jailed. * We will return 0 if we should bypass source address selection in favour * of the primary jail IPv4 address. Only in this case *ia will be updated and * returned in NBO. * Return EAFNOSUPPORT, in case this jail does not allow IPv4. */

Source from the content-addressed store, hash-verified

217 * Return EAFNOSUPPORT, in case this jail does not allow IPv4.
218 */
219int
220prison_saddrsel_ip4(struct ucred *cred, struct in_addr *ia)
221{
222 struct prison *pr;
223 struct in_addr lia;
224 int error;
225
226 KASSERT(cred != NULL, ("%s: cred is NULL", __func__));
227 KASSERT(ia != NULL, ("%s: ia is NULL", __func__));
228
229 if (!jailed(cred))
230 return (1);
231
232 pr = cred->cr_prison;
233 if (pr->pr_flags & PR_IP4_SADDRSEL)
234 return (1);
235
236 lia.s_addr = INADDR_ANY;
237 error = prison_get_ip4(cred, &lia);
238 if (error)
239 return (error);
240 if (lia.s_addr == INADDR_ANY)
241 return (1);
242
243 ia->s_addr = lia.s_addr;
244 return (0);
245}
246
247/*
248 * Return true if pr1 and pr2 have the same IPv4 address restrictions.

Callers 1

in_pcbladdrFunction · 0.70

Calls 2

jailedFunction · 0.85
prison_get_ip4Function · 0.70

Tested by

no test coverage detected