diff options
author | Vincent Gross <vgross@cvs.openbsd.org> | 2015-12-03 14:55:19 +0000 |
---|---|---|
committer | Vincent Gross <vgross@cvs.openbsd.org> | 2015-12-03 14:55:19 +0000 |
commit | 4e9316b1b328edd11be42f18f375a389874034ce (patch) | |
tree | 31a5ab43d5ddcba8954d472f626d836b5083b09b /sys | |
parent | 7d41bfb8b894c3be5eb96adf7ff11db11f64fd44 (diff) |
Remove broadcast matching from ifa_ifwithaddr(), use in_broadcast() where
required.
ok bluhm@ mpi@.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/net/if.c | 9 | ||||
-rw-r--r-- | sys/net/route.c | 6 | ||||
-rw-r--r-- | sys/netinet/in_pcb.c | 16 | ||||
-rw-r--r-- | sys/netinet/ip_output.c | 14 | ||||
-rw-r--r-- | sys/netinet/raw_ip.c | 3 |
5 files changed, 21 insertions, 27 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index 0da69d799a0..728e9a0cdd6 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.418 2015/12/03 12:22:51 dlg Exp $ */ +/* $OpenBSD: if.c,v 1.419 2015/12/03 14:55:17 vgross Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -1220,13 +1220,6 @@ ifa_ifwithaddr(struct sockaddr *addr, u_int rtableid) if (equal(addr, ifa->ifa_addr)) return (ifa); - - /* IPv6 doesn't have broadcast */ - if ((ifp->if_flags & IFF_BROADCAST) && - ifa->ifa_broadaddr && - ifa->ifa_broadaddr->sa_len != 0 && - equal(ifa->ifa_broadaddr, addr)) - return (ifa); } } return (NULL); diff --git a/sys/net/route.c b/sys/net/route.c index 5a10ec14e34..7b6b640aca3 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.285 2015/12/03 14:26:27 mpi Exp $ */ +/* $OpenBSD: route.c,v 1.286 2015/12/03 14:55:17 vgross Exp $ */ /* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */ /* @@ -539,7 +539,9 @@ rtredirect(struct sockaddr *dst, struct sockaddr *gateway, bcmp((caddr_t)(a1), (caddr_t)(a2), (a1)->sa_len) == 0) if (rt != NULL && (!equal(src, rt->rt_gateway) || rt->rt_ifa != ifa)) error = EINVAL; - else if (ifa_ifwithaddr(gateway, rdomain) != NULL) + else if (ifa_ifwithaddr(gateway, rdomain) != NULL || + (gateway->sa_family = AF_INET && + in_broadcast(satosin(gateway)->sin_addr, rdomain))) error = EHOSTUNREACH; if (error) goto done; diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index df22dcd91e8..f39fed59609 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in_pcb.c,v 1.192 2015/12/03 14:05:28 bluhm Exp $ */ +/* $OpenBSD: in_pcb.c,v 1.193 2015/12/03 14:55:18 vgross Exp $ */ /* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */ /* @@ -332,14 +332,13 @@ in_pcbbind(struct inpcb *inp, struct mbuf *nam, struct proc *p) ia = ifatoia(ifa_ifwithaddr(sintosa(sin), inp->inp_rtableid)); - if (ia == NULL) - return (EADDRNOTAVAIL); /* SOCK_RAW does not use in_pcbbind() */ - if (so->so_type != SOCK_DGRAM && - sin->sin_addr.s_addr != - ia->ia_addr.sin_addr.s_addr) - return (EADDRNOTAVAIL); + if (ia == NULL && + (so->so_type != SOCK_DGRAM || + !in_broadcast(sin->sin_addr, + inp->inp_rtableid))) + return (EADDRNOTAVAIL); } } if (lport) { @@ -353,7 +352,8 @@ in_pcbbind(struct inpcb *inp, struct mbuf *nam, struct proc *p) t = in_pcblookup(table, &zeroin_addr, 0, &sin->sin_addr, lport, INPLOOKUP_WILDCARD, inp->inp_rtableid); - if (t && (so->so_euid != t->inp_socket->so_euid)) + if (t && + (so->so_euid != t->inp_socket->so_euid)) return (EADDRINUSE); } t = in_pcblookup(table, &zeroin_addr, 0, diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index be594fbb66f..8bacbda4cb8 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_output.c,v 1.311 2015/12/02 20:50:20 markus Exp $ */ +/* $OpenBSD: ip_output.c,v 1.312 2015/12/03 14:55:18 vgross Exp $ */ /* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */ /* @@ -1368,13 +1368,12 @@ ip_setmoptions(int optname, struct ip_moptions **imop, struct mbuf *m, sin.sin_family = AF_INET; sin.sin_addr = addr; ia = ifatoia(ifa_ifwithaddr(sintosa(&sin), rtableid)); - if (ia && in_hosteq(sin.sin_addr, ia->ia_addr.sin_addr)) - ifp = ia->ia_ifp; - if (ifp == NULL || (ifp->if_flags & IFF_MULTICAST) == 0) { + if (ia == NULL || + (ia->ia_ifp->if_flags & IFF_MULTICAST) == 0) { error = EADDRNOTAVAIL; break; } - imo->imo_ifidx = ifp->if_index; + imo->imo_ifidx = ia->ia_ifp->if_index; break; case IP_MULTICAST_TTL: @@ -1542,12 +1541,11 @@ ip_setmoptions(int optname, struct ip_moptions **imop, struct mbuf *m, sin.sin_family = AF_INET; sin.sin_addr = mreq->imr_interface; ia = ifatoia(ifa_ifwithaddr(sintosa(&sin), rtableid)); - if (ia && in_hosteq(sin.sin_addr, ia->ia_addr.sin_addr)) - ifp = ia->ia_ifp; - else { + if (ia == NULL) { error = EADDRNOTAVAIL; break; } + ifp = ia->ia_ifp; } /* * Find the membership in the membership array. diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c index d15c8c5e0af..ace38bf2735 100644 --- a/sys/netinet/raw_ip.c +++ b/sys/netinet/raw_ip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: raw_ip.c,v 1.84 2015/07/28 12:22:07 bluhm Exp $ */ +/* $OpenBSD: raw_ip.c,v 1.85 2015/12/03 14:55:18 vgross Exp $ */ /* $NetBSD: raw_ip.c,v 1.25 1996/02/18 18:58:33 christos Exp $ */ /* @@ -473,6 +473,7 @@ rip_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam, if (!((so->so_options & SO_BINDANY) || addr->sin_addr.s_addr == INADDR_ANY || addr->sin_addr.s_addr == INADDR_BROADCAST || + in_broadcast(addr->sin_addr, inp->inp_rtableid) || ifa_ifwithaddr(sintosa(addr), inp->inp_rtableid))) { error = EADDRNOTAVAIL; break; |