diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2011-04-04 13:30:04 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2011-04-04 13:30:04 +0000 |
commit | b6fe5c9e806bcb8af8936ec2bc4dd9987c1abba9 (patch) | |
tree | 8b21fd111908f13ee71b1f0fdd570733b89a26cd /sys | |
parent | dbea484e4ab2c4445a5e7bf0f6da1d4d0425bb89 (diff) |
make in_iawithaddr a wrapper for ifa_ifwithaddr plus a hack for old ancient
classful broadcast so we can still netboot sparc and the like.
compat hack untested, i will deal with the fallout if there is any later
at the same time stop exporting in_iawithaddr, everything but ip_input
should (and now does) use ifa_ifwithaddr directly
ok dlg sthen and agreement from many
Diffstat (limited to 'sys')
-rw-r--r-- | sys/netinet/ip_input.c | 45 | ||||
-rw-r--r-- | sys/netinet/ip_var.h | 4 |
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); |