]> git.puffer.fish Git - matthieu/frr.git/commitdiff
ospf6d: Rename ospf6_is_router_abr to more accurately reflect what it does
authorDonald Sharp <sharpd@nvidia.com>
Thu, 10 Jun 2021 11:59:06 +0000 (07:59 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Thu, 10 Jun 2021 11:59:06 +0000 (07:59 -0400)
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 <sharpd@nvidia.com>
ospf6d/ospf6_abr.c
ospf6d/ospf6_abr.h
ospf6d/ospf6_area.c
ospf6d/ospf6_asbr.c
ospf6d/ospf6_intra.c
ospf6d/ospf6_nssa.c
ospf6d/ospf6_snmp.c
ospf6d/ospf6_spf.c
ospf6d/ospf6_top.c

index a43118cb21a2ae258aa753626eebcbd03beace2c..f289bf26b933279eb71250b2770d3b50bfb56296 100644 (file)
@@ -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 */
index 7c1ff4d38987a6c8629b29189a90cac6cc81f68c..a5f0f124b9421fa48d503820a3dc4590238ef0e3 100644 (file)
@@ -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);
index 92934d3764d04c051e51e3475e75eb5102a65011..91f83ac1baed95e383a766d84dd12175c22a0a7e 100644 (file)
@@ -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);
 
index e22e6560d097a20a0df0dc632cf6a8c476aa5e9b..83b1631713cc218b45430a94e863ff33247cd7db 100644 (file)
@@ -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));
index 524edd3fae3636e21e1f60b47342549266248856..bf7c59b9e7e7eadf8cc98fb63ec2118aa84b7877 100644 (file)
@@ -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);
index 4d9b0a19781176425b2756ec963408d51e79861f..dfae51cec15b5d289825f2569b2c2984d5db35bc 100644 (file)
@@ -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);
index dcf76c7038e6d50e9d30556377fdf3b3d65f3318..92922567e833215d84bb16e371ac70b22aab41cd 100644 (file)
@@ -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)
index b0a8f01bccfa6b3cfe7b609c6edc8a374c999b01..f995dd9393bb2c40a06d1582c4019db1d7ee874e 100644 (file)
@@ -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);
index 96bf3ef33f8292fc32447175a7651285af0c0641..4b17a78ef93028f3e71e67f5c8185350e3765122 100644 (file)
@@ -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);
        }