From ab1464ddb076c874a34c16339a966742e5ea6bad Mon Sep 17 00:00:00 2001 From: ckishimo Date: Mon, 28 Sep 2020 14:26:18 -0700 Subject: ospfd: flush type 5 when type 7 is removed When the ASBR stops announcing a prefix into the NSSA area, the LSA type 7 is removed from the area. However the ABR is refreshing the type 5 in its LSDB while removing the Type 7 LSA. Routers outside the area do not get an update. With the following topology: r1---r2---r3, with r3 being the ASBR announcing type 7 LSA: r3 configuration router ospf redistribute static network 10.0.23.0/24 area 1 area 1 nssa ! We stop announcing prefix 3.3.3.3 in the ASBR r3# conf r3(config)# router ospf r3(config-router)# no redistribute static r3(config-router)# r2 (ABR) r2# sh ip os database NSSA-external Link States (Area 0.0.0.1 [NSSA]) Link ID ADV Router Age Seq# CkSum Route 3.3.3.3 33.33.33.33 3600 0x8000002f 0x13be E2 3.3.3.3/32 [0x0] <-- flushed AS External Link States Link ID ADV Router Age Seq# CkSum Route 3.3.3.3 10.0.25.2 7 0x8000002f 0x73c7 E2 3.3.3.3/32 [0x0] <-- refreshed(?) With PR#7086 the LSA type 5 is flushed from the LSDB in r2 and the change is announced to routers outside the area (r1) r2# sh ip os da NSSA-external Link States (Area 0.0.0.1 [NSSA]) Link ID ADV Router Age Seq# CkSum Route 3.3.3.3 33.33.33.33 3600 0x80000002 0x6d91 E2 3.3.3.3/32 [0x0] <-- flushed AS External Link States Link ID ADV Router Age Seq# CkSum Route 3.3.3.3 10.0.25.2 3600 0x80000002 0xcd9a E2 3.3.3.3/32 [0x0] <-- flushed r1# sh ip os da AS External Link States Link ID ADV Router Age Seq# CkSum Route 3.3.3.3 10.0.25.2 3600 0x80000002 0xcd9a E2 3.3.3.3/32 [0x0] <-- flushed Unfortunately I just realized that with PR#7086 I'm introducing a new bug, as Type-5 LSA are not being refreshed when reaching MaxAge r2# sh ip os da NSSA-external Link States (Area 0.0.0.1 [NSSA]) Link ID ADV Router Age Seq# CkSum Route 3.3.3.3 33.33.33.33 35 0x80000002 0x6d91 E2 3.3.3.3/32 [0x0] <--- refreshed AS External Link States Link ID ADV Router Age Seq# CkSum Route 3.3.3.3 10.0.25.2 3600 0x80000002 0xcd9a E2 3.3.3.3/32 [0x0] <--- not refreshed! So this PR should fix the original issue and the bug introduced later, so when stopping redistribution in the ASBR, both type 5 and type 7 are flushed: r2# sh ip os da NSSA-external Link States (Area 0.0.0.1 [NSSA]) Link ID ADV Router Age Seq# CkSum Route 3.3.3.3 33.33.33.33 3600 0x80000002 0x6d91 E2 3.3.3.3/32 [0x0] AS External Link States Link ID ADV Router Age Seq# CkSum Route 3.3.3.3 10.0.25.2 3600 0x80000002 0xcd9a E2 3.3.3.3/32 [0x0] Routers outside the area are also notified r1# sh ip os da Link ID ADV Router Age Seq# CkSum Route 3.3.3.3 10.0.25.2 3600 0x80000002 0xcd9a E2 3.3.3.3/32 [0x0] Re-enabling redistribution, both LSA will be advertised again r3# conf r3(config)# router ospf r3(config-router)# no redistribute static r3(config-router)# redistribute static r3(config-router)# r2# sh ip os da NSSA-external Link States (Area 0.0.0.1 [NSSA]) Link ID ADV Router Age Seq# CkSum Route 3.3.3.3 33.33.33.33 19 0x80000001 0x6f90 E2 3.3.3.3/32 [0x0] AS External Link States Link ID ADV Router Age Seq# CkSum Route 3.3.3.3 10.0.25.2 11 0x80000001 0xcf99 E2 3.3.3.3/32 [0x0] and they are refreshed when reaching MaxAge NSSA-external Link States (Area 0.0.0.1 [NSSA]) Link ID ADV Router Age Seq# CkSum Route 3.3.3.3 33.33.33.33 10 0x80000002 0x6d91 E2 3.3.3.3/32 [0x0] <-- Seq 2 AS External Link States Link ID ADV Router Age Seq# CkSum Route 3.3.3.3 10.0.25.2 2 0x80000002 0xcd9a E2 3.3.3.3/32 [0x0] <-- Seq 2 Signed-off-by: ckishimo --- ospfd/ospf_abr.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'ospfd/ospf_abr.c') diff --git a/ospfd/ospf_abr.c b/ospfd/ospf_abr.c index 2131c8ee9..c59e19bb1 100644 --- a/ospfd/ospf_abr.c +++ b/ospfd/ospf_abr.c @@ -638,19 +638,23 @@ static int ospf_abr_translate_nssa(struct ospf_area *area, struct ospf_lsa *lsa) } /* try find existing AS-External LSA for this prefix */ - old = ospf_external_info_find_lsa(area->ospf, &p); - if (old) { - /* Do not continue if type 5 LSA not approved */ - if (!CHECK_FLAG(old->flags, OSPF_LSA_APPROVED)) { + if (CHECK_FLAG(lsa->flags, OSPF_LSA_IN_MAXAGE)) { + /* if type-7 is removed, remove old translated type-5 lsa */ + if (old) { + UNSET_FLAG(old->flags, OSPF_LSA_APPROVED); if (IS_DEBUG_OSPF_NSSA) zlog_debug( - "ospf_abr_translate_nssa(): LSA Id %s type 5 is not approved", + "ospf_abr_translate_nssa(): remove old translated LSA id %s", inet_ntoa(old->data->id)); - return 1; } + /* if type-7 is removed and type-5 does not exist, do not + * originate */ + return 1; + } + if (old && CHECK_FLAG(old->flags, OSPF_LSA_APPROVED)) { if (IS_DEBUG_OSPF_NSSA) zlog_debug( "ospf_abr_translate_nssa(): found old translated LSA Id %s, refreshing", -- cgit v1.2.3