From 09ee846d9275b4cb0b77f7e458aba6a71b111c52 Mon Sep 17 00:00:00 2001 From: "Ondrej Zajicek (work)" Date: Sat, 28 Sep 2019 14:17:20 +0200 Subject: BGP: AIGP metric support (RFC 7311) --- nest/route.h | 1 + nest/rt-table.c | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'nest') diff --git a/nest/route.h b/nest/route.h index f4f32ce0..cd4b75db 100644 --- a/nest/route.h +++ b/nest/route.h @@ -652,6 +652,7 @@ void rta_dump(rta *); void rta_dump_all(void); void rta_show(struct cli *, rta *); +u32 rt_get_igp_metric(rte *rt); struct hostentry * rt_get_hostentry(rtable *tab, ip_addr a, ip_addr ll, rtable *dep); void rta_apply_hostentry(rta *a, struct hostentry *he, mpls_label_stack *mls); diff --git a/nest/rt-table.c b/nest/rt-table.c index c3ec0314..b55bcd40 100644 --- a/nest/rt-table.c +++ b/nest/rt-table.c @@ -44,6 +44,10 @@ #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; @@ -2934,7 +2938,7 @@ if_local_addr(ip_addr a, struct iface *i) return 0; } -static u32 +u32 rt_get_igp_metric(rte *rt) { eattr *ea = ea_find(rt->attrs->eattrs, EA_GEN_IGP_METRIC); @@ -2956,6 +2960,14 @@ rt_get_igp_metric(rte *rt) 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 + if (a->source == RTS_DEVICE) return 0; -- cgit v1.2.3