0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2025-03-23 14:57:02 +00:00

IGP metric getter refactoring to switch

This commit is contained in:
Maria Matejka 2021-03-20 23:18:34 +01:00
parent a67064a494
commit 9d0dec40f8

View File

@ -2913,33 +2913,36 @@ rt_get_igp_metric(rte *rt)
rta *a = rt->attrs; rta *a = rt->attrs;
switch (a->source)
{
#ifdef CONFIG_OSPF #ifdef CONFIG_OSPF
if ((a->source == RTS_OSPF) || case RTS_OSPF:
(a->source == RTS_OSPF_IA) || case RTS_OSPF_IA:
(a->source == RTS_OSPF_EXT1)) case RTS_OSPF_EXT1:
return rt->u.ospf.metric1; return rt->u.ospf.metric1;
#endif #endif
#ifdef CONFIG_RIP #ifdef CONFIG_RIP
if (a->source == RTS_RIP) case RTS_RIP:
return rt->u.rip.metric; return rt->u.rip.metric;
#endif #endif
#ifdef CONFIG_BGP #ifdef CONFIG_BGP
if (a->source == RTS_BGP) case RTS_BGP:
{ {
u64 metric = bgp_total_aigp_metric(rt); u64 metric = bgp_total_aigp_metric(rt);
return (u32) MIN(metric, (u64) IGP_METRIC_UNKNOWN); return (u32) MIN(metric, (u64) IGP_METRIC_UNKNOWN);
} }
#endif #endif
#ifdef CONFIG_BABEL #ifdef CONFIG_BABEL
if (a->source == RTS_BABEL) case RTS_BABEL:
return rt->u.babel.metric; return rt->u.babel.metric;
#endif #endif
if (a->source == RTS_DEVICE) case RTS_DEVICE:
return 0; return 0;
}
return IGP_METRIC_UNKNOWN; return IGP_METRIC_UNKNOWN;
} }