]> git.proxmox.com Git - mirror_frr.git/blame_incremental - isisd/isis_main.c
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / isisd / isis_main.c
... / ...
CommitLineData
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * IS-IS Rout(e)ing protocol - isis_main.c
4 *
5 * Copyright (C) 2001,2002 Sampo Saaristo
6 * Tampere University of Technology
7 * Institute of Communications Engineering
8 */
9
10#include <zebra.h>
11
12#include "getopt.h"
13#include "thread.h"
14#include "log.h"
15#include <lib/version.h>
16#include "command.h"
17#include "vty.h"
18#include "memory.h"
19#include "stream.h"
20#include "if.h"
21#include "privs.h"
22#include "sigevent.h"
23#include "filter.h"
24#include "plist.h"
25#include "zclient.h"
26#include "vrf.h"
27#include "qobj.h"
28#include "libfrr.h"
29#include "routemap.h"
30#include "affinitymap.h"
31
32#include "isisd/isis_constants.h"
33#include "isisd/isis_common.h"
34#include "isisd/isis_flags.h"
35#include "isisd/isis_circuit.h"
36#include "isisd/isisd.h"
37#include "isisd/isis_dynhn.h"
38#include "isisd/isis_spf.h"
39#include "isisd/isis_route.h"
40#include "isisd/isis_routemap.h"
41#include "isisd/isis_zebra.h"
42#include "isisd/isis_te.h"
43#include "isisd/isis_errors.h"
44#include "isisd/isis_bfd.h"
45#include "isisd/isis_lsp.h"
46#include "isisd/isis_mt.h"
47#include "isisd/fabricd.h"
48#include "isisd/isis_nb.h"
49#include "isisd/isis_ldp_sync.h"
50
51/* Default configuration file name */
52#define ISISD_DEFAULT_CONFIG "isisd.conf"
53/* Default vty port */
54#define ISISD_VTY_PORT 2608
55#define FABRICD_VTY_PORT 2618
56
57/* isisd privileges */
58zebra_capabilities_t _caps_p[] = {ZCAP_NET_RAW, ZCAP_BIND, ZCAP_SYS_ADMIN};
59
60struct zebra_privs_t isisd_privs = {
61#if defined(FRR_USER)
62 .user = FRR_USER,
63#endif
64#if defined FRR_GROUP
65 .group = FRR_GROUP,
66#endif
67#ifdef VTY_GROUP
68 .vty_group = VTY_GROUP,
69#endif
70 .caps_p = _caps_p,
71 .cap_num_p = array_size(_caps_p),
72 .cap_num_i = 0};
73
74/* isisd options */
75static const struct option longopts[] = {
76 {"int_num", required_argument, NULL, 'I'},
77 {0}};
78
79/* Master of threads. */
80struct thread_master *master;
81
82/*
83 * Prototypes.
84 */
85void sighup(void);
86void sigint(void);
87void sigterm(void);
88void sigusr1(void);
89
90
91static __attribute__((__noreturn__)) void terminate(int i)
92{
93 isis_terminate();
94 isis_sr_term();
95 isis_zebra_stop();
96 exit(i);
97}
98
99/*
100 * Signal handlers
101 */
102#ifdef FABRICD
103void sighup(void)
104{
105 zlog_notice("SIGHUP/reload is not implemented for fabricd");
106 return;
107}
108#else
109static struct frr_daemon_info isisd_di;
110void sighup(void)
111{
112 zlog_info("SIGHUP received");
113
114 /* Reload config file. */
115 vty_read_config(NULL, isisd_di.config_file, config_default);
116}
117
118#endif
119
120__attribute__((__noreturn__)) void sigint(void)
121{
122 zlog_notice("Terminating on signal SIGINT");
123 terminate(0);
124}
125
126__attribute__((__noreturn__)) void sigterm(void)
127{
128 zlog_notice("Terminating on signal SIGTERM");
129 terminate(0);
130}
131
132void sigusr1(void)
133{
134 zlog_debug("SIGUSR1 received");
135 zlog_rotate();
136}
137
138struct frr_signal_t isisd_signals[] = {
139 {
140 .signal = SIGHUP,
141 .handler = &sighup,
142 },
143 {
144 .signal = SIGUSR1,
145 .handler = &sigusr1,
146 },
147 {
148 .signal = SIGINT,
149 .handler = &sigint,
150 },
151 {
152 .signal = SIGTERM,
153 .handler = &sigterm,
154 },
155};
156
157
158/* clang-format off */
159static const struct frr_yang_module_info *const isisd_yang_modules[] = {
160 &frr_filter_info,
161 &frr_interface_info,
162#ifndef FABRICD
163 &frr_isisd_info,
164#endif /* ifndef FABRICD */
165 &frr_route_map_info,
166 &frr_affinity_map_info,
167 &frr_vrf_info,
168};
169/* clang-format on */
170
171#ifdef FABRICD
172FRR_DAEMON_INFO(fabricd, OPEN_FABRIC, .vty_port = FABRICD_VTY_PORT,
173
174 .proghelp = "Implementation of the OpenFabric routing protocol.",
175#else
176FRR_DAEMON_INFO(isisd, ISIS, .vty_port = ISISD_VTY_PORT,
177
178 .proghelp = "Implementation of the IS-IS routing protocol.",
179#endif
180 .copyright =
181 "Copyright (c) 2001-2002 Sampo Saaristo, Ofer Wald and Hannes Gredler",
182
183 .signals = isisd_signals,
184 .n_signals = array_size(isisd_signals),
185
186 .privs = &isisd_privs, .yang_modules = isisd_yang_modules,
187 .n_yang_modules = array_size(isisd_yang_modules),
188);
189
190/*
191 * Main routine of isisd. Parse arguments and handle IS-IS state machine.
192 */
193int main(int argc, char **argv, char **envp)
194{
195 int opt;
196 int instance = 1;
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(
204 "I:", longopts,
205 " -I, --int_num Set instance number (label-manager)\n");
206
207 /* Command line argument treatment. */
208 while (1) {
209 opt = frr_getopt(argc, argv, NULL);
210
211 if (opt == EOF)
212 break;
213
214 switch (opt) {
215 case 0:
216 break;
217 case 'I':
218 instance = atoi(optarg);
219 if (instance < 1 || instance > (unsigned short)-1)
220 zlog_err("Instance %i out of range (1..%u)",
221 instance, (unsigned short)-1);
222 break;
223 default:
224 frr_help_exit(1);
225 }
226 }
227
228 /* thread master */
229 isis_master_init(frr_init());
230 master = im->master;
231 /*
232 * initializations
233 */
234 isis_error_init();
235 access_list_init();
236 access_list_add_hook(isis_filter_update);
237 access_list_delete_hook(isis_filter_update);
238 isis_vrf_init();
239 prefix_list_init();
240 prefix_list_add_hook(isis_prefix_list_update);
241 prefix_list_delete_hook(isis_prefix_list_update);
242 isis_init();
243 isis_circuit_init();
244#ifdef FABRICD
245 isis_vty_daemon_init();
246#endif /* FABRICD */
247#ifndef FABRICD
248 isis_cli_init();
249#endif /* ifdef FABRICD */
250 isis_spf_init();
251 isis_redist_init();
252 isis_route_map_init();
253 isis_mpls_te_init();
254 isis_sr_init();
255 lsp_init();
256 mt_init();
257
258 affinity_map_init();
259
260 isis_zebra_init(master, instance);
261 isis_bfd_init(master);
262 isis_ldp_sync_init();
263 fabricd_init();
264
265 frr_config_fork();
266 frr_run(master);
267
268 /* Not reached. */
269 exit(0);
270}