From owner-svn-src-stable-8@FreeBSD.ORG Fri Aug 6 11:58:27 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AE50E1065678; Fri, 6 Aug 2010 11:58:27 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 81C018FC1A; Fri, 6 Aug 2010 11:58:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o76BwRM6007632; Fri, 6 Aug 2010 11:58:27 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o76BwRVl007630; Fri, 6 Aug 2010 11:58:27 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201008061158.o76BwRVl007630@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Fri, 6 Aug 2010 11:58:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r210929 - stable/8/sys/netinet6 X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Aug 2010 11:58:27 -0000 Author: bz Date: Fri Aug 6 11:58:27 2010 New Revision: 210929 URL: http://svn.freebsd.org/changeset/base/210929 Log: MFC r210350: Since r186119 IP6 input counters for octets and packets were not working anymore. In addition more checks and operations were missing. In case lla_lookup results in a match, get the ifaddr to update the statistics counters, and check that the address is neither tentative, duplicate or otherwise invalid before accepting the packet. If ok, record the address information in the mbuf. [ as is done in case lla_lookup does not return a result and we go through the FIB ]. Reported by: remko Tested by: remko Modified: stable/8/sys/netinet6/ip6_input.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cam/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/netinet6/ip6_input.c ============================================================================== --- stable/8/sys/netinet6/ip6_input.c Fri Aug 6 11:49:52 2010 (r210928) +++ stable/8/sys/netinet6/ip6_input.c Fri Aug 6 11:58:27 2010 (r210929) @@ -489,10 +489,54 @@ passin: (struct sockaddr *)&dst6); IF_AFDATA_UNLOCK(ifp); if ((lle != NULL) && (lle->la_flags & LLE_IFADDR)) { - ours = 1; - deliverifp = ifp; + struct ifaddr *ifa; + struct in6_ifaddr *ia6; + int bad; + + bad = 1; +#define sa_equal(a1, a2) \ + (bcmp((a1), (a2), ((a1))->sin6_len) == 0) + IF_ADDR_LOCK(ifp); + TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { + if (ifa->ifa_addr->sa_family != dst6.sin6_family) + continue; + if (sa_equal(&dst6, ifa->ifa_addr)) + break; + } + KASSERT(ifa != NULL, ("%s: ifa not found for lle %p", + __func__, lle)); +#undef sa_equal + + ia6 = (struct in6_ifaddr *)ifa; + if (!(ia6->ia6_flags & IN6_IFF_NOTREADY)) { + /* Count the packet in the ip address stats */ + ia6->ia_ifa.if_ipackets++; + ia6->ia_ifa.if_ibytes += m->m_pkthdr.len; + + /* + * record address information into m_tag. + */ + (void)ip6_setdstifaddr(m, ia6); + + bad = 0; + } else { + char ip6bufs[INET6_ADDRSTRLEN]; + char ip6bufd[INET6_ADDRSTRLEN]; + /* address is not ready, so discard the packet. */ + nd6log((LOG_INFO, + "ip6_input: packet to an unready address %s->%s\n", + ip6_sprintf(ip6bufs, &ip6->ip6_src), + ip6_sprintf(ip6bufd, &ip6->ip6_dst))); + } + IF_ADDR_UNLOCK(ifp); LLE_RUNLOCK(lle); - goto hbhcheck; + if (bad) + goto bad; + else { + ours = 1; + deliverifp = ifp; + goto hbhcheck; + } } if (lle != NULL) LLE_RUNLOCK(lle);