]> git.proxmox.com Git - mirror_frr.git/blob - pimd/pim_vty.c
Merge pull request #13522 from LabNConsulting/chopps/fix-bgp-test
[mirror_frr.git] / pimd / pim_vty.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * PIM for Quagga
4 * Copyright (C) 2008 Everton da Silva Marques
5 */
6
7 #include <zebra.h>
8
9 #include "if.h"
10 #include "linklist.h"
11 #include "prefix.h"
12 #include "vty.h"
13 #include "vrf.h"
14 #include "plist.h"
15
16 #include "pimd.h"
17 #include "pim_vty.h"
18 #include "pim_iface.h"
19 #include "pim_str.h"
20 #include "pim_ssmpingd.h"
21 #include "pim_pim.h"
22 #include "pim_oil.h"
23 #include "pim_static.h"
24 #include "pim_rp.h"
25 #include "pim_msdp.h"
26 #include "pim_ssm.h"
27 #include "pim_bfd.h"
28 #include "pim_bsm.h"
29 #include "pim_vxlan.h"
30 #include "pim6_mld.h"
31
32 int pim_debug_config_write(struct vty *vty)
33 {
34 int writes = 0;
35
36 if (PIM_DEBUG_MSDP_EVENTS) {
37 vty_out(vty, "debug msdp events\n");
38 ++writes;
39 }
40 if (PIM_DEBUG_MSDP_PACKETS) {
41 vty_out(vty, "debug msdp packets\n");
42 ++writes;
43 }
44 if (PIM_DEBUG_MSDP_INTERNAL) {
45 vty_out(vty, "debug msdp internal\n");
46 ++writes;
47 }
48 if (PIM_DEBUG_GM_EVENTS) {
49 vty_out(vty, "debug " GM_AF_DBG " events\n");
50 ++writes;
51 }
52 if (PIM_DEBUG_GM_PACKETS) {
53 vty_out(vty, "debug " GM_AF_DBG " packets\n");
54 ++writes;
55 }
56 /* PIM_DEBUG_GM_TRACE catches _DETAIL too */
57 if (router->debugs & PIM_MASK_GM_TRACE) {
58 vty_out(vty, "debug " GM_AF_DBG " trace\n");
59 ++writes;
60 }
61 if (PIM_DEBUG_GM_TRACE_DETAIL) {
62 vty_out(vty, "debug " GM_AF_DBG " trace detail\n");
63 ++writes;
64 }
65
66 /* PIM_DEBUG_MROUTE catches _DETAIL too */
67 if (router->debugs & PIM_MASK_MROUTE) {
68 vty_out(vty, "debug " PIM_MROUTE_DBG "\n");
69 ++writes;
70 }
71 if (PIM_DEBUG_MROUTE_DETAIL) {
72 vty_out(vty, "debug " PIM_MROUTE_DBG " detail\n");
73 ++writes;
74 }
75
76 if (PIM_DEBUG_MTRACE) {
77 vty_out(vty, "debug mtrace\n");
78 ++writes;
79 }
80
81 if (PIM_DEBUG_PIM_EVENTS) {
82 vty_out(vty, "debug " PIM_AF_DBG " events\n");
83 ++writes;
84 }
85 if (PIM_DEBUG_PIM_PACKETS) {
86 vty_out(vty, "debug " PIM_AF_DBG " packets\n");
87 ++writes;
88 }
89 if (PIM_DEBUG_PIM_PACKETDUMP_SEND) {
90 vty_out(vty, "debug " PIM_AF_DBG " packet-dump send\n");
91 ++writes;
92 }
93 if (PIM_DEBUG_PIM_PACKETDUMP_RECV) {
94 vty_out(vty, "debug " PIM_AF_DBG " packet-dump receive\n");
95 ++writes;
96 }
97
98 /* PIM_DEBUG_PIM_TRACE catches _DETAIL too */
99 if (router->debugs & PIM_MASK_PIM_TRACE) {
100 vty_out(vty, "debug " PIM_AF_DBG " trace\n");
101 ++writes;
102 }
103 if (PIM_DEBUG_PIM_TRACE_DETAIL) {
104 vty_out(vty, "debug " PIM_AF_DBG " trace detail\n");
105 ++writes;
106 }
107
108 if (PIM_DEBUG_ZEBRA) {
109 vty_out(vty, "debug " PIM_AF_DBG " zebra\n");
110 ++writes;
111 }
112
113 if (PIM_DEBUG_MLAG) {
114 vty_out(vty, "debug pim mlag\n");
115 ++writes;
116 }
117
118 if (PIM_DEBUG_BSM) {
119 vty_out(vty, "debug " PIM_AF_DBG " bsm\n");
120 ++writes;
121 }
122
123 if (PIM_DEBUG_VXLAN) {
124 vty_out(vty, "debug " PIM_AF_DBG " 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_AF_DBG " packets hello\n");
135 ++writes;
136 }
137
138 if (PIM_DEBUG_PIM_J_P) {
139 vty_out(vty, "debug " PIM_AF_DBG " packets joins\n");
140 ++writes;
141 }
142
143 if (PIM_DEBUG_PIM_REG) {
144 vty_out(vty, "debug " PIM_AF_DBG " 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_AF_DBG " nht\n");
155 ++writes;
156 }
157
158 if (PIM_DEBUG_PIM_NHT_RP) {
159 vty_out(vty, "debug pim nht rp\n");
160 ++writes;
161 }
162
163 if (PIM_DEBUG_PIM_NHT_DETAIL) {
164 vty_out(vty, "debug " PIM_AF_DBG " nht detail\n");
165 ++writes;
166 }
167
168 return writes;
169 }
170
171 int pim_global_config_write_worker(struct pim_instance *pim, struct vty *vty)
172 {
173 int writes = 0;
174 struct pim_ssm *ssm = pim->ssm_info;
175 char spaces[10];
176
177 if (pim->vrf->vrf_id == VRF_DEFAULT)
178 snprintf(spaces, sizeof(spaces), "%s", "");
179 else
180 snprintf(spaces, sizeof(spaces), "%s", " ");
181
182 writes += pim_msdp_peer_config_write(vty, pim, spaces);
183 writes += pim_msdp_config_write(pim, vty, spaces);
184
185 if (!pim->send_v6_secondary) {
186 vty_out(vty, "%sno ip pim send-v6-secondary\n", spaces);
187 ++writes;
188 }
189
190 writes += pim_rp_config_write(pim, vty, spaces);
191
192 if (pim->vrf->vrf_id == VRF_DEFAULT) {
193 if (router->register_suppress_time
194 != PIM_REGISTER_SUPPRESSION_TIME_DEFAULT) {
195 vty_out(vty, "%s" PIM_AF_NAME " pim register-suppress-time %d\n",
196 spaces, router->register_suppress_time);
197 ++writes;
198 }
199 if (router->t_periodic != PIM_DEFAULT_T_PERIODIC) {
200 vty_out(vty, "%s" PIM_AF_NAME " pim join-prune-interval %d\n",
201 spaces, router->t_periodic);
202 ++writes;
203 }
204
205 if (router->packet_process != PIM_DEFAULT_PACKET_PROCESS) {
206 vty_out(vty, "%s" PIM_AF_NAME " pim packets %d\n", spaces,
207 router->packet_process);
208 ++writes;
209 }
210 }
211 if (pim->keep_alive_time != PIM_KEEPALIVE_PERIOD) {
212 vty_out(vty, "%s" PIM_AF_NAME " pim keep-alive-timer %d\n",
213 spaces, pim->keep_alive_time);
214 ++writes;
215 }
216 if (pim->rp_keep_alive_time != (unsigned int)PIM_RP_KEEPALIVE_PERIOD) {
217 vty_out(vty, "%s" PIM_AF_NAME " pim rp keep-alive-timer %d\n",
218 spaces, pim->rp_keep_alive_time);
219 ++writes;
220 }
221 if (ssm->plist_name) {
222 vty_out(vty, "%sip pim ssm prefix-list %s\n", spaces,
223 ssm->plist_name);
224 ++writes;
225 }
226 if (pim->register_plist) {
227 vty_out(vty, "%sip pim register-accept-list %s\n", spaces,
228 pim->register_plist);
229 ++writes;
230 }
231 if (pim->spt.switchover == PIM_SPT_INFINITY) {
232 if (pim->spt.plist)
233 vty_out(vty,
234 "%s" PIM_AF_NAME " pim spt-switchover infinity-and-beyond prefix-list %s\n",
235 spaces, pim->spt.plist);
236 else
237 vty_out(vty,
238 "%s" PIM_AF_NAME " pim spt-switchover infinity-and-beyond\n",
239 spaces);
240 ++writes;
241 }
242 if (pim->ecmp_rebalance_enable) {
243 vty_out(vty, "%sip pim ecmp rebalance\n", spaces);
244 ++writes;
245 } else if (pim->ecmp_enable) {
246 vty_out(vty, "%sip pim ecmp\n", spaces);
247 ++writes;
248 }
249
250 if (pim->gm_watermark_limit != 0) {
251 #if PIM_IPV == 4
252 vty_out(vty, "%s" PIM_AF_NAME " igmp watermark-warn %u\n",
253 spaces, pim->gm_watermark_limit);
254 #else
255 vty_out(vty, "%s" PIM_AF_NAME " mld watermark-warn %u\n",
256 spaces, pim->gm_watermark_limit);
257 #endif
258 ++writes;
259 }
260
261 if (pim->ssmpingd_list) {
262 struct listnode *node;
263 struct ssmpingd_sock *ss;
264 ++writes;
265 for (ALL_LIST_ELEMENTS_RO(pim->ssmpingd_list, node, ss)) {
266 vty_out(vty, "%s" PIM_AF_NAME " ssmpingd %pPA\n",
267 spaces, &ss->source_addr);
268 ++writes;
269 }
270 }
271
272 if (pim->msdp.hold_time != PIM_MSDP_PEER_HOLD_TIME
273 || pim->msdp.keep_alive != PIM_MSDP_PEER_KA_TIME
274 || pim->msdp.connection_retry != PIM_MSDP_PEER_CONNECT_RETRY_TIME) {
275 vty_out(vty, "%sip msdp timers %u %u", spaces,
276 pim->msdp.hold_time, pim->msdp.keep_alive);
277 if (pim->msdp.connection_retry
278 != PIM_MSDP_PEER_CONNECT_RETRY_TIME)
279 vty_out(vty, " %u", pim->msdp.connection_retry);
280 vty_out(vty, "\n");
281 }
282
283 return writes;
284 }
285
286 #if PIM_IPV == 4
287 static int gm_config_write(struct vty *vty, int writes,
288 struct pim_interface *pim_ifp)
289 {
290 /* IF ip igmp */
291 if (pim_ifp->gm_enable) {
292 vty_out(vty, " ip igmp\n");
293 ++writes;
294 }
295
296 /* ip igmp version */
297 if (pim_ifp->igmp_version != IGMP_DEFAULT_VERSION) {
298 vty_out(vty, " ip igmp version %d\n", pim_ifp->igmp_version);
299 ++writes;
300 }
301
302 /* IF ip igmp query-max-response-time */
303 if (pim_ifp->gm_query_max_response_time_dsec !=
304 GM_QUERY_MAX_RESPONSE_TIME_DSEC) {
305 vty_out(vty, " ip igmp query-max-response-time %d\n",
306 pim_ifp->gm_query_max_response_time_dsec);
307 ++writes;
308 }
309
310 /* IF ip igmp query-interval */
311 if (pim_ifp->gm_default_query_interval != GM_GENERAL_QUERY_INTERVAL) {
312 vty_out(vty, " ip igmp query-interval %d\n",
313 pim_ifp->gm_default_query_interval);
314 ++writes;
315 }
316
317 /* IF ip igmp last-member_query-count */
318 if (pim_ifp->gm_last_member_query_count !=
319 GM_DEFAULT_ROBUSTNESS_VARIABLE) {
320 vty_out(vty, " ip igmp last-member-query-count %d\n",
321 pim_ifp->gm_last_member_query_count);
322 ++writes;
323 }
324
325 /* IF ip igmp last-member_query-interval */
326 if (pim_ifp->gm_specific_query_max_response_time_dsec !=
327 GM_SPECIFIC_QUERY_MAX_RESPONSE_TIME_DSEC) {
328 vty_out(vty, " ip igmp last-member-query-interval %d\n",
329 pim_ifp->gm_specific_query_max_response_time_dsec);
330 ++writes;
331 }
332
333 /* IF ip igmp join */
334 if (pim_ifp->gm_join_list) {
335 struct listnode *node;
336 struct gm_join *ij;
337 for (ALL_LIST_ELEMENTS_RO(pim_ifp->gm_join_list, node, ij)) {
338 if (pim_addr_is_any(ij->source_addr))
339 vty_out(vty, " ip igmp join %pPAs\n",
340 &ij->group_addr);
341 else
342 vty_out(vty, " ip igmp join %pPAs %pPAs\n",
343 &ij->group_addr, &ij->source_addr);
344 ++writes;
345 }
346 }
347
348 return writes;
349 }
350 #else
351 static int gm_config_write(struct vty *vty, int writes,
352 struct pim_interface *pim_ifp)
353 {
354 /* IF ipv6 mld */
355 if (pim_ifp->gm_enable) {
356 vty_out(vty, " ipv6 mld\n");
357 ++writes;
358 }
359
360 if (pim_ifp->mld_version != MLD_DEFAULT_VERSION)
361 vty_out(vty, " ipv6 mld version %d\n", pim_ifp->mld_version);
362
363 /* IF ipv6 mld query-max-response-time */
364 if (pim_ifp->gm_query_max_response_time_dsec !=
365 GM_QUERY_MAX_RESPONSE_TIME_DSEC)
366 vty_out(vty, " ipv6 mld query-max-response-time %d\n",
367 pim_ifp->gm_query_max_response_time_dsec);
368
369 if (pim_ifp->gm_default_query_interval != GM_GENERAL_QUERY_INTERVAL)
370 vty_out(vty, " ipv6 mld query-interval %d\n",
371 pim_ifp->gm_default_query_interval);
372
373 /* IF ipv6 mld last-member_query-count */
374 if (pim_ifp->gm_last_member_query_count !=
375 GM_DEFAULT_ROBUSTNESS_VARIABLE)
376 vty_out(vty, " ipv6 mld last-member-query-count %d\n",
377 pim_ifp->gm_last_member_query_count);
378
379 /* IF ipv6 mld last-member_query-interval */
380 if (pim_ifp->gm_specific_query_max_response_time_dsec !=
381 GM_SPECIFIC_QUERY_MAX_RESPONSE_TIME_DSEC)
382 vty_out(vty, " ipv6 mld last-member-query-interval %d\n",
383 pim_ifp->gm_specific_query_max_response_time_dsec);
384
385 /* IF ipv6 mld join */
386 if (pim_ifp->gm_join_list) {
387 struct listnode *node;
388 struct gm_join *ij;
389 for (ALL_LIST_ELEMENTS_RO(pim_ifp->gm_join_list, node, ij)) {
390 if (pim_addr_is_any(ij->source_addr))
391 vty_out(vty, " ipv6 mld join %pPAs\n",
392 &ij->group_addr);
393 else
394 vty_out(vty, " ipv6 mld join %pPAs %pPAs\n",
395 &ij->group_addr, &ij->source_addr);
396 ++writes;
397 }
398 }
399
400 return writes;
401 }
402 #endif
403
404 int pim_config_write(struct vty *vty, int writes, struct interface *ifp,
405 struct pim_instance *pim)
406 {
407 struct pim_interface *pim_ifp = ifp->info;
408
409 if (pim_ifp->pim_enable) {
410 vty_out(vty, " " PIM_AF_NAME " pim\n");
411 ++writes;
412 }
413
414 /* IF ip pim drpriority */
415 if (pim_ifp->pim_dr_priority != PIM_DEFAULT_DR_PRIORITY) {
416 vty_out(vty, " " PIM_AF_NAME " pim drpriority %u\n",
417 pim_ifp->pim_dr_priority);
418 ++writes;
419 }
420
421 /* IF ip pim hello */
422 if (pim_ifp->pim_hello_period != PIM_DEFAULT_HELLO_PERIOD) {
423 vty_out(vty, " " PIM_AF_NAME " pim hello %d", pim_ifp->pim_hello_period);
424 if (pim_ifp->pim_default_holdtime != -1)
425 vty_out(vty, " %d", pim_ifp->pim_default_holdtime);
426 vty_out(vty, "\n");
427 ++writes;
428 }
429
430 writes += gm_config_write(vty, writes, pim_ifp);
431
432 /* update source */
433 if (!pim_addr_is_any(pim_ifp->update_source)) {
434 vty_out(vty, " " PIM_AF_NAME " pim use-source %pPA\n",
435 &pim_ifp->update_source);
436 ++writes;
437 }
438
439 if (pim_ifp->activeactive)
440 vty_out(vty, " " PIM_AF_NAME " pim active-active\n");
441
442 /* boundary */
443 if (pim_ifp->boundary_oil_plist) {
444 vty_out(vty, " " PIM_AF_NAME " multicast boundary oil %s\n",
445 pim_ifp->boundary_oil_plist);
446 ++writes;
447 }
448
449 if (pim_ifp->pim_passive_enable) {
450 vty_out(vty, " " PIM_AF_NAME " pim passive\n");
451 ++writes;
452 }
453
454 writes += pim_static_write_mroute(pim, vty, ifp);
455 pim_bsm_write_config(vty, ifp);
456 ++writes;
457 pim_bfd_write_config(vty, ifp);
458 ++writes;
459
460 return writes;
461 }
462
463 int pim_interface_config_write(struct vty *vty)
464 {
465 struct pim_instance *pim;
466 struct interface *ifp;
467 struct vrf *vrf;
468 int writes = 0;
469
470 RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
471 pim = vrf->info;
472 if (!pim)
473 continue;
474
475 FOR_ALL_INTERFACES (pim->vrf, ifp) {
476 /* pim is enabled internally/implicitly on the vxlan
477 * termination device ipmr-lo. skip displaying that
478 * config to avoid confusion
479 */
480 if (pim_vxlan_is_term_dev_cfg(pim, ifp))
481 continue;
482
483 /* IF name */
484 if_vty_config_start(vty, ifp);
485
486 ++writes;
487
488 if (ifp->desc) {
489 vty_out(vty, " description %s\n", ifp->desc);
490 ++writes;
491 }
492
493 if (ifp->info) {
494 pim_config_write(vty, writes, ifp, pim);
495 }
496 if_vty_config_end(vty);
497
498 ++writes;
499 }
500 }
501
502 return writes;
503 }