From 0f2be469f897b6d9f925563bbf522438c83522ea Mon Sep 17 00:00:00 2001 From: Alexander Zubkov Date: Wed, 21 Sep 2022 17:07:11 +0200 Subject: KRT: Fix setting default preference Changes in commit eb937358 broke setting of channel preference for alien routes learned during scan. The preference was set only for async routes. Move common attribute processing part of functions krt_learn_async() and krt_learn_async() to a separate function to have only one place for such changes. --- sysdep/unix/krt.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'sysdep/unix/krt.c') diff --git a/sysdep/unix/krt.c b/sysdep/unix/krt.c index c4a3a4a8..cb0f1d4f 100644 --- a/sysdep/unix/krt.c +++ b/sysdep/unix/krt.c @@ -318,6 +318,15 @@ krt_learn_announce_delete(struct krt_proto *p, net *n) rte_update(&p->p, n->n.addr, NULL); } +static void +krt_learn_alien_attr(struct channel *c, rte *e) +{ + ASSERT(!e->attrs->cached); + e->attrs->pref = c->preference; + + e->attrs = rta_lookup(e->attrs); +} + /* Called when alien route is discovered during scan */ static void krt_learn_scan(struct krt_proto *p, rte *e) @@ -326,7 +335,7 @@ krt_learn_scan(struct krt_proto *p, rte *e) net *n = net_get(p->krt_table, n0->n.addr); rte *m, **mm; - e->attrs = rta_lookup(e->attrs); + krt_learn_alien_attr(p->p.main_channel, e); for(mm=&n->routes; m = *mm; mm=&m->next) if (krt_same_key(m, e)) @@ -438,10 +447,7 @@ 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->attrs = rta_lookup(e->attrs); + krt_learn_alien_attr(p->p.main_channel, e); old_best = n->routes; for(gg=&n->routes; g = *gg; gg = &g->next) -- cgit v1.2.3