diff options
author | Maria Matejka <mq@ucw.cz> | 2022-05-30 12:03:03 +0200 |
---|---|---|
committer | Maria Matejka <mq@ucw.cz> | 2022-05-30 14:39:09 +0200 |
commit | 938742decc6e1d6d3a0375dd012b75172e747bbc (patch) | |
tree | a10d9eb2811af43075c2c5272ece7b3dbbb38cdf /sysdep/unix/krt.c | |
parent | 950775f6fa3d569a9d7cd05e33538d35e895d688 (diff) |
Squashing the route attribute structure into one level.
For now, all route attributes are stored as eattrs in ea_list. This
should make route manipulation easier and it also allows for a layered
approach of route attributes where updates from filters will be stored
as an overlay over the previous version.
Diffstat (limited to 'sysdep/unix/krt.c')
-rw-r--r-- | sysdep/unix/krt.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/sysdep/unix/krt.c b/sysdep/unix/krt.c index a0789936..3edbdfa2 100644 --- a/sysdep/unix/krt.c +++ b/sysdep/unix/krt.c @@ -286,7 +286,7 @@ static struct tbf rl_alien = TBF_DEFAULT_LOG_LIMITS; static inline u32 krt_metric(rte *a) { - eattr *ea = ea_find(a->attrs->eattrs, &ea_krt_metric); + eattr *ea = ea_find(a->attrs, &ea_krt_metric); return ea ? ea->u.data : 0; } @@ -306,8 +306,7 @@ static void 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, p->p.main_source); + rte *ee = rte_get_temp(ea_clone(e->attrs), p->p.main_source); rte_update(&p->p, n->n.addr, ee); } @@ -437,10 +436,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); - ea_set_attr_u32(&e->attrs->eattrs, &ea_gen_preference, 0, p->p.main_channel->preference); - - e->attrs = rta_lookup(e->attrs); + ea_list *ea = e->attrs; + ea_set_attr_u32(&ea, &ea_gen_preference, 0, p->p.main_channel->preference); + e->attrs = rta_lookup(ea); old_best = n->routes; for(gg=&n->routes; g = *gg; gg = &g->next) @@ -606,10 +604,10 @@ reject: static int krt_same_dest(rte *k, rte *e) { - rta *ka = k->attrs, *ea = e->attrs; + ea_list *ka = k->attrs, *ea = e->attrs; - eattr *nhea_k = ea_find(ka->eattrs, &ea_gen_nexthop); - eattr *nhea_e = ea_find(ea->eattrs, &ea_gen_nexthop); + eattr *nhea_k = ea_find(ka, &ea_gen_nexthop); + eattr *nhea_e = ea_find(ea, &ea_gen_nexthop); return (!nhea_k == !nhea_e) && adata_same(nhea_k->u.ptr, nhea_e->u.ptr); } |