On Tue, Sep 22, 2015 at 03:14:18PM +0200, Martin Pieuchot wrote:
> Instead of incrementing the rt_use counter when a rtalloc(9) call
> succeeds, let's do it inside ralloc(9).
>
> The route(8) regress tests will need to be updated because all the
> paths calling rtalloc(9) do not increment rt_use.
>
> This change gives us a better understanding of which routes are queried
> and might need a cache.
>
> It will also help me with upcoming counter handling for MP.
>
> ok?
It kind of changes the meaning of the use counter but I think that is
fair. In the end I think this is only used for debugging. As mentioned
earlier I have no problems to remove this counter since I don't see a huge
benefit having it.
--
:wq Claudio
> Index: net/pf.c
> ===================================================================
> RCS file: /cvs/src/sys/net/pf.c,v
> retrieving revision 1.944
> diff -u -p -r1.944 pf.c
> --- net/pf.c 13 Sep 2015 17:53:44 -0000 1.944
> +++ net/pf.c 22 Sep 2015 13:02:42 -0000
> @@ -5520,7 +5520,6 @@ pf_route(struct mbuf **m, struct pf_rule
> }
>
> ifp = rt->rt_ifp;
> - rt->rt_use++;
>
> if (rt->rt_flags & RTF_GATEWAY)
> dst = satosin(rt->rt_gateway);
> Index: net/route.c
> ===================================================================
> RCS file: /cvs/src/sys/net/route.c,v
> retrieving revision 1.241
> diff -u -p -r1.241 route.c
> --- net/route.c 22 Sep 2015 10:05:00 -0000 1.241
> +++ net/route.c 22 Sep 2015 13:04:07 -0000
> @@ -350,12 +350,15 @@ rtalloc(struct sockaddr *dst, int flags,
> rt0 = rt;
> error = rtrequest1(RTM_RESOLVE, &info, RTP_DEFAULT,
> &rt, tableid);
> - if (error)
> + if (error) {
> + rt0->rt_use++;
> goto miss;
> + }
> /* Inform listeners of the new route */
> rt_sendmsg(rt, RTM_ADD, tableid);
> rtfree(rt0);
> }
> + rt->rt_use++;
> } else {
> rtstat.rts_unreach++;
> miss:
> Index: netinet/ip_icmp.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet/ip_icmp.c,v
> retrieving revision 1.140
> diff -u -p -r1.140 ip_icmp.c
> --- netinet/ip_icmp.c 11 Sep 2015 15:12:29 -0000 1.140
> +++ netinet/ip_icmp.c 22 Sep 2015 13:02:36 -0000
> @@ -758,7 +758,6 @@ icmp_reflect(struct mbuf *m, struct mbuf
> }
>
> ia = ifatoia(rt->rt_ifa);
> - rt->rt_use++;
> rtfree(rt);
> }
>
> Index: netinet/ip_output.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet/ip_output.c,v
> retrieving revision 1.298
> diff -u -p -r1.298 ip_output.c
> --- netinet/ip_output.c 13 Sep 2015 17:53:44 -0000 1.298
> +++ netinet/ip_output.c 22 Sep 2015 13:02:33 -0000
> @@ -207,7 +207,6 @@ reroute:
> ifp = if_ref(ro->ro_rt->rt_ifp);
> if ((mtu = ro->ro_rt->rt_rmx.rmx_mtu) == 0)
> mtu = ifp->if_mtu;
> - ro->ro_rt->rt_use++;
>
> if (ro->ro_rt->rt_flags & RTF_GATEWAY)
> dst = satosin(ro->ro_rt->rt_gateway);
> Index: netinet6/ip6_output.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet6/ip6_output.c,v
> retrieving revision 1.188
> diff -u -p -r1.188 ip6_output.c
> --- netinet6/ip6_output.c 13 Sep 2015 13:57:07 -0000 1.188
> +++ netinet6/ip6_output.c 22 Sep 2015 13:02:29 -0000
> @@ -558,12 +558,6 @@ reroute:
> *dst = dstsock;
> }
>
> - /*
> - * then rt (for unicast) and ifp must be non-NULL valid values.
> - */
> - if (rt)
> - rt->rt_use++;
> -
> if (rt && !IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) {
> if (opt && opt->ip6po_nextroute.ro_rt) {
> /*
> Index: netmpls/mpls_input.c
> ===================================================================
> RCS file: /cvs/src/sys/netmpls/mpls_input.c,v
> retrieving revision 1.49
> diff -u -p -r1.49 mpls_input.c
> --- netmpls/mpls_input.c 13 Sep 2015 17:53:44 -0000 1.49
> +++ netmpls/mpls_input.c 22 Sep 2015 13:02:23 -0000
> @@ -182,7 +182,6 @@ do_v6:
> goto done;
> }
>
> - rt->rt_use++;
> rt_mpls = (struct rt_mpls *)rt->rt_llinfo;
>
> if (rt_mpls == NULL || (rt->rt_flags & RTF_MPLS) == 0) {
> @@ -449,7 +448,6 @@ mpls_do_error(struct mbuf *m, int type,
> m_freem(m);
> return (NULL);
> }
> - rt->rt_use++;
> KERNEL_LOCK();
> rtfree(rt);
> if (icmp_reflect(m, NULL, ia)) {
> Index: netmpls/mpls_output.c
> ===================================================================
> RCS file: /cvs/src/sys/netmpls/mpls_output.c,v
> retrieving revision 1.24
> diff -u -p -r1.24 mpls_output.c
> --- netmpls/mpls_output.c 13 Sep 2015 17:53:44 -0000 1.24
> +++ netmpls/mpls_output.c 22 Sep 2015 13:02:13 -0000
> @@ -133,7 +133,6 @@ mpls_output(struct ifnet *ifp0, struct m
> error = EHOSTUNREACH;
> goto bad;
> }
> - rt->rt_use++;
> }
>
> /* write back TTL */
>