diff --git a/ospf6d/ospf6_nssa.c b/ospf6d/ospf6_nssa.c index 1220c32783..53b45d6ca3 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 aggregated Type-7 * @@ -625,7 +626,7 @@ static void ospf6_abr_translate_nssa(struct ospf6_area *area, struct ospf6_lsa * * Later, any Unapproved Translated Type-5's are flushed/discarded */ - struct ospf6_lsa *old = NULL, *new = NULL; + struct ospf6_lsa *old = NULL; struct ospf6_as_external_lsa *nssa_lsa; struct prefix prefix; struct ospf6_route *match; @@ -661,11 +662,36 @@ 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->external_table); + match = ospf6_route_lookup(&prefix, ospf6->route_table); if (match) { - old = ospf6_lsdb_lookup(OSPF6_LSTYPE_AS_EXTERNAL, - match->path.origin.id, ospf6->router_id, + old = ospf6_lsdb_lookup(htons(OSPF6_LSTYPE_AS_EXTERNAL), + lsa->external_lsa_id, ospf6->router_id, ospf6->lsdb); } @@ -675,20 +701,15 @@ static void ospf6_abr_translate_nssa(struct ospf6_area *area, struct ospf6_lsa * return; } - if (old) { + if (old && !OSPF6_LSA_IS_MAXAGE(old)) { if (IS_OSPF6_DEBUG_NSSA) zlog_debug( - "%s : found old translated LSA Id %pI4, refreshing", + "%s : found old translated LSA Id %pI4, skip", __func__, &old->header->id); - /* refresh */ - new = ospf6_translated_nssa_refresh(area, lsa, old); - if (!new) { - if (IS_OSPF6_DEBUG_NSSA) - zlog_debug( - "%s : could not refresh translated LSA Id %pI4", - __func__, &old->header->id); - } + UNSET_FLAG(old->flag, OSPF6_LSA_UNAPPROVED); + return; + } else { /* no existing external route for this LSA Id * originate translated LSA diff --git a/tests/topotests/ospf6_topo2/test_ospf6_topo2.py b/tests/topotests/ospf6_topo2/test_ospf6_topo2.py index eb8561c404..d17aeda3ea 100644 --- a/tests/topotests/ospf6_topo2/test_ospf6_topo2.py +++ b/tests/topotests/ospf6_topo2/test_ospf6_topo2.py @@ -134,6 +134,7 @@ def build_topo(tgen): switch = tgen.add_switch("s4") switch.add_link(tgen.gears["r4"], nodeif="r4-stubnet") + def setup_module(mod): "Sets up the pytest environment" tgen = Topogen(build_topo, mod.__name__) @@ -585,10 +586,11 @@ def test_nssa_range(): logger.info("Expecting NSSA range to be added on r3") routes = { "2001:db8:1000::/64": { - "metricType":2, - "metricCost":20, - "metricCostE2":10, - }} + "metricType": 2, + "metricCost": 20, + "metricCostE2": 10, + } + } expect_ospfv3_routes("r3", routes, wait=30, type="external-2", detail=True) # Change the NSSA range cost. @@ -601,10 +603,11 @@ def test_nssa_range(): logger.info("Expecting NSSA range to be updated with new cost") routes = { "2001:db8:1000::/64": { - "metricType":2, - "metricCost":20, - "metricCostE2":1000, - }} + "metricType": 2, + "metricCost": 20, + "metricCostE2": 1000, + } + } expect_ospfv3_routes("r3", routes, wait=30, type="external-2", detail=True) # Configure the NSSA range to not be advertised. @@ -631,12 +634,12 @@ def test_nssa_range(): logger.info("Expecting previously summarized routes to be re-added") routes = { "2001:db8:1000::1/128": { - "metricType":2, - "metricCost":20, + "metricType": 2, + "metricCostE2": 20, }, "2001:db8:1000::2/128": { - "metricType":2, - "metricCost":20, + "metricType": 2, + "metricCostE2": 20, }, } expect_ospfv3_routes("r3", routes, wait=30, type="external-2", detail=True)