]> git.proxmox.com Git - mirror_frr.git/blob - pathd/path_main.c
Merge pull request #8488 from mjstapp/more_workqueue
[mirror_frr.git] / pathd / path_main.c
1 /*
2 * Copyright (C) 2020 NetDEF, Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation; either version 2 of the License, or (at your option)
7 * any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; see the file COPYING; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 #include <zebra.h>
19
20 #include <lib/version.h>
21 #include "getopt.h"
22 #include "thread.h"
23 #include "command.h"
24 #include "log.h"
25 #include "memory.h"
26 #include "privs.h"
27 #include "sigevent.h"
28 #include "libfrr.h"
29 #include "vrf.h"
30 #include "filter.h"
31
32 #include "pathd.h"
33 #include "path_nb.h"
34 #include "path_zebra.h"
35 #include "path_errors.h"
36
37 char backup_config_file[256];
38
39 zebra_capabilities_t _caps_p[] = {};
40
41 struct zebra_privs_t pathd_privs = {
42 #if defined(FRR_USER) && defined(FRR_GROUP)
43 .user = FRR_USER,
44 .group = FRR_GROUP,
45 #endif
46 #if defined(VTY_GROUP)
47 .vty_group = VTY_GROUP,
48 #endif
49 .caps_p = _caps_p,
50 .cap_num_p = array_size(_caps_p),
51 .cap_num_i = 0};
52
53 struct option longopts[] = {{0}};
54
55 /* Master of threads. */
56 struct thread_master *master;
57
58 static struct frr_daemon_info pathd_di;
59
60 /* SIGHUP handler. */
61 static void sighup(void)
62 {
63 zlog_info("SIGHUP received");
64
65 /* Reload config file. */
66 vty_read_config(NULL, pathd_di.config_file, config_default);
67 }
68
69 /* SIGINT / SIGTERM handler. */
70 static void sigint(void)
71 {
72 zlog_notice("Terminating on signal");
73
74 exit(0);
75 }
76
77 /* SIGUSR1 handler. */
78 static void sigusr1(void)
79 {
80 zlog_rotate();
81 }
82
83 struct quagga_signal_t path_signals[] = {
84 {
85 .signal = SIGHUP,
86 .handler = &sighup,
87 },
88 {
89 .signal = SIGUSR1,
90 .handler = &sigusr1,
91 },
92 {
93 .signal = SIGINT,
94 .handler = &sigint,
95 },
96 {
97 .signal = SIGTERM,
98 .handler = &sigint,
99 },
100 };
101
102 static const struct frr_yang_module_info *pathd_yang_modules[] = {
103 &frr_filter_info,
104 &frr_interface_info,
105 &frr_pathd_info,
106 };
107
108 #define PATH_VTY_PORT 2621
109
110 FRR_DAEMON_INFO(pathd, PATH, .vty_port = PATH_VTY_PORT,
111
112 .proghelp = "Implementation of PATH.",
113
114 .signals = path_signals, .n_signals = array_size(path_signals),
115
116 .privs = &pathd_privs, .yang_modules = pathd_yang_modules,
117 .n_yang_modules = array_size(pathd_yang_modules),
118 );
119
120 int main(int argc, char **argv, char **envp)
121 {
122 frr_preinit(&pathd_di, argc, argv);
123 frr_opt_add("", longopts, "");
124
125 while (1) {
126 int opt;
127
128 opt = frr_getopt(argc, argv, NULL);
129
130 if (opt == EOF)
131 break;
132
133 switch (opt) {
134 case 0:
135 break;
136 default:
137 frr_help_exit(1);
138 break;
139 }
140 }
141
142 master = frr_init();
143
144 access_list_init();
145
146 path_error_init();
147 path_zebra_init(master);
148 path_cli_init();
149
150 frr_config_fork();
151 frr_run(master);
152
153 /* Not reached. */
154 return 0;
155 }