]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Preference moved to RTA and set explicitly in protocols
authorMaria Matejka <mq@jmq.cz>
Mon, 10 Feb 2020 07:41:05 +0000 (08:41 +0100)
committerMaria Matejka <mq@ucw.cz>
Sat, 20 Mar 2021 19:51:53 +0000 (20:51 +0100)
20 files changed:
filter/config.Y
filter/data.h
filter/f-inst.c
lib/hash.h
nest/route.h
nest/rt-attr.c
nest/rt-dev.c
nest/rt-show.c
nest/rt-table.c
proto/babel/babel.c
proto/bgp/attrs.c
proto/bgp/packets.c
proto/ospf/ospf.c
proto/ospf/rt.c
proto/perf/perf.c
proto/pipe/pipe.c
proto/rip/rip.c
proto/rpki/rpki.c
proto/static/static.c
sysdep/unix/krt.c

index 5cd52e40e4411d0236f430d8fcd525726b5f1aa3..6c503dad7b79b5c4ca21c8c7b9ba114db2effa4f 100644 (file)
@@ -248,10 +248,6 @@ assert_assign(struct f_lval *lval, struct f_inst *expr, const char *start, const
       setter = f_new_inst(FI_VAR_SET, expr, lval->sym);
       getter = f_new_inst(FI_VAR_GET, lval->sym);
       break;
-    case F_LVAL_PREFERENCE:
-      setter = f_new_inst(FI_PREF_SET, expr);
-      getter = f_new_inst(FI_PREF_GET);
-      break;
     case F_LVAL_SA:
       setter = f_new_inst(FI_RTA_SET, expr, lval->sa);
       getter = f_new_inst(FI_RTA_GET, lval->sa);
@@ -751,6 +747,7 @@ static_attr:
  | IFNAME  { $$ = f_new_static_attr(T_STRING,     SA_IFNAME,   0); }
  | IFINDEX { $$ = f_new_static_attr(T_INT,        SA_IFINDEX,  1); }
  | WEIGHT  { $$ = f_new_static_attr(T_INT,        SA_WEIGHT,   0); }
+ | PREFERENCE { $$ = f_new_static_attr(T_INT,    SA_PREF,      0); }
  ;
 
 term:
@@ -776,8 +773,6 @@ term:
  | constant { $$ = $1; }
  | constructor { $$ = $1; }
 
- | PREFERENCE { $$ = f_new_inst(FI_PREF_GET); }
-
  | static_attr { $$ = f_new_inst(FI_RTA_GET, $1); }
 
  | dynamic_attr { $$ = f_new_inst(FI_EA_GET, $1); }
@@ -870,9 +865,6 @@ cmd:
        cf_error( "This static attribute is read-only.");
      $$ = f_new_inst(FI_RTA_SET, $3, $1);
    }
- | PREFERENCE '=' term ';' {
-     $$ = f_new_inst(FI_PREF_SET, $3);
-   }
  | UNSET '(' dynamic_attr ')' ';' {
      $$ = f_new_inst(FI_EA_UNSET, $3);
    }
@@ -915,7 +907,6 @@ get_cf_position:
 
 lvalue:
    CF_SYM_KNOWN { cf_assert_symbol($1, SYM_VARIABLE); $$ = (struct f_lval) { .type = F_LVAL_VARIABLE, .sym = $1 }; }
- | PREFERENCE { $$ = (struct f_lval) { .type = F_LVAL_PREFERENCE }; }
  | static_attr { $$ = (struct f_lval) { .type = F_LVAL_SA, .sa = $1 }; }
  | dynamic_attr { $$ = (struct f_lval) { .type = F_LVAL_EA, .da = $1 }; };
 
index 61cdb43e27296c232a09ef152d4286e576a943e8..aec6c4f8cb327e4fd1ec09c4e8e1fc9a9e58c20d 100644 (file)
@@ -100,6 +100,7 @@ enum f_sa_code {
   SA_IFNAME,
   SA_IFINDEX,
   SA_WEIGHT,
+  SA_PREF,
 } PACKED;
 
 /* Static attribute definition (members of struct rta) */
