summaryrefslogtreecommitdiffstats
path: root/sys/netinet/in_pcb.c
diff options
context:
space:
mode:
authorbz <bz@FreeBSD.org>2010-01-17 12:57:11 +0000
committerbz <bz@FreeBSD.org>2010-01-17 12:57:11 +0000
commitd80ba03e3c55996b4cbd43c63798a30f830c08c3 (patch)
tree2b602932505487bf20c4f34fd4d2c8c7b7e2dc5e /sys/netinet/in_pcb.c
parentb89a432ee1889ec29b188c301b5171234c9247bc (diff)
downloadFreeBSD-src-d80ba03e3c55996b4cbd43c63798a30f830c08c3.zip
FreeBSD-src-d80ba03e3c55996b4cbd43c63798a30f830c08c3.tar.gz
Add ip4.saddrsel/ip4.nosaddrsel (and equivalent for ip6) to control
whether to use source address selection (default) or the primary jail address for unbound outgoing connections. This is intended to be used by people upgrading from single-IP jails to multi-IP jails but not having to change firewall rules, application ACLs, ... but to force their connections (unless otherwise changed) to the primry jail IP they had been used for years, as well as for people prefering to implement similar policies. Note that for IPv6, if configured incorrectly, this might lead to scope violations, which single-IPv6 jails could as well, as by the design of jails. [1] Reviewed by: jamie, hrs (ipv6 part) Pointed out by: hrs [1] MFC After: 2 weeks Asked for by: Jase Thew (bazerka beardz.net)
Diffstat (limited to 'sys/netinet/in_pcb.c')
-rw-r--r--sys/netinet/in_pcb.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
index 7a4ac10..204d904 100644
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -552,6 +552,13 @@ in_pcbladdr(struct inpcb *inp, struct in_addr *faddr, struct in_addr *laddr,
KASSERT(laddr != NULL, ("%s: laddr NULL", __func__));
+ /*
+ * Bypass source address selection and use the primary jail IP
+ * if requested.
+ */
+ if (cred != NULL && !prison_saddrsel_ip4(cred, laddr))
+ return (0);
+
error = 0;
bzero(&sro, sizeof(sro));
OpenPOWER on IntegriCloud