summaryrefslogtreecommitdiff
path: root/sys/netinet
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2013-11-27 08:37:09 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2013-11-27 08:37:09 +0000
commit63648746bca8a5752ecfc73a64a621b188a1e719 (patch)
tree64562b7405bbec4d42a7cfbf2790a8f8d0e3696f /sys/netinet
parent0f6d1bcc55b9410e51f77839c4b9f6eccd8d8cf7 (diff)
Replace INADDR_TO_IFP() by in_iawithaddr() and kill the macro.
ok mikeb@, ports@, henning@
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/in_var.h19
-rw-r--r--sys/netinet/ip_output.c16
2 files changed, 12 insertions, 23 deletions
diff --git a/sys/netinet/in_var.h b/sys/netinet/in_var.h
index e76cdba5f71..5f0b1da06ef 100644
--- a/sys/netinet/in_var.h
+++ b/sys/netinet/in_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: in_var.h,v 1.28 2013/11/21 16:34:33 mikeb Exp $ */
+/* $OpenBSD: in_var.h,v 1.29 2013/11/27 08:37:08 mpi Exp $ */
/* $NetBSD: in_var.h,v 1.16 1996/02/13 23:42:15 christos Exp $ */
/*
@@ -82,23 +82,6 @@ TAILQ_HEAD(in_ifaddrhead, in_ifaddr);
extern struct in_ifaddrhead in_ifaddr;
/*
- * Macro for finding the interface (ifnet structure) corresponding to one
- * of our IP addresses.
- */
-#define INADDR_TO_IFP(addr, ifp, rtableid) \
- /* struct in_addr addr; */ \
- /* struct ifnet *ifp; */ \
-do { \
- struct in_ifaddr *ia; \
- \
- TAILQ_FOREACH(ia, &in_ifaddr, ia_list) \
- if (ia->ia_ifp->if_rdomain == rtable_l2(rtableid) && \
- ia->ia_addr.sin_addr.s_addr == (addr).s_addr) \
- break; \
- (ifp) = (ia == NULL) ? NULL : ia->ia_ifp; \
-} while (/* CONSTCOND */ 0)
-
-/*
* Macro for finding the internet address structure (in_ifaddr) corresponding
* to a given interface (ifnet structure).
*/
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c
index 9a2372f22e1..2f0f519c0fb 100644
--- a/sys/netinet/ip_output.c
+++ b/sys/netinet/ip_output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_output.c,v 1.250 2013/10/25 18:44:36 lteo Exp $ */
+/* $OpenBSD: ip_output.c,v 1.251 2013/11/27 08:37:08 mpi Exp $ */
/* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */
/*
@@ -1702,6 +1702,7 @@ ip_setmoptions(int optname, struct ip_moptions **imop, struct mbuf *m,
u_char loop;
int i;
struct in_addr addr;
+ struct in_ifaddr *ia;
struct ip_mreq *mreq;
struct ifnet *ifp;
struct ip_moptions *imo = *imop;
@@ -1753,7 +1754,9 @@ ip_setmoptions(int optname, struct ip_moptions **imop, struct mbuf *m,
* IP address. Find the interface and confirm that
* it supports multicasting.
*/
- INADDR_TO_IFP(addr, ifp, rtableid);
+ ia = in_iawithaddr(addr, rtableid);
+ if (ia)
+ ifp = ia->ia_ifp;
if (ifp == NULL || (ifp->if_flags & IFF_MULTICAST) == 0) {
error = EADDRNOTAVAIL;
break;
@@ -1820,7 +1823,9 @@ ip_setmoptions(int optname, struct ip_moptions **imop, struct mbuf *m,
ifp = ro.ro_rt->rt_ifp;
rtfree(ro.ro_rt);
} else {
- INADDR_TO_IFP(mreq->imr_interface, ifp, rtableid);
+ ia = in_iawithaddr(mreq->imr_interface, rtableid);
+ if (ia)
+ ifp = ia->ia_ifp;
}
/*
* See if we found an interface, and confirm that it
@@ -1906,11 +1911,12 @@ ip_setmoptions(int optname, struct ip_moptions **imop, struct mbuf *m,
if (mreq->imr_interface.s_addr == INADDR_ANY)
ifp = NULL;
else {
- INADDR_TO_IFP(mreq->imr_interface, ifp, rtableid);
- if (ifp == NULL) {
+ ia = in_iawithaddr(mreq->imr_interface, rtableid);
+ if (ia == NULL) {
error = EADDRNOTAVAIL;
break;
}
+ ifp = ia->ia_ifp;
}
/*
* Find the membership in the membership array.