]> git.proxmox.com Git - mirror_frr.git/blob - mgmtd/mgmt.c
Merge pull request #13649 from donaldsharp/unlock_the_node_or_else
[mirror_frr.git] / mgmtd / mgmt.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * FRR Management Daemon (MGMTD) program
4 *
5 * Copyright (C) 2021 Vmware, Inc.
6 * Pushpasis Sarkar
7 */
8
9 #include <zebra.h>
10 #include "debug.h"
11 #include "mgmtd/mgmt.h"
12 #include "mgmtd/mgmt_be_adapter.h"
13 #include "mgmtd/mgmt_ds.h"
14 #include "mgmtd/mgmt_fe_adapter.h"
15 #include "mgmtd/mgmt_history.h"
16 #include "mgmtd/mgmt_memory.h"
17
18 struct debug mgmt_debug_be = {.desc = "Management backend adapater"};
19 struct debug mgmt_debug_ds = {.desc = "Management datastore"};
20 struct debug mgmt_debug_fe = {.desc = "Management frontend adapater"};
21 struct debug mgmt_debug_txn = {.desc = "Management transaction"};
22
23 /* MGMTD process wide configuration. */
24 static struct mgmt_master mgmt_master;
25
26 /* MGMTD process wide configuration pointer to export. */
27 struct mgmt_master *mm;
28
29 void mgmt_master_init(struct event_loop *master, const int buffer_size)
30 {
31 memset(&mgmt_master, 0, sizeof(struct mgmt_master));
32
33 mm = &mgmt_master;
34 mm->master = master;
35 mm->terminating = false;
36 mm->socket_buffer = buffer_size;
37 mm->perf_stats_en = true;
38 }
39
40 void mgmt_init(void)
41 {
42
43 /* Initialize datastores */
44 mgmt_ds_init(mm);
45
46 /* Initialize history */
47 mgmt_history_init();
48
49 /* Initialize MGMTD Transaction module */
50 mgmt_txn_init(mm, mm->master);
51
52 /* Initialize the MGMTD Frontend Adapter Module */
53 mgmt_fe_adapter_init(mm->master);
54
55 /* Initialize the CLI frontend client */
56 vty_init_mgmt_fe();
57
58 /* MGMTD VTY commands installation. */
59 mgmt_vty_init();
60
61 /*
62 * Initialize the MGMTD Backend Adapter Module
63 *
64 * We do this after the FE stuff so that we always read our config file
65 * prior to any BE connection.
66 */
67 mgmt_be_adapter_init(mm->master);
68 }
69
70 void mgmt_terminate(void)
71 {
72 mgmt_fe_adapter_destroy();
73 mgmt_be_adapter_destroy();
74 mgmt_txn_destroy();
75 mgmt_history_destroy();
76 mgmt_ds_destroy();
77 }