]> git.proxmox.com Git - mirror_frr.git/blob - pimd/pim_vty.c
pimd: Dissallow query to be received from a non-connected source
[mirror_frr.git] / pimd / pim_vty.c
1 /*
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 */
19
20 #include <zebra.h>
21
22 #include "if.h"
23 #include "linklist.h"
24 #include "prefix.h"
25 #include "vty.h"
26 #include "vrf.h"
27 #include "plist.h"
28
29 #include "pimd.h"
30 #include "pim_vty.h"
31 #include "pim_iface.h"
32 #include "pim_cmd.h"
33 #include "pim_str.h"
34 #include "pim_ssmpingd.h"
35 #include "pim_pim.h"
36 #include "pim_oil.h"
37 #include "pim_static.h"
38 #include "pim_rp.h"
39 #include "pim_msdp.h"
40 #include "pim_ssm.h"
41 #include "pim_bfd.h"
42 #include "pim_vxlan.h"
43
44 int pim_debug_config_write(struct vty *vty)
45 {
46 int writes = 0;
47
48 if (PIM_DEBUG_MSDP_EVENTS) {
49 vty_out(vty, "debug msdp events\n");
50 ++writes;
51 }
52 if (PIM_DEBUG_MSDP_PACKETS) {
53 vty_out(vty, "debug msdp packets\n");
54 ++writes;
55 }
56 if (PIM_DEBUG_MSDP_INTERNAL) {
57 vty_out(vty, "debug msdp internal\n");
58 ++writes;
59 }
60 if (PIM_DEBUG_IGMP_EVENTS) {
61 vty_out(vty, "debug igmp events\n");
62 ++writes;
63 }
64 if (PIM_DEBUG_IGMP_PACKETS) {
65 vty_out(vty, "debug igmp packets\n");
66 ++writes;
67 }
68 if (PIM_DEBUG_IGMP_TRACE) {
69 vty_out(vty, "debug igmp trace\n");
70 ++writes;
71 }
72 if (PIM_DEBUG_IGMP_TRACE_DETAIL) {
73 vty_out(vty, "debug igmp trace detail\n");
74 ++writes;
75 }
76
77 if (PIM_DEBUG_MROUTE) {
78 vty_out(vty, "debug mroute\n");
79 ++writes;
80 }
81
82 if (PIM_DEBUG_MTRACE) {
83 vty_out(vty, "debug mtrace\n");
84 ++writes;
85 }
86
87 if (PIM_DEBUG_MROUTE_DETAIL) {
88 vty_out(vty, "debug mroute detail\n");
89 ++writes;
90 }
91
92 if (PIM_DEBUG_PIM_EVENTS) {
93 vty_out(vty, "debug pim events\n");
94 ++writes;
95 }
96 if (PIM_DEBUG_PIM_PACKETS) {
97 vty_out(vty, "debug pim packets\n");
98 ++writes;
99 }
100 if (PIM_DEBUG_PIM_PACKETDUMP_SEND) {
101 vty_out(vty, "debug pim packet-dump send\n");
102 ++writes;
103 }
104 if (PIM_DEBUG_PIM_PACKETDUMP_RECV) {
105 vty_out(vty, "debug pim packet-dump receive\n");
106 ++writes;
107 }
108
109 if (PIM_DEBUG_PIM_TRACE) {
110 vty_out(vty, "debug pim trace\n");
111 ++writes;
112 }
113 if (PIM_DEBUG_PIM_TRACE_DETAIL) {
114 vty_out(vty, "debug pim trace detail\n");
115 ++writes;
116 }
117
118 if (PIM_DEBUG_ZEBRA) {
119 vty_out(vty, "debug pim zebra\n");
120 ++writes;
121 }
122
123 if (PIM_DEBUG_VXLAN) {
124 vty_out(vty, "debug pim vxlan\n");
125 ++writes;
126 }
127
128 if (PIM_DEBUG_SSMPINGD) {
129 vty_out(vty, "debug ssmpingd\n");
130 ++writes;
131 }
132
133 if (PIM_DEBUG_PIM_HELLO) {
134 vty_out(vty, "debug pim packets hello\n");
135 ++writes;
136 }
137
138 if (PIM_DEBUG_PIM_J_P) {
139 vty_out(vty, "debug pim packets joins\n");
140 ++writes;
141 }
142
143 if (PIM_DEBUG_PIM_REG) {
144 vty_out(vty, "debug pim packets register\n");
145 ++writes;
146 }
147
148 if (PIM_DEBUG_STATIC) {
149 vty_out(vty, "debug pim static\n");
150 ++writes;
151 }
152
153 if (PIM_DEBUG_PIM_NHT) {
154 vty_out(vty, "debug pim nht\n");
155 ++writes;
156 }
157
158 return writes;
159 }
160
161 int pim_global_config_write_worker(struct pim_instance *pim, struct vty *vty)
162 {
163 int writes = 0;
164 struct pim_ssm *ssm = pim->ssm_info;
165 char spaces[10];
166
167 if (pim->vrf_id == VRF_DEFAULT)
168 sprintf(spaces, "%s", "");
169 else
170 sprintf(spaces, "%s", " ");
171
172 writes += pim_msdp_config_write(pim, vty, spaces);
173
174 if (!pim->send_v6_secondary) {
175 vty_out(vty, "%sno ip pim send-v6-secondary\n", spaces);
176 ++writes;
177 }
178
179 writes += pim_rp_config_write(pim, vty, spaces);
180
181 if (router->register_suppress_time
182 != PIM_REGISTER_SUPPRESSION_TIME_DEFAULT) {
183 vty_out(vty, "%sip pim register-suppress-time %d\n", spaces,
184 router->register_suppress_time);
185 ++writes;
186 }
187 if (router->t_periodic != PIM_DEFAULT_T_PERIODIC) {
188 vty_out(vty, "%sip pim join-prune-interval %d\n", spaces,
189 router->t_periodic);
190 ++writes;
191 }
192 if (pim->keep_alive_time != PIM_KEEPALIVE_PERIOD) {
193 vty_out(vty, "%sip pim keep-alive-timer %d\n", spaces,
194 pim->keep_alive_time);
195 ++writes;
196 }
197 if (pim->rp_keep_alive_time != (unsigned int)PIM_RP_KEEPALIVE_PERIOD) {
198 vty_out(vty, "%sip pim rp keep-alive-timer %d\n", spaces,
199 pim->rp_keep_alive_time);
200 ++writes;
201 }
202 if (router->packet_process != PIM_DEFAULT_PACKET_PROCESS) {
203 vty_out(vty, "%sip pim packets %d\n", spaces,
204 router->packet_process);
205 ++writes;
206 }
207 if (ssm->plist_name) {
208 vty_out(vty, "%sip pim ssm prefix-list %s\n", spaces,
209 ssm->plist_name);
210 ++writes;
211 }
212 if (pim->spt.switchover == PIM_SPT_INFINITY) {
213 if (pim->spt.plist)
214 vty_out(vty,
215 "%sip pim spt-switchover infinity-and-beyond prefix-list %s\n",
216 spaces, pim->spt.plist);
217 else
218 vty_out(vty,
219 "%sip pim spt-switchover infinity-and-beyond\n",
220 spaces);
221 ++writes;
222 }
223 if (pim->ecmp_rebalance_enable) {
224 vty_out(vty, "%sip pim ecmp rebalance\n", spaces);
225 ++writes;
226 } else if (pim->ecmp_enable) {
227 vty_out(vty, "%sip pim ecmp\n", spaces);
228 ++writes;
229 }
230 if (pim->ssmpingd_list) {
231 struct listnode *node;
232 struct ssmpingd_sock *ss;
233 ++writes;
234 for (ALL_LIST_ELEMENTS_RO(pim->ssmpingd_list, node, ss)) {
235 char source_str[INET_ADDRSTRLEN];
236 pim_inet4_dump("<src?>", ss->source_addr, source_str,
237 sizeof(source_str));
238 vty_out(vty, "%sip ssmpingd %s\n", spaces, source_str);
239 ++writes;
240 }
241 }
242
243 pim_vxlan_config_write(vty, spaces, &writes);
244
245 return writes;
246 }
247
248 int pim_interface_config_write(struct vty *vty)
249 {
250 struct pim_instance *pim;
251 struct interface *ifp;
252 struct vrf *vrf;
253 int writes = 0;
254
255 RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
256 pim = vrf->info;
257 if (!pim)
258 continue;
259
260 FOR_ALL_INTERFACES (pim->vrf, ifp) {
261 /* IF name */
262 if (vrf->vrf_id == VRF_DEFAULT)
263 vty_frame(vty, "interface %s\n", ifp->name);
264 else
265 vty_frame(vty, "interface %s vrf %s\n",
266 ifp->name, vrf->name);
267 ++writes;
268
269 if (ifp->desc) {
270 vty_out(vty, " description %s\n", ifp->desc);
271 ++writes;
272 }
273
274 if (ifp->info) {
275 struct pim_interface *pim_ifp = ifp->info;
276
277 if (PIM_IF_TEST_PIM(pim_ifp->options)) {
278 vty_out(vty, " ip pim\n");
279 ++writes;
280 }
281
282 /* IF ip pim drpriority */
283 if (pim_ifp->pim_dr_priority
284 != PIM_DEFAULT_DR_PRIORITY) {
285 vty_out(vty, " ip pim drpriority %u\n",
286 pim_ifp->pim_dr_priority);
287 ++writes;
288 }
289
290 /* IF ip pim hello */
291 if (pim_ifp->pim_hello_period
292 != PIM_DEFAULT_HELLO_PERIOD) {
293 vty_out(vty, " ip pim hello %d",
294 pim_ifp->pim_hello_period);
295 if (pim_ifp->pim_default_holdtime != -1)
296 vty_out(vty, " %d",
297 pim_ifp->pim_default_holdtime);
298 vty_out(vty, "\n");
299 ++writes;
300 }
301
302 /* update source */
303 if (PIM_INADDR_ISNOT_ANY(
304 pim_ifp->update_source)) {
305 char src_str[INET_ADDRSTRLEN];
306 pim_inet4_dump("<src?>",
307 pim_ifp->update_source,
308 src_str,
309 sizeof(src_str));
310 vty_out(vty, " ip pim use-source %s\n",
311 src_str);
312 ++writes;
313 }
314
315 /* IF ip igmp */
316 if (PIM_IF_TEST_IGMP(pim_ifp->options)) {
317 vty_out(vty, " ip igmp\n");
318 ++writes;
319 }
320
321 /* ip igmp version */
322 if (pim_ifp->igmp_version
323 != IGMP_DEFAULT_VERSION) {
324 vty_out(vty, " ip igmp version %d\n",
325 pim_ifp->igmp_version);
326 ++writes;
327 }
328
329 /* IF ip igmp query-max-response-time */
330 if (pim_ifp->igmp_query_max_response_time_dsec
331 != IGMP_QUERY_MAX_RESPONSE_TIME_DSEC) {
332 vty_out(vty,
333 " ip igmp query-max-response-time %d\n",
334 pim_ifp->igmp_query_max_response_time_dsec);
335 ++writes;
336 }
337
338 /* IF ip igmp query-interval */
339 if (pim_ifp->igmp_default_query_interval
340 != IGMP_GENERAL_QUERY_INTERVAL) {
341 vty_out(vty,
342 " ip igmp query-interval %d\n",
343 pim_ifp->igmp_default_query_interval);
344 ++writes;
345 }
346
347 /* IF ip igmp join */
348 if (pim_ifp->igmp_join_list) {
349 struct listnode *node;
350 struct igmp_join *ij;
351 for (ALL_LIST_ELEMENTS_RO(
352 pim_ifp->igmp_join_list,
353 node, ij)) {
354 char group_str[INET_ADDRSTRLEN];
355 char source_str
356 [INET_ADDRSTRLEN];
357 pim_inet4_dump(
358 "<grp?>",
359 ij->group_addr,
360 group_str,
361 sizeof(group_str));
362 inet_ntop(AF_INET,
363 &ij->source_addr,
364 source_str,
365 sizeof(source_str));
366 vty_out(vty,
367 " ip igmp join %s %s\n",
368 group_str, source_str);
369 ++writes;
370 }
371 }
372
373 if (pim_ifp->activeactive)
374 vty_out(vty, " ip pim active-active\n");
375
376 /* boundary */
377 if (pim_ifp->boundary_oil_plist) {
378 vty_out(vty,
379 " ip multicast boundary oil %s\n",
380 pim_ifp->boundary_oil_plist);
381 ++writes;
382 }
383
384 writes +=
385 pim_static_write_mroute(pim, vty, ifp);
386 pim_bfd_write_config(vty, ifp);
387 }
388 vty_endframe(vty, "!\n");
389 ++writes;
390 }
391 }
392
393 return writes;
394 }