index 1378fe4a499f360463b1a7697937b216e6c7a789..a41fcc4f2535c2e21ab8047a08fb8378035e5f75 100644 (file)
       case SA_IFNAME:  RESULT(sa.f_type, s, rta->nh.iface ? rta->nh.iface->name : ""); break;
       case SA_IFINDEX: RESULT(sa.f_type, i, rta->nh.iface ? rta->nh.iface->index : 0); break;
       case SA_WEIGHT:  RESULT(sa.f_type, i, rta->nh.weight + 1); break;
+      case SA_PREF:    RESULT(sa.f_type, i, rta->pref); break;
 
       default:
        bug("Invalid static attribute access (%u/%u)", sa.f_type, sa.sa_code);
         }
        break;
 
+      case SA_PREF:
+       rta->pref = v1.val.i;
+       break;
+
       default:
        bug("Invalid static attribute access (%u/%u)", sa.f_type, sa.sa_code);
       }
     }
   }
 
-  INST(FI_PREF_GET, 0, 1) {
-    ACCESS_RTE;
-    RESULT(T_INT, i, (*fs->rte)->pref);
-  }
-
-  INST(FI_PREF_SET, 1, 0) {
-    ACCESS_RTE;
-    ARG(1,T_INT);
-    if (v1.val.i > 0xFFFF)
-      runtime( "Setting preference value out of bounds" );
-    f_rte_cow(fs);
-    (*fs->rte)->pref = v1.val.i;
-  }
-
   INST(FI_LENGTH, 1, 1) {      /* Get length of */
     ARG_ANY(1);
     switch(v1.type) {
index ea4ca6dde2363be00b0605de2f55057f40d947ce..8febb33fa99117a7c411ee9ca151f8a9d74f3580 100644 (file)
@@ -215,6 +215,12 @@ mem_hash_mix(u64 *h, const void *p, uint s)
     *h = *h * multiplier + pp[i];
 }
 
+static inline void
+mem_hash_mix_num(u64 *h, u64 val)
+{
+  mem_hash_mix(h, &val, sizeof(val));
+}
+
 static inline uint
 mem_hash_value(u64 *h)
 {
index b41bc3f865d02a65f8db066a9988d91f148454c1..f0bea86edac673e9683c815a74dcafce2b5acd18 100644 (file)
@@ -235,7 +235,6 @@ typedef struct rte {
   u32 id;                              /* Table specific route id */
   byte flags;                          /* Flags (REF_...) */
   byte pflags;                         /* Protocol-specific flags */
-  word pref;                           /* Route preference */
   btime lastmod;                       /* Last modified */
   union {                              /* Protocol-dependent data (metrics etc.) */
 #ifdef CONFIG_RIP
@@ -480,10 +479,11 @@ typedef struct rta {
   struct hostentry *hostentry;         /* Hostentry for recursive next-hops */
   ip_addr from;                                /* Advertising router */
   u32 igp_metric;                      /* IGP metric to next hop (for iBGP routes) */
-  u8 source;                           /* Route source (RTS_...) */
-  u8 scope;                            /* Route scope (SCOPE_... -- see ip.h) */
-  u8 dest;                             /* Route destination type (RTD_...) */
-  u8 aflags;
+  u16 cached:1;                                /* Are attributes cached? */
+  u16 source:7;                                /* Route source (RTS_...) */
+  u16 scope:4;                         /* Route scope (SCOPE_... -- see ip.h) */
+  u16 dest:4;                          /* Route destination type (RTD_...) */
+  word pref;
   struct nexthop nh;                   /* Next hop */
 } rta;
 
@@ -505,11 +505,6 @@ typedef struct rta {
 #define RTS_PERF 15                    /* Perf checker */
 #define RTS_MAX 16
 
-#define RTC_UNICAST 0
-#define RTC_BROADCAST 1
-#define RTC_MULTICAST 2
-#define RTC_ANYCAST 3                  /* IPv6 Anycast */
-
 #define RTD_NONE 0                     /* Undefined next hop */
 #define RTD_UNICAST 1                  /* Next hop is neighbor router */
 #define RTD_BLACKHOLE 2                        /* Silently drop packets */
@@ -517,8 +512,6 @@ typedef struct rta {
 #define RTD_PROHIBIT 4                 /* Administratively prohibited */
 #define RTD_MAX 5
 
-#define RTAF_CACHED 1                  /* This is a cached rta */
-
 #define IGP_METRIC_UNKNOWN 0x80000000  /* Default igp_metric used when no other
                                           protocol-specific metric is availabe */
 
@@ -707,7 +700,7 @@ void rta_init(void);
 static inline size_t rta_size(const rta *a) { return sizeof(rta) + sizeof(u32)*a->nh.labels; }
 #define RTA_MAX_SIZE (sizeof(rta) + sizeof(u32)*MPLS_MAX_LABEL_STACK)
 rta *rta_lookup(rta *);                        /* Get rta equivalent to this one, uc++ */
-static inline int rta_is_cached(rta *r) { return r->aflags & RTAF_CACHED; }
+static inline int rta_is_cached(rta *r) { return r->cached; }
 static inline rta *rta_clone(rta *r) { r->uc++; return r; }
 void rta__free(rta *r);
 static inline void rta_free(rta *r) { if (r && !--r->uc) rta__free(r); }
index 25e39488164bf8837f360ece267ad4490213200f..94f8970185b8904e01ef12881d7fe3f8c61e88a2 100644 (file)
@@ -1099,13 +1099,15 @@ rta_hash(rta *a)
   u64 h;
   mem_hash_init(&h);
 #define MIX(f) mem_hash_mix(&h, &(a->f), sizeof(a->f));
+#define BMIX(f) mem_hash_mix_num(&h, a->f);
   MIX(src);
   MIX(hostentry);
   MIX(from);
   MIX(igp_metric);
-  MIX(source);
-  MIX(scope);
-  MIX(dest);
+  BMIX(source);
+  BMIX(scope);
+  BMIX(dest);
+  MIX(pref);
 #undef MIX
 
   return mem_hash_value(&h) ^ nexthop_hash(&(a->nh)) ^ ea_hash(a->eattrs);
@@ -1193,7 +1195,7 @@ rta_lookup(rta *o)
   rta *r;
   uint h;
 
-  ASSERT(!(o->aflags & RTAF_CACHED));
+  ASSERT(!o->cached);
   if (o->eattrs)
     ea_normalize(o->eattrs);
 
@@ -1204,7 +1206,7 @@ rta_lookup(rta *o)
 
   r = rta_copy(o);
   r->hash_key = h;
-  r->aflags = RTAF_CACHED;
+  r->cached = 1;
   rt_lock_source(r->src);
   rt_lock_hostentry(r->hostentry);
   rta_insert(r);
@@ -1218,7 +1220,7 @@ rta_lookup(rta *o)
 void
 rta__free(rta *a)
 {
-  ASSERT(rta_cache_count && (a->aflags & RTAF_CACHED));
+  ASSERT(rta_cache_count && a->cached);
   rta_cache_count--;
   *a->pprev = a->next;
   if (a->next)
@@ -1228,7 +1230,7 @@ rta__free(rta *a)
   if (a->nh.next)
     nexthop_free(a->nh.next);
   ea_free(a->eattrs);
-  a->aflags = 0;               /* Poison the entry */
+  a->cached = 0;
   sl_free(rta_slab(a), a);
 }
 
@@ -1243,7 +1245,7 @@ rta_do_cow(rta *o, linpool *lp)
       memcpy(*nhn, nho, nexthop_size(nho));
       nhn = &((*nhn)->next);
     }
-  r->aflags = 0;
+  r->cached = 0;
   r->uc = 0;
   return r;
 }
@@ -1263,10 +1265,10 @@ rta_dump(rta *a)
                         "RTS_OSPF_EXT2", "RTS_BGP", "RTS_PIPE", "RTS_BABEL" };
   static char *rtd[] = { "", " DEV", " HOLE", " UNREACH", " PROHIBIT" };
 
-  debug("p=%s uc=%d %s %s%s h=%04x",
-       a->src->proto->name, a->uc, rts[a->source], ip_scope_text(a->scope),
+  debug("p=%s pref=%d uc=%d %s %s%s h=%04x",
+       a->src->proto->name, a->pref, a->uc, rts[a->source], ip_scope_text(a->scope),
        rtd[a->dest], a->hash_key);
-  if (!(a->aflags & RTAF_CACHED))
+  if (!a->cached)
     debug(" !CACHED");
   debug(" <-%I", a->from);
   if (a->dest == RTD_UNICAST)
index 240cc8fc307c8a43fb4847fdea313edb0230f7c3..7a3401602840024dec09772f18a62241a481b2fe 100644 (file)
@@ -78,13 +78,14 @@ dev_ifa_notify(struct proto *P, uint flags, struct ifa *ad)
       rta a0 = {
        /* Use iface ID as local source ID */
        .src = rt_get_source(P, ad->iface->index),
+       .pref = c->preference,
        .source = RTS_DEVICE,
        .scope = SCOPE_UNIVERSE,
        .dest = RTD_UNICAST,
        .nh.iface = ad->iface,
       };
       rte e0 = {
-       .attrs = rta_lookup(&a0),
+       .attrs = &a0,
       };
       rte_update(c, net, &e0);
     }
index 7691878dd6dcfb6887ae29abe78dfc98bd99ba9c..11eab25b8888a673bda9c9a676a6ea8d85cac801 100644 (file)
@@ -60,7 +60,7 @@ rt_show_rte(struct cli *c, byte *ia, rte *e, struct rt_show_data *d, int primary
   if (get_route_info)
     get_route_info(e, info);
   else
-    bsprintf(info, " (%d)", e->pref);
+    bsprintf(info, " (%d)", a->pref);
 
   if (d->last_table != d->tab)
     rt_show_table(c, d);
index 2c2a20003f838839cb0c26535980e69b41a120f7..df971032f165d410d13c74c53b04a19984a87e10 100644 (file)
@@ -285,7 +285,7 @@ rte_store(rte *r)
 {
   rte *e = sl_alloc(rte_slab);
   memcpy(e, r, sizeof(rte));
-  if (e->attrs->aflags & RTAF_CACHED)
+  if (e->attrs->cached)
     e->attrs = rta_clone(r->attrs);
   else
     e->attrs = rta_lookup(r->attrs);
@@ -504,9 +504,9 @@ rte_better(rte *new, rte *old)
   if (!rte_is_valid(new))
     return 0;
 
-  if (new->pref > old->pref)
+  if (new->attrs->pref > old->attrs->pref)
     return 1;
-  if (new->pref < old->pref)
+  if (new->attrs->pref < old->attrs->pref)
     return 0;
   if (new->attrs->src->proto->proto != old->attrs->src->proto->proto)
     {
@@ -530,7 +530,7 @@ rte_mergable(rte *pri, rte *sec)
   if (!rte_is_valid(pri) || !rte_is_valid(sec))
     return 0;
 
-  if (pri->pref != sec->pref)
+  if (pri->attrs->pref != sec->attrs->pref)
     return 0;
 
   if (pri->attrs->src->proto->proto != sec->attrs->src->proto->proto)
@@ -1063,7 +1063,6 @@ rte_same(rte *x, rte *y)
   return
     x->attrs == y->attrs &&
     x->pflags == y->pflags &&
-    x->pref == y->pref &&
     (!x->attrs->src->proto->rte_same || x->attrs->src->proto->rte_same(x, y)) &&
     rte_is_filtered(x) == rte_is_filtered(y);
 }
@@ -1410,9 +1409,6 @@ rte_update2(struct channel *c, const net_addr *n, rte *new, struct rte_src *src)
       new->net = nn;
       new->sender = c;
 
-      if (!new->pref)
-       new->pref = c->preference;
-
       stats->imp_updates_received++;
       if (!rte_validate(new))
        {
@@ -1508,6 +1504,12 @@ rte_update(struct channel *c, const net_addr *n, struct rte *new)
   ASSERT(new->attrs);
   ASSERT(new->attrs->src);
 
+  if (!new->attrs->pref)
+  {
+    ASSERT(!new->attrs->cached);
+    new->attrs->pref = c->preference;
+  }
+
   rte *e = sl_alloc(rte_slab);
   *e = *new;
 
@@ -1674,7 +1676,7 @@ rte_dump(rte *e)
 {
   net *n = e->net;
   debug("%-1N ", n->n.addr);
-  debug("PF=%02x pref=%d ", e->pflags, e->pref);
+  debug("PF=%02x ", e->pflags);
   rta_dump(e->attrs);
   if (e->attrs->src->proto->proto->dump_attrs)
     e->attrs->src->proto->proto->dump_attrs(e);
@@ -2127,7 +2129,7 @@ rt_next_hop_update_rte(rtable *tab UNUSED, rte *old)
   memcpy(mls.stack, &a->nh.label[a->nh.labels - mls.len], mls.len * sizeof(u32));
 
   rta_apply_hostentry(a, old->attrs->hostentry, &mls);
-  a->aflags = 0;
+  a->cached = 0;
 
   rte *e = sl_alloc(rte_slab);
   memcpy(e, old, sizeof(rte));
@@ -2490,9 +2492,6 @@ rte_update_in(struct channel *c, const net_addr *n, rte *new, struct rte_src *sr
   {
     net = net_get(tab, n);
 
-    if (!new->pref)
-      new->pref = c->preference;
-
     if (!rta_is_cached(new->attrs))
       new->attrs = rta_lookup(new->attrs);
   }
index 5d4f563b885b205aefa571ae33adcc30f5137740..e51700ae2319c3746ddc00f67d47a9bc6b5c01d9 100644 (file)
@@ -634,6 +634,7 @@ babel_announce_rte(struct babel_proto *p, struct babel_entry *e)
       .source = RTS_BABEL,
       .scope = SCOPE_UNIVERSE,
       .dest = RTD_UNICAST,
+      .pref = c->preference,
       .from = r->neigh->addr,
       .nh.gw = r->next_hop,
       .nh.iface = r->neigh->ifa->iface,
@@ -648,7 +649,7 @@ babel_announce_rte(struct babel_proto *p, struct babel_entry *e)
       a0.nh.flags = RNF_ONLINK;
 
     rte e0 = {
-      .attrs = rta_lookup(&a0),
+      .attrs = &a0,
       .u.babel = {
        .seqno = r->seqno,
        .metric = r->metric,
@@ -668,11 +669,11 @@ babel_announce_rte(struct babel_proto *p, struct babel_entry *e)
       .source = RTS_BABEL,
       .scope = SCOPE_UNIVERSE,
       .dest = RTD_UNREACHABLE,
+      .pref = 1,
     };
 
     rte e0 = {
       .attrs = &a0,
-      .pref = 1,
     };
 
     e->unreachable = 1;
@@ -1857,7 +1858,7 @@ babel_dump(struct proto *P)
 static void
 babel_get_route_info(rte *rte, byte *buf)
 {
-  buf += bsprintf(buf, " (%d/%d) [%lR]", rte->pref, rte->u.babel.metric, rte->u.babel.router_id);
+  buf += bsprintf(buf, " (%d/%d) [%lR]", rte->attrs->pref, rte->u.babel.metric, rte->u.babel.router_id);
 }
 
 static int
index 6752cb7f0a5ccd8d0bc4f7b42e0c18ff21c2cc61..a79508ee77473c601a71506989421a9974dab553 100644 (file)
@@ -2118,7 +2118,7 @@ bgp_rte_mergable(rte *pri, rte *sec)
 static inline int
 same_group(rte *r, u32 lpref, u32 lasn)
 {
-  return (r->pref == lpref) && (bgp_get_neighbor(r) == lasn);
+  return (r->attrs->pref == lpref) && (bgp_get_neighbor(r) == lasn);
 }
 
 static inline int
@@ -2133,7 +2133,7 @@ bgp_rte_recalculate(rtable *table, net *net, rte *new, rte *old, rte *old_best)
 {
   rte *r, *s;
   rte *key = new ? new : old;
-  u32 lpref = key->pref;
+  u32 lpref = key->attrs->pref;
   u32 lasn = bgp_get_neighbor(key);
   int old_suppressed = old ? old->u.bgp.suppressed : 0;
 
@@ -2356,7 +2356,7 @@ bgp_get_route_info(rte *e, byte *buf)
   eattr *o = ea_find(e->attrs->eattrs, EA_CODE(PROTOCOL_BGP, BA_ORIGIN));
   u32 origas;
 
-  buf += bsprintf(buf, " (%d", e->pref);
+  buf += bsprintf(buf, " (%d", e->attrs->pref);
 
   if (e->u.bgp.suppressed)
     buf += bsprintf(buf, "-");
index 55875950b449b10197e47c12ef2fbebcc84a60a6..03f5e7dd451bcfe7b26228a8df711f97e7335911 100644 (file)
@@ -2438,6 +2438,7 @@ bgp_decode_nlri(struct bgp_parse_state *s, u32 afi, byte *nlri, uint len, ea_lis
     a->scope = SCOPE_UNIVERSE;
     a->from = s->proto->remote_ip;
     a->eattrs = ea;
+    a->pref = c->c.preference;
 
     c->desc->decode_next_hop(s, nh, nh_len, a);
     bgp_finish_attrs(s, a);
index ba8c2e2bc12f53c82670619a589ef075066ee686..09cd898ff8c8f48d6e5dbfe2a5059c8bbf8c9266 100644 (file)
@@ -607,7 +607,7 @@ ospf_get_route_info(rte * rte, byte * buf)
   }
 
   buf += bsprintf(buf, " %s", type);
-  buf += bsprintf(buf, " (%d/%d", rte->pref, rte->u.ospf.metric1);
+  buf += bsprintf(buf, " (%d/%d", rte->attrs->pref, rte->u.ospf.metric1);
   if (rte->attrs->source == RTS_OSPF_EXT2)
     buf += bsprintf(buf, "/%d", rte->u.ospf.metric2);
   buf += bsprintf(buf, ")");
index 00d1b2373a6fe0d7aacd0fbaa4097dc84f7c8559..8448d181abbcc823cad879e15d3d3f906f1fa695 100644 (file)
@@ -2052,6 +2052,7 @@ again1:
        .scope = SCOPE_UNIVERSE,
        .dest = RTD_UNICAST,
        .nh = *(nf->n.nhs),
+       .pref = p->p.main_channel->preference,
       };
 
       if (reload || ort_changed(nf, &a0))
index a72023b30b5b67780774d8a07ea1c89fb070c08f..ec2a9014400087aa81e3d34f8ab6ee01e2fffdad 100644 (file)
@@ -147,6 +147,7 @@ perf_loop(void *data)
        .source = RTS_PERF,
        .scope = SCOPE_UNIVERSE,
        .dest = RTD_UNICAST,
+       .pref = p->p.main_channel->preference,
        .nh.iface = p->ifa->iface,
        .nh.gw = gw,
        .nh.weight = 1,
index b79ae0b903fe416ae68fdb36a3b39dda28b0c0c5..a06282eafd71164dfd18d96e96d8e9cf7c4af638 100644 (file)
@@ -68,7 +68,7 @@ pipe_rt_notify(struct proto *P, struct channel *src_ch, net *n, rte *new, rte *o
       a = alloca(rta_size(new->attrs));
       memcpy(a, new->attrs, rta_size(new->attrs));
 
-      a->aflags = 0;
+      a->cached = 0;
       a->hostentry = NULL;
 
       e->attrs = rta_lookup(a);
@@ -76,7 +76,6 @@ pipe_rt_notify(struct proto *P, struct channel *src_ch, net *n, rte *new, rte *o
 
       /* Copy protocol specific embedded attributes. */
       memcpy(&(e->u), &(new->u), sizeof(e->u));
-      e->pref = new->pref;
       e->pflags = new->pflags;
 
 #ifdef CONFIG_BGP
index b67d457fe049d3607fac7585a670fc5a6845774a..d47447be3c7e37c5aa23ae713d3a9a7ffcac2236 100644 (file)
@@ -146,6 +146,7 @@ rip_announce_rte(struct rip_proto *p, struct rip_entry *en)
     /* Update */
     rta a0 = {
       .src = p->p.main_source,
+      .pref = p->p.main_channel->preference,
       .source = RTS_RIP,
       .scope = SCOPE_UNIVERSE,
       .dest = RTD_UNICAST,
@@ -189,7 +190,7 @@ rip_announce_rte(struct rip_proto *p, struct rip_entry *en)
     }
 
     rte e0 = {
-      .attrs = rta_lookup(&a0),
+      .attrs = &a0,
       .u.rip = {
        .from = a0.nh.iface,
        .metric = rt_metric,
@@ -1197,7 +1198,7 @@ rip_reconfigure(struct proto *P, struct proto_config *CF)
 static void
 rip_get_route_info(rte *rte, byte *buf)
 {
-  buf += bsprintf(buf, " (%d/%d)", rte->pref, rte->u.rip.metric);
+  buf += bsprintf(buf, " (%d/%d)", rte->attrs->pref, rte->u.rip.metric);
 
   if (rte->u.rip.tag)
     bsprintf(buf, " [%04x]", rte->u.rip.tag);
index 685507213821309adbfc4e8b579578237e7c62fb..9589b7c914c80f935576609465a96f15c391a428 100644 (file)
@@ -122,12 +122,13 @@ rpki_table_add_roa(struct rpki_cache *cache, struct channel *channel, const net_
 
   rta a0 = {
     .src = p->p.main_source,
+    .pref = channel->preference,
     .source = RTS_RPKI,
     .scope = SCOPE_UNIVERSE,
     .dest = RTD_NONE,
   };
 
-  rte e0 = { .attrs = rta_lookup(&a0) };
+  rte e0 = { .attrs = &a0 };
 
   rte_update(channel, &pfxr->n, &e0);
 }
index e6556f122f79fec07adccb6afe73b3555cbaf962..ff66589ca3d0d60a9112538dc4d2759bf3be7a61 100644 (file)
@@ -60,6 +60,7 @@ static_announce_rte(struct static_proto *p, struct static_route *r)
   a->source = RTS_STATIC;
   a->scope = SCOPE_UNIVERSE;
   a->dest = r->dest;
+  a->pref = p->p.main_channel->preference;
 
   if (r->dest == RTD_UNICAST)
   {
@@ -720,9 +721,9 @@ static_get_route_info(rte *rte, byte *buf)
 {
   eattr *a = ea_find(rte->attrs->eattrs, EA_GEN_IGP_METRIC);
   if (a)
-    buf += bsprintf(buf, " (%d/%u)", rte->pref, a->u.data);
+    buf += bsprintf(buf, " (%d/%u)", rte->attrs->pref, a->u.data);
   else
-    buf += bsprintf(buf, " (%d)", rte->pref);
+    buf += bsprintf(buf, " (%d)", rte->attrs->pref);
 }
 
 static void
index 882f276f2474b628a2d08b1a445b36445d799b3b..1e6fb6be52d31bcd4b3ff1bee2cae7100aa6e960 100644 (file)
@@ -434,6 +434,9 @@ krt_learn_async(struct krt_proto *p, rte *e, int new)
   net *n = net_get(&p->krt_table, n0->n.addr);
   rte *g, **gg, *best, **bestp, *old_best;
 
+  ASSERT(!e->attrs->cached);
+  e->attrs->pref = p->p.main_channel->preference;
+
   e = rte_store(e);
 
   old_best = n->routes;