From 0c293b92eeefeb37203fb0e8565c77a77fc189b0 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Thu, 19 Aug 2021 12:14:47 -0300 Subject: [PATCH] ospf6d: do not allow an area to be stub and NSSA at the same time That should not be allowed under any circumstance. Signed-off-by: Renato Westphal --- ospf6d/ospf6_area.c | 7 ++++++- ospf6d/ospf6_area.h | 1 + ospf6d/ospf6_nssa.c | 5 ++++- ospf6d/ospf6_nssa.h | 1 + 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ospf6d/ospf6_area.c b/ospf6d/ospf6_area.c index 0f1f0612250b..098132b1f6c0 100644 --- a/ospf6d/ospf6_area.c +++ b/ospf6d/ospf6_area.c @@ -189,6 +189,9 @@ static void ospf6_area_stub_update(struct ospf6_area *area) static int ospf6_area_stub_set(struct ospf6 *ospf6, struct ospf6_area *area) { if (!IS_AREA_STUB(area)) { + /* Disable NSSA first. */ + ospf6_area_nssa_unset(ospf6, area); + SET_FLAG(area->flag, OSPF6_AREA_STUB); ospf6_area_stub_update(area); } @@ -196,7 +199,7 @@ static int ospf6_area_stub_set(struct ospf6 *ospf6, struct ospf6_area *area) return 1; } -static void ospf6_area_stub_unset(struct ospf6 *ospf6, struct ospf6_area *area) +void ospf6_area_stub_unset(struct ospf6 *ospf6, struct ospf6_area *area) { if (IS_AREA_STUB(area)) { UNSET_FLAG(area->flag, OSPF6_AREA_STUB); @@ -1266,6 +1269,8 @@ DEFUN(ospf6_area_nssa, ospf6_area_nssa_cmd, return CMD_WARNING_CONFIG_FAILED; } + ospf6_area_no_summary_unset(ospf6, area); + return CMD_SUCCESS; } diff --git a/ospf6d/ospf6_area.h b/ospf6d/ospf6_area.h index dd4d019015ca..b2a275d745be 100644 --- a/ospf6d/ospf6_area.h +++ b/ospf6d/ospf6_area.h @@ -154,6 +154,7 @@ extern void ospf6_area_delete(struct ospf6_area *); extern struct ospf6_area *ospf6_area_lookup(uint32_t, struct ospf6 *); extern struct ospf6_area *ospf6_area_lookup_by_area_id(uint32_t area_id); +extern void ospf6_area_stub_unset(struct ospf6 *ospf6, struct ospf6_area *area); extern void ospf6_area_enable(struct ospf6_area *); extern void ospf6_area_disable(struct ospf6_area *); diff --git a/ospf6d/ospf6_nssa.c b/ospf6d/ospf6_nssa.c index cda92054a2bb..10b7d2d9f65a 100644 --- a/ospf6d/ospf6_nssa.c +++ b/ospf6d/ospf6_nssa.c @@ -1198,7 +1198,7 @@ static void ospf6_check_and_originate_type7_lsa(struct ospf6_area *area) } -static void ospf6_area_nssa_update(struct ospf6_area *area) +void ospf6_area_nssa_update(struct ospf6_area *area) { if (IS_AREA_NSSA(area)) { OSPF6_OPT_CLEAR(area->options, OSPF6_OPT_E); @@ -1246,6 +1246,9 @@ int ospf6_area_nssa_set(struct ospf6 *ospf6, struct ospf6_area *area) { if (!IS_AREA_NSSA(area)) { + /* Disable stub first. */ + ospf6_area_stub_unset(ospf6, area); + SET_FLAG(area->flag, OSPF6_AREA_NSSA); if (IS_OSPF6_DEBUG_NSSA) zlog_debug("area %s nssa set", area->name); diff --git a/ospf6d/ospf6_nssa.h b/ospf6d/ospf6_nssa.h index a171d76d4413..454bdd7fe2eb 100644 --- a/ospf6d/ospf6_nssa.h +++ b/ospf6d/ospf6_nssa.h @@ -61,6 +61,7 @@ extern struct ospf6_lsa *ospf6_translated_nssa_originate(struct ospf6_area *, extern void ospf6_asbr_nssa_redist_task(struct ospf6 *ospf6); extern void ospf6_schedule_abr_task(struct ospf6 *ospf6); +extern void ospf6_area_nssa_update(struct ospf6_area *area); void ospf6_asbr_prefix_readvertise(struct ospf6 *ospf6); extern void ospf6_nssa_lsa_originate(struct ospf6_route *route, struct ospf6_area *area);