diff options
author | 2011-04-12 10:47:29 +0000 | |
---|---|---|
committer | 2011-04-12 10:47:29 +0000 | |
commit | 03231384230c57d154faefce8f5310190771ab47 (patch) | |
tree | 98f1bbe14229aef3b4f071bd22f39cbc4b8449ca /sys/netinet/tcp_input.c | |
parent | add missing tools.h file (diff) | |
download | wireguard-openbsd-03231384230c57d154faefce8f5310190771ab47.tar.xz wireguard-openbsd-03231384230c57d154faefce8f5310190771ab47.zip |
put the accepted socket of a diverted connection into the routing domain
of a connection originator. this allows one to query the source rdomain
with a SO_RTABLE socket option. figured out with reyk, ok claudio.
Diffstat (limited to 'sys/netinet/tcp_input.c')
-rw-r--r-- | sys/netinet/tcp_input.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 37b12d64280..1a724dfa018 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_input.c,v 1.244 2011/04/05 18:16:07 blambert Exp $ */ +/* $OpenBSD: tcp_input.c,v 1.245 2011/04/12 10:47:29 mikeb Exp $ */ /* $NetBSD: tcp_input.c,v 1.23 1996/02/13 23:43:44 christos Exp $ */ /* @@ -3671,6 +3671,9 @@ syn_cache_get(struct sockaddr *src, struct sockaddr *dst, struct tcphdr *th, struct mbuf *am; int s; struct socket *oso; +#if NPF > 0 + struct pf_divert *divert = NULL; +#endif s = splsoftnet(); if ((sc = syn_cache_lookup(src, dst, &scp, @@ -3754,6 +3757,12 @@ syn_cache_get(struct sockaddr *src, struct sockaddr *dst, struct tcphdr *th, inp = (struct inpcb *)so->so_pcb; #endif /* INET6 */ +#if NPF > 0 + if (m && m->m_pkthdr.pf.flags & PF_TAG_DIVERTED && + (divert = pf_find_divert(m)) != NULL) + inp->inp_rtableid = divert->rdomain; + else +#endif /* inherit rtable from listening socket */ inp->inp_rtableid = sc->sc_rtableid; |