]> git.proxmox.com Git - mirror_frr.git/blame - isisd/isis_main.c
Merge pull request #3370 from pguibert6WIND/default_vrf_initialization
[mirror_frr.git] / isisd / isis_main.c
CommitLineData
eb5d44eb 1/*
2 * IS-IS Rout(e)ing protocol - isis_main.c
3 *
4 * Copyright (C) 2001,2002 Sampo Saaristo
d62a17ae 5 * Tampere University of Technology
eb5d44eb 6 * Institute of Communications Engineering
7 *
d62a17ae 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)
eb5d44eb 11 * any later version.
12 *
d62a17ae 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
eb5d44eb 16 * more details.
896014f4
DL
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
eb5d44eb 21 */
22
eb5d44eb 23#include <zebra.h>
eb5d44eb 24
25#include "getopt.h"
26#include "thread.h"
27#include "log.h"
5e4fa164 28#include <lib/version.h>
eb5d44eb 29#include "command.h"
30#include "vty.h"
31#include "memory.h"
fc7948fa 32#include "memory_vty.h"
eb5d44eb 33#include "stream.h"
34#include "if.h"
9e867fe6 35#include "privs.h"
2d75d052 36#include "sigevent.h"
c729c650 37#include "filter.h"
f3ccedaa 38#include "plist.h"
48d8bea8 39#include "zclient.h"
6a69b354 40#include "vrf.h"
676a4ea3 41#include "qobj.h"
4f04a76b 42#include "libfrr.h"
eb5d44eb 43
44#include "isisd/dict.h"
eb5d44eb 45#include "isisd/isis_constants.h"
46#include "isisd/isis_common.h"
47#include "isisd/isis_flags.h"
48#include "isisd/isis_circuit.h"
49#include "isisd/isisd.h"
50#include "isisd/isis_dynhn.h"
3f045a08
JB
51#include "isisd/isis_spf.h"
52#include "isisd/isis_route.h"
f3ccedaa 53#include "isisd/isis_routemap.h"
3f045a08 54#include "isisd/isis_zebra.h"
f8c06e2c 55#include "isisd/isis_te.h"
54ece698 56#include "isisd/isis_errors.h"
ef020087 57#include "isisd/isis_vty_common.h"
52df8228 58#include "isisd/isis_bfd.h"
a5b5e946 59#include "isisd/isis_lsp.h"
d56afe53 60#include "isisd/isis_mt.h"
eb5d44eb 61
62/* Default configuration file name */
63#define ISISD_DEFAULT_CONFIG "isisd.conf"
64/* Default vty port */
fc58e874 65#define ISISD_VTY_PORT 2608
7c0cbd0e 66#define FABRICD_VTY_PORT 2618
eb5d44eb 67
9e867fe6 68/* isisd privileges */
d62a17ae 69zebra_capabilities_t _caps_p[] = {ZCAP_NET_RAW, ZCAP_BIND};
9e867fe6 70
f390d2c7 71struct zebra_privs_t isisd_privs = {
b2f36157 72#if defined(FRR_USER)
d62a17ae 73 .user = FRR_USER,
9e867fe6 74#endif
b2f36157 75#if defined FRR_GROUP
d62a17ae 76 .group = FRR_GROUP,
9e867fe6 77#endif
78#ifdef VTY_GROUP
d62a17ae 79 .vty_group = VTY_GROUP,
9e867fe6 80#endif
d62a17ae 81 .caps_p = _caps_p,
82 .cap_num_p = sizeof(_caps_p) / sizeof(*_caps_p),
83 .cap_num_i = 0};
9e867fe6 84
eb5d44eb 85/* isisd options */
d62a17ae 86struct option longopts[] = {{0}};
eb5d44eb 87
eb5d44eb 88/* Master of threads. */
89struct thread_master *master;
90
41b36e90
PJ
91/*
92 * Prototypes.
93 */
41b36e90
PJ
94void sighup(void);
95void sigint(void);
96void sigterm(void);
97void sigusr1(void);
98
99
d62a17ae 100static __attribute__((__noreturn__)) void terminate(int i)
eb5d44eb 101{
d62a17ae 102 isis_zebra_stop();
103 exit(i);
eb5d44eb 104}
105
106/*
107 * Signal handlers
108 */
2d75d052 109
d62a17ae 110void sighup(void)
eb5d44eb 111{
38937bd5 112 zlog_notice("SIGHUP/reload is not implemented for isisd");
d62a17ae 113 return;
eb5d44eb 114}
115
d62a17ae 116__attribute__((__noreturn__)) void sigint(void)
eb5d44eb 117{
d62a17ae 118 zlog_notice("Terminating on signal SIGINT");
119 terminate(0);
eb5d44eb 120}
121
d62a17ae 122__attribute__((__noreturn__)) void sigterm(void)
eb5d44eb 123{
d62a17ae 124 zlog_notice("Terminating on signal SIGTERM");
125 terminate(0);
eb5d44eb 126}
127
d62a17ae 128void sigusr1(void)
eb5d44eb 129{
d62a17ae 130 zlog_debug("SIGUSR1 received");
131 zlog_rotate();
eb5d44eb 132}
133
d62a17ae 134struct quagga_signal_t isisd_signals[] = {
135 {
136 .signal = SIGHUP,
137 .handler = &sighup,
138 },
139 {
140 .signal = SIGUSR1,
141 .handler = &sigusr1,
142 },
143 {
144 .signal = SIGINT,
145 .handler = &sigint,
146 },
147 {
148 .signal = SIGTERM,
149 .handler = &sigterm,
150 },
2d75d052 151};
eb5d44eb 152
8fcdd0d6 153static const struct frr_yang_module_info *isisd_yang_modules[] = {
a4bed468 154 &frr_interface_info,
8fcdd0d6
RW
155};
156
7c0cbd0e
CF
157#ifdef FABRICD
158FRR_DAEMON_INFO(fabricd, OPEN_FABRIC, .vty_port = FABRICD_VTY_PORT,
159
160 .proghelp = "Implementation of the OpenFabric routing protocol.",
161#else
d62a17ae 162FRR_DAEMON_INFO(isisd, ISIS, .vty_port = ISISD_VTY_PORT,
4f04a76b 163
d62a17ae 164 .proghelp = "Implementation of the IS-IS routing protocol.",
7c0cbd0e 165#endif
d62a17ae 166 .copyright =
167 "Copyright (c) 2001-2002 Sampo Saaristo,"
168 " Ofer Wald and Hannes Gredler",
4f04a76b 169
d62a17ae 170 .signals = isisd_signals,
171 .n_signals = array_size(isisd_signals),
4f04a76b 172
8fcdd0d6
RW
173 .privs = &isisd_privs, .yang_modules = isisd_yang_modules,
174 .n_yang_modules = array_size(isisd_yang_modules), )
4f04a76b 175
eb5d44eb 176/*
177 * Main routine of isisd. Parse arguments and handle IS-IS state machine.
178 */
d62a17ae 179int main(int argc, char **argv, char **envp)
eb5d44eb 180{
d62a17ae 181 int opt;
eb5d44eb 182
7c0cbd0e
CF
183#ifdef FABRICD
184 frr_preinit(&fabricd_di, argc, argv);
185#else
d62a17ae 186 frr_preinit(&isisd_di, argc, argv);
7c0cbd0e 187#endif
d62a17ae 188 frr_opt_add("", longopts, "");
4f04a76b 189
d62a17ae 190 /* Command line argument treatment. */
191 while (1) {
192 opt = frr_getopt(argc, argv, NULL);
f390d2c7 193
d62a17ae 194 if (opt == EOF)
195 break;
f390d2c7 196
d62a17ae 197 switch (opt) {
198 case 0:
199 break;
200 default:
201 frr_help_exit(1);
202 break;
203 }
f390d2c7 204 }
d62a17ae 205
d62a17ae 206 /* thread master */
207 master = frr_init();
208
209 /*
210 * initializations
211 */
54ece698 212 isis_error_init();
d62a17ae 213 access_list_init();
ecbc5a37 214 vrf_init(NULL, NULL, NULL, NULL, NULL);
d62a17ae 215 prefix_list_init();
216 isis_init();
217 isis_circuit_init();
ef020087 218 isis_vty_init();
d62a17ae 219 isis_spf_cmds_init();
220 isis_redist_init();
221 isis_route_map_init();
222 isis_mpls_te_init();
a5b5e946 223 lsp_init();
d56afe53 224 mt_init();
d62a17ae 225
226 /* create the global 'isis' instance */
227 isis_new(1);
228
229 isis_zebra_init(master);
52df8228 230 isis_bfd_init();
d62a17ae 231
232 frr_config_fork();
233 frr_run(master);
234
235 /* Not reached. */
236 exit(0);
eb5d44eb 237}