]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Also next hop update routines are corking themselves when congestion is detected
authorMaria Matejka <mq@ucw.cz>
Tue, 2 Aug 2022 15:51:58 +0000 (17:51 +0200)
committerMaria Matejka <mq@ucw.cz>
Tue, 2 Aug 2022 15:51:58 +0000 (17:51 +0200)
nest/rt-table.c
nest/rt.h

index c1f3098b0946e91096afcb625f2539dc27cd7aa5..15dbc37172b91558fc51f09f35f01563671352c6 100644 (file)
@@ -2392,6 +2392,22 @@ rt_event(void *ptr)
   if (tab->export_used)
     rt_export_cleanup(tab);
 
+  if (
+      tab->hcu_corked ||
+      tab->nhu_corked ||
+      (tab->hcu_scheduled || tab->nhu_state) && rt_cork_check(tab->uncork_event)
+      )
+  {
+    if (!tab->hcu_corked && !tab->nhu_corked && config->table_debug)
+      log(L_TRACE "%s: Auxiliary routines corked", tab->name);
+
+    tab->hcu_corked |= tab->hcu_scheduled;
+    tab->hcu_scheduled = 0;
+
+    tab->nhu_corked |= tab->nhu_state;
+    tab->nhu_state = 0;
+  }
+
   if (tab->hcu_scheduled)
     rt_update_hostcache(tab);
 
@@ -2404,6 +2420,22 @@ rt_event(void *ptr)
   rt_unlock_table(tab);
 }
 
+static void
+rt_uncork_event(void *ptr)
+{
+  rtable *tab = ptr;
+
+  tab->hcu_scheduled |= tab->hcu_corked;
+  tab->hcu_corked = 0;
+
+  tab->nhu_state |= tab->nhu_corked;
+  tab->nhu_corked = 0;
+
+  if (config->table_debug)
+    log(L_TRACE "%s: Auxiliary routines uncorked", tab->name);
+
+  ev_schedule(tab->rt_event);
+}
 
 static void
 rt_prune_timer(timer *t)
@@ -2669,6 +2701,7 @@ rt_setup(pool *pp, struct rtable_config *cf)
   init_list(&t->subscribers);
 
   t->rt_event = ev_new_init(p, rt_event, t);
+  t->uncork_event = ev_new_init(p, rt_uncork_event, t);
   t->prune_timer = tm_new_init(p, rt_prune_timer, t, 0, 0);
   t->exporter.export_timer = tm_new_init(p, rt_announce_exports, t, 0, 0);
   t->last_rt_change = t->gc_time = current_time();
index 58c6ec334d8b48d146874287f5a41bb000a71c8b..66111dde9affe88f9aa763129ec5603904cd64c1 100644 (file)
--- a/nest/rt.h
+++ b/nest/rt.h
@@ -107,6 +107,7 @@ typedef struct rtable {
                                         * obstacle from this routing table.
                                         */
   struct event *rt_event;              /* Routing table event */
+  struct event *uncork_event;          /* Called when uncork happens */
   struct timer *prune_timer;           /* Timer for periodic pruning / GC */
   btime last_rt_change;                        /* Last time when route changed */
   btime base_settle_time;              /* Start time of rtable settling interval */
@@ -115,7 +116,9 @@ typedef struct rtable {
   byte prune_state;                    /* Table prune state, 1 -> scheduled, 2-> running */
   byte prune_trie;                     /* Prune prefix trie during next table prune */
   byte hcu_scheduled;                  /* Hostcache update is scheduled */
+  byte hcu_corked;                     /* Hostcache update is corked with this state */
   byte nhu_state;                      /* Next Hop Update state */
+  byte nhu_corked;                     /* Next Hop Update is corked with this state */
   byte export_used;                    /* Pending Export pruning is scheduled */
   byte cork_active;                    /* Cork has been activated */
   struct rt_cork_threshold cork_threshold;     /* Threshold for table cork */