Merge pull request #7651 from idryzhov/ospf-init-instance

ospf: fix instance initialization when using multi-instance mode
This commit is contained in:
Donald Sharp 2020-12-02 06:50:15 -05:00 committed by GitHub
commit c4ac61cef5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 37 deletions

View File

@ -384,24 +384,11 @@ struct ospf *ospf_lookup_by_inst_name(unsigned short instance, const char *name)
return NULL; return NULL;
} }
struct ospf *ospf_get(unsigned short instance, const char *name, bool *created) static void ospf_init(struct ospf *ospf)
{ {
struct ospf *ospf;
struct vrf *vrf; struct vrf *vrf;
struct interface *ifp; struct interface *ifp;
/* vrf name provided call inst and name based api
* in case of no name pass default ospf instance */
if (name)
ospf = ospf_lookup_by_inst_name(instance, name);
else
ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
*created = (ospf == NULL);
if (ospf == NULL) {
ospf = ospf_new(instance, name);
ospf_add(ospf);
ospf_opaque_type11_lsa_init(ospf); ospf_opaque_type11_lsa_init(ospf);
if (ospf->vrf_id != VRF_UNKNOWN) if (ospf->vrf_id != VRF_UNKNOWN)
@ -435,6 +422,25 @@ struct ospf *ospf_get(unsigned short instance, const char *name, bool *created)
} }
ospf_router_id_update(ospf); ospf_router_id_update(ospf);
}
struct ospf *ospf_get(unsigned short instance, const char *name, bool *created)
{
struct ospf *ospf;
/* vrf name provided call inst and name based api
* in case of no name pass default ospf instance */
if (name)
ospf = ospf_lookup_by_inst_name(instance, name);
else
ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
*created = (ospf == NULL);
if (ospf == NULL) {
ospf = ospf_new(instance, name);
ospf_add(ospf);
ospf_init(ospf);
} }
return ospf; return ospf;
@ -450,7 +456,7 @@ struct ospf *ospf_get_instance(unsigned short instance, bool *created)
ospf = ospf_new(instance, NULL /* VRF_DEFAULT*/); ospf = ospf_new(instance, NULL /* VRF_DEFAULT*/);
ospf_add(ospf); ospf_add(ospf);
ospf_opaque_type11_lsa_init(ospf); ospf_init(ospf);
} }
return ospf; return ospf;

View File

@ -604,7 +604,6 @@ extern int ospf_nbr_nbma_poll_interval_set(struct ospf *, struct in_addr,
unsigned int); unsigned int);
extern int ospf_nbr_nbma_poll_interval_unset(struct ospf *, struct in_addr); extern int ospf_nbr_nbma_poll_interval_unset(struct ospf *, struct in_addr);
extern void ospf_prefix_list_update(struct prefix_list *); extern void ospf_prefix_list_update(struct prefix_list *);
extern void ospf_init(void);
extern void ospf_if_update(struct ospf *, struct interface *); extern void ospf_if_update(struct ospf *, struct interface *);
extern void ospf_ls_upd_queue_empty(struct ospf_interface *); extern void ospf_ls_upd_queue_empty(struct ospf_interface *);
extern void ospf_terminate(void); extern void ospf_terminate(void);