summaryrefslogtreecommitdiff
path: root/nest
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2019-09-28 14:17:20 +0200
committerOndrej Zajicek (work) <santiago@crfreenet.org>2019-10-09 17:53:23 +0200
commit09ee846d9275b4cb0b77f7e458aba6a71b111c52 (patch)
tree21fd5d815e7f7b7dc7d6dd3a473ece834c2d024c /nest
parent759b204be33fa8485c9e28038ee029a49e2e9d3f (diff)
BGP: AIGP metric support (RFC 7311)
Diffstat (limited to 'nest')
-rw-r--r--nest/route.h1
-rw-r--r--nest/rt-table.c14
2 files changed, 14 insertions, 1 deletions
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;