summaryrefslogtreecommitdiff
path: root/ospfd/ospf_route.c
diff options
context:
space:
mode:
Diffstat (limited to 'ospfd/ospf_route.c')
-rw-r--r--ospfd/ospf_route.c50
1 files changed, 49 insertions, 1 deletions
diff --git a/ospfd/ospf_route.c b/ospfd/ospf_route.c
index a5d6d18c..c3acba34 100644
--- a/ospfd/ospf_route.c
+++ b/ospfd/ospf_route.c
@@ -954,6 +954,10 @@ ospf_add_discard_route (struct route_table *rt, struct ospf_area *area,
ospf_route_free (rn->info);
}
+ if (IS_DEBUG_OSPF_EVENT)
+ zlog_debug ("ospf_add_discard_route(): "
+ "adding %s/%d", inet_ntoa (p->prefix), p->prefixlen);
+
new_or = ospf_route_new ();
new_or->type = OSPF_DESTINATION_DISCARD;
new_or->id.s_addr = 0;
@@ -969,8 +973,52 @@ ospf_add_discard_route (struct route_table *rt, struct ospf_area *area,
}
void
-ospf_delete_discard_route (struct prefix_ipv4 *p)
+ospf_delete_discard_route (struct route_table *rt, struct prefix_ipv4 *p)
{
+ struct route_node *rn;
+ struct ospf_route *or;
+
+ if (IS_DEBUG_OSPF_EVENT)
+ zlog_debug ("ospf_delete_discard_route(): "
+ "deleting %s/%d", inet_ntoa (p->prefix), p->prefixlen);
+
+ rn = route_node_lookup (rt, (struct prefix*)p);
+
+ if (rn == NULL)
+ {
+ if (IS_DEBUG_OSPF_EVENT)
+ zlog_debug("ospf_delete_discard_route(): no route found");
+ return;
+ }
+
+ or = rn->info;
+
+ if (or->path_type == OSPF_PATH_INTRA_AREA)
+ {
+ if (IS_DEBUG_OSPF_EVENT)
+ zlog_debug ("ospf_delete_discard_route(): "
+ "an intra-area route exists");
+ return;
+ }
+
+ if (or->type != OSPF_DESTINATION_DISCARD)
+ {
+ if (IS_DEBUG_OSPF_EVENT)
+ zlog_debug ("ospf_delete_discard_route(): "
+ "not a discard entry");
+ return;
+ }
+
+ /* free the route entry and the route node */
+ ospf_route_free (rn->info);
+
+ rn->info = NULL;
+ route_unlock_node (rn);
+ route_unlock_node (rn);
+
+ /* remove the discard entry from the rib */
ospf_zebra_delete_discard(p);
+
+ return;
}