summaryrefslogtreecommitdiff
path: root/ospfd/ospf_interface.c
diff options
context:
space:
mode:
Diffstat (limited to 'ospfd/ospf_interface.c')
-rw-r--r--ospfd/ospf_interface.c45
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))