summaryrefslogtreecommitdiff
path: root/proto/bgp
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2021-03-20 23:18:34 +0100
committerMaria Matejka <mq@ucw.cz>2021-10-13 19:09:04 +0200
commitd471d5fc7ce587ed836ca7fa10a79331bc181d45 (patch)
tree557c529dde26bf83da31b5ddcacd5d842d9421bd /proto/bgp
parent5cff1d5f022755df61af6fc21cc4f2e5d384404e (diff)
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.
Diffstat (limited to 'proto/bgp')
-rw-r--r--proto/bgp/attrs.c7
-rw-r--r--proto/bgp/bgp.c1
-rw-r--r--proto/bgp/bgp.h1
3 files changed, 9 insertions, 0 deletions
diff --git a/proto/bgp/attrs.c b/proto/bgp/attrs.c
index 10706088..18d2985c 100644
--- a/proto/bgp/attrs.c
+++ b/proto/bgp/attrs.c
@@ -371,6 +371,13 @@ bgp_init_aigp_metric(rte *e, u64 *metric, const struct adata **ad)
return *metric < IGP_METRIC_UNKNOWN;
}
+u32
+bgp_rte_igp_metric(struct rte *rt)
+{
+ u64 metric = bgp_total_aigp_metric(rt);
+ return (u32) MIN(metric, (u64) IGP_METRIC_UNKNOWN);
+}
+
/*
* Attribute hooks
diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c
index e4d754b1..5c78bfa1 100644
--- a/proto/bgp/bgp.c
+++ b/proto/bgp/bgp.c
@@ -1694,6 +1694,7 @@ bgp_init(struct proto_config *CF)
P->rte_mergable = bgp_rte_mergable;
P->rte_recalculate = cf->deterministic_med ? bgp_rte_recalculate : NULL;
P->rte_modify = bgp_rte_modify_stale;
+ P->rte_igp_metric = bgp_rte_igp_metric;
p->cf = cf;
p->is_internal = (cf->local_as == cf->remote_as);
diff --git a/proto/bgp/bgp.h b/proto/bgp/bgp.h
index 20944fe6..c440c7af 100644
--- a/proto/bgp/bgp.h
+++ b/proto/bgp/bgp.h
@@ -582,6 +582,7 @@ int bgp_rte_better(struct rte *, struct rte *);
int bgp_rte_mergable(rte *pri, rte *sec);
int bgp_rte_recalculate(rtable *table, net *net, rte *new, rte *old, rte *old_best);
struct rte *bgp_rte_modify_stale(struct rte *r, struct linpool *pool);
+u32 bgp_rte_igp_metric(struct rte *);
void bgp_rt_notify(struct proto *P, struct channel *C, net *n, rte *new, rte *old);
int bgp_preexport(struct proto *, struct rte *);
int bgp_get_attr(const struct eattr *e, byte *buf, int buflen);