summaryrefslogtreecommitdiffstats
path: root/sys/netinet/in.c
diff options
context:
space:
mode:
authorclaudio <claudio@openbsd.org>2009-06-05 00:05:21 +0000
committerclaudio <claudio@openbsd.org>2009-06-05 00:05:21 +0000
commit22760f565a521eee1242a6b1041c186acc77d298 (patch)
treecf09757382c6a5172e7749b5e2348595c70d6bc3 /sys/netinet/in.c
parentMake imsg completely async model agnostic by not requiring an (diff)
downloadwireguard-openbsd-22760f565a521eee1242a6b1041c186acc77d298.tar.xz
wireguard-openbsd-22760f565a521eee1242a6b1041c186acc77d298.zip
Initial support for routing domains. This allows to bind interfaces to
alternate routing table and separate them from other interfaces in distinct routing tables. The same network can now be used in any doamin at the same time without causing conflicts. This diff is mostly mechanical and adds the necessary rdomain checks accross net and netinet. L2 and IPv4 are mostly covered still missing pf and IPv6. input and tested by jsg@, phessler@ and reyk@. "put it in" deraadt@
Diffstat (limited to 'sys/netinet/in.c')
-rw-r--r--sys/netinet/in.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/sys/netinet/in.c b/sys/netinet/in.c
index 887b3fda6b0..13e22342aed 100644
--- a/sys/netinet/in.c
+++ b/sys/netinet/in.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in.c,v 1.53 2009/03/15 19:40:41 miod Exp $ */
+/* $OpenBSD: in.c,v 1.54 2009/06/05 00:05:22 claudio Exp $ */
/* $NetBSD: in.c,v 1.26 1996/02/13 23:41:39 christos Exp $ */
/*
@@ -113,19 +113,24 @@ int hostzeroisbroadcast = HOSTZEROBROADCAST;
* Otherwise, it includes only the directly-connected (sub)nets.
*/
int
-in_localaddr(in)
- struct in_addr in;
+in_localaddr(struct in_addr in, u_int rdomain)
{
struct in_ifaddr *ia;
if (subnetsarelocal) {
- TAILQ_FOREACH(ia, &in_ifaddr, ia_list)
+ TAILQ_FOREACH(ia, &in_ifaddr, ia_list) {
+ if (ia->ia_ifp->if_rdomain != rdomain)
+ continue;
if ((in.s_addr & ia->ia_netmask) == ia->ia_net)
return (1);
+ }
} else {
- TAILQ_FOREACH(ia, &in_ifaddr, ia_list)
+ TAILQ_FOREACH(ia, &in_ifaddr, ia_list) {
+ if (ia->ia_ifp->if_rdomain != rdomain)
+ continue;
if ((in.s_addr & ia->ia_subnetmask) == ia->ia_subnet)
return (1);
+ }
}
return (0);
}
@@ -786,6 +791,8 @@ in_addprefix(target, flags)
}
TAILQ_FOREACH(ia, &in_ifaddr, ia_list) {
+ if (ia->ia_ifp->if_rdomain != target->ia_ifp->if_rdomain)
+ continue;
if (rtinitflags(ia)) {
p = ia->ia_dstaddr.sin_addr;
if (prefix.s_addr != p.s_addr)
@@ -857,6 +864,8 @@ in_scrubprefix(target)
p.s_addr &= ia->ia_sockmask.sin_addr.s_addr;
}
+ if (ia->ia_ifp->if_rdomain != target->ia_ifp->if_rdomain)
+ continue;
if (prefix.s_addr != p.s_addr)
continue;