From 432dfe3b9b97062be243609d69e0f49bdb0bcaf6 Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Fri, 22 Jul 2022 15:48:20 +0200 Subject: [PATCH 1/2] Fixed a rarely used part of Babel: comparing two routes in table by their metric --- proto/babel/babel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proto/babel/babel.c b/proto/babel/babel.c index 7ea1aba8..ecfd2763 100644 --- a/proto/babel/babel.c +++ b/proto/babel/babel.c @@ -2338,8 +2338,8 @@ babel_rt_notify(struct proto *P, struct channel *c UNUSED, struct network *net, static int babel_rte_better(struct rte *new, struct rte *old) { - uint new_metric = ea_find(new->attrs->eattrs, EA_BABEL_SEQNO)->u.data; - uint old_metric = ea_find(old->attrs->eattrs, EA_BABEL_SEQNO)->u.data; + uint new_metric = ea_get_int(new->attrs->eattrs, EA_BABEL_METRIC, BABEL_INFINITY); + uint old_metric = ea_get_int(old->attrs->eattrs, EA_BABEL_METRIC, BABEL_INFINITY); return new_metric < old_metric; } From 73abd91ac661f28d9341c7fbb80d2f7a71db186d Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Fri, 22 Jul 2022 16:09:37 +0200 Subject: [PATCH 2/2] rip_rte_better() uses the IGP_METRIC_UNKNOWN instead of protocol-specific infinity --- proto/rip/rip.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/proto/rip/rip.c b/proto/rip/rip.c index 6ca7a6b5..b0b5b8a1 100644 --- a/proto/rip/rip.c +++ b/proto/rip/rip.c @@ -1101,24 +1101,18 @@ rip_reload_routes(struct channel *C) rip_kick_timer(p); } -static int -rip_rte_better(struct rte *new, struct rte *old) -{ - ASSERT_DIE(new->src == old->src); - struct rip_proto *p = (struct rip_proto *) new->src->proto; - - u32 new_metric = ea_get_int(new->attrs->eattrs, EA_RIP_METRIC, p->infinity); - u32 old_metric = ea_get_int(old->attrs->eattrs, EA_RIP_METRIC, p->infinity); - - return new_metric < old_metric; -} - static u32 rip_rte_igp_metric(struct rte *rt) { return ea_get_int(rt->attrs->eattrs, EA_RIP_METRIC, IGP_METRIC_UNKNOWN); } +static int +rip_rte_better(struct rte *new, struct rte *old) +{ + return rip_rte_igp_metric(new) < rip_rte_igp_metric(old); +} + static void rip_postconfig(struct proto_config *CF) {