summaryrefslogtreecommitdiff
path: root/proto
diff options
context:
space:
mode:
authorToke Høiland-Jørgensen <toke@toke.dk>2023-01-31 15:52:14 +0100
committerOndrej Zajicek <santiago@crfreenet.org>2023-01-31 15:52:14 +0100
commitdc4c5f51f83f97100b207136ecfde8ff94e597e6 (patch)
treeb8435ac6d6430943a0b9577c5ce0e85109f42987 /proto
parent96d7c4679df49b34be004177b10a99210af5f141 (diff)
Babel: Initialise source seqno from incoming message
When creating a new babel_source object we initialise the seqno to 0. The caller will update the source object with the right metric and seqno value, for both newly created and old source objects. However if we initialise the source object seqno to 0 that may actually turn out to be a valid (higher) seqno than the one in the routing table, because of seqno wrapping. In this case the source metric will not be set properly, which breaks feasibility tracking for subsequent updates. To fix this, add a new initial_seqno argument to babel_get_source() which is used when allocating a new object, and set that to the seqno value of the update we're sending. Thanks to Juliusz Chroboczek for the bugreport.
Diffstat (limited to 'proto')
-rw-r--r--proto/babel/babel.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/proto/babel/babel.c b/proto/babel/babel.c
index 25081c3b..becff6d0 100644
--- a/proto/babel/babel.c
+++ b/proto/babel/babel.c
@@ -105,7 +105,8 @@ babel_find_source(struct babel_entry *e, u64 router_id)
}
static struct babel_source *
-babel_get_source(struct babel_proto *p, struct babel_entry *e, u64 router_id)
+babel_get_source(struct babel_proto *p, struct babel_entry *e, u64 router_id,
+ u16 initial_seqno)
{
struct babel_source *s = babel_find_source(e, router_id);
@@ -115,7 +116,7 @@ babel_get_source(struct babel_proto *p, struct babel_entry *e, u64 router_id)
s = sl_allocz(p->source_slab);
s->router_id = router_id;
s->expires = current_time() + BABEL_GARBAGE_INTERVAL;
- s->seqno = 0;
+ s->seqno = initial_seqno;
s->metric = BABEL_INFINITY;
add_tail(&e->sources, NODE s);
@@ -1011,10 +1012,10 @@ babel_send_update_(struct babel_iface *ifa, btime changed, struct fib *rtable)
babel_enqueue(&msg, ifa);
- /* Update feasibility distance for redistributed routes */
+ /* RFC 6126 3.7.3 - update feasibility distance for redistributed routes */
if (e->router_id != p->router_id)
{
- struct babel_source *s = babel_get_source(p, e, e->router_id);
+ struct babel_source *s = babel_get_source(p, e, e->router_id, msg.update.seqno);
s->expires = current_time() + BABEL_GARBAGE_INTERVAL;
if (gt_mod64k(msg.update.seqno, s->seqno) ||