]> git.proxmox.com Git - mirror_frr.git/blame - ripd/rip_main.c
Merge pull request #13555 from LabNConsulting/aceelindem/ospf-p2mp-delayed-reflooding...
[mirror_frr.git] / ripd / rip_main.c
CommitLineData
acddc0ed 1// SPDX-License-Identifier: GPL-2.0-or-later
718e3744 2/* RIPd main routine.
3 * Copyright (C) 1997, 98 Kunihiro Ishiguro <kunihiro@zebra.org>
718e3744 4 */
5
6#include <zebra.h>
7
5e4fa164 8#include <lib/version.h>
718e3744 9#include "getopt.h"
24a58196 10#include "frrevent.h"
718e3744 11#include "command.h"
12#include "memory.h"
13#include "prefix.h"
14#include "filter.h"
15#include "keychain.h"
16#include "log.h"
edd7c245 17#include "privs.h"
2d75d052 18#include "sigevent.h"
b5114685 19#include "zclient.h"
6a69b354 20#include "vrf.h"
8f88441d 21#include "if_rmap.h"
4f04a76b 22#include "libfrr.h"
91835f1f 23#include "routemap.h"
c262df82 24#include "bfd.h"
718e3744 25
26#include "ripd/ripd.h"
c262df82 27#include "ripd/rip_bfd.h"
f80ec39e 28#include "ripd/rip_nb.h"
518e377f 29#include "ripd/rip_errors.h"
718e3744 30
31/* ripd options. */
f28963f7 32static struct option longopts[] = {{0}};
718e3744 33
edd7c245 34/* ripd privileges */
ae7b826a 35zebra_capabilities_t _caps_p[] = {ZCAP_NET_RAW, ZCAP_BIND, ZCAP_SYS_ADMIN};
edd7c245 36
1b839d48
DA
37uint32_t zebra_ecmp_count = MULTIPATH_NUM;
38
d62a17ae 39struct zebra_privs_t ripd_privs = {
b2f36157 40#if defined(FRR_USER)
d62a17ae 41 .user = FRR_USER,
edd7c245 42#endif
b2f36157 43#if defined FRR_GROUP
d62a17ae 44 .group = FRR_GROUP,
d81fadfd 45#endif
46#ifdef VTY_GROUP
d62a17ae 47 .vty_group = VTY_GROUP,
edd7c245 48#endif
d62a17ae 49 .caps_p = _caps_p,
ae7b826a 50 .cap_num_p = array_size(_caps_p),
d62a17ae 51 .cap_num_i = 0};
edd7c245 52
718e3744 53/* Master of threads. */
cd9d0537 54struct event_loop *master;
718e3744 55
eb05883f 56static struct frr_daemon_info ripd_di;
718e3744 57
718e3744 58/* SIGHUP handler. */
d62a17ae 59static void sighup(void)
718e3744 60{
d62a17ae 61 zlog_info("SIGHUP received");
718e3744 62
d62a17ae 63 /* Reload config file. */
1c2facd1 64 vty_read_config(NULL, ripd_di.config_file, config_default);
718e3744 65}
66
67/* SIGINT handler. */
d62a17ae 68static void sigint(void)
718e3744 69{
d62a17ae 70 zlog_notice("Terminating on signal");
718e3744 71
c262df82 72 bfd_protocol_integration_set_shutdown(true);
ae7b826a 73 rip_vrf_terminate();
8f88441d 74 if_rmap_terminate();
d62a17ae 75 rip_zclient_stop();
8879bd22 76 frr_fini();
a2f9eb82 77
d62a17ae 78 exit(0);
718e3744 79}
80
81/* SIGUSR1 handler. */
d62a17ae 82static void sigusr1(void)
718e3744 83{
d62a17ae 84 zlog_rotate();
718e3744 85}
86
7cc91e67 87static struct frr_signal_t ripd_signals[] = {
d62a17ae 88 {
89 .signal = SIGHUP,
90 .handler = &sighup,
91 },
92 {
93 .signal = SIGUSR1,
94 .handler = &sigusr1,
95 },
96 {
97 .signal = SIGINT,
98 .handler = &sigint,
99 },
100 {
101 .signal = SIGTERM,
102 .handler = &sigint,
103 },
104};
4f04a76b 105
0d8c7a26 106static const struct frr_yang_module_info *const ripd_yang_modules[] = {
c2aab693 107 &frr_filter_info,
a4bed468 108 &frr_interface_info,
707656ec 109 &frr_ripd_info,
91835f1f 110 &frr_route_map_info,
6fd8972a 111 &frr_vrf_info,
8fcdd0d6
RW
112};
113
d62a17ae 114FRR_DAEMON_INFO(ripd, RIP, .vty_port = RIP_VTY_PORT,
718e3744 115
d62a17ae 116 .proghelp = "Implementation of the RIP routing protocol.",
718e3744 117
d62a17ae 118 .signals = ripd_signals, .n_signals = array_size(ripd_signals),
718e3744 119
8fcdd0d6 120 .privs = &ripd_privs, .yang_modules = ripd_yang_modules,
80413c20
DL
121 .n_yang_modules = array_size(ripd_yang_modules),
122);
d62a17ae 123
f28963f7 124#define DEPRECATED_OPTIONS ""
c8dde10f 125
d62a17ae 126/* Main routine of ripd. */
127int main(int argc, char **argv)
128{
129 frr_preinit(&ripd_di, argc, argv);
c8dde10f
QY
130
131 frr_opt_add("" DEPRECATED_OPTIONS, longopts, "");
d62a17ae 132
133 /* Command line option parse. */
134 while (1) {
135 int opt;
136
137 opt = frr_getopt(argc, argv, NULL);
138
c8dde10f
QY
139 if (opt && opt < 128 && strchr(DEPRECATED_OPTIONS, opt)) {
140 fprintf(stderr,
141 "The -%c option no longer exists.\nPlease refer to the manual.\n",
142 opt);
143 continue;
144 }
145
d62a17ae 146 if (opt == EOF)
147 break;
148
149 switch (opt) {
150 case 0:
151 break;
d62a17ae 152 default:
153 frr_help_exit(1);
d62a17ae 154 }
718e3744 155 }
718e3744 156
d62a17ae 157 /* Prepare master thread. */
158 master = frr_init();
718e3744 159
d62a17ae 160 /* Library initialization. */
518e377f 161 rip_error_init();
d62a17ae 162 keychain_init();
ae7b826a 163 rip_vrf_init();
718e3744 164
d62a17ae 165 /* RIP related initialization. */
166 rip_init();
167 rip_if_init();
707656ec 168 rip_cli_init();
d62a17ae 169 rip_zclient_init(master);
c262df82 170 rip_bfd_init(master);
718e3744 171
d62a17ae 172 frr_config_fork();
173 frr_run(master);
718e3744 174
d62a17ae 175 /* Not reached. */
95f7965d 176 return 0;
718e3744 177}