]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Nest: names for nhu_state values
authorJan Moskyto Matejka <mq@ucw.cz>
Wed, 22 Feb 2017 13:02:03 +0000 (14:02 +0100)
committerJan Moskyto Matejka <mq@ucw.cz>
Wed, 22 Feb 2017 13:11:01 +0000 (14:11 +0100)
It took too much time to analyze what's the meaning of nhu_state values
so I spent less than the same amount of time documenting it.

nest/route.h
nest/rt-table.c

index c16b2643966c39f50ae5b9b4c285b9dc88680376..928a022d03ed1261dfe689973dfb2a5369e584cc 100644 (file)
@@ -168,6 +168,11 @@ typedef struct rtable {
   struct fib_iterator nhu_fit;         /* Next Hop Update FIB iterator */
 } rtable;
 
+#define NHU_CLEAN      0
+#define NHU_SCHEDULED  1
+#define NHU_RUNNING    2
+#define NHU_DIRTY      3
+
 typedef struct network {
   struct rte *routes;                  /* Available routes for this network */
   struct fib_node n;                   /* FIB flags reserved for kernel syncer */
index a33b790963d9ad09b95b8b7b478dfa98e37aaa04..1e1dde253621a0aaf1d0c2b870cb51ec34b87cc1 100644 (file)
@@ -1561,11 +1561,14 @@ rt_schedule_hcu(rtable *tab)
 static inline void
 rt_schedule_nhu(rtable *tab)
 {
-  if (tab->nhu_state == 0)
+  if (tab->nhu_state == NHU_CLEAN)
     ev_schedule(tab->rt_event);
 
-  /* state change 0->1, 2->3 */
-  tab->nhu_state |= 1;
+  /* state change:
+   *   NHU_CLEAN   -> NHU_SCHEDULED
+   *   NHU_RUNNING -> NHU_DIRTY
+   */
+  tab->nhu_state |= NHU_SCHEDULED;
 }
 
 void
@@ -1897,13 +1900,13 @@ rt_next_hop_update(rtable *tab)
   struct fib_iterator *fit = &tab->nhu_fit;
   int max_feed = 32;
 
-  if (tab->nhu_state == 0)
+  if (tab->nhu_state == NHU_CLEAN)
     return;
 
-  if (tab->nhu_state == 1)
+  if (tab->nhu_state == NHU_SCHEDULED)
     {
       FIB_ITERATE_INIT(fit, &tab->fib);
-      tab->nhu_state = 2;
+      tab->nhu_state = NHU_RUNNING;
     }
 
   FIB_ITERATE_START(&tab->fib, fit, net, n)
@@ -1918,10 +1921,13 @@ rt_next_hop_update(rtable *tab)
     }
   FIB_ITERATE_END;
 
-  /* state change 2->0, 3->1 */
+  /* State change:
+   *   NHU_DIRTY   -> NHU_SCHEDULED
+   *   NHU_RUNNING -> NHU_CLEAN
+   */
   tab->nhu_state &= 1;
 
-  if (tab->nhu_state > 0)
+  if (tab->nhu_state != NHU_CLEAN)
     ev_schedule(tab->rt_event);
 }