summaryrefslogtreecommitdiff
path: root/sys/net/route.c
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2010-06-29 21:28:39 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2010-06-29 21:28:39 +0000
commitc36b5d99497a4a214b119ea16ba106bed6f5ede0 (patch)
treeac95210d4972524b0bd01abeea100971d31958c3 /sys/net/route.c
parentde3823732bf5afd3afd9f14563e9818df599ec58 (diff)
Replace enc(4) with a new implementation as a cloner device. We still
create enc0 by default, but it is possible to add additional enc interfaces. This will be used later to allow alternative encs per policy or to have an enc per rdomain when IPsec becomes rdomain-aware. manpage bits ok jmc@ input from henning@ deraadt@ toby@ naddy@ ok henning@ claudio@
Diffstat (limited to 'sys/net/route.c')
-rw-r--r--sys/net/route.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/sys/net/route.c b/sys/net/route.c
index c8497bf0dad..85ca1fdfbb1 100644
--- a/sys/net/route.c
+++ b/sys/net/route.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.c,v 1.120 2010/06/28 18:50:37 claudio Exp $ */
+/* $OpenBSD: route.c,v 1.121 2010/06/29 21:28:37 reyk Exp $ */
/* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */
/*
@@ -168,7 +168,12 @@ TAILQ_HEAD(rt_labels, rt_label) rt_labels = TAILQ_HEAD_INITIALIZER(rt_labels);
struct ifaddr *
encap_findgwifa(struct sockaddr *gw)
{
- return (TAILQ_FIRST(&encif[0].sc_if.if_addrlist));
+ struct ifnet *encif;
+
+ if ((encif = enc_getif(0)) == NULL)
+ return (NULL);
+
+ return (TAILQ_FIRST(&encif->if_addrlist));
}
#endif
@@ -256,6 +261,22 @@ rtable_add(u_int id) /* must be called at splsoftnet */
return (rtable_init(&rt_tables[id], id));
}
+void
+rtable_addif(struct ifnet *ifp, u_int id)
+{
+ /* make sure that the routing table exists */
+ if (!rtable_exists(id)) {
+ if (rtable_add(id) == -1)
+ panic("rtable_addif: rtable_add");
+ }
+ if (id != rtable_l2(id)) {
+ /* XXX we should probably flush the table */
+ rtable_l2set(id, id);
+ }
+
+ ifp->if_rdomain = id;
+}
+
u_int
rtable_l2(u_int id)
{