summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/netinet/ip_input.c45
-rw-r--r--sys/netinet/ip_var.h4
2 files changed, 26 insertions, 23 deletions
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c
index af86146ed39..61c2cfe25b0 100644
--- a/sys/netinet/ip_input.c
+++ b/sys/netinet/ip_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_input.c,v 1.187 2011/04/02 14:38:09 henning Exp $ */
+/* $OpenBSD: ip_input.c,v 1.188 2011/04/04 13:30:03 henning Exp $ */
/* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */
/*
@@ -144,6 +144,9 @@ struct pool ipq_pool;
struct ipstat ipstat;
+struct in_ifaddr *
+ in_iawithaddr(struct in_addr, struct mbuf *, u_int);
+
char *
inet_ntoa(ina)
struct in_addr ina;
@@ -682,30 +685,32 @@ bad:
struct in_ifaddr *
in_iawithaddr(struct in_addr ina, struct mbuf *m, u_int rdomain)
{
- struct in_ifaddr *ia;
+ struct in_ifaddr *ia;
+ struct sockaddr_in sin;
- rdomain = rtable_l2(rdomain);
- TAILQ_FOREACH(ia, &in_ifaddr, ia_list) {
- if (ia->ia_ifp->if_rdomain != rdomain)
- continue;
- if (ina.s_addr == ia->ia_addr.sin_addr.s_addr)
- return ia;
- /* check ancient classful too, e. g. for rarp-based netboot */
- if (((ip_directedbcast == 0) || (m && ip_directedbcast &&
- ia->ia_ifp == m->m_pkthdr.rcvif)) &&
- (ia->ia_ifp->if_flags & IFF_BROADCAST)) {
- if (ina.s_addr == ia->ia_broadaddr.sin_addr.s_addr ||
+ bzero(&sin, sizeof(sin));
+ sin.sin_len = sizeof(sin);
+ sin.sin_family = AF_INET;
+ sin.sin_addr = ina;
+ ia = (struct in_ifaddr *)ifa_ifwithaddr(sintosa(&sin), rdomain);
+
+ /* check ancient classful, e. g. for rarp-based netboot */
+ if (ia == NULL && m->m_flags | M_BCAST &&
+ IN_CLASSFULBROADCAST(ina.s_addr, ina.s_addr)) {
+ TAILQ_FOREACH(ia, &in_ifaddr, ia_list) {
+ if (ia->ia_ifp->if_rdomain != rdomain)
+ continue;
+ if (((ip_directedbcast == 0) ||
+ (m && ip_directedbcast &&
+ ia->ia_ifp == m->m_pkthdr.rcvif)) &&
+ (ia->ia_ifp->if_flags & IFF_BROADCAST) &&
IN_CLASSFULBROADCAST(ina.s_addr,
- ia->ia_addr.sin_addr.s_addr)) {
- /* Make sure M_BCAST is set */
- if (m)
- m->m_flags |= M_BCAST;
- return ia;
- }
+ ia->ia_addr.sin_addr.s_addr))
+ return (ia);
}
}
- return NULL;
+ return (ia);
}
/*
diff --git a/sys/netinet/ip_var.h b/sys/netinet/ip_var.h
index 853b4816e85..ae70da7f37b 100644
--- a/sys/netinet/ip_var.h
+++ b/sys/netinet/ip_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_var.h,v 1.39 2009/06/05 00:05:22 claudio Exp $ */
+/* $OpenBSD: ip_var.h,v 1.40 2011/04/04 13:30:03 henning Exp $ */
/* $NetBSD: ip_var.h,v 1.16 1996/02/13 23:43:20 christos Exp $ */
/*
@@ -172,8 +172,6 @@ int ip_pcbopts(struct mbuf **, struct mbuf *);
struct mbuf *
ip_reass(struct ipqent *, struct ipq *);
struct in_ifaddr *
- in_iawithaddr(struct in_addr, struct mbuf *, u_int);
-struct in_ifaddr *
ip_rtaddr(struct in_addr, u_int);
u_int16_t
ip_randomid(void);