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))
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);
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(
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))
extern void ospf_if_interface(struct interface *ifp);
+extern uint32_t ospf_if_count_area_params(struct interface *ifp);
+
DECLARE_HOOK(ospf_vl_add, (struct ospf_vl_data * vd), (vd));
DECLARE_HOOK(ospf_vl_delete, (struct ospf_vl_data * vd), (vd));
struct prefix_ipv4 p;
struct in_addr area_id;
int ret, format;
+ uint32_t count;
if (ospf->instance) {
vty_out(vty,
return CMD_WARNING_CONFIG_FAILED;
}
- if (ospf->if_ospf_cli_count > 0) {
+ count = ospf_count_area_params(ospf);
+ if (count > 0) {
vty_out(vty,
"Please remove all ip ospf area x.x.x.x commands first.\n");
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
"%s ospf vrf %s num of %u ip ospf area x config",
__func__, ospf->name ? ospf->name : "NIL",
- ospf->if_ospf_cli_count);
+ count);
return CMD_WARNING_CONFIG_FAILED;
}
if (count > 0) {
ospf = ospf_lookup_by_vrf_id(ifp->vrf_id);
- if (ospf) {
+ if (ospf)
ospf_interface_area_unset(ospf, ifp);
- ospf->if_ospf_cli_count -= count;
- }
}
return CMD_NOT_MY_INSTANCE;
params->if_area_id_fmt = format;
}
- if (ospf) {
+ if (ospf)
ospf_interface_area_set(ospf, ifp);
- ospf->if_ospf_cli_count++;
- }
return CMD_SUCCESS;
}
if (ospf) {
ospf_interface_area_unset(ospf, ifp);
- ospf->if_ospf_cli_count--;
ospf_area_check_free(ospf, area_id);
}
static void ospf_init(struct ospf *ospf)
{
- struct vrf *vrf;
- struct interface *ifp;
-
ospf_opaque_type11_lsa_init(ospf);
if (ospf->vrf_id != VRF_UNKNOWN)
ospf->oi_running = 1;
- /* Activate 'ip ospf area x' configured interfaces for given
- * vrf. Activate area on vrf x aware interfaces.
- * vrf_enable callback calls router_id_update which
- * internally will call ospf_if_update to trigger
- * network_run_state
- */
- vrf = vrf_lookup_by_id(ospf->vrf_id);
-
- FOR_ALL_INTERFACES (vrf, ifp) {
- 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++;
-
- if (count > 0) {
- ospf_interface_area_set(ospf, ifp);
- ospf->if_ospf_cli_count += count;
- }
- }
-
ospf_router_id_update(ospf);
}
return (vrf->info) ? (struct ospf *)vrf->info : NULL;
}
+uint32_t ospf_count_area_params(struct ospf *ospf)
+{
+ struct vrf *vrf;
+ struct interface *ifp;
+ uint32_t count = 0;
+
+ if (ospf->vrf_id != VRF_UNKNOWN) {
+ vrf = vrf_lookup_by_id(ospf->vrf_id);
+
+ FOR_ALL_INTERFACES (vrf, ifp) {
+ count += ospf_if_count_area_params(ifp);
+ }
+ }
+
+ return count;
+}
+
/* It should only be used when processing incoming info update from zebra.
* Other situations, it is not sufficient to lookup the ospf instance by
* vrf_name only without using the instance number.
/* Statistics for LSA used for new instantiation. */
uint32_t rx_lsa_count;
- /* Counter of "ip ospf area x.x.x.x" used
- * for mutual exclusion of network command under
- * router ospf or ip ospf area x under interface. */
- uint32_t if_ospf_cli_count;
-
struct route_table *distance_table;
/* Used during ospf instance going down send LSDB
extern struct ospf *ospf_lookup_by_inst_name(unsigned short instance,
const char *name);
extern struct ospf *ospf_lookup_by_vrf_id(vrf_id_t vrf_id);
+extern uint32_t ospf_count_area_params(struct ospf *ospf);
extern void ospf_finish(struct ospf *);
extern void ospf_process_refresh_data(struct ospf *ospf, bool reset);
extern void ospf_router_id_update(struct ospf *ospf);