From 95b3f03d89101fa812a8e4648f5745e2d532037b Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 10 Jun 2021 07:59:06 -0400 Subject: [PATCH] ospf6d: Rename ospf6_is_router_abr to more accurately reflect what it does The ospf6_is_router_abr is checking to see if ospfv3 is an abr router and also setting values. Let's rename it too `ospf6_check_and_set_router_abr` to more accurately reflect what it is doing. Additionally fix coverity #1505176 where we were not checking the return value of ospf6_is_router_abr like we did every other time. In this case we don't care about the return value so indicate that we do not. Signed-off-by: Donald Sharp --- ospf6d/ospf6_abr.c | 8 ++++---- ospf6d/ospf6_abr.h | 2 +- ospf6d/ospf6_area.c | 4 ++-- ospf6d/ospf6_asbr.c | 2 +- ospf6d/ospf6_intra.c | 2 +- ospf6d/ospf6_nssa.c | 12 ++++++------ ospf6d/ospf6_snmp.c | 7 ++++--- ospf6d/ospf6_spf.c | 4 ++-- ospf6d/ospf6_top.c | 2 +- 9 files changed, 22 insertions(+), 21 deletions(-) diff --git a/ospf6d/ospf6_abr.c b/ospf6d/ospf6_abr.c index a43118cb21..f289bf26b9 100644 --- a/ospf6d/ospf6_abr.c +++ b/ospf6d/ospf6_abr.c @@ -53,7 +53,7 @@ unsigned char conf_debug_ospf6_abr; -int ospf6_is_router_abr(struct ospf6 *o) +bool ospf6_check_and_set_router_abr(struct ospf6 *o) { struct listnode *node; struct ospf6_area *oa; @@ -74,12 +74,12 @@ int ospf6_is_router_abr(struct ospf6 *o) if (IS_OSPF6_DEBUG_ABR) zlog_debug("%s : set flag OSPF6_FLAG_ABR", __func__); SET_FLAG(o->flag, OSPF6_FLAG_ABR); - return 1; + return true; } else { if (IS_OSPF6_DEBUG_ABR) zlog_debug("%s : reset flag OSPF6_FLAG_ABR", __func__); UNSET_FLAG(o->flag, OSPF6_FLAG_ABR); - return 0; + return false; } } @@ -1359,7 +1359,7 @@ void ospf6_abr_reexport(struct ospf6_area *oa) struct ospf6_route *route; /* if not a ABR return success */ - if (!ospf6_is_router_abr(oa->ospf6)) + if (!ospf6_check_and_set_router_abr(oa->ospf6)) return; /* Redo summaries if required */ diff --git a/ospf6d/ospf6_abr.h b/ospf6d/ospf6_abr.h index 7c1ff4d389..a5f0f124b9 100644 --- a/ospf6d/ospf6_abr.h +++ b/ospf6d/ospf6_abr.h @@ -58,7 +58,7 @@ struct ospf6_inter_router_lsa { #define OSPF6_ABR_RANGE_CLEAR_COST(range) (range->path.cost = OSPF_AREA_RANGE_COST_UNSPEC) #define IS_OSPF6_ABR(o) ((o)->flag & OSPF6_FLAG_ABR) -extern int ospf6_is_router_abr(struct ospf6 *o); +extern bool ospf6_check_and_set_router_abr(struct ospf6 *o); extern void ospf6_abr_enable_area(struct ospf6_area *oa); extern void ospf6_abr_disable_area(struct ospf6_area *oa); diff --git a/ospf6d/ospf6_area.c b/ospf6d/ospf6_area.c index 92934d3764..91f83ac1ba 100644 --- a/ospf6d/ospf6_area.c +++ b/ospf6d/ospf6_area.c @@ -538,7 +538,7 @@ DEFUN (area_range, ospf6_route_add(range, oa->range_table); } - if (ospf6_is_router_abr(ospf6)) { + if (ospf6_check_and_set_router_abr(ospf6)) { /* Redo summaries if required */ ospf6_abr_prefix_resummarize(ospf6); } @@ -584,7 +584,7 @@ DEFUN (no_area_range, return CMD_SUCCESS; } - if (ospf6_is_router_abr(oa->ospf6)) { + if (ospf6_check_and_set_router_abr(oa->ospf6)) { /* Blow away the aggregated LSA and route */ SET_FLAG(range->flag, OSPF6_ROUTE_REMOVE); diff --git a/ospf6d/ospf6_asbr.c b/ospf6d/ospf6_asbr.c index e22e6560d0..83b1631713 100644 --- a/ospf6d/ospf6_asbr.c +++ b/ospf6d/ospf6_asbr.c @@ -687,7 +687,7 @@ void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa, zlog_debug("%s: Withdraw AS-External route for %s", __func__, lsa->name); - if (ospf6_is_router_abr(ospf6)) + if (ospf6_check_and_set_router_abr(ospf6)) oa = ospf6->backbone; else oa = listgetdata(listhead(ospf6->area_list)); diff --git a/ospf6d/ospf6_intra.c b/ospf6d/ospf6_intra.c index 524edd3fae..bf7c59b9e7 100644 --- a/ospf6d/ospf6_intra.c +++ b/ospf6d/ospf6_intra.c @@ -182,7 +182,7 @@ static void ospf6_router_lsa_options_set(struct ospf6_area *oa, OSPF6_OPT_CLEAR_ALL(router_lsa->options); memcpy(router_lsa->options, oa->options, 3); - if (ospf6_is_router_abr(oa->ospf6)) + if (ospf6_check_and_set_router_abr(oa->ospf6)) SET_FLAG(router_lsa->bits, OSPF6_ROUTER_BIT_B); else UNSET_FLAG(router_lsa->bits, OSPF6_ROUTER_BIT_B); diff --git a/ospf6d/ospf6_nssa.c b/ospf6d/ospf6_nssa.c index 4d9b0a1978..dfae51cec1 100644 --- a/ospf6d/ospf6_nssa.c +++ b/ospf6d/ospf6_nssa.c @@ -1093,7 +1093,7 @@ static int ospf6_abr_task_timer(struct thread *thread) if (IS_OSPF6_DEBUG_ABR) zlog_debug("Running ABR task on timer"); - ospf6_is_router_abr(ospf6); + (void)ospf6_check_and_set_router_abr(ospf6); ospf6_abr_nssa_check_status(ospf6); ospf6_abr_task(ospf6); /* if nssa-abr, then scan Type-7 LSDB */ @@ -1137,7 +1137,7 @@ static void ospf6_nssa_flush_area(struct ospf6_area *area) SET_FLAG(lsa->flag, OSPF6_LSA_FLUSH); ospf6_flood(NULL, lsa); /* Flush the translated LSA */ - if (ospf6_is_router_abr(ospf6)) { + if (ospf6_check_and_set_router_abr(ospf6)) { type = htons(OSPF6_LSTYPE_AS_EXTERNAL); type5 = ospf6_lsdb_lookup( htons(type), lsa->external_lsa_id, @@ -1158,7 +1158,7 @@ static void ospf6_area_nssa_update(struct ospf6_area *area) struct ospf6_route *route; if (IS_AREA_NSSA(area)) { - if (!ospf6_is_router_abr(area->ospf6)) + if (!ospf6_check_and_set_router_abr(area->ospf6)) OSPF6_OPT_CLEAR(area->options, OSPF6_OPT_E); area->ospf6->anyNSSA++; OSPF6_OPT_SET(area->options, OSPF6_OPT_N); @@ -1167,7 +1167,7 @@ static void ospf6_area_nssa_update(struct ospf6_area *area) if (IS_OSPF6_DEBUG_ORIGINATE(ROUTER)) zlog_debug("Normal area for if %s", area->name); OSPF6_OPT_CLEAR(area->options, OSPF6_OPT_N); - if (ospf6_is_router_abr(area->ospf6)) + if (ospf6_check_and_set_router_abr(area->ospf6)) OSPF6_OPT_SET(area->options, OSPF6_OPT_E); area->ospf6->anyNSSA--; area->NSSATranslatorState = OSPF6_NSSA_TRANSLATE_DISABLED; @@ -1178,7 +1178,7 @@ static void ospf6_area_nssa_update(struct ospf6_area *area) OSPF6_ROUTER_LSA_SCHEDULE(area); /* Check if router is ABR */ - if (ospf6_is_router_abr(area->ospf6)) { + if (ospf6_check_and_set_router_abr(area->ospf6)) { if (IS_OSPF6_DEBUG_NSSA) zlog_debug("Router is ABR area %s", area->name); ospf6_schedule_abr_task(area->ospf6); @@ -1353,7 +1353,7 @@ void ospf6_abr_check_translate_nssa(struct ospf6_area *area, lsa->external_lsa_id, ospf6->router_id, ospf6->lsdb); - if (ospf6_is_router_abr(ospf6) && (type5 == NULL)) { + if (ospf6_check_and_set_router_abr(ospf6) && (type5 == NULL)) { if (IS_OSPF6_DEBUG_NSSA) zlog_debug("%s : Originating type5 LSA", __func__); ospf6_lsa_translated_nssa_new(area, lsa); diff --git a/ospf6d/ospf6_snmp.c b/ospf6d/ospf6_snmp.c index dcf76c7038..92922567e8 100644 --- a/ospf6d/ospf6_snmp.c +++ b/ospf6d/ospf6_snmp.c @@ -664,9 +664,10 @@ static uint8_t *ospfv3GeneralGroup(struct variable *v, oid *name, return SNMP_INTEGER(3); case OSPFv3AREABDRRTRSTATUS: if (ospf6) - return SNMP_INTEGER(ospf6_is_router_abr(ospf6) - ? SNMP_TRUE - : SNMP_FALSE); + return SNMP_INTEGER( + ospf6_check_and_set_router_abr(ospf6) + ? SNMP_TRUE + : SNMP_FALSE); return SNMP_INTEGER(SNMP_FALSE); case OSPFv3ASBDRRTRSTATUS: if (ospf6) diff --git a/ospf6d/ospf6_spf.c b/ospf6d/ospf6_spf.c index b0a8f01bcc..f995dd9393 100644 --- a/ospf6d/ospf6_spf.c +++ b/ospf6d/ospf6_spf.c @@ -605,7 +605,7 @@ static int ospf6_spf_calculation_thread(struct thread *t) monotime(&start); ospf6->ts_spf = start; - if (ospf6_is_router_abr(ospf6)) + if (ospf6_check_and_set_router_abr(ospf6)) ospf6_abr_range_reset_cost(ospf6); for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, node, oa)) { @@ -645,7 +645,7 @@ static int ospf6_spf_calculation_thread(struct thread *t) /* External LSA calculation */ ospf6_ase_calculate_timer_add(ospf6); - if (ospf6_is_router_abr(ospf6)) + if (ospf6_check_and_set_router_abr(ospf6)) ospf6_abr_defaults_to_stub(ospf6); monotime(&end); diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c index 96bf3ef33f..4b17a78ef9 100644 --- a/ospf6d/ospf6_top.c +++ b/ospf6d/ospf6_top.c @@ -948,7 +948,7 @@ DEFUN (ospf6_interface_area, ospf6_interface_enable(oi); /* If the router is ABR, originate summary routes */ - if (ospf6_is_router_abr(ospf6)) { + if (ospf6_check_and_set_router_abr(ospf6)) { ospf6_abr_enable_area(oa); ospf6_schedule_abr_task(oa->ospf6); } -- 2.39.5