RTFREE - rtfree

2014-10-08 Thread Martin Pieuchot
 ||
ro-ro_tableid != m-m_pkthdr.ph_rtableid)) {
-   RTFREE(ro-ro_rt);
-   ro-ro_rt = (struct rtentry *)0;
+   rtfree(ro-ro_rt);
+   ro-ro_rt = NULL;
}
 
if (ro-ro_rt == 0) {
@@ -328,8 +328,8 @@ reroute:
if (ro-ro_rt  ((ro-ro_rt-rt_flags  RTF_UP) == 0 ||
dst-sin_addr.s_addr != ip-ip_dst.s_addr ||
ro-ro_tableid != m-m_pkthdr.ph_rtableid)) {
-   RTFREE(ro-ro_rt);
-   ro-ro_rt = (struct rtentry *)0;
+   rtfree(ro-ro_rt);
+   ro-ro_rt = NULL;
}
 
if (ro-ro_rt == 0) {
@@ -582,7 +582,7 @@ sendit:
if (rt != NULL) {
rt-rt_rmx.rmx_mtu = icmp_mtu;
if (ro  ro-ro_rt != NULL) {
-   RTFREE(ro-ro_rt);
+   rtfree(ro-ro_rt);
ro-ro_rt = rtalloc1(ro-ro_dst, 
RT_REPORT,
m-m_pkthdr.ph_rtableid);
}
@@ -717,7 +717,7 @@ sendit:
 
 done:
if (ro == iproute  ro-ro_rt)
-   RTFREE(ro-ro_rt);
+   rtfree(ro-ro_rt);
return (error);
 bad:
 #ifdef IPSEC
Index: netinet/ip_spd.c
===
RCS file: /home/ncvs/src/sys/netinet/ip_spd.c,v
retrieving revision 1.73
diff -u -p -r1.73 ip_spd.c
--- netinet/ip_spd.c27 Sep 2014 12:26:16 -  1.73
+++ netinet/ip_spd.c8 Oct 2014 10:20:33 -
@@ -260,14 +260,14 @@ ipsp_spd_lookup(struct mbuf *m, int af, 
if ((re-re_rt-rt_gateway == NULL) ||
(((struct sockaddr_encap *) re-re_rt-rt_gateway)-sen_type !=
SENT_IPSP)) {
-   RTFREE(re-re_rt);
+   rtfree(re-re_rt);
*error = EHOSTUNREACH;
DPRINTF((ip_spd_lookup: no gateway in SPD entry!));
return NULL;
}
 
ipo = ((struct sockaddr_encap *) (re-re_rt-rt_gateway))-sen_ipsp;
-   RTFREE(re-re_rt);
+   rtfree(re-re_rt);
if (ipo == NULL) {
*error = EHOSTUNREACH;
DPRINTF((ip_spd_lookup: no policy attached to SPD entry!));
Index: netinet/tcp_input.c
===
RCS file: /home/ncvs/src/sys/netinet/tcp_input.c,v
retrieving revision 1.278
diff -u -p -r1.278 tcp_input.c
--- netinet/tcp_input.c 22 Jul 2014 11:06:10 -  1.278
+++ netinet/tcp_input.c 8 Oct 2014 10:20:33 -
@@ -3375,8 +3375,10 @@ syn_cache_put(struct syn_cache *sc)
 {
if (sc-sc_ipopts)
(void) m_free(sc-sc_ipopts);
-   if (sc-sc_route4.ro_rt != NULL)
-   RTFREE(sc-sc_route4.ro_rt);
+   if (sc-sc_route4.ro_rt != NULL) {
+   rtfree(sc-sc_route4.ro_rt);
+   sc-sc_route4.ro_rt = NULL;
+   }
timeout_set(sc-sc_timer, syn_cache_reaper, sc);
timeout_add(sc-sc_timer, 0);
 }
Index: netinet6/frag6.c
===
RCS file: /home/ncvs/src/sys/netinet6/frag6.c,v
retrieving revision 1.55
diff -u -p -r1.55 frag6.c
--- netinet6/frag6.c27 Sep 2014 12:26:16 -  1.55
+++ netinet6/frag6.c8 Oct 2014 10:20:33 -
@@ -200,7 +200,7 @@ frag6_input(struct mbuf **mp, int *offp,
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);
Index: netinet6/icmp6.c
===
RCS file: /home/ncvs/src/sys/netinet6/icmp6.c,v
retrieving revision 1.148
diff -u -p -r1.148 icmp6.c
--- netinet6/icmp6.c27 Aug 2014 14:04:16 -  1.148
+++ netinet6/icmp6.c8 Oct 2014 10:20:33 -
@@ -1046,9 +1046,8 @@ icmp6_mtudisc_update(struct ip6ctlparam 
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

Re: RTFREE - rtfree

2014-10-08 Thread Mike Belopuhov
On 8 October 2014 12:24, Martin Pieuchot mpieuc...@nolizard.org wrote:
 Diff below kills the macro and use the fonction instead since they are
 equivalent.  It also replaces some 0 - NULL where it applies.  It does
 not include the manpage bits, I'll deal with that afterward.

 I'd appreciate reviews and oks.


although syn_cache_put doesn't really require nullification,
i'm ok with the diff.