diff options
Diffstat (limited to 'sys/netinet/ip_input.c')
-rw-r--r-- | sys/netinet/ip_input.c | 45 |
1 files changed, 25 insertions, 20 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); } /* |