From fe89d151b4f89772a45ecefccf751aff4999a7ae Mon Sep 17 00:00:00 2001 From: Yagizhan Isik Date: Fri, 30 Oct 2026 08:13:29 +0100 Subject: [PATCH] Babel: Re-check feasibility of candidate routes at selection time Currently, BIRD's Babel implementation checks the feasibility of a route when its update arrives and stores the result with the route. The node's own feasibility distance can decrease later when it advertises a better metric, but the stored result is not updated until the neighbor sends a new update. So a route that is no longer feasible can still be selected, which can cause a routing loop. This happens when updates are delayed or lost like in mobility scenarios or unstable wireless links. This patch re-checks candidate routes against the current source table before selecting them, as the code did before commit 3b3b0910f. Introduced-In: 3b3b0910f Target: patch --- proto/babel/babel.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/proto/babel/babel.c b/proto/babel/babel.c index f5d3b012a..f5baffc4c 100644 --- a/proto/babel/babel.c +++ b/proto/babel/babel.c @@ -573,6 +573,13 @@ babel_is_feasible(struct babel_source *s, u16 seqno, u16 metric) ((seqno == s->seqno) && (metric < s->metric)); } +static inline int +babel_route_feasible(struct babel_entry *e, struct babel_route *r) +{ + return r->feasible && + babel_is_feasible(babel_find_source(e, r->router_id), r->seqno, r->advert_metric); +} + /* Simple additive metric - Appendix 3.1 in the RFC */ static inline u16 babel_compute_metric(struct babel_neighbor *n, uint metric) @@ -803,7 +810,7 @@ babel_select_route(struct babel_proto *p, struct babel_entry *e, struct babel_ro if (mod && (mod != best)) { /* Either select modified route, or keep old best route */ - if ((mod->metric < (best ? best->metric : BABEL_INFINITY)) && mod->feasible) + if ((mod->metric < (best ? best->metric : BABEL_INFINITY)) && babel_route_feasible(e, mod)) best = mod; else return; @@ -816,7 +823,7 @@ babel_select_route(struct babel_proto *p, struct babel_entry *e, struct babel_ro /* Find the best feasible route from all routes */ WALK_LIST(r, e->routes) - if ((r->metric < (best ? best->metric : BABEL_INFINITY)) && r->feasible) + if ((r->metric < (best ? best->metric : BABEL_INFINITY)) && babel_route_feasible(e, r)) best = r; } -- 2.43.0