]> git.ipfire.org Git - thirdparty/bird.git/blobdiff - sysdep/unix/krt.c
Merge branch 'master' into mq-filter-stack
[thirdparty/bird.git] / sysdep / unix / krt.c
index a79df54eac9913275bb05198facef48f07d029c9..27868fab61e15deb58513d0706a56c41d64e5b0f 100644 (file)
@@ -301,7 +301,7 @@ krt_learn_announce_update(struct krt_proto *p, rte *e)
   net *n = e->net;
   rta *aa = rta_clone(e->attrs);
   rte *ee = rte_get_temp(aa);
-  ee->pflags = 0;
+  ee->pflags = EA_ID_FLAG(EA_KRT_SOURCE) | EA_ID_FLAG(EA_KRT_METRIC);
   ee->u.krt = e->u.krt;
   rte_update(&p->p, n->n.addr, ee);
 }
@@ -562,7 +562,7 @@ static struct rte *
 krt_export_net(struct krt_proto *p, net *net, rte **rt_free)
 {
   struct channel *c = p->p.main_channel;
-  struct filter *filter = c->out_filter;
+  const struct filter *filter = c->out_filter;
   rte *rt;
 
   if (c->ra_mode == RA_MERGED)
@@ -577,9 +577,9 @@ krt_export_net(struct krt_proto *p, net *net, rte **rt_free)
   if (filter == FILTER_REJECT)
     return NULL;
 
-  rte_make_tmp_attrs(&rt, krt_filter_lp);
+  rte_make_tmp_attrs(&rt, krt_filter_lp, NULL);
 
-  /* We could run krt_import_control() here, but it is already handled by KRF_INSTALLED */
+  /* We could run krt_preexport() here, but it is already handled by KRF_INSTALLED */
 
   if (filter == FILTER_ACCEPT)
     goto accept;
@@ -784,7 +784,8 @@ krt_got_route_async(struct krt_proto *p, rte *e, int new)
   switch (e->u.krt.src)
     {
     case KRT_SRC_BIRD:
-      ASSERT(0);                       /* Should be filtered by the back end */
+      /* Should be filtered by the back end */
+      bug("BIRD originated routes should not get here.");
 
     case KRT_SRC_REDIRECT:
       if (new)
@@ -909,37 +910,24 @@ krt_scan_timer_kick(struct krt_proto *p)
  *     Updates
  */
 
-static struct ea_list *
-krt_make_tmp_attrs(rte *rt, struct linpool *pool)
+static void
+krt_make_tmp_attrs(struct rte *rt, struct linpool *pool)
 {
-  struct ea_list *l = lp_alloc(pool, sizeof(struct ea_list) + 2 * sizeof(eattr));
-
-  l->next = NULL;
-  l->flags = EALF_SORTED;
-  l->count = 2;
-
-  l->attrs[0].id = EA_KRT_SOURCE;
-  l->attrs[0].flags = 0;
-  l->attrs[0].type = EAF_TYPE_INT | EAF_TEMP;
-  l->attrs[0].u.data = rt->u.krt.proto;
-
-  l->attrs[1].id = EA_KRT_METRIC;
-  l->attrs[1].flags = 0;
-  l->attrs[1].type = EAF_TYPE_INT | EAF_TEMP;
-  l->attrs[1].u.data = rt->u.krt.metric;
-
-  return l;
+  rte_init_tmp_attrs(rt, pool, 2);
+  rte_make_tmp_attr(rt, EA_KRT_SOURCE, EAF_TYPE_INT, rt->u.krt.proto);
+  rte_make_tmp_attr(rt, EA_KRT_METRIC, EAF_TYPE_INT, rt->u.krt.metric);
 }
 
 static void
-krt_store_tmp_attrs(rte *rt)
+krt_store_tmp_attrs(struct rte *rt, struct linpool *pool)
 {
-  /* EA_KRT_SOURCE is read-only */
-  rt->u.krt.metric = ea_get_int(rt->attrs->eattrs, EA_KRT_METRIC, 0);
+  rte_init_tmp_attrs(rt, pool, 2);
+  rt->u.krt.proto = rte_store_tmp_attr(rt, EA_KRT_SOURCE);
+  rt->u.krt.metric = rte_store_tmp_attr(rt, EA_KRT_METRIC);
 }
 
 static int
-krt_import_control(struct proto *P, rte **new, struct linpool *pool UNUSED)
+krt_preexport(struct proto *P, rte **new, struct linpool *pool UNUSED)
 {
   // struct krt_proto *p = (struct krt_proto *) P;
   rte *e = *new;
@@ -1084,7 +1072,7 @@ krt_init(struct proto_config *CF)
 
   p->p.main_channel = proto_add_channel(&p->p, proto_cf_main_channel(CF));
 
-  p->p.import_control = krt_import_control;
+  p->p.preexport = krt_preexport;
   p->p.rt_notify = krt_rt_notify;
   p->p.if_notify = krt_if_notify;
   p->p.reload_routes = krt_reload_routes;
@@ -1141,7 +1129,7 @@ krt_shutdown(struct proto *P)
   krt_scan_timer_stop(p);
 
   /* FIXME we should flush routes even when persist during reconfiguration */
-  if (p->initialized && !KRT_CF->persist)
+  if (p->initialized && !KRT_CF->persist && (P->down_code != PDC_CMD_GR_DOWN))
     krt_flush_routes(p);
 
   p->ready = 0;