summaryrefslogtreecommitdiffstats
path: root/ospfd/ospfd.c
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2021-01-28 00:41:07 +0100
committerIgor Ryzhov <iryzhov@nfware.com>2021-02-24 13:31:20 +0100
commit409f98ab443682ec360e3e76954f1c8985b3371d (patch)
tree817839e523aed152eae3f7336ef4cb431538cb99 /ospfd/ospfd.c
parentMerge pull request #7879 from AnuradhaKaruppiah/advertise-svi-mac (diff)
downloadfrr-409f98ab443682ec360e3e76954f1c8985b3371d.tar.xz
frr-409f98ab443682ec360e3e76954f1c8985b3371d.zip
ospfd: don't rely on instance existence in vty
Store instance index at startup and use it when processing vty commands. The instance itself may be created and deleted by the user in runtime using `[no] router ospf X` command. Fixes #7908 Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Diffstat (limited to 'ospfd/ospfd.c')
-rw-r--r--ospfd/ospfd.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c
index 04397d50a..9590a9c73 100644
--- a/ospfd/ospfd.c
+++ b/ospfd/ospfd.c
@@ -70,6 +70,8 @@ static struct ospf_master ospf_master;
/* OSPF process wide configuration pointer to export. */
struct ospf_master *om;
+unsigned short ospf_instance;
+
extern struct zclient *zclient;
@@ -511,36 +513,28 @@ static void ospf_init(struct ospf *ospf)
ospf_router_id_update(ospf);
}
-struct ospf *ospf_get(unsigned short instance, const char *name, bool *created)
+struct ospf *ospf_lookup(unsigned short instance, const char *name)
{
struct ospf *ospf;
- /* vrf name provided call inst and name based api
- * in case of no name pass default ospf instance */
- if (name)
+ if (ospf_instance) {
+ ospf = ospf_lookup_instance(instance);
+ } else {
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;
}
-struct ospf *ospf_get_instance(unsigned short instance, bool *created)
+struct ospf *ospf_get(unsigned short instance, const char *name, bool *created)
{
struct ospf *ospf;
- ospf = ospf_lookup_instance(instance);
+ ospf = ospf_lookup(instance, name);
+
*created = (ospf == NULL);
if (ospf == NULL) {
- ospf = ospf_new(instance, NULL /* VRF_DEFAULT*/);
+ ospf = ospf_new(instance, name);
ospf_add(ospf);
ospf_init(ospf);