summaryrefslogtreecommitdiffstats
path: root/sys/netinet6
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2014-10-14 09:52:25 +0000
committermpi <mpi@openbsd.org>2014-10-14 09:52:25 +0000
commit27ae666c98839b54ee31f46d4088ba4f1bccd084 (patch)
treed31864036956f5d7a0710856890ab05ec1501154 /sys/netinet6
parentsync (diff)
downloadwireguard-openbsd-27ae666c98839b54ee31f46d4088ba4f1bccd084.tar.xz
wireguard-openbsd-27ae666c98839b54ee31f46d4088ba4f1bccd084.zip
Use rtfree() instead of RTFREE(), NULLify some free'd route pointers and
kill the macro. ok mikeb@, henning@
Diffstat (limited to 'sys/netinet6')
-rw-r--r--sys/netinet6/frag6.c8
-rw-r--r--sys/netinet6/icmp6.c18
-rw-r--r--sys/netinet6/in6.c14
-rw-r--r--sys/netinet6/in6_src.c16
-rw-r--r--sys/netinet6/ip6_forward.c14
-rw-r--r--sys/netinet6/ip6_input.c6
-rw-r--r--sys/netinet6/ip6_output.c14
-rw-r--r--sys/netinet6/nd6.c6
-rw-r--r--sys/netinet6/nd6_nbr.c10
9 files changed, 52 insertions, 54 deletions
diff --git a/sys/netinet6/frag6.c b/sys/netinet6/frag6.c
index 356b45ad66a..f23534f9b94 100644
--- a/sys/netinet6/frag6.c
+++ b/sys/netinet6/frag6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: frag6.c,v 1.55 2014/09/27 12:26:16 mpi Exp $ */
+/* $OpenBSD: frag6.c,v 1.56 2014/10/14 09:52:26 mpi Exp $ */
/* $KAME: frag6.c,v 1.40 2002/05/27 21:40:31 itojun Exp $ */
/*
@@ -200,7 +200,7 @@ frag6_input(struct mbuf **mp, int *offp, int proto)
if (ro.ro_rt != NULL && ro.ro_rt->rt_ifa != NULL)
dstifp = ifatoia6(ro.ro_rt->rt_ifa)->ia_ifp;
if (ro.ro_rt != NULL) {
- RTFREE(ro.ro_rt);
+ rtfree(ro.ro_rt);
ro.ro_rt = NULL;
}
#else
@@ -673,8 +673,8 @@ frag6_slowtimo(void)
* destination and the cache is never replaced.
*/
if (ip6_forward_rt.ro_rt) {
- RTFREE(ip6_forward_rt.ro_rt);
- ip6_forward_rt.ro_rt = 0;
+ rtfree(ip6_forward_rt.ro_rt);
+ ip6_forward_rt.ro_rt = NULL;
}
splx(s);
diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c
index c43857759d6..6aa29fa05bc 100644
--- a/sys/netinet6/icmp6.c
+++ b/sys/netinet6/icmp6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: icmp6.c,v 1.148 2014/08/27 14:04:16 florian Exp $ */
+/* $OpenBSD: icmp6.c,v 1.149 2014/10/14 09:52:26 mpi Exp $ */
/* $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */
/*
@@ -1046,9 +1046,8 @@ icmp6_mtudisc_update(struct ip6ctlparam *ip6cp, int validated)
rt->rt_rmx.rmx_mtu = mtu;
}
}
- if (rt) { /* XXX: need braces to avoid conflict with else in RTFREE. */
- RTFREE(rt);
- }
+ if (rt)
+ rtfree(rt);
/*
* Notify protocols that the MTU for this destination
@@ -1281,9 +1280,8 @@ icmp6_reflect(struct mbuf *m, size_t off)
bzero(&ro, sizeof(ro));
error = in6_selectsrc(&src, &sa6_src, NULL, NULL, &ro, NULL,
m->m_pkthdr.ph_rtableid);
- if (ro.ro_rt) { /* XXX: see comments in icmp6_mtudisc_update */
- RTFREE(ro.ro_rt); /* XXX: we could use this */
- }
+ if (ro.ro_rt)
+ rtfree(ro.ro_rt); /* XXX: we could use this */
if (error) {
nd6log((LOG_DEBUG,
"icmp6_reflect: source can't be determined: "
@@ -1442,7 +1440,7 @@ icmp6_redirect_input(struct mbuf *m, int off)
"ICMP6 redirect rejected; no route "
"with inet6 gateway found for redirect dst: %s\n",
icmp6_redirect_diag(&src6, &reddst6, &redtgt6)));
- RTFREE(rt);
+ rtfree(rt);
goto bad;
}
@@ -1454,7 +1452,7 @@ icmp6_redirect_input(struct mbuf *m, int off)
"%s\n",
inet_ntop(AF_INET6, gw6, addr, sizeof(addr)),
icmp6_redirect_diag(&src6, &reddst6, &redtgt6)));
- RTFREE(rt);
+ rtfree(rt);
goto bad;
}
} else {
@@ -1464,7 +1462,7 @@ icmp6_redirect_input(struct mbuf *m, int off)
icmp6_redirect_diag(&src6, &reddst6, &redtgt6)));
goto bad;
}
- RTFREE(rt);
+ rtfree(rt);
rt = NULL;
}
diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c
index 1c6faae9cd1..98ef79db83a 100644
--- a/sys/netinet6/in6.c
+++ b/sys/netinet6/in6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in6.c,v 1.141 2014/10/07 08:47:28 mpi Exp $ */
+/* $OpenBSD: in6.c,v 1.142 2014/10/14 09:52:26 mpi Exp $ */
/* $KAME: in6.c,v 1.372 2004/06/14 08:14:21 itojun Exp $ */
/*
@@ -878,7 +878,7 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra,
if (memcmp(&mltaddr.sin6_addr,
&satosin6(rt_key(rt))->sin6_addr,
32 / 8)) {
- RTFREE(rt);
+ rtfree(rt);
rt = NULL;
}
}
@@ -897,7 +897,7 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra,
if (error)
goto cleanup;
} else {
- RTFREE(rt);
+ rtfree(rt);
}
imm = in6_joingroup(ifp, &mltaddr.sin6_addr, &error);
if (!imm) {
@@ -947,7 +947,7 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra,
if (memcmp(&mltaddr.sin6_addr,
&satosin6(rt_key(rt))->sin6_addr,
32 / 8)) {
- RTFREE(rt);
+ rtfree(rt);
rt = NULL;
}
}
@@ -965,7 +965,7 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra,
if (error)
goto cleanup;
} else {
- RTFREE(rt);
+ rtfree(rt);
}
imm = in6_joingroup(ifp, &mltaddr.sin6_addr, &error);
if (!imm) {
@@ -1620,11 +1620,11 @@ in6_ifpprefix(const struct ifnet *ifp, const struct in6_addr *addr)
rt->rt_ifp->if_carpdev != ifp->if_carpdev) &&
#endif
1)) {
- RTFREE(rt);
+ rtfree(rt);
return (0);
}
- RTFREE(rt);
+ rtfree(rt);
return (1);
}
diff --git a/sys/netinet6/in6_src.c b/sys/netinet6/in6_src.c
index 85a1153d97a..5fc56b90951 100644
--- a/sys/netinet6/in6_src.c
+++ b/sys/netinet6/in6_src.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in6_src.c,v 1.46 2014/09/27 12:26:16 mpi Exp $ */
+/* $OpenBSD: in6_src.c,v 1.47 2014/10/14 09:52:26 mpi Exp $ */
/* $KAME: in6_src.c,v 1.36 2001/02/06 04:08:17 itojun Exp $ */
/*
@@ -248,8 +248,8 @@ in6_selectsrc(struct in6_addr **in6src, struct sockaddr_in6 *dstsock,
if (ro) {
if (ro->ro_rt && ((ro->ro_rt->rt_flags & RTF_UP) == 0 ||
!IN6_ARE_ADDR_EQUAL(&ro->ro_dst.sin6_addr, dst))) {
- RTFREE(ro->ro_rt);
- ro->ro_rt = (struct rtentry *)0;
+ rtfree(ro->ro_rt);
+ ro->ro_rt = NULL;
}
if (ro->ro_rt == (struct rtentry *)0 ||
ro->ro_rt->rt_ifp == (struct ifnet *)0) {
@@ -375,7 +375,7 @@ selectroute(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts,
!IN6_ARE_ADDR_EQUAL(&ron->ro_dst.sin6_addr,
&sin6_next->sin6_addr)) {
if (ron->ro_rt) {
- RTFREE(ron->ro_rt);
+ rtfree(ron->ro_rt);
ron->ro_rt = NULL;
}
ron->ro_dst = *sin6_next;
@@ -387,7 +387,7 @@ selectroute(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts,
if (ron->ro_rt == NULL ||
(ron->ro_rt->rt_flags & RTF_GATEWAY)) {
if (ron->ro_rt) {
- RTFREE(ron->ro_rt);
+ rtfree(ron->ro_rt);
ron->ro_rt = NULL;
}
error = EHOSTUNREACH;
@@ -395,7 +395,7 @@ selectroute(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts,
}
}
if (!nd6_is_addr_neighbor(sin6_next, ron->ro_rt->rt_ifp)) {
- RTFREE(ron->ro_rt);
+ rtfree(ron->ro_rt);
ron->ro_rt = NULL;
error = EHOSTUNREACH;
goto done;
@@ -421,7 +421,7 @@ selectroute(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts,
(!(ro->ro_rt->rt_flags & RTF_UP) ||
sin6tosa(&ro->ro_dst)->sa_family != AF_INET6 ||
!IN6_ARE_ADDR_EQUAL(&ro->ro_dst.sin6_addr, dst))) {
- RTFREE(ro->ro_rt);
+ rtfree(ro->ro_rt);
ro->ro_rt = NULL;
}
if (ro->ro_rt == NULL) {
@@ -449,7 +449,7 @@ selectroute(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts,
ifp = ro->ro_rt->rt_ifp;
if (ifp == NULL) { /* can this really happen? */
- RTFREE(ro->ro_rt);
+ rtfree(ro->ro_rt);
ro->ro_rt = NULL;
}
}
diff --git a/sys/netinet6/ip6_forward.c b/sys/netinet6/ip6_forward.c
index 70513db5259..7f45088d854 100644
--- a/sys/netinet6/ip6_forward.c
+++ b/sys/netinet6/ip6_forward.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip6_forward.c,v 1.68 2014/09/27 12:26:16 mpi Exp $ */
+/* $OpenBSD: ip6_forward.c,v 1.69 2014/10/14 09:52:26 mpi Exp $ */
/* $KAME: ip6_forward.c,v 1.75 2001/06/29 12:42:13 jinmei Exp $ */
/*
@@ -245,8 +245,8 @@ reroute:
(ip6_forward_rt.ro_rt->rt_flags & RTF_UP) == 0 ||
ip6_forward_rt.ro_tableid != rtableid) {
if (ip6_forward_rt.ro_rt) {
- RTFREE(ip6_forward_rt.ro_rt);
- ip6_forward_rt.ro_rt = 0;
+ rtfree(ip6_forward_rt.ro_rt);
+ ip6_forward_rt.ro_rt = NULL;
}
/* this probably fails but give it a try again */
ip6_forward_rt.ro_tableid = rtableid;
@@ -271,8 +271,8 @@ reroute:
!IN6_ARE_ADDR_EQUAL(&ip6->ip6_dst, &dst->sin6_addr) ||
ip6_forward_rt.ro_tableid != rtableid) {
if (ip6_forward_rt.ro_rt) {
- RTFREE(ip6_forward_rt.ro_rt);
- ip6_forward_rt.ro_rt = 0;
+ rtfree(ip6_forward_rt.ro_rt);
+ ip6_forward_rt.ro_rt = NULL;
}
bzero(dst, sizeof(*dst));
dst->sin6_len = sizeof(struct sockaddr_in6);
@@ -546,8 +546,8 @@ senderr:
#ifndef SMALL_KERNEL
if (ip6_multipath && ip6_forward_rt.ro_rt &&
(ip6_forward_rt.ro_rt->rt_flags & RTF_MPATH)) {
- RTFREE(ip6_forward_rt.ro_rt);
- ip6_forward_rt.ro_rt = 0;
+ rtfree(ip6_forward_rt.ro_rt);
+ ip6_forward_rt.ro_rt = NULL;
}
#endif
return;
diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c
index 14c681791b9..76424275ee3 100644
--- a/sys/netinet6/ip6_input.c
+++ b/sys/netinet6/ip6_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip6_input.c,v 1.129 2014/09/27 12:26:16 mpi Exp $ */
+/* $OpenBSD: ip6_input.c,v 1.130 2014/10/14 09:52:26 mpi Exp $ */
/* $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $ */
/*
@@ -439,8 +439,8 @@ ip6_input(struct mbuf *m)
if (ip6_forward_rt.ro_rt) {
/* route is down or destination is different */
ip6stat.ip6s_forward_cachemiss++;
- RTFREE(ip6_forward_rt.ro_rt);
- ip6_forward_rt.ro_rt = 0;
+ rtfree(ip6_forward_rt.ro_rt);
+ ip6_forward_rt.ro_rt = NULL;
}
bzero(&ip6_forward_rt.ro_dst, sizeof(struct sockaddr_in6));
diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c
index 5b1dce4e0a2..357b9b3ddcb 100644
--- a/sys/netinet6/ip6_output.c
+++ b/sys/netinet6/ip6_output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip6_output.c,v 1.159 2014/09/27 12:26:16 mpi Exp $ */
+/* $OpenBSD: ip6_output.c,v 1.160 2014/10/14 09:52:26 mpi Exp $ */
/* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */
/*
@@ -958,10 +958,10 @@ reroute:
ip6stat.ip6s_fragmented++;
done:
- if (ro == &ip6route && ro->ro_rt) { /* brace necessary for RTFREE */
- RTFREE(ro->ro_rt);
+ if (ro == &ip6route && ro->ro_rt) {
+ rtfree(ro->ro_rt);
} else if (ro_pmtu == &ip6route && ro_pmtu->ro_rt) {
- RTFREE(ro_pmtu->ro_rt);
+ rtfree(ro_pmtu->ro_rt);
}
return (error);
@@ -1219,7 +1219,7 @@ ip6_getpmtu(struct route_in6 *ro_pmtu, struct route_in6 *ro,
if (ro_pmtu->ro_rt &&
((ro_pmtu->ro_rt->rt_flags & RTF_UP) == 0 ||
!IN6_ARE_ADDR_EQUAL(&sa6_dst->sin6_addr, dst))) {
- RTFREE(ro_pmtu->ro_rt);
+ rtfree(ro_pmtu->ro_rt);
ro_pmtu->ro_rt = NULL;
}
if (ro_pmtu->ro_rt == 0) {
@@ -2256,7 +2256,7 @@ ip6_clearpktopts(struct ip6_pktopts *pktopt, int optname)
pktopt->ip6po_tclass = -1;
if (optname == -1 || optname == IPV6_NEXTHOP) {
if (pktopt->ip6po_nextroute.ro_rt) {
- RTFREE(pktopt->ip6po_nextroute.ro_rt);
+ rtfree(pktopt->ip6po_nextroute.ro_rt);
pktopt->ip6po_nextroute.ro_rt = NULL;
}
if (pktopt->ip6po_nexthop)
@@ -2278,7 +2278,7 @@ ip6_clearpktopts(struct ip6_pktopts *pktopt, int optname)
free(pktopt->ip6po_rhinfo.ip6po_rhi_rthdr, M_IP6OPT, 0);
pktopt->ip6po_rhinfo.ip6po_rhi_rthdr = NULL;
if (pktopt->ip6po_route.ro_rt) {
- RTFREE(pktopt->ip6po_route.ro_rt);
+ rtfree(pktopt->ip6po_route.ro_rt);
pktopt->ip6po_route.ro_rt = NULL;
}
}
diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c
index e2d018fc4c9..4fb5ebd2a25 100644
--- a/sys/netinet6/nd6.c
+++ b/sys/netinet6/nd6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nd6.c,v 1.122 2014/08/25 14:00:34 florian Exp $ */
+/* $OpenBSD: nd6.c,v 1.123 2014/10/14 09:52:26 mpi Exp $ */
/* $KAME: nd6.c,v 1.280 2002/06/08 19:52:07 itojun Exp $ */
/*
@@ -664,8 +664,8 @@ nd6_lookup(struct in6_addr *addr6, int create, struct ifnet *ifp,
* interface route.
*/
if (create) {
- RTFREE(rt);
- rt = 0;
+ rtfree(rt);
+ rt = NULL;
}
}
if (!rt) {
diff --git a/sys/netinet6/nd6_nbr.c b/sys/netinet6/nd6_nbr.c
index c8a3e543c2f..555509dbc16 100644
--- a/sys/netinet6/nd6_nbr.c
+++ b/sys/netinet6/nd6_nbr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nd6_nbr.c,v 1.80 2014/07/12 18:44:23 tedu Exp $ */
+/* $OpenBSD: nd6_nbr.c,v 1.81 2014/10/14 09:52:26 mpi Exp $ */
/* $KAME: nd6_nbr.c,v 1.61 2001/02/10 16:06:14 jinmei Exp $ */
/*
@@ -528,13 +528,13 @@ nd6_ns_output(struct ifnet *ifp, struct in6_addr *daddr6,
icmp6stat.icp6s_outhist[ND_NEIGHBOR_SOLICIT]++;
if (ro.ro_rt) { /* we don't cache this route. */
- RTFREE(ro.ro_rt);
+ rtfree(ro.ro_rt);
}
return;
bad:
if (ro.ro_rt) {
- RTFREE(ro.ro_rt);
+ rtfree(ro.ro_rt);
}
m_freem(m);
return;
@@ -1044,13 +1044,13 @@ nd6_na_output(struct ifnet *ifp, struct in6_addr *daddr6,
icmp6stat.icp6s_outhist[ND_NEIGHBOR_ADVERT]++;
if (ro.ro_rt) { /* we don't cache this route. */
- RTFREE(ro.ro_rt);
+ rtfree(ro.ro_rt);
}
return;
bad:
if (ro.ro_rt) {
- RTFREE(ro.ro_rt);
+ rtfree(ro.ro_rt);
}
m_freem(m);
return;