svn commit: r368150 - head/sys/net/route

Alexander V. Chernikov melifaro at FreeBSD.org
Sun Nov 29 13:54:50 UTC 2020


Author: melifaro
Date: Sun Nov 29 13:54:49 2020
New Revision: 368150
URL: https://svnweb.freebsd.org/changeset/base/368150

Log:
  Introduce rib_walk_ext_internal() to allow iteration with rnh pointer.
  
  This solves the case when rib is not yet attached/detached to/from the
   system rib array.
  
  Differential Revision:	https://reviews.freebsd.org/D27406

Modified:
  head/sys/net/route/route_ctl.h
  head/sys/net/route/route_helpers.c

Modified: head/sys/net/route/route_ctl.h
==============================================================================
--- head/sys/net/route/route_ctl.h	Sun Nov 29 13:52:06 2020	(r368149)
+++ head/sys/net/route/route_ctl.h	Sun Nov 29 13:54:49 2020	(r368150)
@@ -67,17 +67,19 @@ enum rib_walk_hook {
 };
 typedef int rib_walktree_f_t(struct rtentry *, void *);
 typedef void rib_walk_hook_f_t(struct rib_head *rnh, enum rib_walk_hook stage,
-  void *arg);
+    void *arg);
 void rib_walk(uint32_t fibnum, int af, bool wlock, rib_walktree_f_t *wa_f,
-  void *arg);
+    void *arg);
 void rib_walk_ext(uint32_t fibnum, int af, bool wlock, rib_walktree_f_t *wa_f,
-  rib_walk_hook_f_t *hook_f, void *arg);
+    rib_walk_hook_f_t *hook_f, void *arg);
+void rib_walk_ext_internal(struct rib_head *rnh, bool wlock,
+    rib_walktree_f_t *wa_f, rib_walk_hook_f_t *hook_f, void *arg);
 
 void rib_walk_del(u_int fibnum, int family, rib_filter_f_t *filter_f,
-  void *arg, bool report);
+    void *arg, bool report);
 
 void rib_foreach_table_walk(int family, bool wlock, rib_walktree_f_t *wa_f,
-  rib_walk_hook_f_t *hook_f, void *arg);
+    rib_walk_hook_f_t *hook_f, void *arg);
 void rib_foreach_table_walk_del(int family, rib_filter_f_t *filter_f, void *arg);
 
 struct route_nhop_data;

Modified: head/sys/net/route/route_helpers.c
==============================================================================
--- head/sys/net/route/route_helpers.c	Sun Nov 29 13:52:06 2020	(r368149)
+++ head/sys/net/route/route_helpers.c	Sun Nov 29 13:54:49 2020	(r368150)
@@ -77,15 +77,11 @@ __FBSDID("$FreeBSD$");
  * Table is traversed under read lock unless @wlock is set.
  */
 void
-rib_walk_ext(uint32_t fibnum, int family, bool wlock, rib_walktree_f_t *wa_f,
+rib_walk_ext_internal(struct rib_head *rnh, bool wlock, rib_walktree_f_t *wa_f,
     rib_walk_hook_f_t *hook_f, void *arg)
 {
 	RIB_RLOCK_TRACKER;
-	struct rib_head *rnh;
 
-	if ((rnh = rt_tables_get_rnh(fibnum, family)) == NULL)
-		return;
-
 	if (wlock)
 		RIB_WLOCK(rnh);
 	else
@@ -99,6 +95,16 @@ rib_walk_ext(uint32_t fibnum, int family, bool wlock, 
 		RIB_WUNLOCK(rnh);
 	else
 		RIB_RUNLOCK(rnh);
+}
+
+void
+rib_walk_ext(uint32_t fibnum, int family, bool wlock, rib_walktree_f_t *wa_f,
+    rib_walk_hook_f_t *hook_f, void *arg)
+{
+	struct rib_head *rnh;
+
+	if ((rnh = rt_tables_get_rnh(fibnum, family)) != NULL)
+		rib_walk_ext_internal(rnh, wlock, wa_f, hook_f, arg);
 }
 
 /*


More information about the svn-src-all mailing list