summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2011-04-28 09:56:28 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2011-04-28 09:56:28 +0000
commit959bb9f6884c49637c3bcde1c528f737d6f881bd (patch)
tree6b60f6ed2c927369b9b628e1b106c709a243c7f7 /sys
parentd8e44e7cc59e0f8ed2759d99780e241c2d7d0277 (diff)
Make in_broadcast() rdomain aware. Mostly mechanical change.
This fixes the problem of binding sockets to broadcast IPs in other rdomains. OK henning@
Diffstat (limited to 'sys')
-rw-r--r--sys/netinet/in.c11
-rw-r--r--sys/netinet/in.h4
-rw-r--r--sys/netinet/in_pcb.c5
-rw-r--r--sys/netinet/ip_output.c5
-rw-r--r--sys/netinet/raw_ip.c4
-rw-r--r--sys/netinet/tcp_input.c5
-rw-r--r--sys/netinet/tcp_usrreq.c5
-rw-r--r--sys/netinet/udp_usrreq.c7
8 files changed, 27 insertions, 19 deletions
diff --git a/sys/netinet/in.c b/sys/netinet/in.c
index 14bf9d88394..1d795e591b0 100644
--- a/sys/netinet/in.c
+++ b/sys/netinet/in.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in.c,v 1.64 2010/11/28 20:24:33 claudio Exp $ */
+/* $OpenBSD: in.c,v 1.65 2011/04/28 09:56:27 claudio Exp $ */
/* $NetBSD: in.c,v 1.26 1996/02/13 23:41:39 christos Exp $ */
/*
@@ -886,12 +886,13 @@ in_scrubprefix(target)
* Return 1 if the address might be a local broadcast address.
*/
int
-in_broadcast(in, ifp)
- struct in_addr in;
- struct ifnet *ifp;
+in_broadcast(struct in_addr in, struct ifnet *ifp, u_int rtableid)
{
struct ifnet *ifn, *if_first, *if_target;
struct ifaddr *ifa;
+ u_int rdomain;
+
+ rdomain = rtable_l2(rtableid);
if (in.s_addr == INADDR_BROADCAST ||
in.s_addr == INADDR_ANY)
@@ -912,6 +913,8 @@ in_broadcast(in, ifp)
* If ifp is NULL, check against all the interfaces.
*/
for (ifn = if_first; ifn != if_target; ifn = TAILQ_NEXT(ifn, if_list)) {
+ if (ifn->if_rdomain != rdomain)
+ continue;
if ((ifn->if_flags & IFF_BROADCAST) == 0)
continue;
TAILQ_FOREACH(ifa, &ifn->if_addrlist, ifa_list)
diff --git a/sys/netinet/in.h b/sys/netinet/in.h
index 2577ddbfda1..9ee7987a31e 100644
--- a/sys/netinet/in.h
+++ b/sys/netinet/in.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: in.h,v 1.86 2011/04/04 17:44:43 henning Exp $ */
+/* $OpenBSD: in.h,v 1.87 2011/04/28 09:56:27 claudio Exp $ */
/* $NetBSD: in.h,v 1.20 1996/02/13 23:41:47 christos Exp $ */
/*
@@ -792,7 +792,7 @@ in_cksum_addword(u_int16_t a, u_int16_t b)
extern struct in_addr zeroin_addr;
-int in_broadcast(struct in_addr, struct ifnet *);
+int in_broadcast(struct in_addr, struct ifnet *, u_int);
int in_canforward(struct in_addr);
int in_cksum(struct mbuf *, int);
int in4_cksum(struct mbuf *, u_int8_t, int, int);
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
index 50dced25268..1a125bc5296 100644
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in_pcb.c,v 1.118 2011/04/28 07:10:03 claudio Exp $ */
+/* $OpenBSD: in_pcb.c,v 1.119 2011/04/28 09:56:27 claudio Exp $ */
/* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */
/*
@@ -280,7 +280,8 @@ in_pcbbind(v, nam, p)
inp->inp_rtableid) == NULL)
/* SOCK_RAW does not use in_pcbbind() */
if (!(so->so_type == SOCK_DGRAM &&
- in_broadcast(sin->sin_addr, NULL)))
+ in_broadcast(sin->sin_addr, NULL,
+ inp->inp_rtableid)))
return (EADDRNOTAVAIL);
}
if (lport) {
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c
index 26fa3fa1b56..6c5a3d0c9ca 100644
--- a/sys/netinet/ip_output.c
+++ b/sys/netinet/ip_output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_output.c,v 1.218 2011/04/05 20:33:12 henning Exp $ */
+/* $OpenBSD: ip_output.c,v 1.219 2011/04/28 09:56:27 claudio Exp $ */
/* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */
/*
@@ -544,7 +544,8 @@ reroute:
* such a packet; if the packet is going in an IPsec tunnel, skip
* this check.
*/
- if ((sproto == 0) && (in_broadcast(dst->sin_addr, ifp))) {
+ if ((sproto == 0) && (in_broadcast(dst->sin_addr, ifp,
+ m->m_pkthdr.rdomain))) {
if ((ifp->if_flags & IFF_BROADCAST) == 0) {
error = EADDRNOTAVAIL;
goto bad;
diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c
index ecc0f95f22b..efac6a6d96c 100644
--- a/sys/netinet/raw_ip.c
+++ b/sys/netinet/raw_ip.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: raw_ip.c,v 1.56 2011/04/28 07:11:58 claudio Exp $ */
+/* $OpenBSD: raw_ip.c,v 1.57 2011/04/28 09:56:27 claudio Exp $ */
/* $NetBSD: raw_ip.c,v 1.25 1996/02/18 18:58:33 christos Exp $ */
/*
@@ -442,7 +442,7 @@ rip_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
}
if (!((so->so_options & SO_BINDANY) ||
in_iawithaddr(addr->sin_addr, inp->inp_rtableid) ||
- in_broadcast(addr->sin_addr, NULL))) {
+ in_broadcast(addr->sin_addr, NULL, inp->inp_rtableid))) {
error = EADDRNOTAVAIL;
break;
}
diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c
index b66bfc7754f..60d4cd6385f 100644
--- a/sys/netinet/tcp_input.c
+++ b/sys/netinet/tcp_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_input.c,v 1.246 2011/04/24 19:36:54 bluhm Exp $ */
+/* $OpenBSD: tcp_input.c,v 1.247 2011/04/28 09:56:27 claudio Exp $ */
/* $NetBSD: tcp_input.c,v 1.23 1996/02/13 23:43:44 christos Exp $ */
/*
@@ -477,7 +477,8 @@ tcp_input(struct mbuf *m, ...)
case AF_INET:
ip = mtod(m, struct ip *);
if (IN_MULTICAST(ip->ip_dst.s_addr) ||
- in_broadcast(ip->ip_dst, m->m_pkthdr.rcvif))
+ in_broadcast(ip->ip_dst, m->m_pkthdr.rcvif,
+ m->m_pkthdr.rdomain))
goto drop;
#ifdef TCP_ECN
/* save ip_tos before clearing it for checksum */
diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c
index f5b5096dd9d..2e14907f448 100644
--- a/sys/netinet/tcp_usrreq.c
+++ b/sys/netinet/tcp_usrreq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_usrreq.c,v 1.106 2011/04/04 21:11:22 claudio Exp $ */
+/* $OpenBSD: tcp_usrreq.c,v 1.107 2011/04/28 09:56:27 claudio Exp $ */
/* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */
/*
@@ -288,7 +288,8 @@ tcp_usrreq(so, req, m, nam, control, p)
{
if ((sin->sin_addr.s_addr == INADDR_ANY) ||
IN_MULTICAST(sin->sin_addr.s_addr) ||
- in_broadcast(sin->sin_addr, NULL)) {
+ in_broadcast(sin->sin_addr, NULL,
+ inp->inp_rtableid)) {
error = EINVAL;
break;
}
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c
index 42daf24c458..58e0a040ec1 100644
--- a/sys/netinet/udp_usrreq.c
+++ b/sys/netinet/udp_usrreq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: udp_usrreq.c,v 1.141 2011/04/24 19:36:54 bluhm Exp $ */
+/* $OpenBSD: udp_usrreq.c,v 1.142 2011/04/28 09:56:27 claudio Exp $ */
/* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */
/*
@@ -412,10 +412,11 @@ udp_input(struct mbuf *m, ...)
#ifdef INET6
if ((ip6 && IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) ||
(ip && IN_MULTICAST(ip->ip_dst.s_addr)) ||
- (ip && in_broadcast(ip->ip_dst, m->m_pkthdr.rcvif))) {
+ (ip && in_broadcast(ip->ip_dst, m->m_pkthdr.rcvif,
+ m->m_pkthdr.rdomain))) {
#else /* INET6 */
if (IN_MULTICAST(ip->ip_dst.s_addr) ||
- in_broadcast(ip->ip_dst, m->m_pkthdr.rcvif)) {
+ in_broadcast(ip->ip_dst, m->m_pkthdr.rcvif, m->m_pkthdr.rdomain)) {
#endif /* INET6 */
struct inpcb *last;
/*