]> git.proxmox.com Git - mirror_frr.git/blame - pimd/pim_vty.c
Merge pull request #13249 from Pdoijode/connected-route-install-fix
[mirror_frr.git] / pimd / pim_vty.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 "if.h"
10#include "linklist.h"
dfe43e25
DW
11#include "prefix.h"
12#include "vty.h"
469351b3 13#include "vrf.h"
dfe43e25 14#include "plist.h"
12e41d03
DL
15
16#include "pimd.h"
17#include "pim_vty.h"
18#include "pim_iface.h"
12e41d03
DL
19#include "pim_str.h"
20#include "pim_ssmpingd.h"
dedccda6 21#include "pim_pim.h"
9867746a 22#include "pim_oil.h"
f91f89bc 23#include "pim_static.h"
75a26779 24#include "pim_rp.h"
3c72d654 25#include "pim_msdp.h"
15a5dafe 26#include "pim_ssm.h"
ba4eb1bc 27#include "pim_bfd.h"
16c926c8 28#include "pim_bsm.h"
7c85225c 29#include "pim_vxlan.h"
5afe22f5 30#include "pim6_mld.h"
12e41d03 31
d62a17ae 32int pim_debug_config_write(struct vty *vty)
12e41d03 33{
d62a17ae 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 }
95b13dc5 48 if (PIM_DEBUG_GM_EVENTS) {
a2559761 49 vty_out(vty, "debug " GM_AF_DBG " events\n");
d62a17ae 50 ++writes;
51 }
55eb347d 52 if (PIM_DEBUG_GM_PACKETS) {
a2559761 53 vty_out(vty, "debug " GM_AF_DBG " packets\n");
d62a17ae 54 ++writes;
55 }
a96d64b0 56 /* PIM_DEBUG_GM_TRACE catches _DETAIL too */
d891fa78 57 if (router->debugs & PIM_MASK_GM_TRACE) {
a2559761 58 vty_out(vty, "debug " GM_AF_DBG " trace\n");
d62a17ae 59 ++writes;
e9c59240 60 }
a96d64b0 61 if (PIM_DEBUG_GM_TRACE_DETAIL) {
a2559761 62 vty_out(vty, "debug " GM_AF_DBG " trace detail\n");
e9c59240 63 ++writes;
d62a17ae 64 }
d62a17ae 65
92fed03c
DL
66 /* PIM_DEBUG_MROUTE catches _DETAIL too */
67 if (router->debugs & PIM_MASK_MROUTE) {
ca8cbecd 68 vty_out(vty, "debug " PIM_MROUTE_DBG "\n");
d62a17ae 69 ++writes;
70 }
92fed03c 71 if (PIM_DEBUG_MROUTE_DETAIL) {
ca8cbecd 72 vty_out(vty, "debug " PIM_MROUTE_DBG " detail\n");
4d9ad5dc
MS
73 ++writes;
74 }
75
92fed03c
DL
76 if (PIM_DEBUG_MTRACE) {
77 vty_out(vty, "debug mtrace\n");
d62a17ae 78 ++writes;
79 }
80
81 if (PIM_DEBUG_PIM_EVENTS) {
68a7caf4 82 vty_out(vty, "debug " PIM_AF_DBG " events\n");
d62a17ae 83 ++writes;
84 }
85 if (PIM_DEBUG_PIM_PACKETS) {
68a7caf4 86 vty_out(vty, "debug " PIM_AF_DBG " packets\n");
d62a17ae 87 ++writes;
88 }
89 if (PIM_DEBUG_PIM_PACKETDUMP_SEND) {
68a7caf4 90 vty_out(vty, "debug " PIM_AF_DBG " packet-dump send\n");
d62a17ae 91 ++writes;
92 }
93 if (PIM_DEBUG_PIM_PACKETDUMP_RECV) {
68a7caf4 94 vty_out(vty, "debug " PIM_AF_DBG " packet-dump receive\n");
d62a17ae 95 ++writes;
96 }
97
92fed03c
DL
98 /* PIM_DEBUG_PIM_TRACE catches _DETAIL too */
99 if (router->debugs & PIM_MASK_PIM_TRACE) {
68a7caf4 100 vty_out(vty, "debug " PIM_AF_DBG " trace\n");
d62a17ae 101 ++writes;
102 }
92fed03c 103 if (PIM_DEBUG_PIM_TRACE_DETAIL) {
68a7caf4 104 vty_out(vty, "debug " PIM_AF_DBG " trace detail\n");
d62a17ae 105 ++writes;
106 }
107
108 if (PIM_DEBUG_ZEBRA) {
68a7caf4 109 vty_out(vty, "debug " PIM_AF_DBG " zebra\n");
d62a17ae 110 ++writes;
111 }
112
17823cdd
DS
113 if (PIM_DEBUG_MLAG) {
114 vty_out(vty, "debug pim mlag\n");
115 ++writes;
116 }
117
16c926c8 118 if (PIM_DEBUG_BSM) {
614b77fe 119 vty_out(vty, "debug " PIM_AF_DBG " bsm\n");
16c926c8 120 ++writes;
121 }
122
4d913fa6 123 if (PIM_DEBUG_VXLAN) {
614b77fe 124 vty_out(vty, "debug " PIM_AF_DBG " vxlan\n");
4d913fa6
AK
125 ++writes;
126 }
127
d62a17ae 128 if (PIM_DEBUG_SSMPINGD) {
129 vty_out(vty, "debug ssmpingd\n");
130 ++writes;
131 }
132
133 if (PIM_DEBUG_PIM_HELLO) {
68a7caf4 134 vty_out(vty, "debug " PIM_AF_DBG " packets hello\n");
d62a17ae 135 ++writes;
136 }
137
138 if (PIM_DEBUG_PIM_J_P) {
68a7caf4 139 vty_out(vty, "debug " PIM_AF_DBG " packets joins\n");
d62a17ae 140 ++writes;
141 }
142
143 if (PIM_DEBUG_PIM_REG) {
68a7caf4 144 vty_out(vty, "debug " PIM_AF_DBG " packets register\n");
d62a17ae 145 ++writes;
146 }
147
148 if (PIM_DEBUG_STATIC) {
149 vty_out(vty, "debug pim static\n");
150 ++writes;
151 }
152
40f1f31b 153 if (PIM_DEBUG_PIM_NHT) {
68a7caf4 154 vty_out(vty, "debug " PIM_AF_DBG " nht\n");
40f1f31b
DS
155 ++writes;
156 }
157
5c4508cb 158 if (PIM_DEBUG_PIM_NHT_RP) {
159 vty_out(vty, "debug pim nht rp\n");
160 ++writes;
161 }
162
6d733f0d 163 if (PIM_DEBUG_PIM_NHT_DETAIL) {
68a7caf4 164 vty_out(vty, "debug " PIM_AF_DBG " nht detail\n");
6d733f0d
SG
165 ++writes;
166 }
167
d62a17ae 168 return writes;
12e41d03
DL
169}
170
9ecb7b77 171int pim_global_config_write_worker(struct pim_instance *pim, struct vty *vty)
12e41d03 172{
d62a17ae 173 int writes = 0;
6196ed71 174 struct pim_ssm *ssm = pim->ssm_info;
0c8b717e
DS
175 char spaces[10];
176
d3cc1e45 177 if (pim->vrf->vrf_id == VRF_DEFAULT)
772270f3 178 snprintf(spaces, sizeof(spaces), "%s", "");
0c8b717e 179 else
772270f3 180 snprintf(spaces, sizeof(spaces), "%s", " ");
12e41d03 181
8c70c9e2 182 writes += pim_msdp_peer_config_write(vty, pim, spaces);
84f25989 183 writes += pim_msdp_config_write(pim, vty, spaces);
d62a17ae 184
6196ed71 185 if (!pim->send_v6_secondary) {
c9657fdc 186 vty_out(vty, "%sno ip pim send-v6-secondary\n", spaces);
d62a17ae 187 ++writes;
6b775f61 188 }
12e41d03 189
0c8b717e 190 writes += pim_rp_config_write(pim, vty, spaces);
d62a17ae 191
d3cc1e45 192 if (pim->vrf->vrf_id == VRF_DEFAULT) {
bb4b6eb5
DS
193 if (router->register_suppress_time
194 != PIM_REGISTER_SUPPRESSION_TIME_DEFAULT) {
ae97d577
MR
195 vty_out(vty, "%s" PIM_AF_NAME " pim register-suppress-time %d\n",
196 spaces, router->register_suppress_time);
bb4b6eb5
DS
197 ++writes;
198 }
199 if (router->t_periodic != PIM_DEFAULT_T_PERIODIC) {
ae97d577 200 vty_out(vty, "%s" PIM_AF_NAME " pim join-prune-interval %d\n",
bb4b6eb5
DS
201 spaces, router->t_periodic);
202 ++writes;
203 }
204
205 if (router->packet_process != PIM_DEFAULT_PACKET_PROCESS) {
ae97d577 206 vty_out(vty, "%s" PIM_AF_NAME " pim packets %d\n", spaces,
bb4b6eb5
DS
207 router->packet_process);
208 ++writes;
209 }
d62a17ae 210 }
19b807ca 211 if (pim->keep_alive_time != PIM_KEEPALIVE_PERIOD) {
ae97d577
MR
212 vty_out(vty, "%s" PIM_AF_NAME " pim keep-alive-timer %d\n",
213 spaces, pim->keep_alive_time);
d62a17ae 214 ++writes;
215 }
cc14df13 216 if (pim->rp_keep_alive_time != (unsigned int)PIM_RP_KEEPALIVE_PERIOD) {
ae97d577
MR
217 vty_out(vty, "%s" PIM_AF_NAME " pim rp keep-alive-timer %d\n",
218 spaces, pim->rp_keep_alive_time);
cc14df13
DS
219 ++writes;
220 }
d62a17ae 221 if (ssm->plist_name) {
c9657fdc
DS
222 vty_out(vty, "%sip pim ssm prefix-list %s\n", spaces,
223 ssm->plist_name);
d62a17ae 224 ++writes;
f4e74bd0
DS
225 }
226 if (pim->register_plist) {
227 vty_out(vty, "%sip pim register-accept-list %s\n", spaces,
228 pim->register_plist);
229 ++writes;
d62a17ae 230 }
6196ed71
DS
231 if (pim->spt.switchover == PIM_SPT_INFINITY) {
232 if (pim->spt.plist)
d62a17ae 233 vty_out(vty,
ae97d577 234 "%s" PIM_AF_NAME " pim spt-switchover infinity-and-beyond prefix-list %s\n",
c9657fdc 235 spaces, pim->spt.plist);
d62a17ae 236 else
237 vty_out(vty,
ae97d577 238 "%s" PIM_AF_NAME " pim spt-switchover infinity-and-beyond\n",
c9657fdc 239 spaces);
d62a17ae 240 ++writes;
241 }
4795fff7 242 if (pim->ecmp_rebalance_enable) {
c9657fdc 243 vty_out(vty, "%sip pim ecmp rebalance\n", spaces);
d62a17ae 244 ++writes;
4795fff7 245 } else if (pim->ecmp_enable) {
c9657fdc 246 vty_out(vty, "%sip pim ecmp\n", spaces);
d62a17ae 247 ++writes;
248 }
339f7695 249
229a20e2 250 if (pim->gm_watermark_limit != 0) {
889d43b1
SG
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
339f7695 258 ++writes;
259 }
260
71ad9915 261 if (pim->ssmpingd_list) {
d62a17ae 262 struct listnode *node;
263 struct ssmpingd_sock *ss;
d62a17ae 264 ++writes;
71ad9915 265 for (ALL_LIST_ELEMENTS_RO(pim->ssmpingd_list, node, ss)) {
a8caf78d
BG
266 vty_out(vty, "%s" PIM_AF_NAME " ssmpingd %pPA\n",
267 spaces, &ss->source_addr);
d62a17ae 268 ++writes;
269 }
270 }
271
622fd3f1
RZ
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
d62a17ae 283 return writes;
284}
12e41d03 285
0da95b2f 286#if PIM_IPV == 4
5afe22f5
DL
287static int gm_config_write(struct vty *vty, int writes,
288 struct pim_interface *pim_ifp)
0da95b2f 289{
0da95b2f 290 /* IF ip igmp */
4fecac21 291 if (pim_ifp->gm_enable) {
0da95b2f
SG
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 !=
de5dc092 304 GM_QUERY_MAX_RESPONSE_TIME_DSEC) {
0da95b2f
SG
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 */
de5dc092 311 if (pim_ifp->gm_default_query_interval != GM_GENERAL_QUERY_INTERVAL) {
0da95b2f
SG
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 !=
de5dc092 319 GM_DEFAULT_ROBUSTNESS_VARIABLE) {
0da95b2f
SG
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 !=
de5dc092 327 GM_SPECIFIC_QUERY_MAX_RESPONSE_TIME_DSEC) {
0da95b2f
SG
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 char group_str[INET_ADDRSTRLEN];
339 char source_str[INET_ADDRSTRLEN];
340 pim_inet4_dump("<grp?>", ij->group_addr, group_str,
341 sizeof(group_str));
342 if (ij->source_addr.s_addr == INADDR_ANY) {
343 vty_out(vty, " ip igmp join %s\n", group_str);
344 } else {
345 inet_ntop(AF_INET, &ij->source_addr, source_str,
346 sizeof(source_str));
347 vty_out(vty, " ip igmp join %s %s\n", group_str,
348 source_str);
349 }
350 ++writes;
351 }
352 }
353
078c5867
MR
354 return writes;
355}
5afe22f5
DL
356#else
357static int gm_config_write(struct vty *vty, int writes,
358 struct pim_interface *pim_ifp)
359{
5c1b3cd2
A
360 /* IF ipv6 mld */
361 if (pim_ifp->gm_enable) {
362 vty_out(vty, " ipv6 mld\n");
363 ++writes;
364 }
365
5afe22f5
DL
366 if (pim_ifp->mld_version != MLD_DEFAULT_VERSION)
367 vty_out(vty, " ipv6 mld version %d\n", pim_ifp->mld_version);
914710d7
A
368
369 /* IF ipv6 mld query-max-response-time */
370 if (pim_ifp->gm_query_max_response_time_dsec !=
de5dc092 371 GM_QUERY_MAX_RESPONSE_TIME_DSEC)
914710d7
A
372 vty_out(vty, " ipv6 mld query-max-response-time %d\n",
373 pim_ifp->gm_query_max_response_time_dsec);
374
de5dc092 375 if (pim_ifp->gm_default_query_interval != GM_GENERAL_QUERY_INTERVAL)
5afe22f5
DL
376 vty_out(vty, " ipv6 mld query-interval %d\n",
377 pim_ifp->gm_default_query_interval);
51b4991f
A
378
379 /* IF ipv6 mld last-member_query-count */
380 if (pim_ifp->gm_last_member_query_count !=
de5dc092 381 GM_DEFAULT_ROBUSTNESS_VARIABLE)
51b4991f
A
382 vty_out(vty, " ipv6 mld last-member-query-count %d\n",
383 pim_ifp->gm_last_member_query_count);
384
707a9e9a
A
385 /* IF ipv6 mld last-member_query-interval */
386 if (pim_ifp->gm_specific_query_max_response_time_dsec !=
de5dc092 387 GM_SPECIFIC_QUERY_MAX_RESPONSE_TIME_DSEC)
707a9e9a
A
388 vty_out(vty, " ipv6 mld last-member-query-interval %d\n",
389 pim_ifp->gm_specific_query_max_response_time_dsec);
390
00fb4b9d 391 return writes;
5afe22f5 392}
078c5867
MR
393#endif
394
078c5867
MR
395int pim_config_write(struct vty *vty, int writes, struct interface *ifp,
396 struct pim_instance *pim)
397{
398 struct pim_interface *pim_ifp = ifp->info;
399
b6fcc0b7 400 if (pim_ifp->pim_enable) {
d17b6892 401 vty_out(vty, " " PIM_AF_NAME " pim\n");
078c5867
MR
402 ++writes;
403 }
404
405 /* IF ip pim drpriority */
406 if (pim_ifp->pim_dr_priority != PIM_DEFAULT_DR_PRIORITY) {
d17b6892 407 vty_out(vty, " " PIM_AF_NAME " pim drpriority %u\n",
078c5867
MR
408 pim_ifp->pim_dr_priority);
409 ++writes;
410 }
411
412 /* IF ip pim hello */
413 if (pim_ifp->pim_hello_period != PIM_DEFAULT_HELLO_PERIOD) {
d17b6892 414 vty_out(vty, " " PIM_AF_NAME " pim hello %d", pim_ifp->pim_hello_period);
078c5867
MR
415 if (pim_ifp->pim_default_holdtime != -1)
416 vty_out(vty, " %d", pim_ifp->pim_default_holdtime);
417 vty_out(vty, "\n");
418 ++writes;
419 }
420
5afe22f5 421 writes += gm_config_write(vty, writes, pim_ifp);
078c5867
MR
422
423 /* update source */
424 if (!pim_addr_is_any(pim_ifp->update_source)) {
d17b6892 425 vty_out(vty, " " PIM_AF_NAME " pim use-source %pPA\n",
078c5867
MR
426 &pim_ifp->update_source);
427 ++writes;
428 }
429
0da95b2f 430 if (pim_ifp->activeactive)
d17b6892 431 vty_out(vty, " " PIM_AF_NAME " pim active-active\n");
0da95b2f
SG
432
433 /* boundary */
434 if (pim_ifp->boundary_oil_plist) {
d17b6892 435 vty_out(vty, " " PIM_AF_NAME " multicast boundary oil %s\n",
0da95b2f
SG
436 pim_ifp->boundary_oil_plist);
437 ++writes;
438 }
439
2a66cf63 440 if (pim_ifp->pim_passive_enable) {
441 vty_out(vty, " " PIM_AF_NAME " pim passive\n");
442 ++writes;
443 }
444
0da95b2f
SG
445 writes += pim_static_write_mroute(pim, vty, ifp);
446 pim_bsm_write_config(vty, ifp);
447 ++writes;
448 pim_bfd_write_config(vty, ifp);
449 ++writes;
450
451 return writes;
452}
0da95b2f 453
d62a17ae 454int pim_interface_config_write(struct vty *vty)
455{
024d6a75 456 struct pim_instance *pim;
d62a17ae 457 struct interface *ifp;
024d6a75
DS
458 struct vrf *vrf;
459 int writes = 0;
d62a17ae 460
a2addae8 461 RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
024d6a75
DS
462 pim = vrf->info;
463 if (!pim)
464 continue;
d62a17ae 465
451fda4f 466 FOR_ALL_INTERFACES (pim->vrf, ifp) {
d149c75a
AK
467 /* pim is enabled internally/implicitly on the vxlan
468 * termination device ipmr-lo. skip displaying that
469 * config to avoid confusion
470 */
471 if (pim_vxlan_is_term_dev_cfg(pim, ifp))
472 continue;
473
024d6a75 474 /* IF name */
788a036f
IR
475 if_vty_config_start(vty, ifp);
476
024d6a75 477 ++writes;
d62a17ae 478
91e5b43a
RW
479 if (ifp->desc) {
480 vty_out(vty, " description %s\n", ifp->desc);
481 ++writes;
482 }
d17b6892
SG
483
484 if (ifp->info) {
0da95b2f 485 pim_config_write(vty, writes, ifp, pim);
d17b6892 486 }
788a036f 487 if_vty_config_end(vty);
d17b6892 488
024d6a75 489 ++writes;
d62a17ae 490 }
12e41d03 491 }
12e41d03 492
d62a17ae 493 return writes;
12e41d03 494}