]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Route export: Packed all the export code before export table update to one function
authorMaria Matejka <mq@jmq.cz>
Fri, 8 May 2020 21:08:07 +0000 (23:08 +0200)
committerMaria Matejka <mq@ucw.cz>
Sat, 20 Mar 2021 23:11:00 +0000 (00:11 +0100)
nest/rt-table.c

index 76d7171400c38d23257a69d401d45aa6c6fe3ab0..bc0050717198e9d3a22da1bc2fa57f32a465f11c 100644 (file)
@@ -707,8 +707,8 @@ rt_notify_merged(struct channel *c, struct rte_export_internal *e)
   return RTE_EXPORT_IS_OK(ep);
 }
 
-static void
-rte_export(struct channel *c, struct rte_export_internal *e)
+static struct rte_export *
+rte_export_obtain(struct channel *c, struct rte_export_internal *e)
 {
   uint ra_mode = c->ra_mode;
   _Bool accepted = 0;
@@ -741,12 +741,11 @@ rte_export(struct channel *c, struct rte_export_internal *e)
   if (!accepted)
   {
     DBG("Idempotent export.\n");
-    goto cleanup;
+    return NULL;
   }
 
   struct rte_export *ep = &(e->pub);
 
-  struct proto *p = c->proto;
   struct proto_stats *stats = &c->stats;
 
   if (e->refeed && ep->new.attrs)
@@ -763,10 +762,21 @@ rte_export(struct channel *c, struct rte_export_internal *e)
     {
       stats->exp_updates_rejected++;
       rte_trace_out(D_FILTERS, c, &ep->new, "rejected [limit]");
-      goto cleanup;
+      return NULL;
     }
   }
 
+  return ep;
+}
+
+static void
+rte_export(struct channel *c, struct rte_export_internal *e)
+{
+  struct rte_export *ep = rte_export_obtain(c, e);
+
+  if (!ep)
+    goto cleanup;
+
   struct rte_storage *old_stored = NULL;
   /* Apply export table */
   if (c->out_table)
@@ -778,6 +788,9 @@ rte_export(struct channel *c, struct rte_export_internal *e)
     /* We aren't sure about the old route attributes */
     ep->old.attrs = NULL;
 
+  struct proto_stats *stats = &c->stats;
+  struct proto *p = c->proto;
+
   if (ep->new.attrs)
     stats->exp_updates_accepted++;
   else