]> git.proxmox.com Git - mirror_frr.git/blame - pimd/pim_main.c
Merge pull request #13522 from LabNConsulting/chopps/fix-bgp-test
[mirror_frr.git] / pimd / pim_main.c
CommitLineData
acddc0ed 1// SPDX-License-Identifier: GPL-2.0-or-later
12e41d03 2/*
896014f4
DL
3 * PIM for Quagga
4 * Copyright (C) 2008 Everton da Silva Marques
896014f4 5 */
12e41d03
DL
6
7#include <zebra.h>
8
9#include "log.h"
d62a17ae 10#include "privs.h"
09781197 11#include "lib/version.h"
12e41d03
DL
12#include <getopt.h>
13#include "command.h"
24a58196 14#include "frrevent.h"
12e41d03
DL
15#include <signal.h>
16
17#include "memory.h"
fc7948fa 18#include "vrf.h"
12e41d03
DL
19#include "filter.h"
20#include "vty.h"
21#include "sigevent.h"
0e8ce7e6
DS
22#include "prefix.h"
23#include "plist.h"
48e8451b 24#include "vrf.h"
4f04a76b 25#include "libfrr.h"
4b6b4784 26#include "routemap.h"
299c66b3 27#include "routing_nb.h"
12e41d03
DL
28
29#include "pimd.h"
c2cf4b02 30#include "pim_instance.h"
12e41d03
DL
31#include "pim_signals.h"
32#include "pim_zebra.h"
11128587 33#include "pim_msdp.h"
7176984f 34#include "pim_iface.h"
ba4eb1bc 35#include "pim_bfd.h"
36b5b98f 36#include "pim_mlag.h"
d9ff4302 37#include "pim_errors.h"
299c66b3 38#include "pim_nb.h"
12e41d03 39
12e41d03
DL
40extern struct host host;
41
d62a17ae 42struct option longopts[] = {{0}};
12e41d03
DL
43
44/* pimd privileges */
d62a17ae 45zebra_capabilities_t _caps_p[] = {
9d303b37 46 ZCAP_NET_ADMIN, ZCAP_SYS_ADMIN, ZCAP_NET_RAW, ZCAP_BIND,
12e41d03
DL
47};
48
49/* pimd privileges to run with */
d62a17ae 50struct zebra_privs_t pimd_privs = {
b2f36157 51#if defined(FRR_USER) && defined(FRR_GROUP)
d62a17ae 52 .user = FRR_USER,
53 .group = FRR_GROUP,
12e41d03
DL
54#endif
55#ifdef VTY_GROUP
d62a17ae 56 .vty_group = VTY_GROUP,
12e41d03 57#endif
d62a17ae 58 .caps_p = _caps_p,
97b5d752 59 .cap_num_p = array_size(_caps_p),
d62a17ae 60 .cap_num_i = 0};
4f04a76b 61
0d8c7a26 62static const struct frr_yang_module_info *const pimd_yang_modules[] = {
fb7f5aa8 63 &frr_filter_info,
a4bed468 64 &frr_interface_info,
4b6b4784 65 &frr_route_map_info,
6fd8972a 66 &frr_vrf_info,
299c66b3
SP
67 &frr_routing_info,
68 &frr_pim_info,
69 &frr_pim_rp_info,
3051f443 70 &frr_gmp_info,
8fcdd0d6
RW
71};
72
d62a17ae 73FRR_DAEMON_INFO(pimd, PIM, .vty_port = PIMD_VTY_PORT,
12e41d03 74
d62a17ae 75 .proghelp = "Implementation of the PIM routing protocol.",
1bc98276 76
d62a17ae 77 .signals = pimd_signals,
78 .n_signals = 4 /* XXX array_size(pimd_signals) XXX*/,
4f04a76b 79
8fcdd0d6 80 .privs = &pimd_privs, .yang_modules = pimd_yang_modules,
80413c20
DL
81 .n_yang_modules = array_size(pimd_yang_modules),
82);
4f04a76b 83
4f04a76b 84
d62a17ae 85int main(int argc, char **argv, char **envp)
86{
87 frr_preinit(&pimd_di, argc, argv);
88 frr_opt_add("", longopts, "");
89
90 /* this while just reads the options */
91 while (1) {
92 int opt;
93
94 opt = frr_getopt(argc, argv, NULL);
95
96 if (opt == EOF)
97 break;
98
99 switch (opt) {
100 case 0:
101 break;
102 default:
103 frr_help_exit(1);
d62a17ae 104 }
105 }
106
36417fcc 107 pim_router_init();
d62a17ae 108
109 /*
110 * Initializations
111 */
d9ff4302 112 pim_error_init();
d62a17ae 113 pim_vrf_init();
114 access_list_init();
115 prefix_list_init();
116 prefix_list_add_hook(pim_prefix_list_update);
117 prefix_list_delete_hook(pim_prefix_list_update);
118
119 pim_route_map_init();
120 pim_init();
d62a17ae 121
122 /*
123 * Initialize zclient "update" and "lookup" sockets
124 */
6b88faa7 125 pim_iface_init();
d62a17ae 126 pim_zebra_init();
127 pim_bfd_init();
36b5b98f 128 pim_mlag_init();
d62a17ae 129
299c66b3
SP
130 hook_register(routing_conf_event,
131 routing_control_plane_protocols_name_validate);
132
2ada6269
IR
133 routing_control_plane_protocols_register_vrf_dependency();
134
d62a17ae 135 frr_config_fork();
12e41d03 136
12e41d03 137#ifdef PIM_DEBUG_BYDEFAULT
d62a17ae 138 zlog_notice("PIM_DEBUG_BYDEFAULT: Enabling all debug commands");
139 PIM_DO_DEBUG_PIM_EVENTS;
140 PIM_DO_DEBUG_PIM_PACKETS;
141 PIM_DO_DEBUG_PIM_TRACE;
d891fa78
SG
142 PIM_DO_DEBUG_GM_EVENTS;
143 PIM_DO_DEBUG_GM_PACKETS;
144 PIM_DO_DEBUG_GM_TRACE;
d62a17ae 145 PIM_DO_DEBUG_ZEBRA;
12e41d03
DL
146#endif
147
12e41d03 148#ifdef PIM_CHECK_RECV_IFINDEX_SANITY
d62a17ae 149 zlog_notice(
150 "PIM_CHECK_RECV_IFINDEX_SANITY: will match sock/recv ifindex");
12e41d03 151#ifdef PIM_REPORT_RECV_IFINDEX_MISMATCH
d62a17ae 152 zlog_notice(
153 "PIM_REPORT_RECV_IFINDEX_MISMATCH: will report sock/recv ifindex mismatch");
12e41d03
DL
154#endif
155#endif
156
157#ifdef PIM_UNEXPECTED_KERNEL_UPCALL
d62a17ae 158 zlog_notice(
159 "PIM_UNEXPECTED_KERNEL_UPCALL: report unexpected kernel upcall");
12e41d03
DL
160#endif
161
36417fcc 162 frr_run(router->master);
12e41d03 163
d62a17ae 164 /* never reached */
165 return 0;
12e41d03 166}