summaryrefslogtreecommitdiffstats
path: root/sys/netinet
diff options
context:
space:
mode:
authorphessler <phessler@openbsd.org>2013-10-20 11:03:00 +0000
committerphessler <phessler@openbsd.org>2013-10-20 11:03:00 +0000
commitdc01e491976fd30bd71a4912a9e6ec8a4e5ca36c (patch)
treec0563dc277ac816d20f19bcccdbf26debcb80045 /sys/netinet
parentWSDISPLAYIO_GTYPE ioctl support for KMS drivers. ok jsg@ (diff)
downloadwireguard-openbsd-dc01e491976fd30bd71a4912a9e6ec8a4e5ca36c.tar.xz
wireguard-openbsd-dc01e491976fd30bd71a4912a9e6ec8a4e5ca36c.zip
Put a large chunk of the IPv6 rdomain support in-tree.
Still some important missing pieces, and this is not yet enabled. OK bluhm@
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/in_pcb.c28
-rw-r--r--sys/netinet/in_pcb.h9
-rw-r--r--sys/netinet/ip_carp.c5
-rw-r--r--sys/netinet/ip_icmp.c4
-rw-r--r--sys/netinet/tcp_input.c8
-rw-r--r--sys/netinet/tcp_subr.c10
-rw-r--r--sys/netinet/tcp_usrreq.c10
-rw-r--r--sys/netinet/udp_usrreq.c18
8 files changed, 54 insertions, 38 deletions
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
index 02330f5718c..b710bf30fd7 100644
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in_pcb.c,v 1.142 2013/10/18 21:27:27 bluhm Exp $ */
+/* $OpenBSD: in_pcb.c,v 1.143 2013/10/20 11:03:00 phessler Exp $ */
/* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */
/*
@@ -122,9 +122,9 @@ int inpcb_pool_initialized = 0;
&(table)->inpt_hashtbl[(ntohl((faddr)->s_addr) + \
ntohs((fport)) + ntohs((lport)) + (rdom)) & (table->inpt_hash)]
-#define IN6PCBHASH(table, faddr, fport, laddr, lport) \
+#define IN6PCBHASH(table, faddr, fport, laddr, lport, rdom) \
&(table)->inpt_hashtbl[(ntohl((faddr)->s6_addr32[0] ^ \
- (faddr)->s6_addr32[3]) + ntohs((fport)) + ntohs((lport))) & \
+ (faddr)->s6_addr32[3]) + ntohs((fport)) + ntohs((lport)) + (rdom)) & \
(table->inpt_hash)]
#define INPCBLHASH(table, lport, rdom) \
@@ -873,8 +873,8 @@ in_pcbrehash(struct inpcb *inp)
#ifdef INET6
if (inp->inp_flags & INP_IPV6) {
LIST_INSERT_HEAD(IN6PCBHASH(table, &inp->inp_faddr6,
- inp->inp_fport, &inp->inp_laddr6, inp->inp_lport),
- inp, inp_hash);
+ inp->inp_fport, &inp->inp_laddr6, inp->inp_lport,
+ rtable_l2(inp->inp_rtableid)), inp, inp_hash);
} else {
#endif /* INET6 */
LIST_INSERT_HEAD(INPCBHASH(table, &inp->inp_faddr,
@@ -944,19 +944,22 @@ in_pcbhashlookup(struct inpcbtable *table, struct in_addr faddr,
#ifdef INET6
struct inpcb *
in6_pcbhashlookup(struct inpcbtable *table, const struct in6_addr *faddr,
- u_int fport_arg, const struct in6_addr *laddr, u_int lport_arg)
+ u_int fport_arg, const struct in6_addr *laddr, u_int lport_arg,
+ u_int rtable)
{
struct inpcbhead *head;
struct inpcb *inp;
u_int16_t fport = fport_arg, lport = lport_arg;
- head = IN6PCBHASH(table, faddr, fport, laddr, lport);
+ rtable = rtable_l2(rtable); /* convert passed rtableid to rdomain */
+ head = IN6PCBHASH(table, faddr, fport, laddr, lport, rtable);
LIST_FOREACH(inp, head, inp_hash) {
if (!(inp->inp_flags & INP_IPV6))
continue;
if (IN6_ARE_ADDR_EQUAL(&inp->inp_faddr6, faddr) &&
inp->inp_fport == fport && inp->inp_lport == lport &&
- IN6_ARE_ADDR_EQUAL(&inp->inp_laddr6, laddr)) {
+ IN6_ARE_ADDR_EQUAL(&inp->inp_laddr6, laddr) &&
+ rtable_l2(inp->inp_rtableid) == rtable) {
/*
* Move this PCB to the head of hash chain so that
* repeated accesses are quicker. This is analogous to
@@ -1062,13 +1065,14 @@ in_pcblookup_listen(struct inpcbtable *table, struct in_addr laddr,
#ifdef INET6
struct inpcb *
in6_pcblookup_listen(struct inpcbtable *table, struct in6_addr *laddr,
- u_int lport_arg, int reverse, struct mbuf *m)
+ u_int lport_arg, int reverse, struct mbuf *m, u_int rtable)
{
struct inpcbhead *head;
struct in6_addr *key1, *key2;
struct inpcb *inp;
u_int16_t lport = lport_arg;
+ rtable = rtable_l2(rtable); /* convert passed rtableid to rdomain */
#if NPF > 0
if (m && m->m_pkthdr.pf.flags & PF_TAG_DIVERTED) {
struct pf_divert *divert;
@@ -1087,21 +1091,23 @@ in6_pcblookup_listen(struct inpcbtable *table, struct in6_addr *laddr,
key2 = &zeroin6_addr;
}
- head = IN6PCBHASH(table, &zeroin6_addr, 0, key1, lport);
+ head = IN6PCBHASH(table, &zeroin6_addr, 0, key1, lport, rtable);
LIST_FOREACH(inp, head, inp_hash) {
if (!(inp->inp_flags & INP_IPV6))
continue;
if (inp->inp_lport == lport && inp->inp_fport == 0 &&
+ rtable_l2(inp->inp_rtableid) == rtable &&
IN6_ARE_ADDR_EQUAL(&inp->inp_laddr6, key1) &&
IN6_IS_ADDR_UNSPECIFIED(&inp->inp_faddr6))
break;
}
if (inp == NULL && ! IN6_ARE_ADDR_EQUAL(key1, key2)) {
- head = IN6PCBHASH(table, &zeroin6_addr, 0, key2, lport);
+ head = IN6PCBHASH(table, &zeroin6_addr, 0, key2, lport, rtable);
LIST_FOREACH(inp, head, inp_hash) {
if (!(inp->inp_flags & INP_IPV6))
continue;
if (inp->inp_lport == lport && inp->inp_fport == 0 &&
+ rtable_l2(inp->inp_rtableid) == rtable &&
IN6_ARE_ADDR_EQUAL(&inp->inp_laddr6, key2) &&
IN6_IS_ADDR_UNSPECIFIED(&inp->inp_faddr6))
break;
diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h
index 9c06a41c7b9..40b53761a85 100644
--- a/sys/netinet/in_pcb.h
+++ b/sys/netinet/in_pcb.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: in_pcb.h,v 1.79 2013/05/31 13:15:53 bluhm Exp $ */
+/* $OpenBSD: in_pcb.h,v 1.80 2013/10/20 11:03:00 phessler Exp $ */
/* $NetBSD: in_pcb.h,v 1.14 1996/02/13 23:42:00 christos Exp $ */
/*
@@ -267,10 +267,11 @@ struct inpcb *
#ifdef INET6
struct inpcb *
in6_pcbhashlookup(struct inpcbtable *, const struct in6_addr *,
- u_int, const struct in6_addr *, u_int);
+ u_int, const struct in6_addr *, u_int, u_int);
struct inpcb *
in6_pcblookup_listen(struct inpcbtable *,
- struct in6_addr *, u_int, int, struct mbuf *);
+ struct in6_addr *, u_int, int, struct mbuf *,
+ u_int);
int in6_pcbbind(struct inpcb *, struct mbuf *, struct proc *);
int in6_pcbconnect(struct inpcb *, struct mbuf *);
int in6_setsockaddr(struct inpcb *, struct mbuf *);
@@ -294,7 +295,7 @@ struct rtentry *
/* INET6 stuff */
int in6_pcbnotify(struct inpcbtable *, struct sockaddr_in6 *,
- u_int, const struct sockaddr_in6 *, u_int, int, void *,
+ u_int, const struct sockaddr_in6 *, u_int, u_int, int, void *,
void (*)(struct inpcb *, int));
int in6_selecthlim(struct inpcb *, struct ifnet *);
int in6_pcbsetport(struct in6_addr *, struct inpcb *, struct proc *);
diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c
index cfa476b9cc0..a967c29e4ff 100644
--- a/sys/netinet/ip_carp.c
+++ b/sys/netinet/ip_carp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_carp.c,v 1.213 2013/10/19 16:09:53 bluhm Exp $ */
+/* $OpenBSD: ip_carp.c,v 1.214 2013/10/20 11:03:01 phessler Exp $ */
/*
* Copyright (c) 2002 Michael Shalayeff. All rights reserved.
@@ -1241,7 +1241,7 @@ carp_send_ad(void *v)
m->m_pkthdr.len = len;
m->m_pkthdr.rcvif = NULL;
m->m_pkthdr.pf.prio = CARP_IFQ_PRIO;
- /* XXX m->m_pkthdr.rdomain = sc->sc_if.if_rdomain; */
+ m->m_pkthdr.rdomain = sc->sc_if.if_rdomain;
m->m_len = len;
MH_ALIGN(m, m->m_len);
m->m_flags |= M_MCAST;
@@ -2123,6 +2123,7 @@ carp_set_addr6(struct carp_softc *sc, struct sockaddr_in6 *sin6)
if (ia->ia_ifp != &sc->sc_if &&
ia->ia_ifp->if_type != IFT_CARP &&
(ia->ia_ifp->if_flags & IFF_MULTICAST) &&
+ ia->ia_ifp->if_rdomain == sc->sc_if.if_rdomain &&
(i == 4))
break;
}
diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c
index 40f99cc0df4..d34fc1eaeb5 100644
--- a/sys/netinet/ip_icmp.c
+++ b/sys/netinet/ip_icmp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_icmp.c,v 1.106 2013/08/21 09:05:22 mpi Exp $ */
+/* $OpenBSD: ip_icmp.c,v 1.107 2013/10/20 11:03:01 phessler Exp $ */
/* $NetBSD: ip_icmp.c,v 1.19 1996/02/13 23:42:22 christos Exp $ */
/*
@@ -722,6 +722,7 @@ icmp_reflect(struct mbuf *m, struct mbuf **op, struct in_ifaddr *ia)
struct route ro;
bzero((caddr_t) &ro, sizeof(ro));
+ ro.ro_tableid = m->m_pkthdr.rdomain;
dst = satosin(&ro.ro_dst);
dst->sin_family = AF_INET;
dst->sin_len = sizeof(*dst);
@@ -925,6 +926,7 @@ icmp_mtudisc_clone(struct in_addr dst, u_int rtableid)
int error;
bzero(&ro, sizeof(ro));
+ ro.ro_tableid = rtableid;
sin = satosin(&ro.ro_dst);
sin->sin_family = AF_INET;
sin->sin_len = sizeof(*sin);
diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c
index 978e9474fcf..d9b274a437e 100644
--- a/sys/netinet/tcp_input.c
+++ b/sys/netinet/tcp_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_input.c,v 1.268 2013/09/06 18:35:16 bluhm Exp $ */
+/* $OpenBSD: tcp_input.c,v 1.269 2013/10/20 11:03:01 phessler Exp $ */
/* $NetBSD: tcp_input.c,v 1.23 1996/02/13 23:43:44 christos Exp $ */
/*
@@ -596,7 +596,8 @@ findpcb:
#ifdef INET6
case AF_INET6:
inp = in6_pcbhashlookup(&tcbtable, &ip6->ip6_src,
- th->th_sport, &ip6->ip6_dst, th->th_dport);
+ th->th_sport, &ip6->ip6_dst, th->th_dport,
+ m->m_pkthdr.rdomain);
break;
#endif
case AF_INET:
@@ -621,7 +622,8 @@ findpcb:
#ifdef INET6
case AF_INET6:
inp = in6_pcblookup_listen(&tcbtable,
- &ip6->ip6_dst, th->th_dport, inpl_reverse, m);
+ &ip6->ip6_dst, th->th_dport, inpl_reverse, m,
+ m->m_pkthdr.rdomain);
break;
#endif /* INET6 */
case AF_INET:
diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
index 1546619145c..3bb7f08f688 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_subr.c,v 1.121 2013/10/19 10:38:55 henning Exp $ */
+/* $OpenBSD: tcp_subr.c,v 1.122 2013/10/20 11:03:01 phessler Exp $ */
/* $NetBSD: tcp_subr.c,v 1.22 1996/02/13 23:44:00 christos Exp $ */
/*
@@ -728,7 +728,7 @@ tcp6_ctlinput(int cmd, struct sockaddr *sa, u_int rdomain, void *d)
*/
inp = in6_pcbhashlookup(&tcbtable, &sa6->sin6_addr,
th.th_dport, (struct in6_addr *)&sa6_src->sin6_addr,
- th.th_sport);
+ th.th_sport, rdomain);
if (cmd == PRC_MSGSIZE) {
/*
* Depending on the value of "valid" and routing table
@@ -752,10 +752,10 @@ tcp6_ctlinput(int cmd, struct sockaddr *sa, u_int rdomain, void *d)
inet6ctlerrmap[cmd] == ENETUNREACH ||
inet6ctlerrmap[cmd] == EHOSTDOWN))
syn_cache_unreach((struct sockaddr *)sa6_src,
- sa, &th, /* XXX */ 0);
+ sa, &th, rdomain);
} else {
(void) in6_pcbnotify(&tcbtable, sa6, 0,
- sa6_src, 0, cmd, NULL, notify);
+ sa6_src, 0, rdomain, cmd, NULL, notify);
}
}
#endif
@@ -901,7 +901,7 @@ tcp6_mtudisc_callback(faddr)
sin6.sin6_len = sizeof(struct sockaddr_in6);
sin6.sin6_addr = *faddr;
(void) in6_pcbnotify(&tcbtable, &sin6, 0,
- &sa6_any, 0, PRC_MSGSIZE, NULL, tcp_mtudisc);
+ &sa6_any, 0, /* XXX rdomain */ 0, PRC_MSGSIZE, NULL, tcp_mtudisc);
}
#endif /* INET6 */
diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c
index d979aee0c1d..51c06c73129 100644
--- a/sys/netinet/tcp_usrreq.c
+++ b/sys/netinet/tcp_usrreq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_usrreq.c,v 1.115 2013/10/17 16:27:44 bluhm Exp $ */
+/* $OpenBSD: tcp_usrreq.c,v 1.116 2013/10/20 11:03:01 phessler Exp $ */
/* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */
/*
@@ -830,12 +830,12 @@ tcp_ident(void *oldp, size_t *oldlenp, void *newp, size_t newlen, int dodrop)
#ifdef INET6
case AF_INET6:
inp = in6_pcbhashlookup(&tcbtable, &f6,
- fin6->sin6_port, &l6, lin6->sin6_port);
+ fin6->sin6_port, &l6, lin6->sin6_port, tir.rdomain);
break;
#endif
case AF_INET:
- inp = in_pcbhashlookup(&tcbtable, fin->sin_addr,
- fin->sin_port, lin->sin_addr, lin->sin_port , tir.rdomain);
+ inp = in_pcbhashlookup(&tcbtable, fin->sin_addr,
+ fin->sin_port, lin->sin_addr, lin->sin_port, tir.rdomain);
break;
}
@@ -855,7 +855,7 @@ tcp_ident(void *oldp, size_t *oldlenp, void *newp, size_t newlen, int dodrop)
#ifdef INET6
case AF_INET6:
inp = in6_pcblookup_listen(&tcbtable,
- &l6, lin6->sin6_port, 0, NULL);
+ &l6, lin6->sin6_port, 0, NULL, tir.rdomain);
break;
#endif
case AF_INET:
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c
index 0604b9f0c8a..0aca9ff7d6f 100644
--- a/sys/netinet/udp_usrreq.c
+++ b/sys/netinet/udp_usrreq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: udp_usrreq.c,v 1.169 2013/10/19 10:38:55 henning Exp $ */
+/* $OpenBSD: udp_usrreq.c,v 1.170 2013/10/20 11:03:01 phessler Exp $ */
/* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */
/*
@@ -565,7 +565,8 @@ udp_input(struct mbuf *m, ...)
#ifdef INET6
if (ip6)
inp = in6_pcbhashlookup(&udbtable, &ip6->ip6_src,
- uh->uh_sport, &ip6->ip6_dst, uh->uh_dport);
+ uh->uh_sport, &ip6->ip6_dst, uh->uh_dport,
+ m->m_pkthdr.rdomain);
else
#endif /* INET6 */
inp = in_pcbhashlookup(&udbtable, ip->ip_src, uh->uh_sport,
@@ -585,7 +586,8 @@ udp_input(struct mbuf *m, ...)
#ifdef INET6
if (ip6) {
inp = in6_pcblookup_listen(&udbtable,
- &ip6->ip6_dst, uh->uh_dport, inpl_reverse, m);
+ &ip6->ip6_dst, uh->uh_dport, inpl_reverse, m,
+ m->m_pkthdr.rdomain);
} else
#endif /* INET6 */
inp = in_pcblookup_listen(&udbtable,
@@ -870,7 +872,8 @@ udp6_ctlinput(int cmd, struct sockaddr *sa, u_int rdomain, void *d)
* payload.
*/
if (in6_pcbhashlookup(&udbtable, &sa6.sin6_addr,
- uh.uh_dport, &sa6_src.sin6_addr, uh.uh_sport))
+ uh.uh_dport, &sa6_src.sin6_addr, uh.uh_sport,
+ rdomain))
valid = 1;
#if 0
/*
@@ -881,7 +884,8 @@ udp6_ctlinput(int cmd, struct sockaddr *sa, u_int rdomain, void *d)
* is really ours.
*/
else if (in6_pcblookup_listen(&udbtable,
- &sa6_src.sin6_addr, uh.uh_sport, 0);
+ &sa6_src.sin6_addr, uh.uh_sport, 0,
+ rdomain))
valid = 1;
#endif
@@ -904,10 +908,10 @@ udp6_ctlinput(int cmd, struct sockaddr *sa, u_int rdomain, void *d)
}
(void) in6_pcbnotify(&udbtable, &sa6, uh.uh_dport,
- &sa6_src, uh.uh_sport, cmd, cmdarg, notify);
+ &sa6_src, uh.uh_sport, rdomain, cmd, cmdarg, notify);
} else {
(void) in6_pcbnotify(&udbtable, &sa6, 0,
- &sa6_any, 0, cmd, cmdarg, notify);
+ &sa6_any, 0, rdomain, cmd, cmdarg, notify);
}
}
#endif