svn commit: r194812 - head/sys/net
Robert Watson
rwatson at FreeBSD.org
Wed Jun 24 08:52:10 UTC 2009
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;
More information about the svn-src-all
mailing list