summaryrefslogtreecommitdiff
path: root/sysdep/unix
diff options
context:
space:
mode:
authorAlexander Zubkov <green@qrator.net>2022-09-21 17:07:11 +0200
committerMaria Matejka <mq@ucw.cz>2022-09-27 11:33:41 +0200
commit0f2be469f897b6d9f925563bbf522438c83522ea (patch)
treee22e275ffb573b2520c4401f1b84140cf80aac4d /sysdep/unix
parentc73343de67afc703dfe812b8e94034b1b1dcfca8 (diff)
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.
Diffstat (limited to 'sysdep/unix')
-rw-r--r--sysdep/unix/krt.c16
1 files changed, 11 insertions, 5 deletions
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)