[Midnightbsd-cvs] src [8036] trunk/sys: remove dead code.
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Thu Sep 15 16:45:01 EDT 2016
Revision: 8036
http://svnweb.midnightbsd.org/src/?rev=8036
Author: laffer1
Date: 2016-09-15 16:45:01 -0400 (Thu, 15 Sep 2016)
Log Message:
-----------
remove dead code. remove route caching from IP multicast routing code. there were reference leaks and it didnt do much.
Modified Paths:
--------------
trunk/sys/net/flowtable.c
trunk/sys/net/route.h
trunk/sys/netinet/ip_input.c
trunk/sys/netinet/ip_mroute.c
trunk/sys/netinet/ip_mroute.h
trunk/sys/netinet/ip_output.c
trunk/sys/netinet/sctp_output.c
trunk/sys/netinet6/ip6_mroute.c
trunk/sys/netinet6/ip6_mroute.h
trunk/sys/netinet6/ip6_output.c
trunk/sys/netinet6/nd6_nbr.c
Modified: trunk/sys/net/flowtable.c
===================================================================
--- trunk/sys/net/flowtable.c 2016-09-15 20:42:24 UTC (rev 8035)
+++ trunk/sys/net/flowtable.c 2016-09-15 20:45:01 UTC (rev 8036)
@@ -618,6 +618,7 @@
sin->sin_addr.s_addr = hashkey[2];
ro->ro_rt = __DEVOLATILE(struct rtentry *, fle->f_rt);
ro->ro_lle = __DEVOLATILE(struct llentry *, fle->f_lle);
+ ro->ro_flags |= RT_NORTREF;
}
#endif /* INET */
@@ -825,7 +826,7 @@
memcpy(&sin6->sin6_addr, &hashkey[5], sizeof (struct in6_addr));
ro->ro_rt = __DEVOLATILE(struct rtentry *, fle->f_rt);
ro->ro_lle = __DEVOLATILE(struct llentry *, fle->f_lle);
-
+ ro->ro_flags |= RT_NORTREF;
}
#endif /* INET6 */
Modified: trunk/sys/net/route.h
===================================================================
--- trunk/sys/net/route.h 2016-09-15 20:42:24 UTC (rev 8035)
+++ trunk/sys/net/route.h 2016-09-15 20:45:01 UTC (rev 8036)
@@ -54,7 +54,8 @@
struct sockaddr ro_dst;
};
-#define RT_CACHING_CONTEXT 0x1
+#define RT_CACHING_CONTEXT 0x1 /* XXX: not used anywhere */
+#define RT_NORTREF 0x2 /* doesn't hold reference on ro_rt */
/*
* These numbers are used by reliable protocols for determining
@@ -341,6 +342,18 @@
RTFREE_LOCKED(_rt); \
} while (0)
+#define RO_RTFREE(_ro) do { \
+ if ((_ro)->ro_rt) { \
+ if ((_ro)->ro_flags & RT_NORTREF) { \
+ (_ro)->ro_flags &= ~RT_NORTREF; \
+ (_ro)->ro_rt = NULL; \
+ } else { \
+ RT_LOCK((_ro)->ro_rt); \
+ RTFREE_LOCKED((_ro)->ro_rt); \
+ } \
+ } \
+} while (0)
+
struct radix_node_head *rt_tables_get_rnh(int, int);
struct ifmultiaddr;
Modified: trunk/sys/netinet/ip_input.c
===================================================================
--- trunk/sys/netinet/ip_input.c 2016-09-15 20:42:24 UTC (rev 8035)
+++ trunk/sys/netinet/ip_input.c 2016-09-15 20:45:01 UTC (rev 8036)
@@ -1495,8 +1495,7 @@
if (error == EMSGSIZE && ro.ro_rt)
mtu = ro.ro_rt->rt_rmx.rmx_mtu;
- if (ro.ro_rt)
- RTFREE(ro.ro_rt);
+ RO_RTFREE(&ro);
if (error)
IPSTAT_INC(ips_cantforward);
Modified: trunk/sys/netinet/ip_mroute.c
===================================================================
--- trunk/sys/netinet/ip_mroute.c 2016-09-15 20:42:24 UTC (rev 8035)
+++ trunk/sys/netinet/ip_mroute.c 2016-09-15 20:45:01 UTC (rev 8036)
@@ -924,7 +924,6 @@
vifp->v_pkt_out = 0;
vifp->v_bytes_in = 0;
vifp->v_bytes_out = 0;
- bzero(&vifp->v_route, sizeof(vifp->v_route));
/* Adjust numvifs up if the vifi is higher than numvifs */
if (V_numvifs <= vifcp->vifc_vifi)
@@ -1702,7 +1701,7 @@
* should get rejected because they appear to come from
* the loopback interface, thus preventing looping.
*/
- error = ip_output(m, NULL, &vifp->v_route, IP_FORWARDING, &imo, NULL);
+ error = ip_output(m, NULL, NULL, IP_FORWARDING, &imo, NULL);
CTR3(KTR_IPMF, "%s: vif %td err %d", __func__,
(ptrdiff_t)(vifp - V_viftable), error);
}
Modified: trunk/sys/netinet/ip_mroute.h
===================================================================
--- trunk/sys/netinet/ip_mroute.h 2016-09-15 20:42:24 UTC (rev 8035)
+++ trunk/sys/netinet/ip_mroute.h 2016-09-15 20:45:01 UTC (rev 8036)
@@ -262,7 +262,6 @@
u_long v_pkt_out; /* # pkts out on interface */
u_long v_bytes_in; /* # bytes in on interface */
u_long v_bytes_out; /* # bytes out on interface */
- struct route v_route; /* cached route */
};
#ifdef _KERNEL
Modified: trunk/sys/netinet/ip_output.c
===================================================================
--- trunk/sys/netinet/ip_output.c 2016-09-15 20:42:24 UTC (rev 8035)
+++ trunk/sys/netinet/ip_output.c 2016-09-15 20:45:01 UTC (rev 8036)
@@ -105,6 +105,10 @@
* ip_len and ip_off are in host format.
* The mbuf chain containing the packet will be freed.
* The mbuf opt, if present, will not be freed.
+ * If route ro is present and has ro_rt initialized, route lookup would be
+ * skipped and ro->ro_rt would be used. If ro is present but ro->ro_rt is NULL,
+ * then result of route lookup is stored in ro->ro_rt.
+ *
* In the IP forwarding case, the packet will arrive with options already
* inserted, so must have a NULL opt pointer.
*/
@@ -119,7 +123,6 @@
int mtu;
int n; /* scratchpad */
int error = 0;
- int nortfree = 0;
struct sockaddr_in *dst;
struct in_ifaddr *ia;
int isbroadcast, sw_csum;
@@ -146,24 +149,23 @@
if (ro == NULL) {
ro = &iproute;
bzero(ro, sizeof (*ro));
+ }
#ifdef FLOWTABLE
- {
- struct flentry *fle;
+ if (ro->ro_rt == NULL) {
+ struct flentry *fle;
- /*
- * The flow table returns route entries valid for up to 30
- * seconds; we rely on the remainder of ip_output() taking no
- * longer than that long for the stability of ro_rt. The
- * flow ID assignment must have happened before this point.
- */
- if ((fle = flowtable_lookup_mbuf(V_ip_ft, m, AF_INET)) != NULL) {
- flow_to_route(fle, ro);
- nortfree = 1;
- }
- }
+ /*
+ * The flow table returns route entries valid for up to 30
+ * seconds; we rely on the remainder of ip_output() taking no
+ * longer than that long for the stability of ro_rt. The
+ * flow ID assignment must have happened before this point.
+ */
+ fle = flowtable_lookup_mbuf(V_ip_ft, m, AF_INET);
+ if (fle != NULL)
+ flow_to_route(fle, ro);
+ }
#endif
- }
if (opt) {
int len = 0;
@@ -210,10 +212,9 @@
!RT_LINK_IS_UP(rte->rt_ifp) ||
dst->sin_family != AF_INET ||
dst->sin_addr.s_addr != ip->ip_dst.s_addr)) {
- if (!nortfree)
- RTFREE(rte);
- rte = ro->ro_rt = (struct rtentry *)NULL;
- ro->ro_lle = (struct llentry *)NULL;
+ RO_RTFREE(ro);
+ ro->ro_lle = NULL;
+ rte = NULL;
}
#ifdef IPFIREWALL_FORWARD
if (rte == NULL && fwd_tag == NULL) {
@@ -678,9 +679,8 @@
IPSTAT_INC(ips_fragmented);
done:
- if (ro == &iproute && ro->ro_rt && !nortfree) {
- RTFREE(ro->ro_rt);
- }
+ if (ro == &iproute)
+ RO_RTFREE(ro);
if (ia != NULL)
ifa_free(&ia->ia_ifa);
return (error);
Modified: trunk/sys/netinet/sctp_output.c
===================================================================
--- trunk/sys/netinet/sctp_output.c 2016-09-15 20:42:24 UTC (rev 8035)
+++ trunk/sys/netinet/sctp_output.c 2016-09-15 20:45:01 UTC (rev 8036)
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD: src/sys/netinet/sctp_output.c,v 1.5 2013/01/17 23:29:40 laffer1 Exp $");
+__MBSDID("$MidnightBSD$");
#include <netinet/sctp_os.h>
#include <sys/proc.h>
@@ -4163,10 +4163,7 @@
SCTPDBG(SCTP_DEBUG_OUTPUT3, "IP output returns %d\n", ret);
if (net == NULL) {
/* free tempy routes */
- if (ro->ro_rt) {
- RTFREE(ro->ro_rt);
- ro->ro_rt = NULL;
- }
+ RO_RTFREE(ro);
} else {
/*
* PMTU check versus smallest asoc MTU goes
@@ -4520,9 +4517,7 @@
}
if (net == NULL) {
/* Now if we had a temp route free it */
- if (ro->ro_rt) {
- RTFREE(ro->ro_rt);
- }
+ RO_RTFREE(ro);
} else {
/*
* PMTU check versus smallest asoc MTU goes
@@ -10910,7 +10905,6 @@
int len, cause_len, padding_len, ret;
#ifdef INET
- sctp_route_t ro;
struct ip *iph_out;
#endif
@@ -11074,8 +11068,6 @@
SCTP_ATTACH_CHAIN(o_pak, mout, len);
#ifdef INET
if (iph_out != NULL) {
- /* zap the stack pointer to the route */
- bzero(&ro, sizeof(sctp_route_t));
if (port) {
if (V_udp_cksum) {
udp->uh_sum = in_pseudo(iph_out->ip_src.s_addr, iph_out->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP));
@@ -11108,11 +11100,7 @@
SCTP_STAT_INCR(sctps_sendhwcrc);
#endif
}
- SCTP_IP_OUTPUT(ret, o_pak, &ro, NULL, vrf_id);
- /* Free the route if we got one back */
- if (ro.ro_rt) {
- RTFREE(ro.ro_rt);
- }
+ SCTP_IP_OUTPUT(ret, o_pak, NULL, NULL, vrf_id);
}
#endif
#ifdef INET6
Modified: trunk/sys/netinet6/ip6_mroute.c
===================================================================
--- trunk/sys/netinet6/ip6_mroute.c 2016-09-15 20:42:24 UTC (rev 8035)
+++ trunk/sys/netinet6/ip6_mroute.c 2016-09-15 20:45:01 UTC (rev 8036)
@@ -717,7 +717,6 @@
mifp->m6_pkt_out = 0;
mifp->m6_bytes_in = 0;
mifp->m6_bytes_out = 0;
- bzero(&mifp->m6_route, sizeof(mifp->m6_route));
/* Adjust nummifs up if the mifi is higher than nummifs */
if (nummifs <= mifcp->mif6c_mifi)
@@ -1576,11 +1575,8 @@
struct mbuf *mb_copy;
struct ifnet *ifp = mifp->m6_ifp;
int error = 0;
- struct sockaddr_in6 *dst6;
u_long linkmtu;
- dst6 = &mifp->m6_route.ro_dst;
-
/*
* Make a new reference to the packet; make sure that
* the IPv6 header is actually copied, not just referenced,
@@ -1610,8 +1606,8 @@
/* XXX: ip6_output will override ip6->ip6_hlim */
im6o.im6o_multicast_hlim = ip6->ip6_hlim;
im6o.im6o_multicast_loop = 1;
- error = ip6_output(mb_copy, NULL, &mifp->m6_route,
- IPV6_FORWARDING, &im6o, NULL, NULL);
+ error = ip6_output(mb_copy, NULL, NULL, IPV6_FORWARDING, &im6o,
+ NULL, NULL);
#ifdef MRT6DEBUG
if (V_mrt6debug & DEBUG_XMIT)
@@ -1626,10 +1622,13 @@
* loop back a copy now.
*/
if (in6_mcast_loop) {
- dst6->sin6_len = sizeof(struct sockaddr_in6);
- dst6->sin6_family = AF_INET6;
- dst6->sin6_addr = ip6->ip6_dst;
- ip6_mloopback(ifp, m, &mifp->m6_route.ro_dst);
+ struct sockaddr_in6 dst6;
+
+ bzero(&dst6, sizeof(dst6));
+ dst6.sin6_len = sizeof(struct sockaddr_in6);
+ dst6.sin6_family = AF_INET6;
+ dst6.sin6_addr = ip6->ip6_dst;
+ ip6_mloopback(ifp, m, &dst6);
}
/*
@@ -1638,15 +1637,18 @@
*/
linkmtu = IN6_LINKMTU(ifp);
if (mb_copy->m_pkthdr.len <= linkmtu || linkmtu < IPV6_MMTU) {
- dst6->sin6_len = sizeof(struct sockaddr_in6);
- dst6->sin6_family = AF_INET6;
- dst6->sin6_addr = ip6->ip6_dst;
+ struct sockaddr_in6 dst6;
+
+ bzero(&dst6, sizeof(dst6));
+ dst6.sin6_len = sizeof(struct sockaddr_in6);
+ dst6.sin6_family = AF_INET6;
+ dst6.sin6_addr = ip6->ip6_dst;
/*
* We just call if_output instead of nd6_output here, since
* we need no ND for a multicast forwarded packet...right?
*/
error = (*ifp->if_output)(ifp, mb_copy,
- (struct sockaddr *)&mifp->m6_route.ro_dst, NULL);
+ (struct sockaddr *)&dst6, NULL);
#ifdef MRT6DEBUG
if (V_mrt6debug & DEBUG_XMIT)
log(LOG_DEBUG, "phyint_send on mif %d err %d\n",
Modified: trunk/sys/netinet6/ip6_mroute.h
===================================================================
--- trunk/sys/netinet6/ip6_mroute.h 2016-09-15 20:42:24 UTC (rev 8035)
+++ trunk/sys/netinet6/ip6_mroute.h 2016-09-15 20:45:01 UTC (rev 8036)
@@ -212,7 +212,6 @@
u_quad_t m6_pkt_out; /* # pkts out on interface */
u_quad_t m6_bytes_in; /* # bytes in on interface */
u_quad_t m6_bytes_out; /* # bytes out on interface */
- struct route_in6 m6_route; /* cached route */
#ifdef notyet
u_int m6_rsvp_on; /* RSVP listening on this vif */
struct socket *m6_rsvpd; /* RSVP daemon socket */
Modified: trunk/sys/netinet6/ip6_output.c
===================================================================
--- trunk/sys/netinet6/ip6_output.c 2016-09-15 20:42:24 UTC (rev 8035)
+++ trunk/sys/netinet6/ip6_output.c 2016-09-15 20:45:01 UTC (rev 8036)
@@ -214,6 +214,9 @@
* This function may modify ver and hlim only.
* The mbuf chain containing the packet will be freed.
* The mbuf opt, if present, will not be freed.
+ * If route_in6 ro is present and has ro_rt initialized, route lookup would be
+ * skipped and ro->ro_rt would be used. If ro is present but ro->ro_rt is NULL,
+ * then result of route lookup is stored in ro->ro_rt.
*
* type of "mtu": rt_rmx.rmx_mtu is u_long, ifnet.ifr_mtu is int, and
* nd_ifinfo.linkmtu is u_int32_t. so we use u_long to hold largest one,
@@ -244,7 +247,6 @@
struct in6_addr finaldst, src0, dst0;
u_int32_t zone;
struct route_in6 *ro_pmtu = NULL;
- int flevalid = 0;
int hdrsplit = 0;
int needipsec = 0;
int sw_csum, tso;
@@ -521,7 +523,7 @@
ro = &opt->ip6po_route;
dst = (struct sockaddr_in6 *)&ro->ro_dst;
#ifdef FLOWTABLE
- if (ro == &ip6route) {
+ if (ro->ro_rt == NULL) {
struct flentry *fle;
/*
@@ -530,11 +532,9 @@
* longer than that long for the stability of ro_rt. The
* flow ID assignment must have happened before this point.
*/
- if ((fle = flowtable_lookup_mbuf(V_ip6_ft, m, AF_INET6)) != NULL) {
+ fle = flowtable_lookup_mbuf(V_ip6_ft, m, AF_INET6);
+ if (fle != NULL)
flow_to_route_in6(fle, ro);
- if (ro->ro_rt != NULL && ro->ro_lle != NULL)
- flevalid = 1;
- }
}
#endif
again:
@@ -642,7 +642,7 @@
dst_sa.sin6_family = AF_INET6;
dst_sa.sin6_len = sizeof(dst_sa);
dst_sa.sin6_addr = ip6->ip6_dst;
- if (flevalid) {
+ if (ro->ro_rt) {
rt = ro->ro_rt;
ifp = ro->ro_rt->rt_ifp;
} else if ((error = in6_selectroute_fib(&dst_sa, opt, im6o, ro,
@@ -1198,13 +1198,10 @@
V_ip6stat.ip6s_fragmented++;
done:
- if (ro == &ip6route && ro->ro_rt && flevalid == 0) {
- /* brace necessary for RTFREE */
- RTFREE(ro->ro_rt);
- } else if (ro_pmtu == &ip6route && ro_pmtu->ro_rt &&
- ((flevalid == 0) || (ro_pmtu != ro))) {
- RTFREE(ro_pmtu->ro_rt);
- }
+ if (ro == &ip6route)
+ RO_RTFREE(ro);
+ if (ro_pmtu == &ip6route)
+ RO_RTFREE(ro_pmtu);
#ifdef IPSEC
if (sp != NULL)
KEY_FREESP(&sp);
Modified: trunk/sys/netinet6/nd6_nbr.c
===================================================================
--- trunk/sys/netinet6/nd6_nbr.c 2016-09-15 20:42:24 UTC (rev 8035)
+++ trunk/sys/netinet6/nd6_nbr.c 2016-09-15 20:45:01 UTC (rev 8036)
@@ -595,9 +595,9 @@
icmp6_ifstat_inc(ifp, ifs6_out_neighborsolicit);
ICMP6STAT_INC(icp6s_outhist[ND_NEIGHBOR_SOLICIT]);
- if (ro.ro_rt) { /* we don't cache this route. */
- RTFREE(ro.ro_rt);
- }
+ /* We don't cache this route. */
+ RO_RTFREE(&ro);
+
return;
bad:
@@ -1117,9 +1117,9 @@
icmp6_ifstat_inc(ifp, ifs6_out_neighboradvert);
ICMP6STAT_INC(icp6s_outhist[ND_NEIGHBOR_ADVERT]);
- if (ro.ro_rt) { /* we don't cache this route. */
- RTFREE(ro.ro_rt);
- }
+ /* We don't cache this route. */
+ RO_RTFREE(&ro);
+
return;
bad:
More information about the Midnightbsd-cvs
mailing list