From: Maria Matejka Date: Sat, 20 Mar 2021 22:18:34 +0000 (+0100) Subject: IGP metric getter refactoring to switch X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9d0dec40f8214158682fec3fa2a927bde76c39a0;p=thirdparty%2Fbird.git IGP metric getter refactoring to switch --- diff --git a/nest/rt-table.c b/nest/rt-table.c index df971032f..8cdb6f97e 100644 --- a/nest/rt-table.c +++ b/nest/rt-table.c @@ -2913,33 +2913,36 @@ rt_get_igp_metric(rte *rt) rta *a = rt->attrs; + switch (a->source) + { #ifdef CONFIG_OSPF - if ((a->source == RTS_OSPF) || - (a->source == RTS_OSPF_IA) || - (a->source == RTS_OSPF_EXT1)) - return rt->u.ospf.metric1; + case RTS_OSPF: + case RTS_OSPF_IA: + case RTS_OSPF_EXT1: + return rt->u.ospf.metric1; #endif #ifdef CONFIG_RIP - if (a->source == RTS_RIP) - return rt->u.rip.metric; + case 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); - } + case 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; + case RTS_BABEL: + return rt->u.babel.metric; #endif - if (a->source == RTS_DEVICE) - return 0; + case RTS_DEVICE: + return 0; + } return IGP_METRIC_UNKNOWN; }