1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * IS-IS Rout(e)ing protocol - isis_main.c
5 * Copyright (C) 2001,2002 Sampo Saaristo
6 * Tampere University of Technology
7 * Institute of Communications Engineering
15 #include <lib/version.h>
30 #include "affinitymap.h"
32 #include "isisd/isis_affinitymap.h"
33 #include "isisd/isis_constants.h"
34 #include "isisd/isis_common.h"
35 #include "isisd/isis_flags.h"
36 #include "isisd/isis_circuit.h"
37 #include "isisd/isisd.h"
38 #include "isisd/isis_dynhn.h"
39 #include "isisd/isis_spf.h"
40 #include "isisd/isis_route.h"
41 #include "isisd/isis_routemap.h"
42 #include "isisd/isis_zebra.h"
43 #include "isisd/isis_te.h"
44 #include "isisd/isis_errors.h"
45 #include "isisd/isis_bfd.h"
46 #include "isisd/isis_lsp.h"
47 #include "isisd/isis_mt.h"
48 #include "isisd/fabricd.h"
49 #include "isisd/isis_nb.h"
50 #include "isisd/isis_ldp_sync.h"
52 /* Default configuration file name */
53 #define ISISD_DEFAULT_CONFIG "isisd.conf"
54 /* Default vty port */
55 #define ISISD_VTY_PORT 2608
56 #define FABRICD_VTY_PORT 2618
58 /* isisd privileges */
59 zebra_capabilities_t _caps_p
[] = {ZCAP_NET_RAW
, ZCAP_BIND
, ZCAP_SYS_ADMIN
};
61 struct zebra_privs_t isisd_privs
= {
69 .vty_group
= VTY_GROUP
,
72 .cap_num_p
= array_size(_caps_p
),
76 static const struct option longopts
[] = {
77 {"int_num", required_argument
, NULL
, 'I'},
80 /* Master of threads. */
81 struct event_loop
*master
;
92 static __attribute__((__noreturn__
)) void terminate(int i
)
106 zlog_notice("SIGHUP/reload is not implemented for fabricd");
110 static struct frr_daemon_info isisd_di
;
113 zlog_info("SIGHUP received");
115 /* Reload config file. */
116 vty_read_config(NULL
, isisd_di
.config_file
, config_default
);
121 __attribute__((__noreturn__
)) void sigint(void)
123 zlog_notice("Terminating on signal SIGINT");
127 __attribute__((__noreturn__
)) void sigterm(void)
129 zlog_notice("Terminating on signal SIGTERM");
135 zlog_debug("SIGUSR1 received");
139 struct frr_signal_t isisd_signals
[] = {
159 /* clang-format off */
160 static const struct frr_yang_module_info
*const isisd_yang_modules
[] = {
165 #endif /* ifndef FABRICD */
167 &frr_affinity_map_info
,
170 /* clang-format on */
173 static void isis_config_finish(struct event
*t
)
175 struct listnode
*node
, *inode
;
177 struct isis_area
*area
;
179 for (ALL_LIST_ELEMENTS_RO(im
->isis
, inode
, isis
)) {
180 for (ALL_LIST_ELEMENTS_RO(isis
->area_list
, node
, area
))
181 config_end_lsp_generate(area
);
185 static void isis_config_start(void)
187 /* Max wait time for config to load before generating lsp */
188 #define ISIS_PRE_CONFIG_MAX_WAIT_SECONDS 600
189 EVENT_OFF(t_isis_cfg
);
190 event_add_timer(im
->master
, isis_config_finish
, NULL
,
191 ISIS_PRE_CONFIG_MAX_WAIT_SECONDS
, &t_isis_cfg
);
194 static void isis_config_end(void)
196 /* If ISIS config processing thread isn't running, then
197 * we can return and rely it's properly handled.
199 if (!event_is_scheduled(t_isis_cfg
))
202 EVENT_OFF(t_isis_cfg
);
203 isis_config_finish(t_isis_cfg
);
207 FRR_DAEMON_INFO(fabricd
, OPEN_FABRIC
, .vty_port
= FABRICD_VTY_PORT
,
209 .proghelp
= "Implementation of the OpenFabric routing protocol.",
211 FRR_DAEMON_INFO(isisd
, ISIS
, .vty_port
= ISISD_VTY_PORT
,
213 .proghelp
= "Implementation of the IS-IS routing protocol.",
216 "Copyright (c) 2001-2002 Sampo Saaristo, Ofer Wald and Hannes Gredler",
218 .signals
= isisd_signals
,
219 .n_signals
= array_size(isisd_signals
),
221 .privs
= &isisd_privs
, .yang_modules
= isisd_yang_modules
,
222 .n_yang_modules
= array_size(isisd_yang_modules
),
226 * Main routine of isisd. Parse arguments and handle IS-IS state machine.
228 int main(int argc
, char **argv
, char **envp
)
234 frr_preinit(&fabricd_di
, argc
, argv
);
236 frr_preinit(&isisd_di
, argc
, argv
);
240 " -I, --int_num Set instance number (label-manager)\n");
242 /* Command line argument treatment. */
244 opt
= frr_getopt(argc
, argv
, NULL
);
253 instance
= atoi(optarg
);
254 if (instance
< 1 || instance
> (unsigned short)-1)
255 zlog_err("Instance %i out of range (1..%u)",
256 instance
, (unsigned short)-1);
264 isis_master_init(frr_init());
269 cmd_init_config_callbacks(isis_config_start
, isis_config_end
);
272 access_list_add_hook(isis_filter_update
);
273 access_list_delete_hook(isis_filter_update
);
276 prefix_list_add_hook(isis_prefix_list_update
);
277 prefix_list_delete_hook(isis_prefix_list_update
);
281 isis_vty_daemon_init();
285 #endif /* ifndef FABRICD */
288 isis_route_map_init();
295 isis_affinity_map_init();
296 #endif /* ifndef FABRICD */
298 isis_zebra_init(master
, instance
);
299 isis_bfd_init(master
);
300 isis_ldp_sync_init();