summaryrefslogtreecommitdiffstats
path: root/sys/net/if_stf.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2009-06-24 08:52:09 +0000
committerrwatson <rwatson@FreeBSD.org>2009-06-24 08:52:09 +0000
commit5972c25713f63ce6693e3c372df64f62f6f182b8 (patch)
treebbb24922c90ffa9655952dca4de1a0277e9a991f /sys/net/if_stf.c
parent4067f2d3afc89b4896559d919d32b00ba4fb68e5 (diff)
downloadFreeBSD-src-5972c25713f63ce6693e3c372df64f62f6f182b8.zip
FreeBSD-src-5972c25713f63ce6693e3c372df64f62f6f182b8.tar.gz
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
Diffstat (limited to 'sys/net/if_stf.c')
-rw-r--r--sys/net/if_stf.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/sys/net/if_stf.c b/sys/net/if_stf.c
index 911804e..d463ff6 100644
--- a/sys/net/if_stf.c
+++ b/sys/net/if_stf.c
@@ -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;
OpenPOWER on IntegriCloud