summaryrefslogtreecommitdiffstats
path: root/ospfd
diff options
context:
space:
mode:
authorrgirada <rgirada@vmware.com>2020-08-15 10:27:40 +0200
committerrgirada <rgirada@vmware.com>2020-11-02 06:13:20 +0100
commitad7222b76c3bf21914f97b925ed4bf80c2210078 (patch)
tree87a60f2b9dcda5482e522e729ee4bb0cef439b56 /ospfd
parentospfd: summarisation specific data structures. (diff)
downloadfrr-ad7222b76c3bf21914f97b925ed4bf80c2210078.tar.xz
frr-ad7222b76c3bf21914f97b925ed4bf80c2210078.zip
ospfd: Summarisation init/de-init.
Description: Summarisation initilisation and de-init apis. summary route table will be created as part of initilisation at the time of ospf deamon init. Signed-off-by: Rajesh Girada <rgirada@vmware.com>
Diffstat (limited to 'ospfd')
-rw-r--r--ospfd/ospf_asbr.c75
-rw-r--r--ospfd/ospf_asbr.h4
-rw-r--r--ospfd/ospf_memory.c1
-rw-r--r--ospfd/ospf_memory.h1
-rw-r--r--ospfd/ospfd.c19
5 files changed, 100 insertions, 0 deletions
diff --git a/ospfd/ospf_asbr.c b/ospfd/ospf_asbr.c
index fd9b16643..8d262bd73 100644
--- a/ospfd/ospf_asbr.c
+++ b/ospfd/ospf_asbr.c
@@ -327,3 +327,78 @@ void ospf_redistribute_withdraw(struct ospf *ospf, uint8_t type,
rn->info = NULL;
}
}
+
+/* External Route Aggregator Handlers */
+void ospf_asbr_external_aggregator_init(struct ospf *instance)
+{
+ instance->rt_aggr_tbl = route_table_init();
+
+ instance->t_external_aggr = NULL;
+
+ instance->aggr_action = 0;
+
+ instance->aggr_delay_interval = OSPF_EXTL_AGGR_DEFAULT_DELAY;
+}
+
+static unsigned int ospf_external_rt_hash_key(const void *data)
+{
+ const struct external_info *ei = data;
+ unsigned int key = 0;
+
+ key = prefix_hash_key(&ei->p);
+ return key;
+}
+
+static bool ospf_external_rt_hash_cmp(const void *d1, const void *d2)
+{
+ const struct external_info *ei1 = d1;
+ const struct external_info *ei2 = d2;
+
+ return prefix_same((struct prefix *)&ei1->p, (struct prefix *)&ei2->p);
+}
+
+static struct ospf_external_aggr_rt *
+ospf_external_aggregator_new(struct prefix_ipv4 *p)
+{
+ struct ospf_external_aggr_rt *aggr;
+
+ aggr = (struct ospf_external_aggr_rt *)XCALLOC(
+ MTYPE_OSPF_EXTERNAL_RT_AGGR,
+ sizeof(struct ospf_external_aggr_rt));
+
+ if (!aggr)
+ return NULL;
+
+ aggr->p.family = p->family;
+ aggr->p.prefix = p->prefix;
+ aggr->p.prefixlen = p->prefixlen;
+ aggr->match_extnl_hash = hash_create(ospf_external_rt_hash_key,
+ ospf_external_rt_hash_cmp,
+ "Ospf external route hash");
+ return aggr;
+}
+
+static void ospf_aggr_unlink_external_info(void *data)
+{
+ struct external_info *ei = (struct external_info *)data;
+
+ ei->aggr_route = NULL;
+
+ ei->to_be_processed = true;
+}
+
+void ospf_external_aggregator_free(struct ospf_external_aggr_rt *aggr)
+{
+ if (OSPF_EXTERNAL_RT_COUNT(aggr))
+ hash_clean(aggr->match_extnl_hash,
+ (void *)ospf_aggr_unlink_external_info);
+
+ if (IS_DEBUG_OSPF(lsa, EXTNL_LSA_AGGR))
+ zlog_debug("%s: Release the aggregator Address(%s/%d)",
+ __func__, inet_ntoa(aggr->p.prefix),
+ aggr->p.prefixlen);
+ hash_free(aggr->match_extnl_hash);
+ aggr->match_extnl_hash = NULL;
+
+ XFREE(MTYPE_OSPF_EXTERNAL_RT_AGGR, aggr);
+}
diff --git a/ospfd/ospf_asbr.h b/ospfd/ospf_asbr.h
index ec02fa15a..090579363 100644
--- a/ospfd/ospf_asbr.h
+++ b/ospfd/ospf_asbr.h
@@ -130,4 +130,8 @@ extern void ospf_asbr_route_install_lsa(struct ospf_lsa *);
extern struct ospf_lsa *ospf_external_info_find_lsa(struct ospf *,
struct prefix_ipv4 *p);
+/* External Route Aggregator */
+extern void ospf_asbr_external_aggregator_init(struct ospf *instance);
+
+extern void ospf_external_aggregator_free(struct ospf_external_aggr_rt *aggr);
#endif /* _ZEBRA_OSPF_ASBR_H */
diff --git a/ospfd/ospf_memory.c b/ospfd/ospf_memory.c
index d102fddf8..ae22cec41 100644
--- a/ospfd/ospf_memory.c
+++ b/ospfd/ospf_memory.c
@@ -57,3 +57,4 @@ DEFINE_MTYPE(OSPFD, OSPF_PCE_PARAMS, "OSPF PCE parameters")
DEFINE_MTYPE(OSPFD, OSPF_EXT_PARAMS, "OSPF Extended parameters")
DEFINE_MTYPE(OSPFD, OSPF_SR_PARAMS, "OSPF Segment Routing parameters")
DEFINE_MTYPE(OSPFD, OSPF_GR_HELPER, "OSPF Graceful Restart Helper")
+DEFINE_MTYPE(OSPFD, OSPF_EXTERNAL_RT_AGGR, "OSPF External Route Summarisation")
diff --git a/ospfd/ospf_memory.h b/ospfd/ospf_memory.h
index 58f23aa9c..624b1d330 100644
--- a/ospfd/ospf_memory.h
+++ b/ospfd/ospf_memory.h
@@ -56,5 +56,6 @@ DECLARE_MTYPE(OSPF_PCE_PARAMS)
DECLARE_MTYPE(OSPF_SR_PARAMS)
DECLARE_MTYPE(OSPF_EXT_PARAMS)
DECLARE_MTYPE(OSPF_GR_HELPER)
+DECLARE_MTYPE(OSPF_EXTERNAL_RT_AGGR)
#endif /* _QUAGGA_OSPF_MEMORY_H */
diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c
index c6e24eb77..a83980672 100644
--- a/ospfd/ospfd.c
+++ b/ospfd/ospfd.c
@@ -312,6 +312,8 @@ static struct ospf *ospf_new(unsigned short instance, const char *name)
ospf_gr_helper_init(new);
+ ospf_asbr_external_aggregator_init(new);
+
QOBJ_REG(new, ospf);
new->fd = -1;
@@ -716,6 +718,7 @@ static void ospf_finish_final(struct ospf *ospf)
OSPF_TIMER_OFF(ospf->t_opaque_lsa_self);
OSPF_TIMER_OFF(ospf->t_sr_update);
OSPF_TIMER_OFF(ospf->t_default_routemap_timer);
+ OSPF_TIMER_OFF(ospf->t_external_aggr);
LSDB_LOOP (OPAQUE_AS_LSDB(ospf), rn, lsa)
ospf_discard_from_db(ospf, ospf->lsdb, lsa);
@@ -784,6 +787,22 @@ static void ospf_finish_final(struct ospf *ospf)
ospf_distance_reset(ospf);
route_table_finish(ospf->distance_table);
+ /* Release extrenal Aggregator table */
+ for (rn = route_top(ospf->rt_aggr_tbl); rn; rn = route_next(rn)) {
+ struct ospf_external_aggr_rt *aggr;
+
+ aggr = rn->info;
+
+ if (aggr) {
+ ospf_external_aggregator_free(aggr);
+ rn->info = NULL;
+ route_unlock_node(rn);
+ }
+ }
+
+ route_table_finish(ospf->rt_aggr_tbl);
+
+
list_delete(&ospf->areas);
list_delete(&ospf->oi_write_q);