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