diff options
-rw-r--r-- | sys/netinet/ip_input.c | 19 | ||||
-rw-r--r-- | sys/netinet/ip_output.c | 36 | ||||
-rw-r--r-- | sys/netinet/ip_var.h | 4 |
3 files changed, 26 insertions, 33 deletions
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index ab1cac3b971..202b11fc763 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_input.c,v 1.240 2014/11/04 15:24:40 mpi Exp $ */ +/* $OpenBSD: ip_input.c,v 1.241 2014/11/05 14:03:02 mpi Exp $ */ /* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */ /* @@ -721,23 +721,6 @@ in_ouraddr(struct mbuf *m, struct ifnet *ifp, struct in_addr ina) return (ISSET(ia->ia_ifp->if_flags, IFF_UP)); } -struct in_ifaddr * -in_iawithaddr(struct in_addr ina, u_int rtableid) -{ - struct in_ifaddr *ia; - struct sockaddr_in sin; - - memset(&sin, 0, sizeof(sin)); - sin.sin_len = sizeof(sin); - sin.sin_family = AF_INET; - sin.sin_addr = ina; - ia = ifatoia(ifa_ifwithaddr(sintosa(&sin), rtableid)); - if (ia == NULL || ina.s_addr == ia->ia_addr.sin_addr.s_addr) - return (ia); - - return (NULL); -} - /* * Take incoming datagram fragment and try to * reassemble it into whole datagram. If a chain for diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 9e36e6a8743..b224f7f122d 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_output.c,v 1.270 2014/11/01 21:40:38 mpi Exp $ */ +/* $OpenBSD: ip_output.c,v 1.271 2014/11/05 14:03:02 mpi Exp $ */ /* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */ /* @@ -1656,9 +1656,6 @@ int ip_setmoptions(int optname, struct ip_moptions **imop, struct mbuf *m, u_int rtableid) { - int error = 0; - u_char loop; - int i; struct in_addr addr; struct in_ifaddr *ia; struct ip_mreq *mreq; @@ -1666,7 +1663,9 @@ ip_setmoptions(int optname, struct ip_moptions **imop, struct mbuf *m, struct ip_moptions *imo = *imop; struct in_multi **immp; struct route ro; - struct sockaddr_in *dst; + struct sockaddr_in *dst, sin; + int i, error = 0; + u_char loop; if (imo == NULL) { /* @@ -1712,8 +1711,12 @@ ip_setmoptions(int optname, struct ip_moptions **imop, struct mbuf *m, * IP address. Find the interface and confirm that * it supports multicasting. */ - ia = in_iawithaddr(addr, rtableid); - if (ia) + memset(&sin, 0, sizeof(sin)); + sin.sin_len = sizeof(sin); + 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) { error = EADDRNOTAVAIL; @@ -1781,8 +1784,12 @@ ip_setmoptions(int optname, struct ip_moptions **imop, struct mbuf *m, ifp = ro.ro_rt->rt_ifp; rtfree(ro.ro_rt); } else { - ia = in_iawithaddr(mreq->imr_interface, rtableid); - if (ia) + memset(&sin, 0, sizeof(sin)); + sin.sin_len = sizeof(sin); + 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; } /* @@ -1870,12 +1877,17 @@ ip_setmoptions(int optname, struct ip_moptions **imop, struct mbuf *m, if (mreq->imr_interface.s_addr == INADDR_ANY) ifp = NULL; else { - ia = in_iawithaddr(mreq->imr_interface, rtableid); - if (ia == NULL) { + memset(&sin, 0, sizeof(sin)); + sin.sin_len = sizeof(sin); + 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 { error = EADDRNOTAVAIL; break; } - ifp = ia->ia_ifp; } /* * Find the membership in the membership array. diff --git a/sys/netinet/ip_var.h b/sys/netinet/ip_var.h index 5ffb08a563d..c4abff43a44 100644 --- a/sys/netinet/ip_var.h +++ b/sys/netinet/ip_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_var.h,v 1.56 2014/04/21 12:22:26 henning Exp $ */ +/* $OpenBSD: ip_var.h,v 1.57 2014/11/05 14:03:02 mpi Exp $ */ /* $NetBSD: ip_var.h,v 1.16 1996/02/13 23:43:20 christos Exp $ */ /* @@ -189,8 +189,6 @@ int ip_pcbopts(struct mbuf **, struct mbuf *); struct mbuf * ip_reass(struct ipqent *, struct ipq *); struct in_ifaddr * - in_iawithaddr(struct in_addr, u_int); -struct in_ifaddr * ip_rtaddr(struct in_addr, u_int); u_int16_t ip_randomid(void); |