From owner-svn-src-all@FreeBSD.ORG Wed Jun 24 08:52:09 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 76BF11065676; Wed, 24 Jun 2009 08:52:09 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4A8F48FC0A; Wed, 24 Jun 2009 08:52:09 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n5O8q9wa006779; Wed, 24 Jun 2009 08:52:09 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n5O8q9XD006777; Wed, 24 Jun 2009 08:52:09 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <200906240852.n5O8q9XD006777@svn.freebsd.org> From: Robert Watson Date: Wed, 24 Jun 2009 08:52:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r194812 - head/sys/net X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Jun 2009 08:52:10 -0000 Author: rwatson Date: Wed Jun 24 08:52:09 2009 New Revision: 194812 URL: http://svn.freebsd.org/changeset/base/194812 Log: Make stf_getsrcifa6() return a reference to an in6_ifaddr rather than a pointer, and dispose of the references when no longer needed. MFC after: 6 weeks Modified: head/sys/net/if_stf.c Modified: head/sys/net/if_stf.c ============================================================================== --- head/sys/net/if_stf.c Wed Jun 24 06:42:13 2009 (r194811) +++ head/sys/net/if_stf.c Wed Jun 24 08:52:09 2009 (r194812) @@ -349,8 +349,10 @@ stf_encapcheck(m, off, proto, arg) * success on: dst = 10.1.1.1, ia6->ia_addr = 2002:0a01:0101:... */ if (bcmp(GET_V4(&ia6->ia_addr.sin6_addr), &ip.ip_dst, - sizeof(ip.ip_dst)) != 0) + sizeof(ip.ip_dst)) != 0) { + ifa_free(&ia6->ia_ifa); return 0; + } /* * check if IPv4 src matches the IPv4 address derived from the @@ -361,6 +363,7 @@ stf_encapcheck(m, off, proto, arg) bzero(&a, sizeof(a)); bcopy(GET_V4(&ia6->ia_addr.sin6_addr), &a, sizeof(a)); bcopy(GET_V4(&ia6->ia_prefixmask.sin6_addr), &mask, sizeof(mask)); + ifa_free(&ia6->ia_ifa); a.s_addr &= mask.s_addr; b = ip.ip_src; b.s_addr &= mask.s_addr; @@ -396,6 +399,7 @@ stf_getsrcifa6(ifp) if (ia4 == NULL) continue; + ifa_ref(ia); IF_ADDR_UNLOCK(ifp); return (struct in6_ifaddr *)ia; } @@ -457,6 +461,7 @@ stf_output(ifp, m, dst, ro) if (m->m_len < sizeof(*ip6)) { m = m_pullup(m, sizeof(*ip6)); if (!m) { + ifa_free(&ia6->ia_ifa); ifp->if_oerrors++; return ENOBUFS; } @@ -483,6 +488,7 @@ stf_output(ifp, m, dst, ro) else if (IN6_IS_ADDR_6TO4(&dst6->sin6_addr)) ptr = GET_V4(&dst6->sin6_addr); else { + ifa_free(&ia6->ia_ifa); m_freem(m); ifp->if_oerrors++; return ENETUNREACH; @@ -505,6 +511,7 @@ stf_output(ifp, m, dst, ro) if (m && m->m_len < sizeof(struct ip)) m = m_pullup(m, sizeof(struct ip)); if (m == NULL) { + ifa_free(&ia6->ia_ifa); ifp->if_oerrors++; return ENOBUFS; } @@ -514,6 +521,7 @@ stf_output(ifp, m, dst, ro) bcopy(GET_V4(&((struct sockaddr_in6 *)&ia6->ia_addr)->sin6_addr), &ip->ip_src, sizeof(ip->ip_src)); + ifa_free(&ia6->ia_ifa); bcopy(&in4, &ip->ip_dst, sizeof(ip->ip_dst)); ip->ip_p = IPPROTO_IPV6; ip->ip_ttl = ip_stf_ttl;