From 3cd5108d828b5c6a0c4b0f28c984846750d3734b Mon Sep 17 00:00:00 2001 From: ckishimo Date: Wed, 5 Jan 2022 20:27:55 +0100 Subject: [PATCH] ospf6d: fix NSSA area-range command When an area-range command is applied in an ABR, the more specific prefixes need to be removed. r2# sh ipv6 ospf database AS Scoped Link State Database Type LSId AdvRouter Age SeqNum Payload ASE 0.0.0.1 10.254.254.2 53 80000001 :: ASE 0.0.0.2 10.254.254.2 51 80000001 2001:db8:1::/64 ASE 0.0.0.3 10.254.254.2 51 80000001 2001:db8:3::/64 ASE 0.0.0.4 10.254.254.2 51 80000001 2001:db8:2::/64 ASE 0.0.0.5 10.254.254.2 46 80000001 2001:db8:1::/64 ASE 0.0.0.6 10.254.254.2 46 80000001 2001:db8:3::/64 ASE 0.0.0.7 10.254.254.2 46 80000001 2001:db8:2::/64 ASE 0.0.0.8 10.254.254.2 41 80000001 2001:db8:3::/64 ASE 0.0.0.9 10.254.254.2 41 80000001 2001:db8:1000::1/128 <-- ** ASE 0.0.0.10 10.254.254.2 41 80000001 2001:db8:1000::2/128 <-- ** ASE 0.0.0.12 10.254.254.2 24 80000001 2001:db8:1000::/64 ASE 0.0.0.1 10.254.254.3 52 80000001 2001:db8:2::/64 Signed-off-by: ckishimo --- ospf6d/ospf6_nssa.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/ospf6d/ospf6_nssa.c b/ospf6d/ospf6_nssa.c index 7d85b32986..5c3d31dda8 100644 --- a/ospf6d/ospf6_nssa.c +++ b/ospf6d/ospf6_nssa.c @@ -613,7 +613,8 @@ struct ospf6_lsa *ospf6_translated_nssa_refresh(struct ospf6_area *area, return new; } -static void ospf6_abr_translate_nssa(struct ospf6_area *area, struct ospf6_lsa *lsa) +static void ospf6_abr_translate_nssa(struct ospf6_area *area, + struct ospf6_lsa *lsa) { /* Incoming Type-7 or later aggregated Type-7 * @@ -661,12 +662,37 @@ static void ospf6_abr_translate_nssa(struct ospf6_area *area, struct ospf6_lsa * return; } + /* Find the type-5 LSA in the area-range table */ + match = ospf6_route_lookup_bestmatch(&prefix, area->nssa_range_table); + if (match && CHECK_FLAG(match->flag, OSPF6_ROUTE_NSSA_RANGE)) { + if (prefix_same(&prefix, &match->prefix)) { + /* The prefix range is being removed, + * no need to refresh + */ + if + CHECK_FLAG(match->flag, OSPF6_ROUTE_REMOVE) + return; + } else { + if (!CHECK_FLAG(match->flag, OSPF6_ROUTE_REMOVE)) { + if (IS_OSPF6_DEBUG_NSSA) + zlog_debug( + "%s: LSA Id %pI4 suppressed by range %pFX of area %s", + __func__, &lsa->header->id, + &match->prefix, area->name); + /* LSA will be suppressed by area-range command, + * no need to refresh + */ + return; + } + } + } + /* Find the existing AS-External LSA for this prefix */ match = ospf6_route_lookup(&prefix, ospf6->route_table); if (match) { old = ospf6_lsdb_lookup(htons(OSPF6_LSTYPE_AS_EXTERNAL), - lsa->external_lsa_id, ospf6->router_id, - ospf6->lsdb); + lsa->external_lsa_id, ospf6->router_id, + ospf6->lsdb); } if (OSPF6_LSA_IS_MAXAGE(lsa)) {