]> git.proxmox.com Git - mirror_frr.git/blob - isisd/isis_main.c
Merge pull request #5432 from chiragshah6/evpn_dev2
[mirror_frr.git] / isisd / isis_main.c
1 /*
2 * IS-IS Rout(e)ing protocol - isis_main.c
3 *
4 * Copyright (C) 2001,2002 Sampo Saaristo
5 * Tampere University of Technology
6 * Institute of Communications Engineering
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public Licenseas published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; see the file COPYING; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 #include <zebra.h>
24
25 #include "getopt.h"
26 #include "thread.h"
27 #include "log.h"
28 #include <lib/version.h>
29 #include "command.h"
30 #include "vty.h"
31 #include "memory.h"
32 #include "memory_vty.h"
33 #include "stream.h"
34 #include "if.h"
35 #include "privs.h"
36 #include "sigevent.h"
37 #include "filter.h"
38 #include "plist.h"
39 #include "zclient.h"
40 #include "vrf.h"
41 #include "qobj.h"
42 #include "libfrr.h"
43
44 #include "isisd/isis_constants.h"
45 #include "isisd/isis_common.h"
46 #include "isisd/isis_flags.h"
47 #include "isisd/isis_circuit.h"
48 #include "isisd/isisd.h"
49 #include "isisd/isis_dynhn.h"
50 #include "isisd/isis_spf.h"
51 #include "isisd/isis_route.h"
52 #include "isisd/isis_routemap.h"
53 #include "isisd/isis_zebra.h"
54 #include "isisd/isis_te.h"
55 #include "isisd/isis_errors.h"
56 #include "isisd/isis_bfd.h"
57 #include "isisd/isis_lsp.h"
58 #include "isisd/isis_mt.h"
59 #include "isisd/fabricd.h"
60 #include "isisd/isis_nb.h"
61
62 /* Default configuration file name */
63 #define ISISD_DEFAULT_CONFIG "isisd.conf"
64 /* Default vty port */
65 #define ISISD_VTY_PORT 2608
66 #define FABRICD_VTY_PORT 2618
67
68 /* isisd privileges */
69 zebra_capabilities_t _caps_p[] = {ZCAP_NET_RAW, ZCAP_BIND};
70
71 struct zebra_privs_t isisd_privs = {
72 #if defined(FRR_USER)
73 .user = FRR_USER,
74 #endif
75 #if defined FRR_GROUP
76 .group = FRR_GROUP,
77 #endif
78 #ifdef VTY_GROUP
79 .vty_group = VTY_GROUP,
80 #endif
81 .caps_p = _caps_p,
82 .cap_num_p = array_size(_caps_p),
83 .cap_num_i = 0};
84
85 /* isisd options */
86 struct option longopts[] = {{0}};
87
88 /* Master of threads. */
89 struct thread_master *master;
90
91 /*
92 * Prototypes.
93 */
94 void sighup(void);
95 void sigint(void);
96 void sigterm(void);
97 void sigusr1(void);
98
99
100 static __attribute__((__noreturn__)) void terminate(int i)
101 {
102 isis_zebra_stop();
103 exit(i);
104 }
105
106 /*
107 * Signal handlers
108 */
109 #ifdef FABRICD
110 void sighup(void)
111 {
112 zlog_notice("SIGHUP/reload is not implemented for fabricd");
113 return;
114 }
115 #else
116 static struct frr_daemon_info isisd_di;
117 void sighup(void)
118 {
119 zlog_info("SIGHUP received");
120
121 /* Reload config file. */
122 vty_read_config(NULL, isisd_di.config_file, config_default);
123 }
124
125 #endif
126
127 __attribute__((__noreturn__)) void sigint(void)
128 {
129 zlog_notice("Terminating on signal SIGINT");
130 terminate(0);
131 }
132
133 __attribute__((__noreturn__)) void sigterm(void)
134 {
135 zlog_notice("Terminating on signal SIGTERM");
136 terminate(0);
137 }
138
139 void sigusr1(void)
140 {
141 zlog_debug("SIGUSR1 received");
142 zlog_rotate();
143 }
144
145 struct quagga_signal_t isisd_signals[] = {
146 {
147 .signal = SIGHUP,
148 .handler = &sighup,
149 },
150 {
151 .signal = SIGUSR1,
152 .handler = &sigusr1,
153 },
154 {
155 .signal = SIGINT,
156 .handler = &sigint,
157 },
158 {
159 .signal = SIGTERM,
160 .handler = &sigterm,
161 },
162 };
163
164
165 static const struct frr_yang_module_info *const isisd_yang_modules[] = {
166 &frr_interface_info,
167 #ifndef FABRICD
168 &frr_isisd_info,
169 #endif /* ifndef FABRICD */
170 };
171
172 #ifdef FABRICD
173 FRR_DAEMON_INFO(fabricd, OPEN_FABRIC, .vty_port = FABRICD_VTY_PORT,
174
175 .proghelp = "Implementation of the OpenFabric routing protocol.",
176 #else
177 FRR_DAEMON_INFO(isisd, ISIS, .vty_port = ISISD_VTY_PORT,
178
179 .proghelp = "Implementation of the IS-IS routing protocol.",
180 #endif
181 .copyright =
182 "Copyright (c) 2001-2002 Sampo Saaristo,"
183 " Ofer Wald and Hannes Gredler",
184
185 .signals = isisd_signals,
186 .n_signals = array_size(isisd_signals),
187
188 .privs = &isisd_privs, .yang_modules = isisd_yang_modules,
189 .n_yang_modules = array_size(isisd_yang_modules), )
190
191 /*
192 * Main routine of isisd. Parse arguments and handle IS-IS state machine.
193 */
194 int main(int argc, char **argv, char **envp)
195 {
196 int opt;
197
198 #ifdef FABRICD
199 frr_preinit(&fabricd_di, argc, argv);
200 #else
201 frr_preinit(&isisd_di, argc, argv);
202 #endif
203 frr_opt_add("", longopts, "");
204
205 /* Command line argument treatment. */
206 while (1) {
207 opt = frr_getopt(argc, argv, NULL);
208
209 if (opt == EOF)
210 break;
211
212 switch (opt) {
213 case 0:
214 break;
215 default:
216 frr_help_exit(1);
217 break;
218 }
219 }
220
221 /* thread master */
222 master = frr_init();
223
224 /*
225 * initializations
226 */
227 isis_error_init();
228 access_list_init();
229 vrf_init(NULL, NULL, NULL, NULL, NULL);
230 prefix_list_init();
231 isis_init();
232 isis_circuit_init();
233 #ifdef FABRICD
234 isis_vty_daemon_init();
235 #endif /* FABRICD */
236 #ifndef FABRICD
237 isis_cli_init();
238 #endif /* ifdef FABRICD */
239 isis_spf_cmds_init();
240 isis_redist_init();
241 isis_route_map_init();
242 isis_mpls_te_init();
243 lsp_init();
244 mt_init();
245
246 /* create the global 'isis' instance */
247 isis_new(1, VRF_DEFAULT);
248
249 isis_zebra_init(master);
250 isis_bfd_init();
251 fabricd_init();
252
253 frr_config_fork();
254 frr_run(master);
255
256 /* Not reached. */
257 exit(0);
258 }