diff options
author | andre <andre@FreeBSD.org> | 2005-08-22 12:06:26 +0000 |
---|---|---|
committer | andre <andre@FreeBSD.org> | 2005-08-22 12:06:26 +0000 |
commit | 1afbca0a454d70fc5eb818a4eb3a654cdc571f72 (patch) | |
tree | b4c71c9a2d965187f72fabed29e4fb0335b143f8 /sys/netinet/ip_fastfwd.c | |
parent | 61076facb25aece774d46562afc37b84719d8768 (diff) | |
download | FreeBSD-src-1afbca0a454d70fc5eb818a4eb3a654cdc571f72.zip FreeBSD-src-1afbca0a454d70fc5eb818a4eb3a654cdc571f72.tar.gz |
Handle pure layer 2 broad- and multicasts properly and simplify related
checks.
PR: kern/85052
Submitted by: Dmitrij Tejblum <tejblum at yandex-team.ru>
MFC after: 3 days
Diffstat (limited to 'sys/netinet/ip_fastfwd.c')
-rw-r--r-- | sys/netinet/ip_fastfwd.c | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/sys/netinet/ip_fastfwd.c b/sys/netinet/ip_fastfwd.c index 6c5f669..8a84078 100644 --- a/sys/netinet/ip_fastfwd.c +++ b/sys/netinet/ip_fastfwd.c @@ -157,8 +157,6 @@ ip_fastforward(struct mbuf *m) struct mbuf *m0 = NULL; struct route ro; struct sockaddr_in *dst = NULL; - struct in_ifaddr *ia = NULL; - struct ifaddr *ifa = NULL; struct ifnet *ifp; struct in_addr odest, dest; u_short sum, ip_len; @@ -313,11 +311,13 @@ ip_fastforward(struct mbuf *m) * let ip_input handle it. We play safe here and let ip_input * deal with it until it is proven that we can directly drop it. */ - if ((m->m_pkthdr.rcvif->if_flags & IFF_LOOPBACK) || + if ((m->m_flags & (M_BCAST|M_MCAST)) || + (m->m_pkthdr.rcvif->if_flags & IFF_LOOPBACK) || ntohl(ip->ip_src.s_addr) == (u_long)INADDR_BROADCAST || ntohl(ip->ip_dst.s_addr) == (u_long)INADDR_BROADCAST || IN_MULTICAST(ntohl(ip->ip_src.s_addr)) || IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) || + ip->ip_src.s_addr == INADDR_ANY || ip->ip_dst.s_addr == INADDR_ANY ) return 0; @@ -327,22 +327,6 @@ ip_fastforward(struct mbuf *m) if (in_localip(ip->ip_dst)) return 0; - /* - * Or is it for a local IP broadcast address on this host? - */ - if ((m->m_flags & M_BCAST) && - (m->m_pkthdr.rcvif->if_flags & IFF_BROADCAST)) { - TAILQ_FOREACH(ifa, &m->m_pkthdr.rcvif->if_addrhead, ifa_link) { - if (ifa->ifa_addr->sa_family != AF_INET) - continue; - ia = ifatoia(ifa); - if (ia->ia_netbroadcast.s_addr == ip->ip_dst.s_addr) - return 0; - if (satosin(&ia->ia_broadaddr)->sin_addr.s_addr == - ip->ip_dst.s_addr) - return 0; - } - } ipstat.ips_total++; /* |