diff options
| author | Igor Ryzhov <iryzhov@nfware.com> | 2021-03-29 14:47:43 +0300 |
|---|---|---|
| committer | Igor Ryzhov <iryzhov@nfware.com> | 2021-03-30 11:51:21 +0300 |
| commit | cbf32f74ef26de9c4b4eaa128b25d35d2c55b809 (patch) | |
| tree | 3784884b4e809eebb8b7df8cc0e911d75c858bfc /ospfd/ospf_interface.c | |
| parent | 45af60f0bbeadae78ff8f97ea638d3592e7605c9 (diff) | |
ospfd: fix counting of "ip ospf area" commands
Instead of trying to maintain if_ospf_cli_count, let's directly count
the number of configured interfaces when it is needed. Current approach
sometimes leads to an incorrect counter.
Fixes #8321.
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Diffstat (limited to 'ospfd/ospf_interface.c')
| -rw-r--r-- | ospfd/ospf_interface.c | 45 |
1 files changed, 19 insertions, 26 deletions
diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c index d494f0fbce..6829c4a347 100644 --- a/ospfd/ospf_interface.c +++ b/ospfd/ospf_interface.c @@ -1272,12 +1272,27 @@ void ospf_if_interface(struct interface *ifp) hook_call(ospf_if_update, ifp); } -static int ospf_ifp_create(struct interface *ifp) +uint32_t ospf_if_count_area_params(struct interface *ifp) { - struct ospf *ospf = NULL; struct ospf_if_params *params; struct route_node *rn; uint32_t count = 0; + + params = IF_DEF_PARAMS(ifp); + if (OSPF_IF_PARAM_CONFIGURED(params, if_area)) + count++; + + for (rn = route_top(IF_OIFS_PARAMS(ifp)); rn; rn = route_next(rn)) + if ((params = rn->info) + && OSPF_IF_PARAM_CONFIGURED(params, if_area)) + count++; + + return count; +} + +static int ospf_ifp_create(struct interface *ifp) +{ + struct ospf *ospf = NULL; struct ospf_if_info *oii; if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE)) @@ -1303,18 +1318,8 @@ static int ospf_ifp_create(struct interface *ifp) if (!ospf) return 0; - params = IF_DEF_PARAMS(ifp); - if (OSPF_IF_PARAM_CONFIGURED(params, if_area)) - count++; - - for (rn = route_top(IF_OIFS_PARAMS(ifp)); rn; rn = route_next(rn)) - if ((params = rn->info) && OSPF_IF_PARAM_CONFIGURED(params, if_area)) - count++; - - if (count > 0) { - ospf->if_ospf_cli_count += count; + if (ospf_if_count_area_params(ifp) > 0) ospf_interface_area_set(ospf, ifp); - } ospf_if_recalculate_output_cost(ifp); @@ -1382,9 +1387,7 @@ static int ospf_ifp_down(struct interface *ifp) static int ospf_ifp_destroy(struct interface *ifp) { struct ospf *ospf; - struct ospf_if_params *params; struct route_node *rn; - uint32_t count = 0; if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE)) zlog_debug( @@ -1397,18 +1400,8 @@ static int ospf_ifp_destroy(struct interface *ifp) ospf = ospf_lookup_by_vrf_id(ifp->vrf_id); if (ospf) { - params = IF_DEF_PARAMS(ifp); - if (OSPF_IF_PARAM_CONFIGURED(params, if_area)) - count++; - - for (rn = route_top(IF_OIFS_PARAMS(ifp)); rn; rn = route_next(rn)) - if ((params = rn->info) && OSPF_IF_PARAM_CONFIGURED(params, if_area)) - count++; - - if (count > 0) { - ospf->if_ospf_cli_count -= count; + if (ospf_if_count_area_params(ifp) > 0) ospf_interface_area_unset(ospf, ifp); - } } for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next(rn)) |
