summaryrefslogtreecommitdiff
path: root/sys/netinet/ip_input.c
diff options
context:
space:
mode:
authorMike Belopuhov <mikeb@cvs.openbsd.org>2011-06-15 09:11:02 +0000
committerMike Belopuhov <mikeb@cvs.openbsd.org>2011-06-15 09:11:02 +0000
commitfd1f29bf19461cbc80443d08dd9bda476200d3cf (patch)
tree9c0a02009d03a8b5b9d289a216bae96f113aecea /sys/netinet/ip_input.c
parentec79616c56cc740bc77b32d8cf0f3e6ad7815d18 (diff)
Add IP_RECVRTABLE socket option to be used with a IPPROTO_IP
level that allows one to retrieve the original routing domain of UDP datagrams diverted by the pf via "divert-to" with a recvmsg(2). ok claudio
Diffstat (limited to 'sys/netinet/ip_input.c')
-rw-r--r--sys/netinet/ip_input.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c
index 0d71e404e78..812d650c449 100644
--- a/sys/netinet/ip_input.c
+++ b/sys/netinet/ip_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_input.c,v 1.191 2011/04/19 03:47:29 dlg Exp $ */
+/* $OpenBSD: ip_input.c,v 1.192 2011/06/15 09:11:01 mikeb Exp $ */
/* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */
/*
@@ -1790,5 +1790,20 @@ ip_savecontrol(struct inpcb *inp, struct mbuf **mp, struct ip *ip,
if (*mp)
mp = &(*mp)->m_next;
}
+ if (inp->inp_flags & INP_RECVRTABLE) {
+ u_int rtableid = inp->inp_rtableid;
+#if NPF > 0
+ struct pf_divert *divert;
+
+ if (m && m->m_pkthdr.pf.flags & PF_TAG_DIVERTED &&
+ (divert = pf_find_divert(m)) != NULL)
+ rtableid = divert->rdomain;
+#endif
+
+ *mp = sbcreatecontrol((caddr_t) &rtableid,
+ sizeof(u_int), IP_RECVRTABLE, IPPROTO_IP);
+ if (*mp)
+ mp = &(*mp)->m_next;
+ }
}