From 4e0702dc746a0dbf8c0a221b3ab7e15e12f21d05 Mon Sep 17 00:00:00 2001 From: Mobashshera Rasool Date: Mon, 9 Aug 2021 04:24:32 -0700 Subject: [PATCH 1/2] ospf6d: Remove assert and fix LSA removal in ASBR summarisation Fix: 1. The assert at line ospf6_asbr.c:2849 is not required. 2. When Individual LSAs are present and summarisation is configured we need to remove such LSAs and originate the summarised ones. Signed-off-by: Mobashshera Rasool --- ospf6d/ospf6_asbr.c | 78 +++++++++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 35 deletions(-) diff --git a/ospf6d/ospf6_asbr.c b/ospf6d/ospf6_asbr.c index 165e409eed..0762425a1f 100644 --- a/ospf6d/ospf6_asbr.c +++ b/ospf6d/ospf6_asbr.c @@ -2715,33 +2715,13 @@ void ospf6_fill_aggr_route_details(struct ospf6 *ospf6, rt_aggr->path.origin.id = htonl(aggr->id); } -static void ospf6_originate_new_aggr_lsa(struct ospf6 *ospf6, - struct ospf6_external_aggr_rt *aggr) +static void +ospf6_summary_add_aggr_route_and_blackhole(struct ospf6 *ospf6, + struct ospf6_external_aggr_rt *aggr) { - - struct prefix prefix_id; - struct route_node *node; - struct ospf6_lsa *lsa = NULL; struct ospf6_route *rt_aggr; struct ospf6_external_info *info; - if (IS_OSPF6_DEBUG_AGGR) - zlog_debug("%s: Originate new aggregate route(%pFX)", __func__, - &aggr->p); - - aggr->id = ospf6->external_id++; - /* create/update binding in external_id_table */ - prefix_id.family = AF_INET; - prefix_id.prefixlen = 32; - prefix_id.u.prefix4.s_addr = htonl(aggr->id); - node = route_node_get(ospf6->external_id_table, &prefix_id); - node->info = aggr; - - if (IS_OSPF6_DEBUG_AGGR) - zlog_debug( - "Advertise AS-External Id:%pI4 prefix %pFX metric %u", - &prefix_id.u.prefix4, &aggr->p, aggr->metric); - /* Create summary route and save it. */ rt_aggr = ospf6_route_create(ospf6); rt_aggr->type = OSPF6_DEST_TYPE_NETWORK; @@ -2761,9 +2741,37 @@ static void ospf6_originate_new_aggr_lsa(struct ospf6 *ospf6, ospf6_add_route_nexthop_blackhole(rt_aggr); ospf6_zebra_route_update_add(rt_aggr, ospf6); +} + +static void ospf6_originate_new_aggr_lsa(struct ospf6 *ospf6, + struct ospf6_external_aggr_rt *aggr) +{ + struct prefix prefix_id; + struct route_node *node; + struct ospf6_lsa *lsa = NULL; + + if (IS_OSPF6_DEBUG_AGGR) + zlog_debug("%s: Originate new aggregate route(%pFX)", __func__, + &aggr->p); + + aggr->id = ospf6->external_id++; + + /* create/update binding in external_id_table */ + prefix_id.family = AF_INET; + prefix_id.prefixlen = 32; + prefix_id.u.prefix4.s_addr = htonl(aggr->id); + node = route_node_get(ospf6->external_id_table, &prefix_id); + node->info = aggr; + + if (IS_OSPF6_DEBUG_AGGR) + zlog_debug( + "Advertise AS-External Id:%pI4 prefix %pFX metric %u", + &prefix_id.u.prefix4, &aggr->p, aggr->metric); + + ospf6_summary_add_aggr_route_and_blackhole(ospf6, aggr); /* Originate summary LSA */ - lsa = ospf6_originate_type5_type7_lsas(rt_aggr, ospf6); + lsa = ospf6_originate_type5_type7_lsas(aggr->route, ospf6); if (lsa) { if (IS_OSPF6_DEBUG_AGGR) zlog_debug("%s: Set the origination bit for aggregator", @@ -2842,12 +2850,10 @@ ospf6_originate_summary_lsa(struct ospf6 *ospf6, /* The key for ID field is a running number and not prefix */ info = rt->route_option; assert(info); - if (info->id) { + if (info->id) lsa = ospf6_lsdb_lookup(htons(OSPF6_LSTYPE_AS_EXTERNAL), htonl(info->id), ospf6->router_id, ospf6->lsdb); - assert(lsa); - } aggr_lsa = ospf6_lsdb_lookup(htons(OSPF6_LSTYPE_AS_EXTERNAL), htonl(aggr->id), ospf6->router_id, ospf6->lsdb); @@ -2939,20 +2945,22 @@ ospf6_originate_summary_lsa(struct ospf6 *ospf6, /* If the external route prefix same as aggregate route * and if external route is already originated as TYPE-5 - * then it need to be refreshed and originate bit should - * be set. + * then just update the aggr info and remove the route info */ if (lsa && prefix_same(&aggr->p, &rt->prefix)) { if (IS_OSPF6_DEBUG_AGGR) - zlog_debug("%s: External route prefix is same as aggr so refreshing LSA(%pFX)", - __PRETTY_FUNCTION__, - &aggr->p); + zlog_debug( + "%s: Route prefix is same as aggr so no need to re-originate LSA(%pFX)", + __PRETTY_FUNCTION__, &aggr->p); - THREAD_OFF(lsa->refresh); - thread_add_event(master, ospf6_lsa_refresh, lsa, 0, - &lsa->refresh); aggr->id = info->id; + info->id = 0; + rt->path.origin.id = 0; + + ospf6_summary_add_aggr_route_and_blackhole(ospf6, aggr); + SET_FLAG(aggr->aggrflags, OSPF6_EXTERNAL_AGGRT_ORIGINATED); + return; } From 523232c5c5a073e2c8c3f1143ff12732b0931ea1 Mon Sep 17 00:00:00 2001 From: Mobashshera Rasool Date: Mon, 9 Aug 2021 04:57:11 -0700 Subject: [PATCH 2/2] ospf6d: Remove Type-7 LSA when Type-5 LSA is removed Fix: When summarised Type-5 LSA is removed, the corresponding Type-7 LSAs also need to be removed from area. Signed-off-by: Mobashshera Rasool --- ospf6d/ospf6_asbr.c | 16 ---------------- ospf6d/ospf6_flood.c | 19 ++++++++++++++++++- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/ospf6d/ospf6_asbr.c b/ospf6d/ospf6_asbr.c index 0762425a1f..2d70f816ec 100644 --- a/ospf6d/ospf6_asbr.c +++ b/ospf6d/ospf6_asbr.c @@ -1514,8 +1514,6 @@ static void ospf6_asbr_external_lsa_remove_by_id(struct ospf6 *ospf6, uint32_t id) { struct ospf6_lsa *lsa; - struct ospf6_area *oa; - struct listnode *lnode; lsa = ospf6_lsdb_lookup(htons(OSPF6_LSTYPE_AS_EXTERNAL), htonl(id), ospf6->router_id, ospf6->lsdb); @@ -1524,20 +1522,6 @@ static void ospf6_asbr_external_lsa_remove_by_id(struct ospf6 *ospf6, ospf6_external_lsa_purge(ospf6, lsa); - /* Delete the NSSA LSA */ - for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, lnode, oa)) { - lsa = ospf6_lsdb_lookup(htons(OSPF6_LSTYPE_TYPE_7), - htonl(id), ospf6->router_id, - oa->lsdb); - if (lsa) { - if (IS_OSPF6_DEBUG_ASBR) - zlog_debug("withdraw type 7 lsa, LS ID: %u", - htonl(id)); - - ospf6_lsa_purge(lsa); - } - } - } static void diff --git a/ospf6d/ospf6_flood.c b/ospf6d/ospf6_flood.c index 3d52597161..5a4dd72b66 100644 --- a/ospf6d/ospf6_flood.c +++ b/ospf6d/ospf6_flood.c @@ -169,9 +169,26 @@ void ospf6_remove_id_from_external_id_table(struct ospf6 *ospf6, void ospf6_external_lsa_purge(struct ospf6 *ospf6, struct ospf6_lsa *lsa) { + uint32_t id = lsa->header->id; + struct ospf6_area *oa; + struct listnode *lnode; + ospf6_lsa_purge(lsa); - ospf6_remove_id_from_external_id_table(ospf6, lsa->header->id); + ospf6_remove_id_from_external_id_table(ospf6, id); + + /* Delete the corresponding NSSA LSA */ + for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, lnode, oa)) { + lsa = ospf6_lsdb_lookup(htons(OSPF6_LSTYPE_TYPE_7), id, + ospf6->router_id, oa->lsdb); + if (lsa) { + if (IS_OSPF6_DEBUG_NSSA) + zlog_debug("withdraw type 7 lsa, LS ID: %u", + htonl(id)); + + ospf6_lsa_purge(lsa); + } + } } void ospf6_lsa_purge(struct ospf6_lsa *lsa)