summaryrefslogtreecommitdiffstats
path: root/ospfd/ospf_asbr.c
diff options
context:
space:
mode:
Diffstat (limited to 'ospfd/ospf_asbr.c')
-rw-r--r--ospfd/ospf_asbr.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/ospfd/ospf_asbr.c b/ospfd/ospf_asbr.c
index b47c3900..738ac6d8 100644
--- a/ospfd/ospf_asbr.c
+++ b/ospfd/ospf_asbr.c
@@ -168,6 +168,38 @@ void ospf_external_info_delete(struct ospf *ospf, uint8_t type,
}
}
+/*
+ * ospf_external_info_delete_multi_instance
+ *
+ * Delete instances of the external route information for a given route type.
+ * The preserve_instance parameter may be used to prevent the current instance
+ * from being deleted.
+ */
+void ospf_external_info_delete_multi_instance(struct ospf *ospf, uint8_t type, struct prefix_ipv4 p,
+ unsigned long preserve_instance)
+{
+ struct route_node *rn;
+ struct ospf_external *ext;
+ struct list *ext_list;
+ struct listnode *node;
+
+ ext_list = ospf->external[type];
+ if (!ext_list)
+ return;
+
+ for (ALL_LIST_ELEMENTS_RO(ext_list, node, ext)) {
+ if (ext->instance != preserve_instance) {
+ rn = route_node_lookup(EXTERNAL_INFO(ext), (struct prefix *)&p);
+ if (rn) {
+ ospf_external_info_free(rn->info);
+ rn->info = NULL;
+ route_unlock_node(rn);
+ route_unlock_node(rn);
+ }
+ }
+ }
+}
+
struct external_info *ospf_external_info_lookup(struct ospf *ospf, uint8_t type,
unsigned short instance,
struct prefix_ipv4 *p)
@@ -189,6 +221,44 @@ struct external_info *ospf_external_info_lookup(struct ospf *ospf, uint8_t type,
return NULL;
}
+/*
+ * ospf_external_info_default_lookup
+ *
+ * For default information criteria, we really don't care about the
+ * source of the route and there only should be one.
+ */
+struct external_info *ospf_external_info_default_lookup(struct ospf *ospf)
+{
+ struct ospf_external *ext;
+ struct external_info *ei;
+ struct list *ext_list;
+ struct listnode *node;
+ struct route_node *rn;
+ struct prefix_ipv4 p = {
+ .family = AF_INET,
+ .prefixlen = 0,
+ .prefix.s_addr = INADDR_ANY,
+ };
+
+ ext_list = ospf->external[DEFAULT_ROUTE];
+ if (!ext_list)
+ return (NULL);
+
+ for (ALL_LIST_ELEMENTS_RO(ext_list, node, ext)) {
+ rn = route_node_lookup(EXTERNAL_INFO(ext), (struct prefix *)&p);
+ if (rn) {
+ route_unlock_node(rn);
+ if (rn->info) {
+ ei = rn->info;
+ if (ei->type != ZEBRA_ROUTE_OSPF || ei->instance != ospf->instance)
+ return ei;
+ }
+ }
+ }
+
+ return NULL;
+}
+
struct ospf_lsa *ospf_external_info_find_lsa(struct ospf *ospf,
struct prefix_ipv4 *p)
{