diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2013-08-21 09:02:13 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2013-08-21 09:02:13 +0000 |
commit | 099ab8e7cce15c06c1e218536ab21cf8059e9f38 (patch) | |
tree | 74c59199393513f7671b45c8d505db0f616244d3 /sys/netinet/ip_input.c | |
parent | 6fd4f3bd457bb1902baf6e8bb61f26d7d81cc043 (diff) |
When checking for classful broadcast addresses, iterate over the list
from the interface on which the packet was received on instead of
filtering the global list.
ok bluhm@, henning@
Diffstat (limited to 'sys/netinet/ip_input.c')
-rw-r--r-- | sys/netinet/ip_input.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index 1b219001779..daf90221419 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_input.c,v 1.216 2013/08/13 09:52:53 mpi Exp $ */ +/* $OpenBSD: ip_input.c,v 1.217 2013/08/21 09:02:12 mpi Exp $ */ /* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */ /* @@ -694,6 +694,8 @@ in_ouraddr(struct in_addr ina, struct mbuf *m) ia = ifatoia(ifa_ifwithaddr(sintosa(&sin), m->m_pkthdr.rdomain)); if (ia == NULL) { + struct ifaddr *ifa; + /* * No local address or broadcast address found, so check for * ancient classful broadcast addresses. @@ -704,16 +706,19 @@ in_ouraddr(struct in_addr ina, struct mbuf *m) !IN_CLASSFULBROADCAST(ina.s_addr, ina.s_addr)) return (0); + if (m->m_pkthdr.rcvif->if_rdomain != m->m_pkthdr.rdomain) + return (0); /* * The check in the loop assumes you only rx a packet on an UP * interface, and that M_BCAST will only be set on a BROADCAST * interface. */ - TAILQ_FOREACH(ia, &in_ifaddr, ia_list) { - if (ia->ia_ifp == m->m_pkthdr.rcvif && - ia->ia_ifp->if_rdomain == m->m_pkthdr.rdomain && - IN_CLASSFULBROADCAST(ina.s_addr, - ia->ia_addr.sin_addr.s_addr)) + TAILQ_FOREACH(ifa, &m->m_pkthdr.rcvif->if_addrlist, ifa_list) { + if (ifa->ifa_addr->sa_family != AF_INET) + continue; + + if (IN_CLASSFULBROADCAST(ina.s_addr, + ifatoia(ifa)->ia_addr.sin_addr.s_addr)) return (1); } |