summaryrefslogtreecommitdiff
path: root/sysdep/unix/krt.c
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2022-09-27 12:17:05 +0200
committerMaria Matejka <mq@ucw.cz>2022-09-27 12:17:05 +0200
commit57a34d466e85bedbf40a0f7cbde23b843a303c8d (patch)
tree9ecf8d39008f8a7bf111bfde7f1ebebae648fcb3 /sysdep/unix/krt.c
parent69d1ffde4c724882398b3b630ea1199f12c0c288 (diff)
KRT: Fix route learning
This is a reimplementation of commit 0f2be469f897b6d9f925563bbf522438c83522ea by Alexander Zubkov. In the master branch, changes in commit eb937358 broke setting of channel preference for alien routes learned during scan. The preference was set only for async routes. The original solution is extended here to accomodate for v3 specifics.
Diffstat (limited to 'sysdep/unix/krt.c')
-rw-r--r--sysdep/unix/krt.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/sysdep/unix/krt.c b/sysdep/unix/krt.c
index 0a746631..360a2888 100644
--- a/sysdep/unix/krt.c
+++ b/sysdep/unix/krt.c
@@ -313,14 +313,22 @@ krt_learn_announce_delete(struct krt_proto *p, net_addr *n)
rte_update(p->p.main_channel, n, NULL, p->p.main_source);
}
+static struct rte_storage *
+krt_store_async(struct krt_proto *p, net *n, rte *e)
+{
+ ASSERT(!e->attrs->cached);
+ e->attrs->pref = p->p.main_channel->preference;
+ e->src = p->p.main_source;
+ return rte_store(e, n, p->krt_table);
+}
+
/* Called when alien route is discovered during scan */
static void
krt_learn_scan(struct krt_proto *p, rte *e)
{
net *n = net_get(p->krt_table, e->net);
struct rte_storage *m, **mm;
-
- struct rte_storage *ee = rte_store(e, n, p->krt_table);
+ struct rte_storage *ee = krt_store_async(p, n, e);
for(mm = &n->routes; m = *mm; mm = &m->next)
if (krt_same_key(&m->rte, e))
@@ -431,11 +439,7 @@ krt_learn_async(struct krt_proto *p, rte *e, int new)
{
net *n = net_get(p->krt_table, e->net);
struct rte_storage *g, **gg, *best, **bestp, *old_best;
-
- ASSERT(!e->attrs->cached);
- e->attrs->pref = p->p.main_channel->preference;
-
- struct rte_storage *ee = rte_store(e, n, p->krt_table);
+ struct rte_storage *ee = krt_store_async(p, n, e);
old_best = n->routes;
for(gg=&n->routes; g = *gg; gg = &g->next)