Re: svn commit: r286458 - in head/sys: net netinet netinet6

2015-08-11 Thread Alexander V . Chernikov
10.08.2015, 15:20, Alexander V. Chernikov melif...@freebsd.org:
 10.08.2015, 10:55, Julian Elischer jul...@freebsd.org:
 On 8/9/15 2:15 AM, Alexander V. Chernikov wrote:
  Author: melifaro
  Date: Sat Aug 8 18:14:59 2015
  New Revision: 286458
  URL: https://svnweb.freebsd.org/changeset/base/286458

  Log:
 MFP r274295:

 * Move interface route cleanup to route.c:rt_flushifroutes()
 * Convert most of for (fibnum = 0; fibnum  rt_numfibs; fibnum++) 
 users
   to use new rt_foreach_fib() instead of hand-rolling cycles.

 I think rt_foreach_fib() is poorly named. My expectation is that it
 would call a function for each fib,
 or be a macro that just iterates fibs, rather than actually walking
 the tree.
 Yes, you're right.
 Thanks for the hint, I'll rename it to rt_foreach_fib_walk().
Committed as r286594.

 rt_foreach_fib_walk() maybe.

  Mod
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org

Re: svn commit: r286458 - in head/sys: net netinet netinet6

2015-08-10 Thread Julian Elischer

On 8/9/15 2:15 AM, Alexander V. Chernikov wrote:

Author: melifaro
Date: Sat Aug  8 18:14:59 2015
New Revision: 286458
URL: https://svnweb.freebsd.org/changeset/base/286458

Log:
   MFP r274295:
   
   * Move interface route cleanup to route.c:rt_flushifroutes()

   * Convert most of for (fibnum = 0; fibnum  rt_numfibs; fibnum++) users
 to use new rt_foreach_fib() instead of hand-rolling cycles.


I think rt_foreach_fib() is poorly named. My expectation is that it 
would call a function for each fib,
or be a macro that just iterates fibs, rather than actually walking 
the tree.


rt_foreach_fib_walk() maybe.




Mod


___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r286458 - in head/sys: net netinet netinet6

2015-08-10 Thread Alexander V . Chernikov

___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r286458 - in head/sys: net netinet netinet6

2015-08-08 Thread Alexander V. Chernikov
Author: melifaro
Date: Sat Aug  8 18:14:59 2015
New Revision: 286458
URL: https://svnweb.freebsd.org/changeset/base/286458

Log:
  MFP r274295:
  
  * Move interface route cleanup to route.c:rt_flushifroutes()
  * Convert most of for (fibnum = 0; fibnum  rt_numfibs; fibnum++) users
to use new rt_foreach_fib() instead of hand-rolling cycles.

Modified:
  head/sys/net/if.c
  head/sys/net/route.c
  head/sys/net/route.h
  head/sys/netinet/in_rmx.c
  head/sys/netinet6/in6_rmx.c
  head/sys/netinet6/nd6_rtr.c

