mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-15 18:56:40 +00:00
ospfd: don't initialize ospf every time "router ospf" is used
Move ospf initialization to the actual place where it is created. We don't need to do that every time "router ospf" is entered. Also remove a couple of useless checks that can never be true. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
This commit is contained in:
parent
cbf1568110
commit
0549eeda3d
@ -213,9 +213,6 @@ DEFUN_NOSH (router_ospf,
|
||||
struct ospf *ospf = NULL;
|
||||
int ret = CMD_SUCCESS;
|
||||
unsigned short instance = 0;
|
||||
struct vrf *vrf = NULL;
|
||||
struct route_node *rn;
|
||||
struct interface *ifp;
|
||||
|
||||
ospf = ospf_cmd_lookup_ospf(vty, argv, argc, 1, &instance);
|
||||
if (!ospf)
|
||||
@ -227,46 +224,12 @@ DEFUN_NOSH (router_ospf,
|
||||
VTY_PUSH_CONTEXT_NULL(OSPF_NODE);
|
||||
ret = CMD_NOT_MY_INSTANCE;
|
||||
} else {
|
||||
if (ospf->vrf_id != VRF_UNKNOWN)
|
||||
ospf->oi_running = 1;
|
||||
if (IS_DEBUG_OSPF_EVENT)
|
||||
zlog_debug(
|
||||
"Config command 'router ospf %d' received, vrf %s id %u oi_running %u",
|
||||
instance, ospf->name ? ospf->name : "NIL",
|
||||
ospf->vrf_id, ospf->oi_running);
|
||||
VTY_PUSH_CONTEXT(OSPF_NODE, ospf);
|
||||
|
||||
/* 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;
|
||||
|
||||
params = IF_DEF_PARAMS(ifp);
|
||||
if (OSPF_IF_PARAM_CONFIGURED(params, if_area)) {
|
||||
for (rn = route_top(ospf->networks); rn;
|
||||
rn = route_next(rn)) {
|
||||
if (rn->info != NULL) {
|
||||
vty_out(vty,
|
||||
"Interface %s has area config but please remove all network commands first.\n",
|
||||
ifp->name);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
if (!ospf_interface_area_is_already_set(ospf,
|
||||
ifp)) {
|
||||
ospf_interface_area_set(ospf, ifp);
|
||||
ospf->if_ospf_cli_count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ospf_router_id_update(ospf);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -385,6 +385,8 @@ struct ospf *ospf_lookup_by_inst_name(unsigned short instance, const char *name)
|
||||
struct ospf *ospf_get(unsigned short instance, const char *name, bool *created)
|
||||
{
|
||||
struct ospf *ospf;
|
||||
struct vrf *vrf;
|
||||
struct interface *ifp;
|
||||
|
||||
/* vrf name provided call inst and name based api
|
||||
* in case of no name pass default ospf instance */
|
||||
@ -399,6 +401,29 @@ struct ospf *ospf_get(unsigned short instance, const char *name, bool *created)
|
||||
ospf_add(ospf);
|
||||
|
||||
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;
|
||||
|
||||
params = IF_DEF_PARAMS(ifp);
|
||||
if (OSPF_IF_PARAM_CONFIGURED(params, if_area)) {
|
||||
ospf_interface_area_set(ospf, ifp);
|
||||
ospf->if_ospf_cli_count++;
|
||||
}
|
||||
}
|
||||
|
||||
ospf_router_id_update(ospf);
|
||||
}
|
||||
|
||||
return ospf;
|
||||
@ -1128,32 +1153,6 @@ void ospf_interface_area_unset(struct ospf *ospf, struct interface *ifp)
|
||||
update_redistributed(ospf, 0); /* interfaces possibly removed */
|
||||
}
|
||||
|
||||
bool ospf_interface_area_is_already_set(struct ospf *ospf,
|
||||
struct interface *ifp)
|
||||
{
|
||||
struct route_node *rn_oi;
|
||||
|
||||
if (!ospf)
|
||||
return false; /* Ospf not ready yet */
|
||||
|
||||
/* Find interfaces that may need to be removed. */
|
||||
for (rn_oi = route_top(IF_OIFS(ifp)); rn_oi;
|
||||
rn_oi = route_next(rn_oi)) {
|
||||
struct ospf_interface *oi = rn_oi->info;
|
||||
|
||||
if (oi == NULL)
|
||||
continue;
|
||||
|
||||
if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
|
||||
continue;
|
||||
/* at least one route covered by interface
|
||||
* that implies already done
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Check whether interface matches given network
|
||||
* returns: 1, true. 0, false
|
||||
*/
|
||||
|
@ -614,8 +614,6 @@ extern void ospf_area_del_if(struct ospf_area *, struct ospf_interface *);
|
||||
|
||||
extern void ospf_interface_area_set(struct ospf *, struct interface *);
|
||||
extern void ospf_interface_area_unset(struct ospf *, struct interface *);
|
||||
extern bool ospf_interface_area_is_already_set(struct ospf *ospf,
|
||||
struct interface *ifp);
|
||||
|
||||
extern void ospf_route_map_init(void);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user