1
0
mirror of https://gitlab.labs.nic.cz/labs/bird.git synced 2024-05-11 16:54:54 +00:00

IGP metric getter refactoring to protocol callback

Direct protocol hooks for IGP metric inside nest/rt-table.c make the
protocol API unnecessarily complex. Instead, we use a proper callback.
This commit is contained in:
Maria Matejka
2021-03-20 23:18:34 +01:00
parent 5cff1d5f02
commit d471d5fc7c
8 changed files with 34 additions and 32 deletions

View File

@@ -45,10 +45,6 @@
#include "lib/string.h"
#include "lib/alloca.h"
#ifdef CONFIG_BGP
#include "proto/bgp/bgp.h"
#endif
pool *rt_table_pool;
static slab *rte_slab;
@@ -3022,36 +3018,12 @@ rt_get_igp_metric(rte *rt)
if (ea)
return ea->u.data;
rta *a = rt->attrs;
#ifdef CONFIG_OSPF
if ((a->source == RTS_OSPF) ||
(a->source == RTS_OSPF_IA) ||
(a->source == RTS_OSPF_EXT1))
return rt->u.ospf.metric1;
#endif
#ifdef CONFIG_RIP
if (a->source == RTS_RIP)
return rt->u.rip.metric;
#endif
#ifdef CONFIG_BGP
if (a->source == RTS_BGP)
{
u64 metric = bgp_total_aigp_metric(rt);
return (u32) MIN(metric, (u64) IGP_METRIC_UNKNOWN);
}
#endif
#ifdef CONFIG_BABEL
if (a->source == RTS_BABEL)
return rt->u.babel.metric;
#endif
if (a->source == RTS_DEVICE)
if (rt->attrs->source == RTS_DEVICE)
return 0;
if (rt->src->proto->rte_igp_metric)
return rt->src->proto->rte_igp_metric(rt);
return IGP_METRIC_UNKNOWN;
}