]>
Commit | Line | Data |
---|---|---|
12e41d03 | 1 | /* |
896014f4 DL |
2 | * PIM for Quagga |
3 | * Copyright (C) 2008 Everton da Silva Marques | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License as published by | |
7 | * the Free Software Foundation; either version 2 of the License, or | |
8 | * (at your option) any later version. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, but | |
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | * General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License along | |
16 | * with this program; see the file COPYING; if not, write to the Free Software | |
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
18 | */ | |
12e41d03 DL |
19 | |
20 | #include <zebra.h> | |
21 | ||
22 | #include "log.h" | |
d62a17ae | 23 | #include "privs.h" |
09781197 | 24 | #include "lib/version.h" |
12e41d03 DL |
25 | #include <getopt.h> |
26 | #include "command.h" | |
27 | #include "thread.h" | |
28 | #include <signal.h> | |
29 | ||
30 | #include "memory.h" | |
fc7948fa | 31 | #include "vrf.h" |
12e41d03 DL |
32 | #include "filter.h" |
33 | #include "vty.h" | |
34 | #include "sigevent.h" | |
0e8ce7e6 DS |
35 | #include "prefix.h" |
36 | #include "plist.h" | |
48e8451b | 37 | #include "vrf.h" |
4f04a76b | 38 | #include "libfrr.h" |
4b6b4784 | 39 | #include "routemap.h" |
299c66b3 | 40 | #include "routing_nb.h" |
12e41d03 DL |
41 | |
42 | #include "pimd.h" | |
c2cf4b02 | 43 | #include "pim_instance.h" |
12e41d03 DL |
44 | #include "pim_signals.h" |
45 | #include "pim_zebra.h" | |
11128587 | 46 | #include "pim_msdp.h" |
7176984f | 47 | #include "pim_iface.h" |
ba4eb1bc | 48 | #include "pim_bfd.h" |
36b5b98f | 49 | #include "pim_mlag.h" |
d9ff4302 | 50 | #include "pim_errors.h" |
299c66b3 | 51 | #include "pim_nb.h" |
12e41d03 | 52 | |
12e41d03 DL |
53 | extern struct host host; |
54 | ||
d62a17ae | 55 | struct option longopts[] = {{0}}; |
12e41d03 DL |
56 | |
57 | /* pimd privileges */ | |
d62a17ae | 58 | zebra_capabilities_t _caps_p[] = { |
9d303b37 | 59 | ZCAP_NET_ADMIN, ZCAP_SYS_ADMIN, ZCAP_NET_RAW, ZCAP_BIND, |
12e41d03 DL |
60 | }; |
61 | ||
62 | /* pimd privileges to run with */ | |
d62a17ae | 63 | struct zebra_privs_t pimd_privs = { |
b2f36157 | 64 | #if defined(FRR_USER) && defined(FRR_GROUP) |
d62a17ae | 65 | .user = FRR_USER, |
66 | .group = FRR_GROUP, | |
12e41d03 DL |
67 | #endif |
68 | #ifdef VTY_GROUP | |
d62a17ae | 69 | .vty_group = VTY_GROUP, |
12e41d03 | 70 | #endif |
d62a17ae | 71 | .caps_p = _caps_p, |
97b5d752 | 72 | .cap_num_p = array_size(_caps_p), |
d62a17ae | 73 | .cap_num_i = 0}; |
4f04a76b | 74 | |
0d8c7a26 | 75 | static const struct frr_yang_module_info *const pimd_yang_modules[] = { |
fb7f5aa8 | 76 | &frr_filter_info, |
a4bed468 | 77 | &frr_interface_info, |
4b6b4784 | 78 | &frr_route_map_info, |
6fd8972a | 79 | &frr_vrf_info, |
299c66b3 SP |
80 | &frr_routing_info, |
81 | &frr_pim_info, | |
82 | &frr_pim_rp_info, | |
3051f443 | 83 | &frr_gmp_info, |
8fcdd0d6 RW |
84 | }; |
85 | ||
d62a17ae | 86 | FRR_DAEMON_INFO(pimd, PIM, .vty_port = PIMD_VTY_PORT, |
12e41d03 | 87 | |
d62a17ae | 88 | .proghelp = "Implementation of the PIM routing protocol.", |
1bc98276 | 89 | |
d62a17ae | 90 | .signals = pimd_signals, |
91 | .n_signals = 4 /* XXX array_size(pimd_signals) XXX*/, | |
4f04a76b | 92 | |
8fcdd0d6 | 93 | .privs = &pimd_privs, .yang_modules = pimd_yang_modules, |
80413c20 DL |
94 | .n_yang_modules = array_size(pimd_yang_modules), |
95 | ); | |
4f04a76b | 96 | |
4f04a76b | 97 | |
d62a17ae | 98 | int main(int argc, char **argv, char **envp) |
99 | { | |
100 | frr_preinit(&pimd_di, argc, argv); | |
101 | frr_opt_add("", longopts, ""); | |
102 | ||
103 | /* this while just reads the options */ | |
104 | while (1) { | |
105 | int opt; | |
106 | ||
107 | opt = frr_getopt(argc, argv, NULL); | |
108 | ||
109 | if (opt == EOF) | |
110 | break; | |
111 | ||
112 | switch (opt) { | |
113 | case 0: | |
114 | break; | |
115 | default: | |
116 | frr_help_exit(1); | |
d62a17ae | 117 | } |
118 | } | |
119 | ||
36417fcc | 120 | pim_router_init(); |
d62a17ae | 121 | |
122 | /* | |
123 | * Initializations | |
124 | */ | |
d9ff4302 | 125 | pim_error_init(); |
d62a17ae | 126 | pim_vrf_init(); |
127 | access_list_init(); | |
128 | prefix_list_init(); | |
129 | prefix_list_add_hook(pim_prefix_list_update); | |
130 | prefix_list_delete_hook(pim_prefix_list_update); | |
131 | ||
132 | pim_route_map_init(); | |
133 | pim_init(); | |
d62a17ae | 134 | |
135 | /* | |
136 | * Initialize zclient "update" and "lookup" sockets | |
137 | */ | |
6b88faa7 | 138 | pim_iface_init(); |
d62a17ae | 139 | pim_zebra_init(); |
140 | pim_bfd_init(); | |
36b5b98f | 141 | pim_mlag_init(); |
d62a17ae | 142 | |
299c66b3 SP |
143 | hook_register(routing_conf_event, |
144 | routing_control_plane_protocols_name_validate); | |
145 | ||
2ada6269 IR |
146 | routing_control_plane_protocols_register_vrf_dependency(); |
147 | ||
d62a17ae | 148 | frr_config_fork(); |
12e41d03 | 149 | |
12e41d03 | 150 | #ifdef PIM_DEBUG_BYDEFAULT |
d62a17ae | 151 | zlog_notice("PIM_DEBUG_BYDEFAULT: Enabling all debug commands"); |
152 | PIM_DO_DEBUG_PIM_EVENTS; | |
153 | PIM_DO_DEBUG_PIM_PACKETS; | |
154 | PIM_DO_DEBUG_PIM_TRACE; | |
d891fa78 SG |
155 | PIM_DO_DEBUG_GM_EVENTS; |
156 | PIM_DO_DEBUG_GM_PACKETS; | |
157 | PIM_DO_DEBUG_GM_TRACE; | |
d62a17ae | 158 | PIM_DO_DEBUG_ZEBRA; |
12e41d03 DL |
159 | #endif |
160 | ||
12e41d03 | 161 | #ifdef PIM_CHECK_RECV_IFINDEX_SANITY |
d62a17ae | 162 | zlog_notice( |
163 | "PIM_CHECK_RECV_IFINDEX_SANITY: will match sock/recv ifindex"); | |
12e41d03 | 164 | #ifdef PIM_REPORT_RECV_IFINDEX_MISMATCH |
d62a17ae | 165 | zlog_notice( |
166 | "PIM_REPORT_RECV_IFINDEX_MISMATCH: will report sock/recv ifindex mismatch"); | |
12e41d03 DL |
167 | #endif |
168 | #endif | |
169 | ||
170 | #ifdef PIM_UNEXPECTED_KERNEL_UPCALL | |
d62a17ae | 171 | zlog_notice( |
172 | "PIM_UNEXPECTED_KERNEL_UPCALL: report unexpected kernel upcall"); | |
12e41d03 DL |
173 | #endif |
174 | ||
36417fcc | 175 | frr_run(router->master); |
12e41d03 | 176 | |
d62a17ae | 177 | /* never reached */ |
178 | return 0; | |
12e41d03 | 179 | } |