summaryrefslogtreecommitdiff
path: root/ospfd/ospf_main.c
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2021-01-28 02:41:07 +0300
committerIgor Ryzhov <iryzhov@nfware.com>2021-02-24 15:31:20 +0300
commit409f98ab443682ec360e3e76954f1c8985b3371d (patch)
tree817839e523aed152eae3f7336ef4cb431538cb99 /ospfd/ospf_main.c
parent0ff791138668c50a1c60b209333091682d8926d3 (diff)
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/ospf_main.c')
-rw-r--r--ospfd/ospf_main.c20
1 files changed, 3 insertions, 17 deletions
diff --git a/ospfd/ospf_main.c b/ospfd/ospf_main.c
index 6be5486b55..6a90dbff11 100644
--- a/ospfd/ospf_main.c
+++ b/ospfd/ospf_main.c
@@ -146,9 +146,6 @@ FRR_DAEMON_INFO(ospfd, OSPF, .vty_port = OSPF_VTY_PORT,
/* OSPFd main routine. */
int main(int argc, char **argv)
{
- unsigned short instance = 0;
- bool created = false;
-
#ifdef SUPPORT_OSPF_API
/* OSPF apiserver is disabled by default. */
ospf_apiserver_enable = 0;
@@ -169,8 +166,8 @@ int main(int argc, char **argv)
switch (opt) {
case 'n':
- ospfd_di.instance = instance = atoi(optarg);
- if (instance < 1)
+ ospfd_di.instance = ospf_instance = atoi(optarg);
+ if (ospf_instance < 1)
exit(0);
break;
case 0:
@@ -208,7 +205,7 @@ int main(int argc, char **argv)
/* OSPFd inits. */
ospf_if_init();
- ospf_zebra_init(master, instance);
+ ospf_zebra_init(master, ospf_instance);
/* OSPF vty inits. */
ospf_vty_init();
@@ -227,17 +224,6 @@ int main(int argc, char **argv)
/* OSPF errors init */
ospf_error_init();
- /*
- * Need to initialize the default ospf structure, so the interface mode
- * commands can be duly processed if they are received before 'router
- * ospf', when ospfd is restarted
- */
- if (instance && !ospf_get_instance(instance, &created)) {
- flog_err(EC_OSPF_INIT_FAIL, "OSPF instance init failed: %s",
- strerror(errno));
- exit(1);
- }
-
frr_config_fork();
frr_run(master);