diff options
Diffstat (limited to 'nest')
-rw-r--r-- | nest/rt-attr.c | 11 | ||||
-rw-r--r-- | nest/rt-dev.c | 3 | ||||
-rw-r--r-- | nest/rt-show.c | 2 | ||||
-rw-r--r-- | nest/rt-table.c | 9 | ||||
-rw-r--r-- | nest/rt.h | 1 |
5 files changed, 18 insertions, 8 deletions
diff --git a/nest/rt-attr.c b/nest/rt-attr.c index 6bb27623..e5d87b53 100644 --- a/nest/rt-attr.c +++ b/nest/rt-attr.c @@ -65,6 +65,11 @@ struct ea_class ea_gen_igp_metric = { .type = T_INT, }; +struct ea_class ea_gen_preference = { + .name = "preference", + .type = T_INT, +}; + const char * const rta_src_names[RTS_MAX] = { [RTS_STATIC] = "static", [RTS_INHERIT] = "inherit", @@ -1228,7 +1233,6 @@ rta_hash(rta *a) BMIX(source); BMIX(scope); BMIX(dest); - MIX(pref); #undef MIX return mem_hash_value(&h) ^ nexthop_hash(&(a->nh)) ^ ea_hash(a->eattrs); @@ -1389,8 +1393,8 @@ rta_dump(rta *a) "RTS_OSPF_EXT2", "RTS_BGP", "RTS_PIPE", "RTS_BABEL" }; static char *rtd[] = { "", " DEV", " HOLE", " UNREACH", " PROHIBIT" }; - debug("pref=%d uc=%d %s %s%s h=%04x", - a->pref, a->uc, rts[a->source], ip_scope_text(a->scope), + debug("uc=%d %s %s%s h=%04x", + a->uc, rts[a->source], ip_scope_text(a->scope), rtd[a->dest], a->hash_key); if (!a->cached) debug(" !CACHED"); @@ -1469,6 +1473,7 @@ rta_init(void) rte_src_init(); ea_class_init(); + ea_register_init(&ea_gen_preference); ea_register_init(&ea_gen_igp_metric); } diff --git a/nest/rt-dev.c b/nest/rt-dev.c index bdf8584d..696b37b8 100644 --- a/nest/rt-dev.c +++ b/nest/rt-dev.c @@ -83,13 +83,14 @@ dev_ifa_notify(struct proto *P, uint flags, struct ifa *ad) struct rte_src *src = rt_get_source(P, ad->iface->index); rta a0 = { - .pref = c->preference, .source = RTS_DEVICE, .scope = SCOPE_UNIVERSE, .dest = RTD_UNICAST, .nh.iface = ad->iface, }; + ea_set_attr_u32(&a0.eattrs, &ea_gen_preference, 0, c->preference); + a = rta_lookup(&a0); e = rte_get_temp(a, src); e->pflags = 0; diff --git a/nest/rt-show.c b/nest/rt-show.c index 7d02f52e..1c764d8c 100644 --- a/nest/rt-show.c +++ b/nest/rt-show.c @@ -61,7 +61,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)", a->pref); + bsprintf(info, " (%d)", rt_get_preference(e)); if (d->last_table != d->tab) rt_show_table(c, d); diff --git a/nest/rt-table.c b/nest/rt-table.c index 01194e02..919576bd 100644 --- a/nest/rt-table.c +++ b/nest/rt-table.c @@ -652,9 +652,12 @@ rte_better(rte *new, rte *old) if (!rte_is_valid(new)) return 0; - if (new->attrs->pref > old->attrs->pref) + u32 np = rt_get_preference(new); + u32 op = rt_get_preference(old); + + if (np > op) return 1; - if (new->attrs->pref < old->attrs->pref) + if (np < op) return 0; if (new->src->proto->proto != old->src->proto->proto) { @@ -678,7 +681,7 @@ rte_mergable(rte *pri, rte *sec) if (!rte_is_valid(pri) || !rte_is_valid(sec)) return 0; - if (pri->attrs->pref != sec->attrs->pref) + if (rt_get_preference(pri) != rt_get_preference(sec)) return 0; if (pri->src->proto->proto != sec->src->proto->proto) @@ -329,6 +329,7 @@ int rt_flowspec_check(rtable *tab_ip, rtable *tab_flow, const net_addr *n, rta * #define DEF_PREF_BGP 100 /* BGP */ #define DEF_PREF_RPKI 100 /* RPKI */ #define DEF_PREF_INHERITED 10 /* Routes inherited from other routing daemons */ +#define DEF_PREF_UNKNOWN 0 /* Routes with no preference set */ /* * Route Origin Authorization |