summaryrefslogtreecommitdiff
path: root/ospf6d/ospf6_abr.c
diff options
context:
space:
mode:
Diffstat (limited to 'ospf6d/ospf6_abr.c')
-rw-r--r--ospf6d/ospf6_abr.c119
1 files changed, 80 insertions, 39 deletions
diff --git a/ospf6d/ospf6_abr.c b/ospf6d/ospf6_abr.c
index 8cfdf2642c..abcdb40547 100644
--- a/ospf6d/ospf6_abr.c
+++ b/ospf6d/ospf6_abr.c
@@ -160,35 +160,22 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
&& route->type != OSPF6_DEST_TYPE_RANGE
&& ((route->type != OSPF6_DEST_TYPE_ROUTER)
|| !CHECK_FLAG(route->path.router_bits, OSPF6_ROUTER_BIT_E))) {
-#if 0
- zlog_debug(
- "Route type is none of network, range nor ASBR, ignore");
-#endif
return 0;
}
/* AS External routes are never considered */
if (route->path.type == OSPF6_PATH_TYPE_EXTERNAL1
|| route->path.type == OSPF6_PATH_TYPE_EXTERNAL2) {
-#if 0
- zlog_debug("Path type is external, skip");
-#endif
return 0;
}
/* do not generate if the path's area is the same as target area */
if (route->path.area_id == area->area_id) {
-#if 0
- zlog_debug("The route is in the area itself, ignore");
-#endif
return 0;
}
/* do not generate if the nexthops belongs to the target area */
if (ospf6_abr_nexthops_belong_to_area(route, area)) {
-#if 0
- zlog_debug("The route's nexthop is in the same area, ignore");
-#endif
return 0;
}
@@ -770,6 +757,10 @@ void ospf6_abr_old_path_update(struct ospf6_route *old_route,
void ospf6_abr_old_route_remove(struct ospf6_lsa *lsa, struct ospf6_route *old,
struct ospf6_route_table *table)
{
+ if (IS_OSPF6_DEBUG_ABR)
+ zlog_debug("%s: route %pFX, paths %d", __func__, &old->prefix,
+ listcount(old->paths));
+
if (listcount(old->paths) > 1) {
struct listnode *anode, *anext, *nnode, *rnode, *rnext;
struct ospf6_path *o_path;
@@ -778,13 +769,15 @@ void ospf6_abr_old_route_remove(struct ospf6_lsa *lsa, struct ospf6_route *old,
for (ALL_LIST_ELEMENTS(old->paths, anode, anext, o_path)) {
if (o_path->origin.adv_router != lsa->header->adv_router
- && o_path->origin.id != lsa->header->id)
+ || o_path->origin.id != lsa->header->id)
continue;
for (ALL_LIST_ELEMENTS_RO(o_path->nh_list, nnode, nh)) {
for (ALL_LIST_ELEMENTS(old->nh_list,
rnode, rnext, rnh)) {
if (!ospf6_nexthop_is_same(rnh, nh))
continue;
+ if (IS_OSPF6_DEBUG_ABR)
+ zlog_debug("deleted nexthop");
listnode_delete(old->nh_list, rnh);
ospf6_nexthop_delete(rnh);
}
@@ -847,14 +840,16 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
bool old_entry_updated = false;
struct ospf6_path *path, *o_path, *ecmp_path;
struct listnode *anode;
+ bool add_route = false;
memset(&prefix, 0, sizeof(prefix));
if (lsa->header->type == htons(OSPF6_LSTYPE_INTER_PREFIX)) {
if (IS_OSPF6_DEBUG_EXAMIN(INTER_PREFIX)) {
is_debug++;
- zlog_debug("%s: Examin %s in area %s", __func__,
- lsa->name, oa->name);
+ zlog_debug("%s: LSA %s age %d in area %s", __func__,
+ lsa->name, ospf6_lsa_age_current(lsa),
+ oa->name);
}
prefix_lsa =
@@ -873,8 +868,9 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
} else if (lsa->header->type == htons(OSPF6_LSTYPE_INTER_ROUTER)) {
if (IS_OSPF6_DEBUG_EXAMIN(INTER_ROUTER)) {
is_debug++;
- zlog_debug("%s: Examin %s in area %s", __func__,
- lsa->name, oa->name);
+ zlog_debug("%s: LSA %s age %d in area %s", __func__,
+ lsa->name, ospf6_lsa_age_current(lsa),
+ oa->name);
}
router_lsa =
@@ -898,8 +894,12 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
/* Find existing route */
route = ospf6_route_lookup(&prefix, table);
- if (route)
+ if (route) {
ospf6_route_lock(route);
+ if (is_debug)
+ zlog_debug("%s: route %pFX, paths %d", __func__,
+ &prefix, listcount(route->paths));
+ }
while (route && ospf6_route_is_prefix(&prefix, route)) {
if (route->path.area_id == oa->area_id
&& route->path.origin.type == lsa->header->type
@@ -952,6 +952,7 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
return;
}
+
/* (2) if the LSA is self-originated, ignore */
if (lsa->header->adv_router == oa->ospf6->router_id) {
if (is_debug)
@@ -1026,8 +1027,8 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
|| !CHECK_FLAG(abr_entry->path.router_bits, OSPF6_ROUTER_BIT_B)) {
if (is_debug)
zlog_debug(
- "%s: ABR router entry does not exist, ignore",
- __func__);
+ "%s: ABR router entry %pFX does not exist, ignore",
+ __func__, &abr_prefix);
if (old) {
if (old->type == OSPF6_DEST_TYPE_ROUTER &&
oa->intra_brouter_calc) {
@@ -1040,7 +1041,7 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
zlog_debug(
"%s: remove old entry: %s %p ",
__func__, buf, (void *)old);
- ospf6_route_remove(old, table);
+ ospf6_abr_old_route_remove(lsa, old, table);
}
}
return;
@@ -1104,7 +1105,11 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
are identical.
*/
old = ospf6_route_lookup(&prefix, table);
-
+ if (old) {
+ if (is_debug)
+ zlog_debug("%s: found old route %pFX, paths %d",
+ __func__, &prefix, listcount(old->paths));
+ }
for (old_route = old; old_route; old_route = old_route->next) {
if (!ospf6_route_is_same(old_route, route) ||
(old_route->type != route->type) ||
@@ -1186,7 +1191,7 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
"%s: Update route: %s %p old cost %u new cost %u nh %u",
__func__, buf, (void *)old_route,
old_route->path.cost, route->path.cost,
- listcount(route->nh_list));
+ listcount(old_route->nh_list));
/* For Inter-Prefix route: Update RIB/FIB,
* For Inter-Router trigger summary update
@@ -1199,10 +1204,19 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
break;
}
+ /* If the old entry is not updated and old entry not found or old entry
+ * does not match with the new entry then add the new route
+ */
if (old_entry_updated == false) {
+ if ((old == NULL) || (old->type != route->type)
+ || (old->path.type != route->path.type))
+ add_route = true;
+ }
+
+ if (add_route) {
if (is_debug) {
zlog_debug(
- "%s: Install route: %s cost %u nh %u adv_router %pI4",
+ "%s: Install new route: %s cost %u nh %u adv_router %pI4",
__func__, buf, route->path.cost,
listcount(route->nh_list),
&route->path.origin.adv_router);
@@ -1296,7 +1310,9 @@ static char *ospf6_inter_area_prefix_lsa_get_prefix_str(struct ospf6_lsa *lsa,
}
static int ospf6_inter_area_prefix_lsa_show(struct vty *vty,
- struct ospf6_lsa *lsa)
+ struct ospf6_lsa *lsa,
+ json_object *json_obj,
+ bool use_json)
{
struct ospf6_inter_prefix_lsa *prefix_lsa;
char buf[INET6_ADDRSTRLEN];
@@ -1304,16 +1320,29 @@ static int ospf6_inter_area_prefix_lsa_show(struct vty *vty,
prefix_lsa = (struct ospf6_inter_prefix_lsa *)OSPF6_LSA_HEADER_END(
lsa->header);
- vty_out(vty, " Metric: %lu\n",
- (unsigned long)OSPF6_ABR_SUMMARY_METRIC(prefix_lsa));
+ if (use_json) {
+ json_object_int_add(
+ json_obj, "metric",
+ (unsigned long)OSPF6_ABR_SUMMARY_METRIC(prefix_lsa));
+ ospf6_prefix_options_printbuf(prefix_lsa->prefix.prefix_options,
+ buf, sizeof(buf));
+ json_object_string_add(json_obj, "prefixOptions", buf);
+ json_object_string_add(
+ json_obj, "prefix",
+ ospf6_inter_area_prefix_lsa_get_prefix_str(
+ lsa, buf, sizeof(buf), 0));
+ } else {
+ vty_out(vty, " Metric: %lu\n",
+ (unsigned long)OSPF6_ABR_SUMMARY_METRIC(prefix_lsa));
- ospf6_prefix_options_printbuf(prefix_lsa->prefix.prefix_options, buf,
- sizeof(buf));
- vty_out(vty, " Prefix Options: %s\n", buf);
+ ospf6_prefix_options_printbuf(prefix_lsa->prefix.prefix_options,
+ buf, sizeof(buf));
+ vty_out(vty, " Prefix Options: %s\n", buf);
- vty_out(vty, " Prefix: %s\n",
- ospf6_inter_area_prefix_lsa_get_prefix_str(lsa, buf,
- sizeof(buf), 0));
+ vty_out(vty, " Prefix: %s\n",
+ ospf6_inter_area_prefix_lsa_get_prefix_str(
+ lsa, buf, sizeof(buf), 0));
+ }
return 0;
}
@@ -1338,7 +1367,9 @@ static char *ospf6_inter_area_router_lsa_get_prefix_str(struct ospf6_lsa *lsa,
}
static int ospf6_inter_area_router_lsa_show(struct vty *vty,
- struct ospf6_lsa *lsa)
+ struct ospf6_lsa *lsa,
+ json_object *json_obj,
+ bool use_json)
{
struct ospf6_inter_router_lsa *router_lsa;
char buf[64];
@@ -1347,12 +1378,22 @@ static int ospf6_inter_area_router_lsa_show(struct vty *vty,
lsa->header);
ospf6_options_printbuf(router_lsa->options, buf, sizeof(buf));
- vty_out(vty, " Options: %s\n", buf);
- vty_out(vty, " Metric: %lu\n",
- (unsigned long)OSPF6_ABR_SUMMARY_METRIC(router_lsa));
+ if (use_json) {
+ json_object_string_add(json_obj, "options", buf);
+ json_object_int_add(
+ json_obj, "metric",
+ (unsigned long)OSPF6_ABR_SUMMARY_METRIC(router_lsa));
+ } else {
+ vty_out(vty, " Options: %s\n", buf);
+ vty_out(vty, " Metric: %lu\n",
+ (unsigned long)OSPF6_ABR_SUMMARY_METRIC(router_lsa));
+ }
inet_ntop(AF_INET, &router_lsa->router_id, buf, sizeof(buf));
- vty_out(vty, " Destination Router ID: %s\n", buf);
+ if (use_json)
+ json_object_string_add(json_obj, "destinationRouterId", buf);
+ else
+ vty_out(vty, " Destination Router ID: %s\n", buf);
return 0;
}