Modified: head/sys/net/if.c
==
--- head/sys/net/if.c   Sat Aug  8 17:48:54 2015(r286457)
+++ head/sys/net/if.c   Sat Aug  8 18:14:59 2015(r286458)
@@ -166,7 +166,6 @@ static int  if_setflag(struct ifnet *, in
 static int if_transmit(struct ifnet *ifp, struct mbuf *m);
 static voidif_unroute(struct ifnet *, int flag, int fam);
 static voidlink_rtrequest(int, struct rtentry *, struct rt_addrinfo *);
-static int if_rtdel(struct radix_node *, void *);
 static int ifhwioctl(u_long, struct ifnet *, caddr_t, struct thread *);
 static int if_delmulti_locked(struct ifnet *, struct ifmultiaddr *, int);
 static voiddo_link_state_change(void *, int);
@@ -885,8 +884,7 @@ static void
 if_detach_internal(struct ifnet *ifp, int vmove, struct if_clone **ifcp)
 {
struct ifaddr *ifa;
-   struct radix_node_head  *rnh;
-   int i, j;
+   int i;
struct domain *dp;
struct ifnet *iter;
int found = 0;
@@ -974,23 +972,7 @@ if_detach_internal(struct ifnet *ifp, in
}
}
 
-   /*
-* Delete all remaining routes using this interface
-* Unfortuneatly the only way to do this is to slog through
-* the entire routing table looking for routes which point
-* to this interface...oh well...
-*/
-   for (i = 1; i = AF_MAX; i++) {
-   for (j = 0; j  rt_numfibs; j++) {
-   rnh = rt_tables_get_rnh(j, i);
-   if (rnh == NULL)
-   continue;
-   RADIX_NODE_HEAD_LOCK(rnh);
-   (void) rnh-rnh_walktree(rnh, if_rtdel, ifp);
-   RADIX_NODE_HEAD_UNLOCK(rnh);
-   }
-   }
-
+   rt_flushifroutes(ifp);
if_delgroups(ifp);
 
/*
@@ -1411,49 +1393,6 @@ if_getgroupmembers(struct ifgroupreq *da
 }
 
 /*
- * Delete Routes for a Network Interface
- *
- * Called for each routing entry via the rnh-rnh_walktree() call above
- * to delete all route entries referencing a detaching network interface.
- *
- * Arguments:
- * rn  pointer to node in the routing table
- * arg argument passed to rnh-rnh_walktree() - detaching interface
- *
- * Returns:
- * 0   successful
- * errno   failed - reason indicated
- *
- */
-static int
-if_rtdel(struct radix_node *rn, void *arg)
-{
-   struct rtentry  *rt = (struct rtentry *)rn;
-   struct ifnet*ifp = arg;
-   int err;
-
-   if (rt-rt_ifp == ifp) {
-
-   /*
-* Protect (sorta) against walktree recursion problems
-* with cloned routes
-*/
-   if ((rt-rt_flags  RTF_UP) == 0)
-   return (0);
-
-   err = rtrequest_fib(RTM_DELETE, rt_key(rt), rt-rt_gateway,
-   rt_mask(rt),
-   rt-rt_flags|RTF_RNH_LOCKED|RTF_PINNED,
-   (struct rtentry **) NULL, rt-rt_fibnum);
-   if (err) {
-   log(LOG_WARNING, if_rtdel: error %d\n, err);
-   }
-   }
-
-   return (0);
-}
-
-/*
  * Return counter values from counter(9)s stored in ifnet.
  */
 uint64_t

Modified: head/sys/net/route.c
==
--- head/sys/net/route.cSat Aug  8 17:48:54 2015(r286457)
+++ head/sys/net/route.cSat Aug  8 18:14:59 2015(r286458)
@@ -139,6 +139,7 @@ static VNET_DEFINE(uma_zone_t, rtzone); 
 static int rtrequest1_fib_change(struct radix_node_head *, struct rt_addrinfo 
*,
 struct rtentry **, u_int);
 static void rt_setmetrics(const struct rt_addrinfo *, struct rtentry *);
+static int rt_ifdelroute(struct rtentry *rt, void *arg);
 
 struct if_mtuinfo
 {
@@ -811,6 +812,96 @@ rtrequest_fib(int req,
return rtrequest1_fib(req, info, ret_nrt, fibnum);
 }
 
+
+void
+rt_foreach_fib(int af, rt_setwarg_t *setwa_f, rt_walktree_f_t *wa_f, void *arg)
+{
+   struct radix_node_head *rnh;
+   uint32_t fibnum;
+   int i;
+
+   for (fibnum = 0; fibnum  rt_numfibs; fibnum++) {
+   /* Do we want some specific family? */
+   if (af != AF_UNSPEC) {
+   rnh = rt_tables_get_rnh(fibnum, af);
+   if (rnh == NULL)
+