]> git.proxmox.com Git - mirror_frr.git/blame - pimd/pim_cmd.c
Merge pull request #11598 from patrasar/pim_get_instance
[mirror_frr.git] / pimd / pim_cmd.c
CommitLineData
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 19
12e41d03
DL
20#include <zebra.h>
21
9bf3c633 22#include "lib/json.h"
12e41d03
DL
23#include "command.h"
24#include "if.h"
25#include "prefix.h"
26#include "zclient.h"
dfe43e25 27#include "plist.h"
cba44481
CS
28#include "hash.h"
29#include "nexthop.h"
02a16316 30#include "vrf.h"
37664928 31#include "ferr.h"
12e41d03
DL
32
33#include "pimd.h"
9867746a 34#include "pim_mroute.h"
12e41d03
DL
35#include "pim_cmd.h"
36#include "pim_iface.h"
37#include "pim_vty.h"
38#include "pim_mroute.h"
39#include "pim_str.h"
40#include "pim_igmp.h"
41#include "pim_igmpv3.h"
42#include "pim_sock.h"
43#include "pim_time.h"
44#include "pim_util.h"
45#include "pim_oil.h"
46#include "pim_neighbor.h"
47#include "pim_pim.h"
48#include "pim_ifchannel.h"
49#include "pim_hello.h"
50#include "pim_msg.h"
51#include "pim_upstream.h"
52#include "pim_rpf.h"
53#include "pim_macro.h"
54#include "pim_ssmpingd.h"
55#include "pim_zebra.h"
6250610a 56#include "pim_static.h"
a920d6e7 57#include "pim_rp.h"
05b0d0d0 58#include "pim_zlookup.h"
2a333e0f 59#include "pim_msdp.h"
15a5dafe 60#include "pim_ssm.h"
cba44481 61#include "pim_nht.h"
ba4eb1bc 62#include "pim_bfd.h"
f1e2901a 63#include "pim_vxlan.h"
36b5b98f 64#include "pim_mlag.h"
ba4eb1bc 65#include "bfd.h"
4616b2e9 66#include "pim_bsm.h"
b0475d5a
SP
67#include "lib/northbound_cli.h"
68#include "pim_errors.h"
69#include "pim_nb.h"
24de75a2 70#include "pim_addr.h"
26cd3d66 71#include "pim_cmd_common.h"
12e41d03 72
414d885a
DS
73#ifndef VTYSH_EXTRACT_PL
74#include "pimd/pim_cmd_clippy.c"
75#endif
76
62b346ee 77static struct cmd_node debug_node = {
f4b8291f 78 .name = "debug",
62b346ee
DL
79 .node = DEBUG_NODE,
80 .prompt = "",
612c2c15 81 .config_write = pim_debug_config_write,
62b346ee 82};
eb7a976a 83
02a16316
DS
84static struct vrf *pim_cmd_lookup_vrf(struct vty *vty, struct cmd_token *argv[],
85 const int argc, int *idx)
86{
87 struct vrf *vrf;
88
89 if (argv_find(argv, argc, "NAME", idx))
90 vrf = vrf_lookup_by_name(argv[*idx]->arg);
91 else
92 vrf = vrf_lookup_by_id(VRF_DEFAULT);
93
94 if (!vrf)
95 vty_out(vty, "Specified VRF: %s does not exist\n",
96 argv[*idx]->arg);
97
98 return vrf;
99}
100
1a8a3da8
DS
101static void pim_show_assert_helper(struct vty *vty,
102 struct pim_interface *pim_ifp,
996c9314 103 struct pim_ifchannel *ch, time_t now)
1a8a3da8 104{
1a8a3da8
DS
105 char winner_str[INET_ADDRSTRLEN];
106 struct in_addr ifaddr;
107 char uptime[10];
108 char timer[10];
ee2bbf7c 109 char buf[PREFIX_STRLEN];
1a8a3da8
DS
110
111 ifaddr = pim_ifp->primary_address;
112
1a8a3da8
DS
113 pim_inet4_dump("<assrt_win?>", ch->ifassert_winner, winner_str,
114 sizeof(winner_str));
115
996c9314
LB
116 pim_time_uptime(uptime, sizeof(uptime), now - ch->ifassert_creation);
117 pim_time_timer_to_mmss(timer, sizeof(timer), ch->t_ifassert_timer);
1a8a3da8 118
8e8be741 119 vty_out(vty, "%-16s %-15s %-15pPAs %-15pPAs %-6s %-15s %-8s %-5s\n",
ee2bbf7c 120 ch->interface->name,
8e8be741
DL
121 inet_ntop(AF_INET, &ifaddr, buf, sizeof(buf)), &ch->sg.src,
122 &ch->sg.grp, pim_ifchannel_ifassert_name(ch->ifassert_state),
ee2bbf7c 123 winner_str, uptime, timer);
1a8a3da8
DS
124}
125
64c86530 126static void pim_show_assert(struct pim_instance *pim, struct vty *vty)
12e41d03 127{
d62a17ae 128 struct pim_interface *pim_ifp;
129 struct pim_ifchannel *ch;
1a8a3da8 130 struct interface *ifp;
d62a17ae 131 time_t now;
132
133 now = pim_time_monotonic_sec();
134
135 vty_out(vty,
ff415346 136 "Interface Address Source Group State Winner Uptime Timer\n");
d62a17ae 137
451fda4f 138 FOR_ALL_INTERFACES (pim->vrf, ifp) {
1a8a3da8 139 pim_ifp = ifp->info;
d62a17ae 140 if (!pim_ifp)
141 continue;
142
a2addae8 143 RB_FOREACH (ch, pim_ifchannel_rb, &pim_ifp->ifchannel_rb) {
35e5ef55
DS
144 if (ch->ifassert_state == PIM_IFASSERT_NOINFO)
145 continue;
146
1a8a3da8
DS
147 pim_show_assert_helper(vty, pim_ifp, ch, now);
148 } /* scan interface channels */
149 }
150}
d62a17ae 151
1a8a3da8
DS
152static void pim_show_assert_internal_helper(struct vty *vty,
153 struct pim_interface *pim_ifp,
154 struct pim_ifchannel *ch)
155{
1a8a3da8 156 struct in_addr ifaddr;
ee2bbf7c 157 char buf[PREFIX_STRLEN];
d62a17ae 158
1a8a3da8
DS
159 ifaddr = pim_ifp->primary_address;
160
8e8be741 161 vty_out(vty, "%-16s %-15s %-15pPAs %-15pPAs %-3s %-3s %-3s %-4s\n",
ee2bbf7c 162 ch->interface->name,
8e8be741
DL
163 inet_ntop(AF_INET, &ifaddr, buf, sizeof(buf)), &ch->sg.src,
164 &ch->sg.grp,
1a8a3da8
DS
165 PIM_IF_FLAG_TEST_COULD_ASSERT(ch->flags) ? "yes" : "no",
166 pim_macro_ch_could_assert_eval(ch) ? "yes" : "no",
996c9314 167 PIM_IF_FLAG_TEST_ASSERT_TRACKING_DESIRED(ch->flags) ? "yes"
521c5b9d 168 : "no",
996c9314 169 pim_macro_assert_tracking_desired_eval(ch) ? "yes" : "no");
12e41d03
DL
170}
171
64c86530 172static void pim_show_assert_internal(struct pim_instance *pim, struct vty *vty)
12e41d03 173{
d62a17ae 174 struct pim_interface *pim_ifp;
d62a17ae 175 struct pim_ifchannel *ch;
1a8a3da8 176 struct interface *ifp;
d62a17ae 177
178 vty_out(vty,
179 "CA: CouldAssert\n"
180 "ECA: Evaluate CouldAssert\n"
181 "ATD: AssertTrackingDesired\n"
182 "eATD: Evaluate AssertTrackingDesired\n\n");
183
184 vty_out(vty,
ff415346 185 "Interface Address Source Group CA eCA ATD eATD\n");
451fda4f 186 FOR_ALL_INTERFACES (pim->vrf, ifp) {
1a8a3da8 187 pim_ifp = ifp->info;
d62a17ae 188 if (!pim_ifp)
189 continue;
190
a2addae8 191 RB_FOREACH (ch, pim_ifchannel_rb, &pim_ifp->ifchannel_rb) {
1a8a3da8
DS
192 pim_show_assert_internal_helper(vty, pim_ifp, ch);
193 } /* scan interface channels */
194 }
195}
196
197static void pim_show_assert_metric_helper(struct vty *vty,
198 struct pim_interface *pim_ifp,
199 struct pim_ifchannel *ch)
200{
1a8a3da8
DS
201 char addr_str[INET_ADDRSTRLEN];
202 struct pim_assert_metric am;
203 struct in_addr ifaddr;
ee2bbf7c 204 char buf[PREFIX_STRLEN];
1a8a3da8
DS
205
206 ifaddr = pim_ifp->primary_address;
207
208 am = pim_macro_spt_assert_metric(&ch->upstream->rpf,
209 pim_ifp->primary_address);
d62a17ae 210
996c9314 211 pim_inet4_dump("<addr?>", am.ip_address, addr_str, sizeof(addr_str));
1a8a3da8 212
8e8be741 213 vty_out(vty, "%-16s %-15s %-15pPAs %-15pPAs %-3s %4u %6u %-15s\n",
ee2bbf7c 214 ch->interface->name,
8e8be741
DL
215 inet_ntop(AF_INET, &ifaddr, buf, sizeof(buf)), &ch->sg.src,
216 &ch->sg.grp, am.rpt_bit_flag ? "yes" : "no",
ee2bbf7c 217 am.metric_preference, am.route_metric, addr_str);
12e41d03
DL
218}
219
64c86530 220static void pim_show_assert_metric(struct pim_instance *pim, struct vty *vty)
12e41d03 221{
d62a17ae 222 struct pim_interface *pim_ifp;
d62a17ae 223 struct pim_ifchannel *ch;
1a8a3da8 224 struct interface *ifp;
ea4a71fc 225
d62a17ae 226 vty_out(vty,
ff415346 227 "Interface Address Source Group RPT Pref Metric Address \n");
12e41d03 228
451fda4f 229 FOR_ALL_INTERFACES (pim->vrf, ifp) {
1a8a3da8 230 pim_ifp = ifp->info;
d62a17ae 231 if (!pim_ifp)
232 continue;
12e41d03 233
a2addae8 234 RB_FOREACH (ch, pim_ifchannel_rb, &pim_ifp->ifchannel_rb) {
1a8a3da8
DS
235 pim_show_assert_metric_helper(vty, pim_ifp, ch);
236 } /* scan interface channels */
237 }
238}
12e41d03 239
1a8a3da8
DS
240static void pim_show_assert_winner_metric_helper(struct vty *vty,
241 struct pim_interface *pim_ifp,
242 struct pim_ifchannel *ch)
243{
1a8a3da8
DS
244 char addr_str[INET_ADDRSTRLEN];
245 struct pim_assert_metric *am;
246 struct in_addr ifaddr;
a2dc7057
DL
247 char pref_str[16];
248 char metr_str[16];
ee2bbf7c 249 char buf[PREFIX_STRLEN];
1a8a3da8
DS
250
251 ifaddr = pim_ifp->primary_address;
252
253 am = &ch->ifassert_winner_metric;
254
996c9314 255 pim_inet4_dump("<addr?>", am->ip_address, addr_str, sizeof(addr_str));
1a8a3da8
DS
256
257 if (am->metric_preference == PIM_ASSERT_METRIC_PREFERENCE_MAX)
258 snprintf(pref_str, sizeof(pref_str), "INFI");
259 else
260 snprintf(pref_str, sizeof(pref_str), "%4u",
261 am->metric_preference);
262
263 if (am->route_metric == PIM_ASSERT_ROUTE_METRIC_MAX)
264 snprintf(metr_str, sizeof(metr_str), "INFI");
265 else
996c9314 266 snprintf(metr_str, sizeof(metr_str), "%6u", am->route_metric);
1a8a3da8 267
8e8be741 268 vty_out(vty, "%-16s %-15s %-15pPAs %-15pPAs %-3s %-4s %-6s %-15s\n",
ee2bbf7c 269 ch->interface->name,
8e8be741
DL
270 inet_ntop(AF_INET, &ifaddr, buf, sizeof(buf)), &ch->sg.src,
271 &ch->sg.grp, am->rpt_bit_flag ? "yes" : "no", pref_str,
272 metr_str, addr_str);
12e41d03
DL
273}
274
64c86530
DS
275static void pim_show_assert_winner_metric(struct pim_instance *pim,
276 struct vty *vty)
12e41d03 277{
d62a17ae 278 struct pim_interface *pim_ifp;
d62a17ae 279 struct pim_ifchannel *ch;
1a8a3da8 280 struct interface *ifp;
d62a17ae 281
282 vty_out(vty,
ff415346 283 "Interface Address Source Group RPT Pref Metric Address \n");
d62a17ae 284
451fda4f 285 FOR_ALL_INTERFACES (pim->vrf, ifp) {
1a8a3da8 286 pim_ifp = ifp->info;
d62a17ae 287 if (!pim_ifp)
288 continue;
12e41d03 289
a2addae8 290 RB_FOREACH (ch, pim_ifchannel_rb, &pim_ifp->ifchannel_rb) {
1a8a3da8
DS
291 pim_show_assert_winner_metric_helper(vty, pim_ifp, ch);
292 } /* scan interface channels */
293 }
12e41d03
DL
294}
295
64c86530 296static void igmp_show_interfaces(struct pim_instance *pim, struct vty *vty,
088f1098 297 bool uj)
12e41d03 298{
d62a17ae 299 struct interface *ifp;
300 time_t now;
ee2bbf7c 301 char buf[PREFIX_STRLEN];
d62a17ae 302 json_object *json = NULL;
303 json_object *json_row = NULL;
304
305 now = pim_time_monotonic_sec();
306
307 if (uj)
308 json = json_object_new_object();
309 else
310 vty_out(vty,
9a7cee26 311 "Interface State Address V Querier QuerierIp Query Timer Uptime\n");
d62a17ae 312
451fda4f 313 FOR_ALL_INTERFACES (pim->vrf, ifp) {
d62a17ae 314 struct pim_interface *pim_ifp;
315 struct listnode *sock_node;
c5f76fad 316 struct gm_sock *igmp;
d62a17ae 317
318 pim_ifp = ifp->info;
319
320 if (!pim_ifp)
321 continue;
322
18adcff1 323 for (ALL_LIST_ELEMENTS_RO(pim_ifp->gm_socket_list, sock_node,
d62a17ae 324 igmp)) {
325 char uptime[10];
326 char query_hhmmss[10];
327
328 pim_time_uptime(uptime, sizeof(uptime),
329 now - igmp->sock_creation);
330 pim_time_timer_to_hhmmss(query_hhmmss,
331 sizeof(query_hhmmss),
332 igmp->t_igmp_query_timer);
333
334 if (uj) {
335 json_row = json_object_new_object();
336 json_object_pim_ifp_add(json_row, ifp);
337 json_object_string_add(json_row, "upTime",
338 uptime);
339 json_object_int_add(json_row, "version",
29e58225 340 pim_ifp->igmp_version);
d62a17ae 341
342 if (igmp->t_igmp_query_timer) {
343 json_object_boolean_true_add(json_row,
344 "querier");
345 json_object_string_add(json_row,
346 "queryTimer",
347 query_hhmmss);
348 }
b0d5264e
DA
349 json_object_string_addf(json_row, "querierIp",
350 "%pI4",
351 &igmp->querier_addr);
d62a17ae 352
353 json_object_object_add(json, ifp->name,
354 json_row);
355
f83f3966
MS
356 if (igmp->mtrace_only) {
357 json_object_boolean_true_add(
358 json_row, "mtraceOnly");
359 }
d62a17ae 360 } else {
361 vty_out(vty,
9a7cee26 362 "%-16s %5s %15s %d %7s %17pI4 %11s %8s\n",
d62a17ae 363 ifp->name,
f83f3966 364 if_is_up(ifp)
9a7cee26 365 ? (igmp->mtrace_only ? "mtrc"
366 : "up")
367 : "down",
368 inet_ntop(AF_INET, &igmp->ifaddr, buf,
369 sizeof(buf)),
29e58225 370 pim_ifp->igmp_version,
d62a17ae 371 igmp->t_igmp_query_timer ? "local"
9a7cee26 372 : "other",
373 &igmp->querier_addr, query_hhmmss,
374 uptime);
d62a17ae 375 }
376 }
377 }
378
3757f964
DA
379 if (uj)
380 vty_json(vty, json);
d62a17ae 381}
382
64c86530
DS
383static void igmp_show_interfaces_single(struct pim_instance *pim,
384 struct vty *vty, const char *ifname,
088f1098 385 bool uj)
d62a17ae 386{
c5f76fad 387 struct gm_sock *igmp;
d62a17ae 388 struct interface *ifp;
d62a17ae 389 struct listnode *sock_node;
390 struct pim_interface *pim_ifp;
391 char uptime[10];
392 char query_hhmmss[10];
393 char other_hhmmss[10];
394 int found_ifname = 0;
395 int sqi;
d62a17ae 396 long gmi_msec; /* Group Membership Interval */
397 long lmqt_msec;
398 long ohpi_msec;
399 long oqpi_msec; /* Other Querier Present Interval */
400 long qri_msec;
401 time_t now;
59115451 402 int lmqc;
d62a17ae 403
404 json_object *json = NULL;
405 json_object *json_row = NULL;
406
407 if (uj)
408 json = json_object_new_object();
409
410 now = pim_time_monotonic_sec();
411
451fda4f 412 FOR_ALL_INTERFACES (pim->vrf, ifp) {
d62a17ae 413 pim_ifp = ifp->info;
414
415 if (!pim_ifp)
416 continue;
417
418 if (strcmp(ifname, "detail") && strcmp(ifname, ifp->name))
419 continue;
420
18adcff1 421 for (ALL_LIST_ELEMENTS_RO(pim_ifp->gm_socket_list, sock_node,
d62a17ae 422 igmp)) {
423 found_ifname = 1;
424 pim_time_uptime(uptime, sizeof(uptime),
425 now - igmp->sock_creation);
426 pim_time_timer_to_hhmmss(query_hhmmss,
427 sizeof(query_hhmmss),
428 igmp->t_igmp_query_timer);
429 pim_time_timer_to_hhmmss(other_hhmmss,
430 sizeof(other_hhmmss),
431 igmp->t_other_querier_timer);
432
433 gmi_msec = PIM_IGMP_GMI_MSEC(
434 igmp->querier_robustness_variable,
435 igmp->querier_query_interval,
18adcff1 436 pim_ifp->gm_query_max_response_time_dsec);
d62a17ae 437
18adcff1 438 sqi = PIM_IGMP_SQI(pim_ifp->gm_default_query_interval);
d62a17ae 439
440 oqpi_msec = PIM_IGMP_OQPI_MSEC(
441 igmp->querier_robustness_variable,
442 igmp->querier_query_interval,
18adcff1 443 pim_ifp->gm_query_max_response_time_dsec);
d62a17ae 444
445 lmqt_msec = PIM_IGMP_LMQT_MSEC(
18adcff1
SG
446 pim_ifp->gm_specific_query_max_response_time_dsec,
447 pim_ifp->gm_last_member_query_count);
d62a17ae 448
449 ohpi_msec =
450 PIM_IGMP_OHPI_DSEC(
451 igmp->querier_robustness_variable,
452 igmp->querier_query_interval,
18adcff1
SG
453 pim_ifp->gm_query_max_response_time_dsec) *
454 100;
d62a17ae 455
18adcff1
SG
456 qri_msec =
457 pim_ifp->gm_query_max_response_time_dsec * 100;
18adcff1 458 lmqc = pim_ifp->gm_last_member_query_count;
d62a17ae 459
460 if (uj) {
461 json_row = json_object_new_object();
462 json_object_pim_ifp_add(json_row, ifp);
463 json_object_string_add(json_row, "upTime",
464 uptime);
465 json_object_string_add(json_row, "querier",
466 igmp->t_igmp_query_timer
521c5b9d
MS
467 ? "local"
468 : "other");
b0d5264e
DA
469 json_object_string_addf(json_row, "querierIp",
470 "%pI4",
471 &igmp->querier_addr);
d62a17ae 472 json_object_int_add(json_row, "queryStartCount",
473 igmp->startup_query_count);
474 json_object_string_add(json_row,
475 "queryQueryTimer",
476 query_hhmmss);
477 json_object_string_add(json_row,
478 "queryOtherTimer",
479 other_hhmmss);
480 json_object_int_add(json_row, "version",
29e58225 481 pim_ifp->igmp_version);
d62a17ae 482 json_object_int_add(
483 json_row,
484 "timerGroupMembershipIntervalMsec",
485 gmi_msec);
59115451
SP
486 json_object_int_add(json_row,
487 "lastMemberQueryCount",
488 lmqc);
d62a17ae 489 json_object_int_add(json_row,
490 "timerLastMemberQueryMsec",
491 lmqt_msec);
492 json_object_int_add(
493 json_row,
494 "timerOlderHostPresentIntervalMsec",
495 ohpi_msec);
496 json_object_int_add(
497 json_row,
498 "timerOtherQuerierPresentIntervalMsec",
499 oqpi_msec);
500 json_object_int_add(
501 json_row, "timerQueryInterval",
502 igmp->querier_query_interval);
503 json_object_int_add(
504 json_row,
505 "timerQueryResponseIntervalMsec",
506 qri_msec);
507 json_object_int_add(
508 json_row, "timerRobustnessVariable",
509 igmp->querier_robustness_variable);
510 json_object_int_add(json_row,
511 "timerStartupQueryInterval",
512 sqi);
513
514 json_object_object_add(json, ifp->name,
515 json_row);
516
f83f3966
MS
517 if (igmp->mtrace_only) {
518 json_object_boolean_true_add(
519 json_row, "mtraceOnly");
520 }
d62a17ae 521 } else {
522 vty_out(vty, "Interface : %s\n", ifp->name);
523 vty_out(vty, "State : %s\n",
521c5b9d
MS
524 if_is_up(ifp) ? (igmp->mtrace_only ?
525 "mtrace"
526 : "up")
527 : "down");
ee2bbf7c
MS
528 vty_out(vty, "Address : %pI4\n",
529 &pim_ifp->primary_address);
d62a17ae 530 vty_out(vty, "Uptime : %s\n", uptime);
531 vty_out(vty, "Version : %d\n",
29e58225 532 pim_ifp->igmp_version);
d62a17ae 533 vty_out(vty, "\n");
534 vty_out(vty, "\n");
535
536 vty_out(vty, "Querier\n");
537 vty_out(vty, "-------\n");
538 vty_out(vty, "Querier : %s\n",
539 igmp->t_igmp_query_timer ? "local"
521c5b9d 540 : "other");
9a7cee26 541 vty_out(vty, "QuerierIp : %pI4",
542 &igmp->querier_addr);
543 if (pim_ifp->primary_address.s_addr
544 == igmp->querier_addr.s_addr)
545 vty_out(vty, " (this router)\n");
546 else
547 vty_out(vty, "\n");
548
d62a17ae 549 vty_out(vty, "Start Count : %d\n",
550 igmp->startup_query_count);
551 vty_out(vty, "Query Timer : %s\n",
552 query_hhmmss);
553 vty_out(vty, "Other Timer : %s\n",
554 other_hhmmss);
555 vty_out(vty, "\n");
556 vty_out(vty, "\n");
557
558 vty_out(vty, "Timers\n");
559 vty_out(vty, "------\n");
560 vty_out(vty,
561 "Group Membership Interval : %lis\n",
562 gmi_msec / 1000);
59115451
SP
563 vty_out(vty,
564 "Last Member Query Count : %d\n",
565 lmqc);
d62a17ae 566 vty_out(vty,
567 "Last Member Query Time : %lis\n",
568 lmqt_msec / 1000);
569 vty_out(vty,
570 "Older Host Present Interval : %lis\n",
571 ohpi_msec / 1000);
572 vty_out(vty,
573 "Other Querier Present Interval : %lis\n",
574 oqpi_msec / 1000);
575 vty_out(vty,
576 "Query Interval : %ds\n",
577 igmp->querier_query_interval);
578 vty_out(vty,
579 "Query Response Interval : %lis\n",
580 qri_msec / 1000);
581 vty_out(vty,
582 "Robustness Variable : %d\n",
583 igmp->querier_robustness_variable);
584 vty_out(vty,
585 "Startup Query Interval : %ds\n",
586 sqi);
587 vty_out(vty, "\n");
588 vty_out(vty, "\n");
589
c532e503 590 pim_print_ifp_flags(vty, ifp);
d62a17ae 591 }
592 }
593 }
594
3757f964
DA
595 if (uj)
596 vty_json(vty, json);
597 else if (!found_ifname)
598 vty_out(vty, "%% No such interface\n");
12e41d03
DL
599}
600
85c82866 601static void igmp_show_interface_join(struct pim_instance *pim, struct vty *vty,
602 bool uj)
12e41d03 603{
d62a17ae 604 struct interface *ifp;
605 time_t now;
85c82866 606 json_object *json = NULL;
607 json_object *json_iface = NULL;
608 json_object *json_grp = NULL;
609 json_object *json_grp_arr = NULL;
d62a17ae 610
611 now = pim_time_monotonic_sec();
612
85c82866 613 if (uj) {
614 json = json_object_new_object();
615 json_object_string_add(json, "vrf",
d3cc1e45 616 vrf_id_to_name(pim->vrf->vrf_id));
85c82866 617 } else {
618 vty_out(vty,
619 "Interface Address Source Group Socket Uptime \n");
620 }
d62a17ae 621
451fda4f 622 FOR_ALL_INTERFACES (pim->vrf, ifp) {
d62a17ae 623 struct pim_interface *pim_ifp;
624 struct listnode *join_node;
7caa9451 625 struct gm_join *ij;
d62a17ae 626 struct in_addr pri_addr;
627 char pri_addr_str[INET_ADDRSTRLEN];
628
629 pim_ifp = ifp->info;
630
631 if (!pim_ifp)
632 continue;
633
18adcff1 634 if (!pim_ifp->gm_join_list)
d62a17ae 635 continue;
636
637 pri_addr = pim_find_primary_addr(ifp);
638 pim_inet4_dump("<pri?>", pri_addr, pri_addr_str,
639 sizeof(pri_addr_str));
640
18adcff1 641 for (ALL_LIST_ELEMENTS_RO(pim_ifp->gm_join_list, join_node,
29e58225 642 ij)) {
d62a17ae 643 char group_str[INET_ADDRSTRLEN];
644 char source_str[INET_ADDRSTRLEN];
645 char uptime[10];
646
647 pim_time_uptime(uptime, sizeof(uptime),
648 now - ij->sock_creation);
649 pim_inet4_dump("<grp?>", ij->group_addr, group_str,
650 sizeof(group_str));
651 pim_inet4_dump("<src?>", ij->source_addr, source_str,
652 sizeof(source_str));
653
85c82866 654 if (uj) {
655 json_object_object_get_ex(json, ifp->name,
656 &json_iface);
657
658 if (!json_iface) {
659 json_iface = json_object_new_object();
660 json_object_string_add(
661 json_iface, "name", ifp->name);
662 json_object_object_add(json, ifp->name,
663 json_iface);
664 json_grp_arr = json_object_new_array();
665 json_object_object_add(json_iface,
666 "groups",
667 json_grp_arr);
668 }
669
670 json_grp = json_object_new_object();
671 json_object_string_add(json_grp, "source",
672 source_str);
673 json_object_string_add(json_grp, "group",
674 group_str);
675 json_object_string_add(json_grp, "primaryAddr",
676 pri_addr_str);
677 json_object_int_add(json_grp, "sockFd",
678 ij->sock_fd);
679 json_object_string_add(json_grp, "upTime",
680 uptime);
681 json_object_array_add(json_grp_arr, json_grp);
682 } else {
683 vty_out(vty,
684 "%-16s %-15s %-15s %-15s %6d %8s\n",
685 ifp->name, pri_addr_str, source_str,
686 group_str, ij->sock_fd, uptime);
687 }
18adcff1 688 } /* for (pim_ifp->gm_join_list) */
d62a17ae 689
690 } /* for (iflist) */
85c82866 691
3757f964
DA
692 if (uj)
693 vty_json(vty, json);
d62a17ae 694}
695
21313cbf 696static void igmp_show_statistics(struct pim_instance *pim, struct vty *vty,
088f1098 697 const char *ifname, bool uj)
21313cbf
MS
698{
699 struct interface *ifp;
f2058cb4 700 struct igmp_stats igmp_stats;
42982834
DA
701 bool found_ifname = false;
702 json_object *json = NULL;
21313cbf 703
f2058cb4 704 igmp_stats_init(&igmp_stats);
21313cbf 705
42982834
DA
706 if (uj)
707 json = json_object_new_object();
708
21313cbf
MS
709 FOR_ALL_INTERFACES (pim->vrf, ifp) {
710 struct pim_interface *pim_ifp;
1e02f2f9 711 struct listnode *sock_node, *source_node, *group_node;
c5f76fad 712 struct gm_sock *igmp;
1e02f2f9
DA
713 struct gm_group *group;
714 struct gm_source *src;
21313cbf
MS
715
716 pim_ifp = ifp->info;
717
718 if (!pim_ifp)
719 continue;
720
721 if (ifname && strcmp(ifname, ifp->name))
722 continue;
723
42982834
DA
724 found_ifname = true;
725
f2058cb4
DA
726 igmp_stats.joins_failed += pim_ifp->igmp_ifstat_joins_failed;
727 igmp_stats.joins_sent += pim_ifp->igmp_ifstat_joins_sent;
728 igmp_stats.total_groups +=
1e02f2f9
DA
729 pim_ifp->gm_group_list
730 ? listcount(pim_ifp->gm_group_list)
731 : 0;
3e5d8665
DA
732 igmp_stats.peak_groups += pim_ifp->igmp_peak_group_count;
733
1e02f2f9
DA
734
735 for (ALL_LIST_ELEMENTS_RO(pim_ifp->gm_group_list, group_node,
736 group)) {
737 for (ALL_LIST_ELEMENTS_RO(group->group_source_list,
738 source_node, src)) {
739 if (pim_addr_is_any(src->source_addr))
740 continue;
741
f2058cb4 742 igmp_stats.total_source_groups++;
1e02f2f9
DA
743 }
744 }
745
18adcff1 746 for (ALL_LIST_ELEMENTS_RO(pim_ifp->gm_socket_list, sock_node,
21313cbf 747 igmp)) {
f2058cb4 748 igmp_stats_add(&igmp_stats, &igmp->igmp_stats);
21313cbf
MS
749 }
750 }
21313cbf 751
42982834
DA
752 if (!found_ifname) {
753 if (uj)
754 vty_json(vty, json);
755 else
756 vty_out(vty, "%% No such interface\n");
757 return;
758 }
759
760 if (uj) {
761 json_object *json_row = json_object_new_object();
21313cbf 762
42982834
DA
763 json_object_string_add(json_row, "name",
764 ifname ? ifname : "global");
f2058cb4
DA
765 json_object_int_add(json_row, "queryV1", igmp_stats.query_v1);
766 json_object_int_add(json_row, "queryV2", igmp_stats.query_v2);
767 json_object_int_add(json_row, "queryV3", igmp_stats.query_v3);
768 json_object_int_add(json_row, "leaveV2", igmp_stats.leave_v2);
769 json_object_int_add(json_row, "reportV1", igmp_stats.report_v1);
770 json_object_int_add(json_row, "reportV2", igmp_stats.report_v2);
771 json_object_int_add(json_row, "reportV3", igmp_stats.report_v3);
21313cbf 772 json_object_int_add(json_row, "mtraceResponse",
f2058cb4 773 igmp_stats.mtrace_rsp);
21313cbf 774 json_object_int_add(json_row, "mtraceRequest",
f2058cb4 775 igmp_stats.mtrace_req);
21313cbf 776 json_object_int_add(json_row, "unsupported",
f2058cb4 777 igmp_stats.unsupported);
ca3e7807
DA
778 json_object_int_add(json_row, "totalReceivedMessages",
779 igmp_stats.total_recv_messages);
3e5d8665
DA
780 json_object_int_add(json_row, "peakGroups",
781 igmp_stats.peak_groups);
1e02f2f9 782 json_object_int_add(json_row, "totalGroups",
f2058cb4 783 igmp_stats.total_groups);
1e02f2f9 784 json_object_int_add(json_row, "totalSourceGroups",
f2058cb4
DA
785 igmp_stats.total_source_groups);
786 json_object_int_add(json_row, "joinsFailed",
787 igmp_stats.joins_failed);
788 json_object_int_add(json_row, "joinsSent",
789 igmp_stats.joins_sent);
278912ea
DA
790 json_object_int_add(json_row, "generalQueriesSent",
791 igmp_stats.general_queries_sent);
792 json_object_int_add(json_row, "groupQueriesSent",
793 igmp_stats.group_queries_sent);
21313cbf
MS
794 json_object_object_add(json, ifname ? ifname : "global",
795 json_row);
3757f964 796 vty_json(vty, json);
21313cbf 797 } else {
f2058cb4 798 vty_out(vty, "IGMP statistics\n");
ca3e7807 799 vty_out(vty, "Interface : %s\n",
21313cbf 800 ifname ? ifname : "global");
ca3e7807 801 vty_out(vty, "V1 query : %u\n",
278912ea 802 igmp_stats.query_v1);
ca3e7807 803 vty_out(vty, "V2 query : %u\n",
278912ea 804 igmp_stats.query_v2);
ca3e7807 805 vty_out(vty, "V3 query : %u\n",
278912ea 806 igmp_stats.query_v3);
ca3e7807 807 vty_out(vty, "V2 leave : %u\n",
278912ea 808 igmp_stats.leave_v2);
ca3e7807 809 vty_out(vty, "V1 report : %u\n",
f2058cb4 810 igmp_stats.report_v1);
ca3e7807 811 vty_out(vty, "V2 report : %u\n",
f2058cb4 812 igmp_stats.report_v2);
ca3e7807 813 vty_out(vty, "V3 report : %u\n",
f2058cb4 814 igmp_stats.report_v3);
ca3e7807 815 vty_out(vty, "mtrace response : %u\n",
f2058cb4 816 igmp_stats.mtrace_rsp);
ca3e7807 817 vty_out(vty, "mtrace request : %u\n",
f2058cb4 818 igmp_stats.mtrace_req);
ca3e7807 819 vty_out(vty, "unsupported : %u\n",
f2058cb4 820 igmp_stats.unsupported);
ca3e7807
DA
821 vty_out(vty, "total received messages : %u\n",
822 igmp_stats.total_recv_messages);
823 vty_out(vty, "joins failed : %u\n",
f2058cb4 824 igmp_stats.joins_failed);
ca3e7807 825 vty_out(vty, "joins sent : %u\n",
f2058cb4 826 igmp_stats.joins_sent);
ca3e7807 827 vty_out(vty, "general queries sent : %u\n",
278912ea 828 igmp_stats.general_queries_sent);
ca3e7807 829 vty_out(vty, "group queries sent : %u\n",
278912ea 830 igmp_stats.group_queries_sent);
3e5d8665
DA
831 vty_out(vty, "peak groups : %u\n",
832 igmp_stats.peak_groups);
ca3e7807 833 vty_out(vty, "total groups : %u\n",
f2058cb4 834 igmp_stats.total_groups);
ca3e7807 835 vty_out(vty, "total source groups : %u\n",
f2058cb4 836 igmp_stats.total_source_groups);
21313cbf
MS
837 }
838}
839
0d1a4e24 840/* Display the bsm database details */
841static void pim_show_bsm_db(struct pim_instance *pim, struct vty *vty, bool uj)
842{
0d1a4e24 843 int count = 0;
844 int fragment = 1;
d4a4525c 845 struct bsm_frag *bsfrag;
0d1a4e24 846 json_object *json = NULL;
847 json_object *json_group = NULL;
848 json_object *json_row = NULL;
849
d4a4525c 850 count = bsm_frags_count(pim->global_scope.bsm_frags);
0d1a4e24 851
852 if (uj) {
853 json = json_object_new_object();
854 json_object_int_add(json, "Number of the fragments", count);
855 } else {
856 vty_out(vty, "Scope Zone: Global\n");
857 vty_out(vty, "Number of the fragments: %d\n", count);
858 vty_out(vty, "\n");
859 }
860
d4a4525c 861 frr_each (bsm_frags, pim->global_scope.bsm_frags, bsfrag) {
93a5bc80 862 char grp_str[PREFIX_STRLEN];
0d1a4e24 863 struct bsmmsg_grpinfo *group;
1407e40f 864 struct bsmmsg_rpinfo *bsm_rpinfo;
0d1a4e24 865 struct prefix grp;
866 struct bsm_hdr *hdr;
cefb7247 867 pim_addr bsr_addr;
0d1a4e24 868 uint32_t offset = 0;
869 uint8_t *buf;
870 uint32_t len = 0;
871 uint32_t frag_rp_cnt = 0;
872
d4a4525c
DL
873 buf = bsfrag->data;
874 len = bsfrag->size;
0d1a4e24 875
876 /* skip pim header */
877 buf += PIM_MSG_HEADER_LEN;
878 len -= PIM_MSG_HEADER_LEN;
879
880 hdr = (struct bsm_hdr *)buf;
cefb7247
DL
881 /* NB: bshdr->bsr_addr.addr is packed/unaligned => memcpy */
882 memcpy(&bsr_addr, &hdr->bsr_addr.addr, sizeof(bsr_addr));
0d1a4e24 883
884 /* BSM starts with bsr header */
885 buf += sizeof(struct bsm_hdr);
886 len -= sizeof(struct bsm_hdr);
887
0d1a4e24 888 if (uj) {
cefb7247
DL
889 json_object_string_addf(json, "BSR address", "%pPA",
890 &bsr_addr);
0d1a4e24 891 json_object_int_add(json, "BSR priority",
892 hdr->bsr_prio);
893 json_object_int_add(json, "Hashmask Length",
894 hdr->hm_len);
895 json_object_int_add(json, "Fragment Tag",
896 ntohs(hdr->frag_tag));
897 } else {
898 vty_out(vty, "BSM Fragment : %d\n", fragment);
899 vty_out(vty, "------------------\n");
900 vty_out(vty, "%-15s %-15s %-15s %-15s\n", "BSR-Address",
901 "BSR-Priority", "Hashmask-len", "Fragment-Tag");
cefb7247
DL
902 vty_out(vty, "%-15pPA %-15d %-15d %-15d\n", &bsr_addr,
903 hdr->bsr_prio, hdr->hm_len,
904 ntohs(hdr->frag_tag));
0d1a4e24 905 }
906
907 vty_out(vty, "\n");
908
909 while (offset < len) {
910 group = (struct bsmmsg_grpinfo *)buf;
911
912 if (group->group.family == PIM_MSG_ADDRESS_FAMILY_IPV4)
913 grp.family = AF_INET;
7b56b13f 914 else if (group->group.family ==
915 PIM_MSG_ADDRESS_FAMILY_IPV6)
916 grp.family = AF_INET6;
0d1a4e24 917
918 grp.prefixlen = group->group.mask;
7b56b13f 919#if PIM_IPV == 4
920 grp.u.prefix4 = group->group.addr;
921#else
922 grp.u.prefix6 = group->group.addr;
923#endif
0d1a4e24 924
925 prefix2str(&grp, grp_str, sizeof(grp_str));
926
927 buf += sizeof(struct bsmmsg_grpinfo);
928 offset += sizeof(struct bsmmsg_grpinfo);
929
930 if (uj) {
931 json_object_object_get_ex(json, grp_str,
932 &json_group);
933 if (!json_group) {
934 json_group = json_object_new_object();
935 json_object_int_add(json_group,
936 "Rp Count",
937 group->rp_count);
938 json_object_int_add(
939 json_group, "Fragment Rp count",
940 group->frag_rp_count);
941 json_object_object_add(json, grp_str,
942 json_group);
943 }
944 } else {
945 vty_out(vty, "Group : %s\n", grp_str);
946 vty_out(vty, "-------------------\n");
947 vty_out(vty, "Rp Count:%d\n", group->rp_count);
948 vty_out(vty, "Fragment Rp Count : %d\n",
949 group->frag_rp_count);
950 }
951
952 frag_rp_cnt = group->frag_rp_count;
953
954 if (!frag_rp_cnt)
955 continue;
956
957 if (!uj)
958 vty_out(vty,
959 "RpAddress HoldTime Priority\n");
960
961 while (frag_rp_cnt--) {
cefb7247
DL
962 pim_addr rp_addr;
963
1407e40f 964 bsm_rpinfo = (struct bsmmsg_rpinfo *)buf;
cefb7247
DL
965 /* unaligned, again */
966 memcpy(&rp_addr, &bsm_rpinfo->rpaddr,
967 sizeof(rp_addr));
0d1a4e24 968
969 buf += sizeof(struct bsmmsg_rpinfo);
970 offset += sizeof(struct bsmmsg_rpinfo);
971
0d1a4e24 972 if (uj) {
973 json_row = json_object_new_object();
1407e40f 974 json_object_string_addf(
975 json_row, "Rp Address", "%pPA",
cefb7247 976 &rp_addr);
0d1a4e24 977 json_object_int_add(
978 json_row, "Rp HoldTime",
1407e40f 979 ntohs(bsm_rpinfo->rp_holdtime));
0d1a4e24 980 json_object_int_add(json_row,
981 "Rp Priority",
1407e40f 982 bsm_rpinfo->rp_pri);
983 json_object_object_addf(
984 json_group, json_row, "%pPA",
cefb7247 985 &rp_addr);
0d1a4e24 986 } else {
1407e40f 987 vty_out(vty, "%-15pPA %-12d %d\n",
cefb7247 988 &rp_addr,
1407e40f 989 ntohs(bsm_rpinfo->rp_holdtime),
990 bsm_rpinfo->rp_pri);
0d1a4e24 991 }
992 }
993 vty_out(vty, "\n");
994 }
995
996 fragment++;
997 }
998
3757f964
DA
999 if (uj)
1000 vty_json(vty, json);
0d1a4e24 1001}
1002
321295c1 1003/*Display the group-rp mappings */
1004static void pim_show_group_rp_mappings_info(struct pim_instance *pim,
1005 struct vty *vty, bool uj)
1006{
1007 struct bsgrp_node *bsgrp;
321295c1 1008 struct bsm_rpinfo *bsm_rp;
1009 struct route_node *rn;
321295c1 1010 json_object *json = NULL;
1011 json_object *json_group = NULL;
1012 json_object *json_row = NULL;
1013
321295c1 1014 if (uj) {
1015 json = json_object_new_object();
e309769a 1016 json_object_string_addf(json, "BSR Address", "%pPA",
7b56b13f 1017 &pim->global_scope.current_bsr);
e309769a 1018 } else
7b56b13f 1019 vty_out(vty, "BSR Address %pPA\n",
1020 &pim->global_scope.current_bsr);
321295c1 1021
1022 for (rn = route_top(pim->global_scope.bsrp_table); rn;
1023 rn = route_next(rn)) {
1024 bsgrp = (struct bsgrp_node *)rn->info;
1025
1026 if (!bsgrp)
1027 continue;
1028
93a5bc80 1029 char grp_str[PREFIX_STRLEN];
321295c1 1030
1031 prefix2str(&bsgrp->group, grp_str, sizeof(grp_str));
1032
1033 if (uj) {
1034 json_object_object_get_ex(json, grp_str, &json_group);
1035 if (!json_group) {
1036 json_group = json_object_new_object();
1037 json_object_object_add(json, grp_str,
1038 json_group);
1039 }
1040 } else {
2dbe669b 1041 vty_out(vty, "Group Address %pFX\n", &bsgrp->group);
321295c1 1042 vty_out(vty, "--------------------------\n");
1043 vty_out(vty, "%-15s %-15s %-15s %-15s\n", "Rp Address",
1044 "priority", "Holdtime", "Hash");
1045
1046 vty_out(vty, "(ACTIVE)\n");
1047 }
1048
fdab2940 1049 frr_each (bsm_rpinfos, bsgrp->bsrp_list, bsm_rp) {
fdab2940
DL
1050 if (uj) {
1051 json_row = json_object_new_object();
11e1593f 1052 json_object_string_addf(json_row, "Rp Address",
7b56b13f 1053 "%pPA",
1054 &bsm_rp->rp_address);
fdab2940
DL
1055 json_object_int_add(json_row, "Rp HoldTime",
1056 bsm_rp->rp_holdtime);
1057 json_object_int_add(json_row, "Rp Priority",
1058 bsm_rp->rp_prio);
1059 json_object_int_add(json_row, "Hash Val",
1060 bsm_rp->hash);
11e1593f 1061 json_object_object_addf(json_group, json_row,
7b56b13f 1062 "%pPA",
1063 &bsm_rp->rp_address);
321295c1 1064
fdab2940 1065 } else {
11e1593f 1066 vty_out(vty, "%-15pPA %-15u %-15u %-15u\n",
1067 &bsm_rp->rp_address, bsm_rp->rp_prio,
fdab2940 1068 bsm_rp->rp_holdtime, bsm_rp->hash);
321295c1 1069 }
321295c1 1070 }
fdab2940
DL
1071 if (!bsm_rpinfos_count(bsgrp->bsrp_list) && !uj)
1072 vty_out(vty, "Active List is empty.\n");
321295c1 1073
1074 if (uj) {
1075 json_object_int_add(json_group, "Pending RP count",
1076 bsgrp->pend_rp_cnt);
1077 } else {
1078 vty_out(vty, "(PENDING)\n");
1079 vty_out(vty, "Pending RP count :%d\n",
1080 bsgrp->pend_rp_cnt);
1081 if (bsgrp->pend_rp_cnt)
1082 vty_out(vty, "%-15s %-15s %-15s %-15s\n",
1083 "Rp Address", "priority", "Holdtime",
1084 "Hash");
1085 }
1086
fdab2940 1087 frr_each (bsm_rpinfos, bsgrp->partial_bsrp_list, bsm_rp) {
fdab2940
DL
1088 if (uj) {
1089 json_row = json_object_new_object();
11e1593f 1090 json_object_string_addf(json_row, "Rp Address",
1091 "%pPA",
1092 &bsm_rp->rp_address);
fdab2940
DL
1093 json_object_int_add(json_row, "Rp HoldTime",
1094 bsm_rp->rp_holdtime);
1095 json_object_int_add(json_row, "Rp Priority",
1096 bsm_rp->rp_prio);
1097 json_object_int_add(json_row, "Hash Val",
1098 bsm_rp->hash);
11e1593f 1099 json_object_object_addf(json_group, json_row,
1100 "%pPA",
7b56b13f 1101 &bsm_rp->rp_address);
fdab2940 1102 } else {
11e1593f 1103 vty_out(vty, "%-15pPA %-15u %-15u %-15u\n",
1104 &bsm_rp->rp_address, bsm_rp->rp_prio,
fdab2940 1105 bsm_rp->rp_holdtime, bsm_rp->hash);
321295c1 1106 }
321295c1 1107 }
fdab2940
DL
1108 if (!bsm_rpinfos_count(bsgrp->partial_bsrp_list) && !uj)
1109 vty_out(vty, "Partial List is empty\n");
321295c1 1110
1111 if (!uj)
1112 vty_out(vty, "\n");
1113 }
1114
3757f964
DA
1115 if (uj)
1116 vty_json(vty, json);
321295c1 1117}
1118
088f1098 1119static void igmp_show_groups(struct pim_instance *pim, struct vty *vty, bool uj)
d62a17ae 1120{
d62a17ae 1121 struct interface *ifp;
1122 time_t now;
1123 json_object *json = NULL;
1124 json_object *json_iface = NULL;
4d360968 1125 json_object *json_group = NULL;
1126 json_object *json_groups = NULL;
d62a17ae 1127
1128 now = pim_time_monotonic_sec();
1129
339f7695 1130 if (uj) {
d62a17ae 1131 json = json_object_new_object();
339f7695 1132 json_object_int_add(json, "totalGroups", pim->igmp_group_count);
1133 json_object_int_add(json, "watermarkLimit",
229a20e2 1134 pim->gm_watermark_limit);
339f7695 1135 } else {
1136 vty_out(vty, "Total IGMP groups: %u\n", pim->igmp_group_count);
1137 vty_out(vty, "Watermark warn limit(%s): %u\n",
229a20e2
SG
1138 pim->gm_watermark_limit ? "Set" : "Not Set",
1139 pim->gm_watermark_limit);
d62a17ae 1140 vty_out(vty,
dda4d23c 1141 "Interface Group Mode Timer Srcs V Uptime \n");
339f7695 1142 }
d62a17ae 1143
1144 /* scan interfaces */
451fda4f 1145 FOR_ALL_INTERFACES (pim->vrf, ifp) {
d62a17ae 1146 struct pim_interface *pim_ifp = ifp->info;
dda4d23c 1147 struct listnode *grpnode;
a16db099 1148 struct gm_group *grp;
d62a17ae 1149
1150 if (!pim_ifp)
1151 continue;
1152
dda4d23c 1153 /* scan igmp groups */
18adcff1 1154 for (ALL_LIST_ELEMENTS_RO(pim_ifp->gm_group_list, grpnode,
29e58225 1155 grp)) {
dda4d23c
DL
1156 char group_str[INET_ADDRSTRLEN];
1157 char hhmmss[10];
1158 char uptime[10];
d62a17ae 1159
a1a4295a
DL
1160 pim_inet4_dump("<group?>", grp->group_addr, group_str,
1161 sizeof(group_str));
dda4d23c
DL
1162 pim_time_timer_to_hhmmss(hhmmss, sizeof(hhmmss),
1163 grp->t_group_timer);
1164 pim_time_uptime(uptime, sizeof(uptime),
1165 now - grp->group_creation);
d62a17ae 1166
dda4d23c 1167 if (uj) {
a1a4295a
DL
1168 json_object_object_get_ex(json, ifp->name,
1169 &json_iface);
d62a17ae 1170
dda4d23c 1171 if (!json_iface) {
a1a4295a
DL
1172 json_iface = json_object_new_object();
1173 json_object_pim_ifp_add(json_iface,
1174 ifp);
1175 json_object_object_add(json, ifp->name,
1176 json_iface);
1177 json_groups = json_object_new_array();
1178 json_object_object_add(json_iface,
1179 "groups",
1180 json_groups);
d62a17ae 1181 }
dda4d23c
DL
1182
1183 json_group = json_object_new_object();
a1a4295a 1184 json_object_string_add(json_group, "group",
dda4d23c
DL
1185 group_str);
1186
1187 if (grp->igmp_version == 3)
1188 json_object_string_add(
1189 json_group, "mode",
1190 grp->group_filtermode_isexcl
a1a4295a
DL
1191 ? "EXCLUDE"
1192 : "INCLUDE");
dda4d23c 1193
a1a4295a
DL
1194 json_object_string_add(json_group, "timer",
1195 hhmmss);
dda4d23c
DL
1196 json_object_int_add(
1197 json_group, "sourcesCount",
a1a4295a 1198 grp->group_source_list ? listcount(
dda4d23c 1199 grp->group_source_list)
a1a4295a
DL
1200 : 0);
1201 json_object_int_add(json_group, "version",
1202 grp->igmp_version);
1203 json_object_string_add(json_group, "uptime",
1204 uptime);
1205 json_object_array_add(json_groups, json_group);
dda4d23c 1206 } else {
a1a4295a 1207 vty_out(vty, "%-16s %-15s %4s %8s %4d %d %8s\n",
dda4d23c
DL
1208 ifp->name, group_str,
1209 grp->igmp_version == 3
a1a4295a
DL
1210 ? (grp->group_filtermode_isexcl
1211 ? "EXCL"
1212 : "INCL")
1213 : "----",
dda4d23c 1214 hhmmss,
a1a4295a 1215 grp->group_source_list ? listcount(
dda4d23c 1216 grp->group_source_list)
a1a4295a 1217 : 0,
dda4d23c
DL
1218 grp->igmp_version, uptime);
1219 }
1220 } /* scan igmp groups */
1221 } /* scan interfaces */
d62a17ae 1222
3757f964
DA
1223 if (uj)
1224 vty_json(vty, json);
12e41d03
DL
1225}
1226
64c86530
DS
1227static void igmp_show_group_retransmission(struct pim_instance *pim,
1228 struct vty *vty)
12e41d03 1229{
d62a17ae 1230 struct interface *ifp;
1231
1232 vty_out(vty,
dda4d23c 1233 "Interface Group RetTimer Counter RetSrcs\n");
d62a17ae 1234
1235 /* scan interfaces */
451fda4f 1236 FOR_ALL_INTERFACES (pim->vrf, ifp) {
d62a17ae 1237 struct pim_interface *pim_ifp = ifp->info;
dda4d23c 1238 struct listnode *grpnode;
a16db099 1239 struct gm_group *grp;
d62a17ae 1240
1241 if (!pim_ifp)
1242 continue;
1243
dda4d23c 1244 /* scan igmp groups */
18adcff1 1245 for (ALL_LIST_ELEMENTS_RO(pim_ifp->gm_group_list, grpnode,
29e58225 1246 grp)) {
dda4d23c
DL
1247 char group_str[INET_ADDRSTRLEN];
1248 char grp_retr_mmss[10];
1249 struct listnode *src_node;
51700107 1250 struct gm_source *src;
dda4d23c 1251 int grp_retr_sources = 0;
d62a17ae 1252
a1a4295a
DL
1253 pim_inet4_dump("<group?>", grp->group_addr, group_str,
1254 sizeof(group_str));
dda4d23c
DL
1255 pim_time_timer_to_mmss(
1256 grp_retr_mmss, sizeof(grp_retr_mmss),
1257 grp->t_group_query_retransmit_timer);
d62a17ae 1258
dda4d23c
DL
1259
1260 /* count group sources with retransmission state
1261 */
a1a4295a
DL
1262 for (ALL_LIST_ELEMENTS_RO(grp->group_source_list,
1263 src_node, src)) {
1264 if (src->source_query_retransmit_count > 0) {
dda4d23c 1265 ++grp_retr_sources;
d62a17ae 1266 }
dda4d23c 1267 }
d62a17ae 1268
a1a4295a
DL
1269 vty_out(vty, "%-16s %-15s %-8s %7d %7d\n", ifp->name,
1270 group_str, grp_retr_mmss,
dda4d23c
DL
1271 grp->group_specific_query_retransmit_count,
1272 grp_retr_sources);
d62a17ae 1273
dda4d23c
DL
1274 } /* scan igmp groups */
1275 } /* scan interfaces */
12e41d03
DL
1276}
1277
4527b70a
SG
1278static void igmp_show_sources(struct pim_instance *pim, struct vty *vty,
1279 bool uj)
12e41d03 1280{
d62a17ae 1281 struct interface *ifp;
1282 time_t now;
4527b70a
SG
1283 json_object *json = NULL;
1284 json_object *json_iface = NULL;
1285 json_object *json_group = NULL;
1286 json_object *json_source = NULL;
1287 json_object *json_sources = NULL;
d62a17ae 1288
1289 now = pim_time_monotonic_sec();
1290
4527b70a
SG
1291 if (uj)
1292 json = json_object_new_object();
1293 else
1294 vty_out(vty,
e1f87dce 1295 "Interface Group Source Timer Fwd Uptime \n");
d62a17ae 1296
1297 /* scan interfaces */
451fda4f 1298 FOR_ALL_INTERFACES (pim->vrf, ifp) {
d62a17ae 1299 struct pim_interface *pim_ifp = ifp->info;
dda4d23c 1300 struct listnode *grpnode;
a16db099 1301 struct gm_group *grp;
d62a17ae 1302
1303 if (!pim_ifp)
1304 continue;
1305
dda4d23c 1306 /* scan igmp groups */
18adcff1 1307 for (ALL_LIST_ELEMENTS_RO(pim_ifp->gm_group_list, grpnode,
29e58225 1308 grp)) {
dda4d23c
DL
1309 char group_str[INET_ADDRSTRLEN];
1310 struct listnode *srcnode;
51700107 1311 struct gm_source *src;
dda4d23c 1312
a1a4295a
DL
1313 pim_inet4_dump("<group?>", grp->group_addr, group_str,
1314 sizeof(group_str));
dda4d23c
DL
1315
1316 /* scan group sources */
a1a4295a
DL
1317 for (ALL_LIST_ELEMENTS_RO(grp->group_source_list,
1318 srcnode, src)) {
dda4d23c
DL
1319 char source_str[INET_ADDRSTRLEN];
1320 char mmss[10];
1321 char uptime[10];
d62a17ae 1322
a1a4295a
DL
1323 pim_inet4_dump("<source?>", src->source_addr,
1324 source_str, sizeof(source_str));
d62a17ae 1325
a1a4295a
DL
1326 pim_time_timer_to_mmss(mmss, sizeof(mmss),
1327 src->t_source_timer);
d62a17ae 1328
a1a4295a
DL
1329 pim_time_uptime(uptime, sizeof(uptime),
1330 now - src->source_creation);
d62a17ae 1331
4527b70a
SG
1332 if (uj) {
1333 json_object_object_get_ex(
1334 json, ifp->name, &json_iface);
1335 if (!json_iface) {
1336 json_iface =
1337 json_object_new_object();
1338 json_object_string_add(
1339 json_iface, "name",
1340 ifp->name);
1341 json_object_object_add(
1342 json, ifp->name,
1343 json_iface);
1344 }
1345 json_object_object_get_ex(json_iface,
1346 group_str,
1347 &json_group);
1348
1349 if (!json_group) {
1350 json_group =
1351 json_object_new_object();
1352 json_object_string_add(
1353 json_group, "group",
1354 group_str);
1355 json_object_object_add(
1356 json_iface, group_str,
1357 json_group);
1358 json_sources =
1359 json_object_new_array();
1360 json_object_object_add(
1361 json_group, "sources",
1362 json_sources);
1363 }
1364 json_source = json_object_new_object();
1365 json_object_string_add(json_source,
1366 "source",
1367 source_str);
1368 json_object_string_add(json_source,
1369 "timer", mmss);
1370 json_object_boolean_add(
1371 json_source, "forwarded",
1372 IGMP_SOURCE_TEST_FORWARDING(
1373 src->source_flags));
1374 json_object_string_add(
1375 json_source, "uptime", uptime);
1376 json_object_array_add(json_sources,
1377 json_source);
1378
1379 } else {
1380 vty_out(vty,
1381 "%-16s %-15s %-15s %5s %3s %8s\n",
1382 ifp->name, group_str,
1383 source_str, mmss,
1384 IGMP_SOURCE_TEST_FORWARDING(
1385 src->source_flags)
1386 ? "Y"
1387 : "N",
1388 uptime);
1389 }
d62a17ae 1390
dda4d23c 1391 } /* scan group sources */
18adcff1 1392 } /* scan igmp groups */
dda4d23c 1393 } /* scan interfaces */
4527b70a
SG
1394 if (uj)
1395 vty_json(vty, json);
12e41d03
DL
1396}
1397
64c86530
DS
1398static void igmp_show_source_retransmission(struct pim_instance *pim,
1399 struct vty *vty)
12e41d03 1400{
d62a17ae 1401 struct interface *ifp;
1402
1403 vty_out(vty,
dda4d23c 1404 "Interface Group Source Counter\n");
d62a17ae 1405
1406 /* scan interfaces */
451fda4f 1407 FOR_ALL_INTERFACES (pim->vrf, ifp) {
d62a17ae 1408 struct pim_interface *pim_ifp = ifp->info;
dda4d23c 1409 struct listnode *grpnode;
a16db099 1410 struct gm_group *grp;
d62a17ae 1411
1412 if (!pim_ifp)
1413 continue;
1414
dda4d23c 1415 /* scan igmp groups */
18adcff1 1416 for (ALL_LIST_ELEMENTS_RO(pim_ifp->gm_group_list, grpnode,
29e58225 1417 grp)) {
dda4d23c
DL
1418 char group_str[INET_ADDRSTRLEN];
1419 struct listnode *srcnode;
51700107 1420 struct gm_source *src;
d62a17ae 1421
a1a4295a
DL
1422 pim_inet4_dump("<group?>", grp->group_addr, group_str,
1423 sizeof(group_str));
d62a17ae 1424
dda4d23c 1425 /* scan group sources */
a1a4295a
DL
1426 for (ALL_LIST_ELEMENTS_RO(grp->group_source_list,
1427 srcnode, src)) {
dda4d23c 1428 char source_str[INET_ADDRSTRLEN];
d62a17ae 1429
a1a4295a
DL
1430 pim_inet4_dump("<source?>", src->source_addr,
1431 source_str, sizeof(source_str));
d62a17ae 1432
a1a4295a 1433 vty_out(vty, "%-16s %-15s %-15s %7d\n",
dda4d23c
DL
1434 ifp->name, group_str, source_str,
1435 src->source_query_retransmit_count);
d62a17ae 1436
dda4d23c 1437 } /* scan group sources */
18adcff1 1438 } /* scan igmp groups */
dda4d23c 1439 } /* scan interfaces */
12e41d03
DL
1440}
1441
256392eb 1442static void pim_show_bsr(struct pim_instance *pim,
1443 struct vty *vty,
1444 bool uj)
1445{
1446 char uptime[10];
1447 char last_bsm_seen[10];
1448 time_t now;
1449 char bsr_state[20];
256392eb 1450 json_object *json = NULL;
1451
e309769a 1452 if (pim_addr_is_any(pim->global_scope.current_bsr)) {
256392eb 1453 pim_time_uptime(uptime, sizeof(uptime),
1454 pim->global_scope.current_bsr_first_ts);
1455 pim_time_uptime(last_bsm_seen, sizeof(last_bsm_seen),
1456 pim->global_scope.current_bsr_last_ts);
1457 }
1458
1459 else {
256392eb 1460 now = pim_time_monotonic_sec();
1461 pim_time_uptime(uptime, sizeof(uptime),
1462 (now - pim->global_scope.current_bsr_first_ts));
1463 pim_time_uptime(last_bsm_seen, sizeof(last_bsm_seen),
1464 now - pim->global_scope.current_bsr_last_ts);
1465 }
1466
1467 switch (pim->global_scope.state) {
1468 case NO_INFO:
fbd74c7d 1469 strlcpy(bsr_state, "NO_INFO", sizeof(bsr_state));
256392eb 1470 break;
1471 case ACCEPT_ANY:
fbd74c7d 1472 strlcpy(bsr_state, "ACCEPT_ANY", sizeof(bsr_state));
256392eb 1473 break;
1474 case ACCEPT_PREFERRED:
fbd74c7d 1475 strlcpy(bsr_state, "ACCEPT_PREFERRED", sizeof(bsr_state));
256392eb 1476 break;
1477 default:
fbd74c7d 1478 strlcpy(bsr_state, "", sizeof(bsr_state));
256392eb 1479 }
1480
e309769a 1481
256392eb 1482 if (uj) {
1483 json = json_object_new_object();
e309769a 1484 json_object_string_addf(json, "bsr", "%pPA",
1485 &pim->global_scope.current_bsr);
256392eb 1486 json_object_int_add(json, "priority",
1487 pim->global_scope.current_bsr_prio);
a5f610e4 1488 json_object_int_add(json, "fragmentTag",
256392eb 1489 pim->global_scope.bsm_frag_tag);
1490 json_object_string_add(json, "state", bsr_state);
1491 json_object_string_add(json, "upTime", uptime);
a5f610e4 1492 json_object_string_add(json, "lastBsmSeen", last_bsm_seen);
256392eb 1493 }
1494
1495 else {
36afe486 1496 vty_out(vty, "PIMv2 Bootstrap information\n");
e309769a 1497 vty_out(vty, "Current preferred BSR address: %pPA\n",
1498 &pim->global_scope.current_bsr);
256392eb 1499 vty_out(vty,
1500 "Priority Fragment-Tag State UpTime\n");
1501 vty_out(vty, " %-12d %-12d %-13s %7s\n",
1502 pim->global_scope.current_bsr_prio,
1503 pim->global_scope.bsm_frag_tag,
1504 bsr_state,
1505 uptime);
1506 vty_out(vty, "Last BSM seen: %s\n", last_bsm_seen);
1507 }
1508
3757f964
DA
1509 if (uj)
1510 vty_json(vty, json);
256392eb 1511}
1512
c68ba0d7 1513static void clear_igmp_interfaces(struct pim_instance *pim)
12e41d03 1514{
d62a17ae 1515 struct interface *ifp;
12e41d03 1516
451fda4f 1517 FOR_ALL_INTERFACES (pim->vrf, ifp)
d62a17ae 1518 pim_if_addr_del_all_igmp(ifp);
12e41d03 1519
451fda4f 1520 FOR_ALL_INTERFACES (pim->vrf, ifp)
d62a17ae 1521 pim_if_addr_add_all(ifp);
12e41d03
DL
1522}
1523
c68ba0d7 1524static void clear_pim_interfaces(struct pim_instance *pim)
12e41d03 1525{
d62a17ae 1526 struct interface *ifp;
12e41d03 1527
451fda4f 1528 FOR_ALL_INTERFACES (pim->vrf, ifp) {
d62a17ae 1529 if (ifp->info) {
1530 pim_neighbor_delete_all(ifp, "interface cleared");
1531 }
1532 }
12e41d03
DL
1533}
1534
c68ba0d7 1535static void clear_interfaces(struct pim_instance *pim)
12e41d03 1536{
c68ba0d7
DS
1537 clear_igmp_interfaces(pim);
1538 clear_pim_interfaces(pim);
12e41d03
DL
1539}
1540
521c5b9d
MS
1541#define PIM_GET_PIM_INTERFACE(pim_ifp, ifp) \
1542 pim_ifp = ifp->info; \
1543 if (!pim_ifp) { \
1544 vty_out(vty, \
21b3e44e 1545 "%% Enable PIM and/or IGMP on this interface first\n"); \
521c5b9d 1546 return CMD_WARNING_CONFIG_FAILED; \
21b3e44e
QY
1547 }
1548
e2809e61
RZ
1549/**
1550 * Compatibility function to keep the legacy mesh group CLI behavior:
1551 * Delete group when there are no more configurations in it.
1552 *
1553 * NOTE:
1554 * Don't forget to call `nb_cli_apply_changes` after this.
1555 */
1556static void pim_cli_legacy_mesh_group_behavior(struct vty *vty,
1557 const char *gname)
1558{
1559 const char *vrfname;
1560 char xpath_value[XPATH_MAXLEN];
1561 char xpath_member_value[XPATH_MAXLEN];
1562 const struct lyd_node *member_dnode;
1563
1564 vrfname = pim_cli_get_vrf_name(vty);
1565 if (vrfname == NULL)
1566 return;
1567
1568 /* Get mesh group base XPath. */
1569 snprintf(xpath_value, sizeof(xpath_value),
698f4147 1570 FRR_PIM_VRF_XPATH "/msdp-mesh-groups[name='%s']",
e2809e61
RZ
1571 "frr-pim:pimd", "pim", vrfname, "frr-routing:ipv4", gname);
1572 /* Group must exists, otherwise just quit. */
1573 if (!yang_dnode_exists(vty->candidate_config->dnode, xpath_value))
1574 return;
1575
1576 /* Group members check: */
1577 strlcpy(xpath_member_value, xpath_value, sizeof(xpath_member_value));
1578 strlcat(xpath_member_value, "/members", sizeof(xpath_member_value));
1579 if (yang_dnode_exists(vty->candidate_config->dnode,
1580 xpath_member_value)) {
1581 member_dnode = yang_dnode_get(vty->candidate_config->dnode,
1582 xpath_member_value);
46877489 1583 if (!member_dnode || !yang_is_last_list_dnode(member_dnode))
e2809e61
RZ
1584 return;
1585 }
1586
1587 /* Source address check: */
1588 strlcpy(xpath_member_value, xpath_value, sizeof(xpath_member_value));
1589 strlcat(xpath_member_value, "/source", sizeof(xpath_member_value));
1590 if (yang_dnode_exists(vty->candidate_config->dnode, xpath_member_value))
1591 return;
1592
1593 /* No configurations found: delete it. */
1594 nb_cli_enqueue_change(vty, xpath_value, NB_OP_DESTROY, NULL);
1595}
1596
12e41d03
DL
1597DEFUN (clear_ip_interfaces,
1598 clear_ip_interfaces_cmd,
20a7e5fd 1599 "clear ip interfaces [vrf NAME]",
12e41d03
DL
1600 CLEAR_STR
1601 IP_STR
c68ba0d7
DS
1602 "Reset interfaces\n"
1603 VRF_CMD_HELP_STR)
12e41d03 1604{
c68ba0d7
DS
1605 int idx = 2;
1606 struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
1607
1608 if (!vrf)
1609 return CMD_WARNING;
1610
1611 clear_interfaces(vrf->info);
12e41d03 1612
d62a17ae 1613 return CMD_SUCCESS;
12e41d03
DL
1614}
1615
1616DEFUN (clear_ip_igmp_interfaces,
1617 clear_ip_igmp_interfaces_cmd,
20a7e5fd 1618 "clear ip igmp [vrf NAME] interfaces",
12e41d03
DL
1619 CLEAR_STR
1620 IP_STR
1621 CLEAR_IP_IGMP_STR
c68ba0d7 1622 VRF_CMD_HELP_STR
12e41d03
DL
1623 "Reset IGMP interfaces\n")
1624{
c68ba0d7
DS
1625 int idx = 2;
1626 struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
1627
1628 if (!vrf)
1629 return CMD_WARNING;
1630
1631 clear_igmp_interfaces(vrf->info);
12e41d03 1632
d62a17ae 1633 return CMD_SUCCESS;
12e41d03
DL
1634}
1635
ef1b0a2d 1636DEFPY (clear_ip_pim_statistics,
415f6350 1637 clear_ip_pim_statistics_cmd,
ef1b0a2d 1638 "clear ip pim statistics [vrf NAME]$name",
415f6350 1639 CLEAR_STR
1640 IP_STR
1641 CLEAR_IP_PIM_STR
1642 VRF_CMD_HELP_STR
1643 "Reset PIM statistics\n")
1644{
ef1b0a2d 1645 struct vrf *v = pim_cmd_lookup(vty, name);
415f6350 1646
ef1b0a2d 1647 if (!v)
415f6350 1648 return CMD_WARNING;
1649
ef1b0a2d
SG
1650 clear_pim_statistics(v->info);
1651
415f6350 1652 return CMD_SUCCESS;
1653}
1654
a14ae314 1655DEFPY (clear_ip_mroute,
12e41d03 1656 clear_ip_mroute_cmd,
a14ae314 1657 "clear ip mroute [vrf NAME]$name",
12e41d03
DL
1658 CLEAR_STR
1659 IP_STR
215d10a1 1660 MROUTE_STR
c68ba0d7 1661 VRF_CMD_HELP_STR)
12e41d03 1662{
a14ae314 1663 struct vrf *v = pim_cmd_lookup(vty, name);
c68ba0d7 1664
a14ae314 1665 if (!v)
c68ba0d7
DS
1666 return CMD_WARNING;
1667
a14ae314 1668 clear_mroute(v->info);
12e41d03 1669
d62a17ae 1670 return CMD_SUCCESS;
12e41d03
DL
1671}
1672
1673DEFUN (clear_ip_pim_interfaces,
1674 clear_ip_pim_interfaces_cmd,
20a7e5fd 1675 "clear ip pim [vrf NAME] interfaces",
12e41d03
DL
1676 CLEAR_STR
1677 IP_STR
1678 CLEAR_IP_PIM_STR
c68ba0d7 1679 VRF_CMD_HELP_STR
12e41d03
DL
1680 "Reset PIM interfaces\n")
1681{
c68ba0d7
DS
1682 int idx = 2;
1683 struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
1684
1685 if (!vrf)
1686 return CMD_WARNING;
1687
1688 clear_pim_interfaces(vrf->info);
12e41d03 1689
d62a17ae 1690 return CMD_SUCCESS;
12e41d03
DL
1691}
1692
39438188
CS
1693DEFUN (clear_ip_pim_interface_traffic,
1694 clear_ip_pim_interface_traffic_cmd,
20a7e5fd 1695 "clear ip pim [vrf NAME] interface traffic",
39438188
CS
1696 "Reset functions\n"
1697 "IP information\n"
1698 "PIM clear commands\n"
c68ba0d7 1699 VRF_CMD_HELP_STR
39438188
CS
1700 "Reset PIM interfaces\n"
1701 "Reset Protocol Packet counters\n")
1702{
c68ba0d7
DS
1703 int idx = 2;
1704 struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
d62a17ae 1705 struct interface *ifp = NULL;
1706 struct pim_interface *pim_ifp = NULL;
1707
c68ba0d7
DS
1708 if (!vrf)
1709 return CMD_WARNING;
1710
451fda4f 1711 FOR_ALL_INTERFACES (vrf, ifp) {
d62a17ae 1712 pim_ifp = ifp->info;
1713
1714 if (!pim_ifp)
1715 continue;
1716
1717 pim_ifp->pim_ifstat_hello_recv = 0;
1718 pim_ifp->pim_ifstat_hello_sent = 0;
1719 pim_ifp->pim_ifstat_join_recv = 0;
1720 pim_ifp->pim_ifstat_join_send = 0;
1721 pim_ifp->pim_ifstat_prune_recv = 0;
1722 pim_ifp->pim_ifstat_prune_send = 0;
1723 pim_ifp->pim_ifstat_reg_recv = 0;
1724 pim_ifp->pim_ifstat_reg_send = 0;
1725 pim_ifp->pim_ifstat_reg_stop_recv = 0;
1726 pim_ifp->pim_ifstat_reg_stop_send = 0;
1727 pim_ifp->pim_ifstat_assert_recv = 0;
1728 pim_ifp->pim_ifstat_assert_send = 0;
5164ad1e 1729 pim_ifp->pim_ifstat_bsm_rx = 0;
1730 pim_ifp->pim_ifstat_bsm_tx = 0;
f2058cb4
DA
1731 pim_ifp->igmp_ifstat_joins_sent = 0;
1732 pim_ifp->igmp_ifstat_joins_failed = 0;
3e5d8665 1733 pim_ifp->igmp_peak_group_count = 0;
d62a17ae 1734 }
39438188 1735
d62a17ae 1736 return CMD_SUCCESS;
39438188
CS
1737}
1738
09a754ea 1739DEFPY (clear_ip_pim_oil,
12e41d03 1740 clear_ip_pim_oil_cmd,
09a754ea 1741 "clear ip pim [vrf NAME]$name oil",
12e41d03
DL
1742 CLEAR_STR
1743 IP_STR
1744 CLEAR_IP_PIM_STR
c68ba0d7 1745 VRF_CMD_HELP_STR
12e41d03
DL
1746 "Rescan PIM OIL (output interface list)\n")
1747{
09a754ea 1748 struct vrf *v = pim_cmd_lookup(vty, name);
c68ba0d7 1749
09a754ea 1750 if (!v)
c68ba0d7
DS
1751 return CMD_WARNING;
1752
09a754ea 1753 pim_scan_oil(v->info);
12e41d03 1754
d62a17ae 1755 return CMD_SUCCESS;
12e41d03
DL
1756}
1757
e7016ceb 1758DEFUN (clear_ip_pim_bsr_db,
1759 clear_ip_pim_bsr_db_cmd,
1760 "clear ip pim [vrf NAME] bsr-data",
1761 CLEAR_STR
1762 IP_STR
1763 CLEAR_IP_PIM_STR
1764 VRF_CMD_HELP_STR
1765 "Reset pim bsr data\n")
1766{
1767 int idx = 2;
1768 struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
1769
1770 if (!vrf)
1771 return CMD_WARNING;
1772
b09bd804 1773 pim_bsm_clear(vrf->info);
e7016ceb 1774
1775 return CMD_SUCCESS;
1776}
1777
12e41d03
DL
1778DEFUN (show_ip_igmp_interface,
1779 show_ip_igmp_interface_cmd,
20a7e5fd 1780 "show ip igmp [vrf NAME] interface [detail|WORD] [json]",
12e41d03
DL
1781 SHOW_STR
1782 IP_STR
1783 IGMP_STR
c68ba0d7 1784 VRF_CMD_HELP_STR
a268493f 1785 "IGMP interface information\n"
9b91bb50 1786 "Detailed output\n"
a268493f 1787 "interface name\n"
f5da2cc2 1788 JSON_STR)
12e41d03 1789{
c68ba0d7
DS
1790 int idx = 2;
1791 struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
9f049418 1792 bool uj = use_json(argc, argv);
c68ba0d7
DS
1793
1794 if (!vrf)
1795 return CMD_WARNING;
72e81cf4 1796
d62a17ae 1797 if (argv_find(argv, argc, "detail", &idx)
1798 || argv_find(argv, argc, "WORD", &idx))
64c86530 1799 igmp_show_interfaces_single(vrf->info, vty, argv[idx]->arg, uj);
d62a17ae 1800 else
64c86530 1801 igmp_show_interfaces(vrf->info, vty, uj);
12e41d03 1802
d62a17ae 1803 return CMD_SUCCESS;
12e41d03
DL
1804}
1805
a25de56b
DS
1806DEFUN (show_ip_igmp_interface_vrf_all,
1807 show_ip_igmp_interface_vrf_all_cmd,
1808 "show ip igmp vrf all interface [detail|WORD] [json]",
1809 SHOW_STR
1810 IP_STR
1811 IGMP_STR
1812 VRF_CMD_HELP_STR
1813 "IGMP interface information\n"
1814 "Detailed output\n"
1815 "interface name\n"
f5da2cc2 1816 JSON_STR)
a25de56b
DS
1817{
1818 int idx = 2;
9f049418 1819 bool uj = use_json(argc, argv);
a25de56b
DS
1820 struct vrf *vrf;
1821 bool first = true;
1822
1823 if (uj)
1824 vty_out(vty, "{ ");
a2addae8 1825 RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
a25de56b
DS
1826 if (uj) {
1827 if (!first)
1828 vty_out(vty, ", ");
1829 vty_out(vty, " \"%s\": ", vrf->name);
1830 first = false;
1831 } else
1832 vty_out(vty, "VRF: %s\n", vrf->name);
1833 if (argv_find(argv, argc, "detail", &idx)
1834 || argv_find(argv, argc, "WORD", &idx))
1835 igmp_show_interfaces_single(vrf->info, vty,
1836 argv[idx]->arg, uj);
1837 else
1838 igmp_show_interfaces(vrf->info, vty, uj);
1839 }
1840 if (uj)
1841 vty_out(vty, "}\n");
1842
1843 return CMD_SUCCESS;
1844}
1845
12e41d03
DL
1846DEFUN (show_ip_igmp_join,
1847 show_ip_igmp_join_cmd,
85c82866 1848 "show ip igmp [vrf NAME] join [json]",
12e41d03
DL
1849 SHOW_STR
1850 IP_STR
1851 IGMP_STR
c68ba0d7 1852 VRF_CMD_HELP_STR
85c82866 1853 "IGMP static join information\n"
1854 JSON_STR)
12e41d03 1855{
c68ba0d7
DS
1856 int idx = 2;
1857 struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
85c82866 1858 bool uj = use_json(argc, argv);
c68ba0d7
DS
1859
1860 if (!vrf)
1861 return CMD_WARNING;
1862
85c82866 1863 igmp_show_interface_join(vrf->info, vty, uj);
12e41d03 1864
d62a17ae 1865 return CMD_SUCCESS;
12e41d03
DL
1866}
1867
a25de56b
DS
1868DEFUN (show_ip_igmp_join_vrf_all,
1869 show_ip_igmp_join_vrf_all_cmd,
85c82866 1870 "show ip igmp vrf all join [json]",
a25de56b
DS
1871 SHOW_STR
1872 IP_STR
1873 IGMP_STR
1874 VRF_CMD_HELP_STR
85c82866 1875 "IGMP static join information\n"
1876 JSON_STR)
a25de56b 1877{
9f049418 1878 bool uj = use_json(argc, argv);
a25de56b
DS
1879 struct vrf *vrf;
1880 bool first = true;
1881
1882 if (uj)
1883 vty_out(vty, "{ ");
a2addae8 1884 RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
a25de56b
DS
1885 if (uj) {
1886 if (!first)
1887 vty_out(vty, ", ");
1888 vty_out(vty, " \"%s\": ", vrf->name);
1889 first = false;
1890 } else
1891 vty_out(vty, "VRF: %s\n", vrf->name);
85c82866 1892 igmp_show_interface_join(vrf->info, vty, uj);
a25de56b
DS
1893 }
1894 if (uj)
1895 vty_out(vty, "}\n");
1896
1897 return CMD_SUCCESS;
1898}
1899
12e41d03
DL
1900DEFUN (show_ip_igmp_groups,
1901 show_ip_igmp_groups_cmd,
20a7e5fd 1902 "show ip igmp [vrf NAME] groups [json]",
12e41d03
DL
1903 SHOW_STR
1904 IP_STR
1905 IGMP_STR
c68ba0d7 1906 VRF_CMD_HELP_STR
9b91bb50 1907 IGMP_GROUP_STR
f5da2cc2 1908 JSON_STR)
12e41d03 1909{
c68ba0d7
DS
1910 int idx = 2;
1911 struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
9f049418 1912 bool uj = use_json(argc, argv);
c68ba0d7
DS
1913
1914 if (!vrf)
1915 return CMD_WARNING;
1916
64c86530 1917 igmp_show_groups(vrf->info, vty, uj);
12e41d03 1918
d62a17ae 1919 return CMD_SUCCESS;
12e41d03
DL
1920}
1921
a25de56b
DS
1922DEFUN (show_ip_igmp_groups_vrf_all,
1923 show_ip_igmp_groups_vrf_all_cmd,
1924 "show ip igmp vrf all groups [json]",
1925 SHOW_STR
1926 IP_STR
1927 IGMP_STR
1928 VRF_CMD_HELP_STR
1929 IGMP_GROUP_STR
f5da2cc2 1930 JSON_STR)
a25de56b 1931{
9f049418 1932 bool uj = use_json(argc, argv);
a25de56b
DS
1933 struct vrf *vrf;
1934 bool first = true;
1935
1936 if (uj)
1937 vty_out(vty, "{ ");
a2addae8 1938 RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
a25de56b
DS
1939 if (uj) {
1940 if (!first)
1941 vty_out(vty, ", ");
1942 vty_out(vty, " \"%s\": ", vrf->name);
1943 first = false;
1944 } else
1945 vty_out(vty, "VRF: %s\n", vrf->name);
1946 igmp_show_groups(vrf->info, vty, uj);
1947 }
1948 if (uj)
1949 vty_out(vty, "}\n");
1950
1951 return CMD_SUCCESS;
1952}
1953
12e41d03
DL
1954DEFUN (show_ip_igmp_groups_retransmissions,
1955 show_ip_igmp_groups_retransmissions_cmd,
20a7e5fd 1956 "show ip igmp [vrf NAME] groups retransmissions",
12e41d03
DL
1957 SHOW_STR
1958 IP_STR
1959 IGMP_STR
c68ba0d7 1960 VRF_CMD_HELP_STR
12e41d03
DL
1961 IGMP_GROUP_STR
1962 "IGMP group retransmissions\n")
1963{
c68ba0d7
DS
1964 int idx = 2;
1965 struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
1966
1967 if (!vrf)
1968 return CMD_WARNING;
1969
64c86530 1970 igmp_show_group_retransmission(vrf->info, vty);
12e41d03 1971
d62a17ae 1972 return CMD_SUCCESS;
12e41d03
DL
1973}
1974
12e41d03
DL
1975DEFUN (show_ip_igmp_sources,
1976 show_ip_igmp_sources_cmd,
4527b70a 1977 "show ip igmp [vrf NAME] sources [json]",
12e41d03
DL
1978 SHOW_STR
1979 IP_STR
1980 IGMP_STR
c68ba0d7 1981 VRF_CMD_HELP_STR
4527b70a
SG
1982 IGMP_SOURCE_STR
1983 JSON_STR)
12e41d03 1984{
c68ba0d7
DS
1985 int idx = 2;
1986 struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
1987
1988 if (!vrf)
1989 return CMD_WARNING;
1990
4527b70a 1991 igmp_show_sources(vrf->info, vty, use_json(argc, argv));
12e41d03 1992
d62a17ae 1993 return CMD_SUCCESS;
12e41d03
DL
1994}
1995
1996DEFUN (show_ip_igmp_sources_retransmissions,
1997 show_ip_igmp_sources_retransmissions_cmd,
20a7e5fd 1998 "show ip igmp [vrf NAME] sources retransmissions",
12e41d03
DL
1999 SHOW_STR
2000 IP_STR
2001 IGMP_STR
c68ba0d7 2002 VRF_CMD_HELP_STR
12e41d03
DL
2003 IGMP_SOURCE_STR
2004 "IGMP source retransmissions\n")
2005{
c68ba0d7
DS
2006 int idx = 2;
2007 struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
2008
2009 if (!vrf)
2010 return CMD_WARNING;
2011
64c86530 2012 igmp_show_source_retransmission(vrf->info, vty);
12e41d03 2013
d62a17ae 2014 return CMD_SUCCESS;
12e41d03
DL
2015}
2016
21313cbf
MS
2017DEFUN (show_ip_igmp_statistics,
2018 show_ip_igmp_statistics_cmd,
2019 "show ip igmp [vrf NAME] statistics [interface WORD] [json]",
2020 SHOW_STR
2021 IP_STR
2022 IGMP_STR
2023 VRF_CMD_HELP_STR
2024 "IGMP statistics\n"
2025 "interface\n"
2026 "IGMP interface\n"
2027 JSON_STR)
2028{
2029 int idx = 2;
2030 struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
9f049418 2031 bool uj = use_json(argc, argv);
21313cbf
MS
2032
2033 if (!vrf)
2034 return CMD_WARNING;
2035
2036 if (argv_find(argv, argc, "WORD", &idx))
2037 igmp_show_statistics(vrf->info, vty, argv[idx]->arg, uj);
2038 else
2039 igmp_show_statistics(vrf->info, vty, NULL, uj);
2040
2041 return CMD_SUCCESS;
2042}
2043
17823cdd
DS
2044DEFUN (show_ip_pim_mlag_summary,
2045 show_ip_pim_mlag_summary_cmd,
2046 "show ip pim mlag summary [json]",
2047 SHOW_STR
2048 IP_STR
2049 PIM_STR
2050 "MLAG\n"
2051 "status and stats\n"
2052 JSON_STR)
2053{
2054 bool uj = use_json(argc, argv);
2055 char role_buf[MLAG_ROLE_STRSIZE];
2056 char addr_buf[INET_ADDRSTRLEN];
2057
2058 if (uj) {
2059 json_object *json = NULL;
2060 json_object *json_stat = NULL;
2061
2062 json = json_object_new_object();
2063 if (router->mlag_flags & PIM_MLAGF_LOCAL_CONN_UP)
2064 json_object_boolean_true_add(json, "mlagConnUp");
2065 if (router->mlag_flags & PIM_MLAGF_PEER_CONN_UP)
2066 json_object_boolean_true_add(json, "mlagPeerConnUp");
2067 if (router->mlag_flags & PIM_MLAGF_PEER_ZEBRA_UP)
2068 json_object_boolean_true_add(json, "mlagPeerZebraUp");
2069 json_object_string_add(json, "mlagRole",
521c5b9d
MS
2070 mlag_role2str(router->mlag_role,
2071 role_buf, sizeof(role_buf)));
17823cdd 2072 inet_ntop(AF_INET, &router->local_vtep_ip,
521c5b9d 2073 addr_buf, INET_ADDRSTRLEN);
17823cdd
DS
2074 json_object_string_add(json, "localVtepIp", addr_buf);
2075 inet_ntop(AF_INET, &router->anycast_vtep_ip,
521c5b9d 2076 addr_buf, INET_ADDRSTRLEN);
17823cdd
DS
2077 json_object_string_add(json, "anycastVtepIp", addr_buf);
2078 json_object_string_add(json, "peerlinkRif",
521c5b9d 2079 router->peerlink_rif);
17823cdd
DS
2080
2081 json_stat = json_object_new_object();
2082 json_object_int_add(json_stat, "mlagConnFlaps",
521c5b9d 2083 router->mlag_stats.mlagd_session_downs);
17823cdd 2084 json_object_int_add(json_stat, "mlagPeerConnFlaps",
521c5b9d 2085 router->mlag_stats.peer_session_downs);
17823cdd 2086 json_object_int_add(json_stat, "mlagPeerZebraFlaps",
521c5b9d 2087 router->mlag_stats.peer_zebra_downs);
17823cdd 2088 json_object_int_add(json_stat, "mrouteAddRx",
521c5b9d 2089 router->mlag_stats.msg.mroute_add_rx);
17823cdd 2090 json_object_int_add(json_stat, "mrouteAddTx",
521c5b9d 2091 router->mlag_stats.msg.mroute_add_tx);
17823cdd 2092 json_object_int_add(json_stat, "mrouteDelRx",
521c5b9d 2093 router->mlag_stats.msg.mroute_del_rx);
17823cdd 2094 json_object_int_add(json_stat, "mrouteDelTx",
521c5b9d 2095 router->mlag_stats.msg.mroute_del_tx);
17823cdd 2096 json_object_int_add(json_stat, "mlagStatusUpdates",
521c5b9d 2097 router->mlag_stats.msg.mlag_status_updates);
17823cdd 2098 json_object_int_add(json_stat, "peerZebraStatusUpdates",
521c5b9d 2099 router->mlag_stats.msg.peer_zebra_status_updates);
17823cdd 2100 json_object_int_add(json_stat, "pimStatusUpdates",
521c5b9d 2101 router->mlag_stats.msg.pim_status_updates);
17823cdd 2102 json_object_int_add(json_stat, "vxlanUpdates",
521c5b9d 2103 router->mlag_stats.msg.vxlan_updates);
17823cdd
DS
2104 json_object_object_add(json, "connStats", json_stat);
2105
3757f964 2106 vty_json(vty, json);
17823cdd
DS
2107 return CMD_SUCCESS;
2108 }
2109
2110 vty_out(vty, "MLAG daemon connection: %s\n",
2111 (router->mlag_flags & PIM_MLAGF_LOCAL_CONN_UP)
521c5b9d 2112 ? "up" : "down");
17823cdd
DS
2113 vty_out(vty, "MLAG peer state: %s\n",
2114 (router->mlag_flags & PIM_MLAGF_PEER_CONN_UP)
521c5b9d 2115 ? "up" : "down");
17823cdd
DS
2116 vty_out(vty, "Zebra peer state: %s\n",
2117 (router->mlag_flags & PIM_MLAGF_PEER_ZEBRA_UP)
521c5b9d 2118 ? "up" : "down");
17823cdd
DS
2119 vty_out(vty, "MLAG role: %s\n",
2120 mlag_role2str(router->mlag_role, role_buf, sizeof(role_buf)));
2121 inet_ntop(AF_INET, &router->local_vtep_ip,
521c5b9d 2122 addr_buf, INET_ADDRSTRLEN);
17823cdd
DS
2123 vty_out(vty, "Local VTEP IP: %s\n", addr_buf);
2124 inet_ntop(AF_INET, &router->anycast_vtep_ip,
521c5b9d 2125 addr_buf, INET_ADDRSTRLEN);
17823cdd
DS
2126 vty_out(vty, "Anycast VTEP IP: %s\n", addr_buf);
2127 vty_out(vty, "Peerlink: %s\n", router->peerlink_rif);
2128 vty_out(vty, "Session flaps: mlagd: %d mlag-peer: %d zebra-peer: %d\n",
521c5b9d
MS
2129 router->mlag_stats.mlagd_session_downs,
2130 router->mlag_stats.peer_session_downs,
2131 router->mlag_stats.peer_zebra_downs);
17823cdd
DS
2132 vty_out(vty, "Message Statistics:\n");
2133 vty_out(vty, " mroute adds: rx: %d, tx: %d\n",
521c5b9d
MS
2134 router->mlag_stats.msg.mroute_add_rx,
2135 router->mlag_stats.msg.mroute_add_tx);
17823cdd 2136 vty_out(vty, " mroute dels: rx: %d, tx: %d\n",
521c5b9d
MS
2137 router->mlag_stats.msg.mroute_del_rx,
2138 router->mlag_stats.msg.mroute_del_tx);
17823cdd 2139 vty_out(vty, " peer zebra status updates: %d\n",
521c5b9d 2140 router->mlag_stats.msg.peer_zebra_status_updates);
17823cdd 2141 vty_out(vty, " PIM status updates: %d\n",
521c5b9d 2142 router->mlag_stats.msg.pim_status_updates);
17823cdd 2143 vty_out(vty, " VxLAN updates: %d\n",
521c5b9d 2144 router->mlag_stats.msg.vxlan_updates);
17823cdd
DS
2145
2146 return CMD_SUCCESS;
2147}
2148
12e41d03
DL
2149DEFUN (show_ip_pim_assert,
2150 show_ip_pim_assert_cmd,
20a7e5fd 2151 "show ip pim [vrf NAME] assert",
12e41d03
DL
2152 SHOW_STR
2153 IP_STR
2154 PIM_STR
c68ba0d7 2155 VRF_CMD_HELP_STR
12e41d03
DL
2156 "PIM interface assert\n")
2157{
c68ba0d7
DS
2158 int idx = 2;
2159 struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
2160
2161 if (!vrf)
2162 return CMD_WARNING;
2163
64c86530 2164 pim_show_assert(vrf->info, vty);
12e41d03 2165
d62a17ae 2166 return CMD_SUCCESS;
12e41d03
DL
2167}
2168
2169DEFUN (show_ip_pim_assert_internal,
2170 show_ip_pim_assert_internal_cmd,
20a7e5fd 2171 "show ip pim [vrf NAME] assert-internal",
12e41d03
DL
2172 SHOW_STR
2173 IP_STR
2174 PIM_STR
c68ba0d7 2175 VRF_CMD_HELP_STR
12e41d03
DL
2176 "PIM interface internal assert state\n")
2177{
c68ba0d7
DS
2178 int idx = 2;
2179 struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
2180
2181 if (!vrf)
2182 return CMD_WARNING;
2183
64c86530 2184 pim_show_assert_internal(vrf->info, vty);
12e41d03 2185
d62a17ae 2186 return CMD_SUCCESS;
12e41d03
DL
2187}
2188
2189DEFUN (show_ip_pim_assert_metric,
2190 show_ip_pim_assert_metric_cmd,
20a7e5fd 2191 "show ip pim [vrf NAME] assert-metric",
12e41d03
DL
2192 SHOW_STR
2193 IP_STR
2194 PIM_STR
c68ba0d7 2195 VRF_CMD_HELP_STR
12e41d03
DL
2196 "PIM interface assert metric\n")
2197{
c68ba0d7
DS
2198 int idx = 2;
2199 struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
2200
2201 if (!vrf)
2202 return CMD_WARNING;
2203
64c86530 2204 pim_show_assert_metric(vrf->info, vty);
12e41d03 2205
d62a17ae 2206 return CMD_SUCCESS;
12e41d03
DL
2207}
2208
2209DEFUN (show_ip_pim_assert_winner_metric,
2210 show_ip_pim_assert_winner_metric_cmd,
20a7e5fd 2211 "show ip pim [vrf NAME] assert-winner-metric",
12e41d03
DL
2212 SHOW_STR
2213 IP_STR
2214 PIM_STR
c68ba0d7 2215 VRF_CMD_HELP_STR
12e41d03
DL
2216 "PIM interface assert winner metric\n")
2217{
c68ba0d7
DS
2218 int idx = 2;
2219 struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
2220
2221 if (!vrf)
2222 return CMD_WARNING;
2223
64c86530 2224 pim_show_assert_winner_metric(vrf->info, vty);
12e41d03 2225
d62a17ae 2226 return CMD_SUCCESS;
12e41d03
DL
2227}
2228
44f99d22 2229DEFPY (show_ip_pim_interface,
12e41d03 2230 show_ip_pim_interface_cmd,
44f99d22 2231 "show ip pim [mlag$mlag] [vrf NAME] interface [detail|WORD]$interface [json$json]",
12e41d03
DL
2232 SHOW_STR
2233 IP_STR
2234 PIM_STR
17823cdd 2235 "MLAG\n"
c68ba0d7 2236 VRF_CMD_HELP_STR
a268493f 2237 "PIM interface information\n"
9b91bb50 2238 "Detailed output\n"
a268493f 2239 "interface name\n"
f5da2cc2 2240 JSON_STR)
12e41d03 2241{
8282b988
SG
2242 return pim_show_interface_cmd_helper(vrf, vty, !!json, !!mlag,
2243 interface);
12e41d03
DL
2244}
2245
44f99d22 2246DEFPY (show_ip_pim_interface_vrf_all,
a25de56b 2247 show_ip_pim_interface_vrf_all_cmd,
44f99d22 2248 "show ip pim [mlag$mlag] vrf all interface [detail|WORD]$interface [json$json]",
a25de56b
DS
2249 SHOW_STR
2250 IP_STR
2251 PIM_STR
17823cdd 2252 "MLAG\n"
a25de56b
DS
2253 VRF_CMD_HELP_STR
2254 "PIM interface information\n"
2255 "Detailed output\n"
2256 "interface name\n"
f5da2cc2 2257 JSON_STR)
a25de56b 2258{
342ba5f3
SG
2259 return pim_show_interface_vrf_all_cmd_helper(vty, !!json, !!mlag,
2260 interface);
a25de56b
DS
2261}
2262
6de45bcc 2263DEFPY (show_ip_pim_join,
12e41d03 2264 show_ip_pim_join_cmd,
6de45bcc 2265 "show ip pim [vrf NAME] join [A.B.C.D$s_or_g [A.B.C.D$g]] [json$json]",
12e41d03
DL
2266 SHOW_STR
2267 IP_STR
2268 PIM_STR
c68ba0d7 2269 VRF_CMD_HELP_STR
a957a05b 2270 "PIM interface join information\n"
6de45bcc
DS
2271 "The Source or Group\n"
2272 "The Group\n"
a957a05b 2273 JSON_STR)
12e41d03 2274{
94c691ba 2275 return pim_show_join_cmd_helper(vrf, vty, s_or_g, g, json);
12e41d03
DL
2276}
2277
24de75a2 2278DEFPY (show_ip_pim_join_vrf_all,
a25de56b 2279 show_ip_pim_join_vrf_all_cmd,
24de75a2 2280 "show ip pim vrf all join [json$json]",
a25de56b
DS
2281 SHOW_STR
2282 IP_STR
2283 PIM_STR
2284 VRF_CMD_HELP_STR
2285 "PIM interface join information\n"
2286 JSON_STR)
2287{
94c691ba 2288 return pim_show_join_vrf_all_cmd_helper(vty, json);
a25de56b
DS
2289}
2290
87b7cd5b
AK
2291DEFPY (show_ip_pim_jp_agg,
2292 show_ip_pim_jp_agg_cmd,
2293 "show ip pim [vrf NAME] jp-agg",
2294 SHOW_STR
2295 IP_STR
2296 PIM_STR
2297 VRF_CMD_HELP_STR
2298 "join prune aggregation list\n")
2299{
3ca40823 2300 return pim_show_jp_agg_list_cmd_helper(vrf, vty);
87b7cd5b
AK
2301}
2302
de11054e 2303DEFPY (show_ip_pim_local_membership,
12e41d03 2304 show_ip_pim_local_membership_cmd,
de11054e 2305 "show ip pim [vrf NAME] local-membership [json$json]",
12e41d03
DL
2306 SHOW_STR
2307 IP_STR
2308 PIM_STR
c68ba0d7 2309 VRF_CMD_HELP_STR
a957a05b
DS
2310 "PIM interface local-membership\n"
2311 JSON_STR)
12e41d03 2312{
bec5bdbe 2313 return pim_show_membership_cmd_helper(vrf, vty, !!json);
12e41d03
DL
2314}
2315
f80427e9 2316static void pim_show_mlag_up_entry_detail(struct vrf *vrf,
521c5b9d
MS
2317 struct vty *vty,
2318 struct pim_upstream *up,
2319 char *src_str, char *grp_str,
2320 json_object *json)
f80427e9
AK
2321{
2322 if (json) {
2323 json_object *json_row = NULL;
2324 json_object *own_list = NULL;
2325 json_object *json_group = NULL;
2326
2327
2328 json_object_object_get_ex(json, grp_str, &json_group);
2329 if (!json_group) {
2330 json_group = json_object_new_object();
2331 json_object_object_add(json, grp_str,
521c5b9d 2332 json_group);
f80427e9
AK
2333 }
2334
2335 json_row = json_object_new_object();
2336 json_object_string_add(json_row, "source", src_str);
2337 json_object_string_add(json_row, "group", grp_str);
2338
2339 own_list = json_object_new_array();
2340 if (pim_up_mlag_is_local(up))
2341 json_object_array_add(own_list,
521c5b9d 2342 json_object_new_string("local"));
f80427e9
AK
2343 if (up->flags & (PIM_UPSTREAM_FLAG_MASK_MLAG_PEER))
2344 json_object_array_add(own_list,
521c5b9d 2345 json_object_new_string("peer"));
f80427e9
AK
2346 if (up->flags & (PIM_UPSTREAM_FLAG_MASK_MLAG_INTERFACE))
2347 json_object_array_add(
2348 own_list, json_object_new_string("Interface"));
2349 json_object_object_add(json_row, "owners", own_list);
2350
2351 json_object_int_add(json_row, "localCost",
521c5b9d 2352 pim_up_mlag_local_cost(up));
f80427e9 2353 json_object_int_add(json_row, "peerCost",
521c5b9d 2354 pim_up_mlag_peer_cost(up));
f80427e9
AK
2355 if (PIM_UPSTREAM_FLAG_TEST_MLAG_NON_DF(up->flags))
2356 json_object_boolean_false_add(json_row, "df");
2357 else
2358 json_object_boolean_true_add(json_row, "df");
2359 json_object_object_add(json_group, src_str, json_row);
2360 } else {
2361 char own_str[6];
2362
2363 own_str[0] = '\0';
2364 if (pim_up_mlag_is_local(up))
6c1b7a8c 2365 strlcat(own_str, "L", sizeof(own_str));
f80427e9 2366 if (up->flags & (PIM_UPSTREAM_FLAG_MASK_MLAG_PEER))
6c1b7a8c 2367 strlcat(own_str, "P", sizeof(own_str));
f80427e9 2368 if (up->flags & (PIM_UPSTREAM_FLAG_MASK_MLAG_INTERFACE))
6c1b7a8c 2369 strlcat(own_str, "I", sizeof(own_str));
f80427e9
AK
2370 /* XXX - fixup, print paragraph output */
2371 vty_out(vty,
521c5b9d
MS
2372 "%-15s %-15s %-6s %-11u %-10d %2s\n",
2373 src_str, grp_str, own_str,
2374 pim_up_mlag_local_cost(up),
2375 pim_up_mlag_peer_cost(up),
2376 PIM_UPSTREAM_FLAG_TEST_MLAG_NON_DF(up->flags)
2377 ? "n" : "y");
f80427e9
AK
2378 }
2379}
2380
2381static void pim_show_mlag_up_detail(struct vrf *vrf,
521c5b9d
MS
2382 struct vty *vty, const char *src_or_group,
2383 const char *group, bool uj)
f80427e9 2384{
8e8be741
DL
2385 char src_str[PIM_ADDRSTRLEN];
2386 char grp_str[PIM_ADDRSTRLEN];
f80427e9
AK
2387 struct pim_upstream *up;
2388 struct pim_instance *pim = vrf->info;
2389 json_object *json = NULL;
2390
2391 if (uj)
2392 json = json_object_new_object();
2393 else
2394 vty_out(vty,
2395 "Source Group Owner Local-cost Peer-cost DF\n");
2396
2397 frr_each (rb_pim_upstream, &pim->upstream_head, up) {
2398 if (!(up->flags & PIM_UPSTREAM_FLAG_MASK_MLAG_PEER)
2399 && !(up->flags & PIM_UPSTREAM_FLAG_MASK_MLAG_INTERFACE)
2400 && !pim_up_mlag_is_local(up))
2401 continue;
2402
8e8be741
DL
2403 snprintfrr(grp_str, sizeof(grp_str), "%pPAs", &up->sg.grp);
2404 snprintfrr(src_str, sizeof(src_str), "%pPAs", &up->sg.src);
2405
f80427e9
AK
2406 /* XXX: strcmps are clearly inefficient. we should do uint comps
2407 * here instead.
2408 */
2409 if (group) {
2410 if (strcmp(src_str, src_or_group) ||
6c1b7a8c 2411 strcmp(grp_str, group))
f80427e9
AK
2412 continue;
2413 } else {
2414 if (strcmp(src_str, src_or_group) &&
6c1b7a8c 2415 strcmp(grp_str, src_or_group))
f80427e9
AK
2416 continue;
2417 }
2418 pim_show_mlag_up_entry_detail(vrf, vty, up,
6c1b7a8c 2419 src_str, grp_str, json);
f80427e9
AK
2420 }
2421
3757f964
DA
2422 if (uj)
2423 vty_json(vty, json);
f80427e9
AK
2424}
2425
2426static void pim_show_mlag_up_vrf(struct vrf *vrf, struct vty *vty, bool uj)
2427{
2428 json_object *json = NULL;
2429 json_object *json_row;
2430 struct pim_upstream *up;
f80427e9
AK
2431 struct pim_instance *pim = vrf->info;
2432 json_object *json_group = NULL;
2433
2434 if (uj) {
2435 json = json_object_new_object();
2436 } else {
2437 vty_out(vty,
2438 "Source Group Owner Local-cost Peer-cost DF\n");
2439 }
2440
2441 frr_each (rb_pim_upstream, &pim->upstream_head, up) {
2442 if (!(up->flags & PIM_UPSTREAM_FLAG_MASK_MLAG_PEER)
2443 && !(up->flags & PIM_UPSTREAM_FLAG_MASK_MLAG_INTERFACE)
2444 && !pim_up_mlag_is_local(up))
2445 continue;
f80427e9 2446 if (uj) {
8e8be741
DL
2447 char src_str[PIM_ADDRSTRLEN];
2448 char grp_str[PIM_ADDRSTRLEN];
f80427e9
AK
2449 json_object *own_list = NULL;
2450
8e8be741
DL
2451 snprintfrr(grp_str, sizeof(grp_str), "%pPAs",
2452 &up->sg.grp);
2453 snprintfrr(src_str, sizeof(src_str), "%pPAs",
2454 &up->sg.src);
2455
f80427e9
AK
2456 json_object_object_get_ex(json, grp_str, &json_group);
2457 if (!json_group) {
2458 json_group = json_object_new_object();
2459 json_object_object_add(json, grp_str,
521c5b9d 2460 json_group);
f80427e9
AK
2461 }
2462
2463 json_row = json_object_new_object();
2464 json_object_string_add(json_row, "vrf", vrf->name);
2465 json_object_string_add(json_row, "source", src_str);
2466 json_object_string_add(json_row, "group", grp_str);
2467
2468 own_list = json_object_new_array();
2469 if (pim_up_mlag_is_local(up)) {
2470
2471 json_object_array_add(own_list,
521c5b9d
MS
2472 json_object_new_string(
2473 "local"));
f80427e9
AK
2474 }
2475 if (up->flags & (PIM_UPSTREAM_FLAG_MASK_MLAG_PEER)) {
2476 json_object_array_add(own_list,
521c5b9d
MS
2477 json_object_new_string(
2478 "peer"));
f80427e9
AK
2479 }
2480 json_object_object_add(json_row, "owners", own_list);
2481
2482 json_object_int_add(json_row, "localCost",
521c5b9d 2483 pim_up_mlag_local_cost(up));
f80427e9 2484 json_object_int_add(json_row, "peerCost",
521c5b9d 2485 pim_up_mlag_peer_cost(up));
f80427e9
AK
2486 if (PIM_UPSTREAM_FLAG_TEST_MLAG_NON_DF(up->flags))
2487 json_object_boolean_false_add(json_row, "df");
2488 else
2489 json_object_boolean_true_add(json_row, "df");
2490 json_object_object_add(json_group, src_str, json_row);
2491 } else {
2492 char own_str[6];
2493
2494 own_str[0] = '\0';
2495 if (pim_up_mlag_is_local(up))
6c1b7a8c 2496 strlcat(own_str, "L", sizeof(own_str));
f80427e9 2497 if (up->flags & (PIM_UPSTREAM_FLAG_MASK_MLAG_PEER))
6c1b7a8c 2498 strlcat(own_str, "P", sizeof(own_str));
f80427e9 2499 if (up->flags & (PIM_UPSTREAM_FLAG_MASK_MLAG_INTERFACE))
6c1b7a8c 2500 strlcat(own_str, "I", sizeof(own_str));
f80427e9 2501 vty_out(vty,
8e8be741
DL
2502 "%-15pPAs %-15pPAs %-6s %-11u %-10u %2s\n",
2503 &up->sg.src, &up->sg.grp, own_str,
f80427e9
AK
2504 pim_up_mlag_local_cost(up),
2505 pim_up_mlag_peer_cost(up),
2506 PIM_UPSTREAM_FLAG_TEST_MLAG_NON_DF(up->flags)
521c5b9d 2507 ? "n" : "y");
f80427e9
AK
2508 }
2509 }
3757f964
DA
2510 if (uj)
2511 vty_json(vty, json);
f80427e9
AK
2512}
2513
2514static void pim_show_mlag_help_string(struct vty *vty, bool uj)
2515{
2516 if (!uj) {
2517 vty_out(vty, "Owner codes:\n");
2518 vty_out(vty,
3efd0893 2519 "L: EVPN-MLAG Entry, I:PIM-MLAG Entry, P: Peer Entry\n");
f80427e9
AK
2520 }
2521}
2522
2523
2524DEFUN(show_ip_pim_mlag_up, show_ip_pim_mlag_up_cmd,
2525 "show ip pim [vrf NAME] mlag upstream [A.B.C.D [A.B.C.D]] [json]",
2526 SHOW_STR
2527 IP_STR
2528 PIM_STR
2529 VRF_CMD_HELP_STR
2530 "MLAG\n"
2531 "upstream\n"
2532 "Unicast or Multicast address\n"
2533 "Multicast address\n" JSON_STR)
2534{
2535 const char *src_or_group = NULL;
2536 const char *group = NULL;
2537 int idx = 2;
2538 struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
2539 bool uj = use_json(argc, argv);
2540
2541 if (!vrf || !vrf->info) {
2542 vty_out(vty, "%s: VRF or Info missing\n", __func__);
2543 return CMD_WARNING;
2544 }
2545
2546 if (uj)
2547 argc--;
2548
2549 if (argv_find(argv, argc, "A.B.C.D", &idx)) {
2550 src_or_group = argv[idx]->arg;
2551 if (idx + 1 < argc)
2552 group = argv[idx + 1]->arg;
2553 }
2554
2555 pim_show_mlag_help_string(vty, uj);
2556
6c1b7a8c 2557 if (src_or_group)
f80427e9
AK
2558 pim_show_mlag_up_detail(vrf, vty, src_or_group, group, uj);
2559 else
2560 pim_show_mlag_up_vrf(vrf, vty, uj);
2561
2562 return CMD_SUCCESS;
2563}
2564
2565
2566DEFUN(show_ip_pim_mlag_up_vrf_all, show_ip_pim_mlag_up_vrf_all_cmd,
2567 "show ip pim vrf all mlag upstream [json]",
2568 SHOW_STR IP_STR PIM_STR VRF_CMD_HELP_STR
2569 "MLAG\n"
2570 "upstream\n" JSON_STR)
2571{
2572 struct vrf *vrf;
2573 bool uj = use_json(argc, argv);
2574
2575 pim_show_mlag_help_string(vty, uj);
2576 RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
2577 pim_show_mlag_up_vrf(vrf, vty, uj);
2578 }
2579
2580 return CMD_SUCCESS;
2581}
2582
1295dbeb 2583DEFPY (show_ip_pim_neighbor,
12e41d03 2584 show_ip_pim_neighbor_cmd,
1295dbeb 2585 "show ip pim [vrf NAME] neighbor [detail|WORD]$interface [json$json]",
12e41d03
DL
2586 SHOW_STR
2587 IP_STR
2588 PIM_STR
c68ba0d7 2589 VRF_CMD_HELP_STR
a268493f 2590 "PIM neighbor information\n"
9b91bb50 2591 "Detailed output\n"
a268493f 2592 "Name of interface or neighbor\n"
f5da2cc2 2593 JSON_STR)
12e41d03 2594{
154aa4fc 2595 return pim_show_neighbors_cmd_helper(vrf, vty, json, interface);
12e41d03
DL
2596}
2597
1295dbeb 2598DEFPY (show_ip_pim_neighbor_vrf_all,
a25de56b 2599 show_ip_pim_neighbor_vrf_all_cmd,
1295dbeb 2600 "show ip pim vrf all neighbor [detail|WORD]$interface [json$json]",
a25de56b
DS
2601 SHOW_STR
2602 IP_STR
2603 PIM_STR
2604 VRF_CMD_HELP_STR
2605 "PIM neighbor information\n"
2606 "Detailed output\n"
2607 "Name of interface or neighbor\n"
f5da2cc2 2608 JSON_STR)
a25de56b 2609{
78b0e690 2610 return pim_show_neighbors_vrf_all_cmd_helper(vty, json, interface);
a25de56b
DS
2611}
2612
626dab7f 2613DEFPY (show_ip_pim_secondary,
12e41d03 2614 show_ip_pim_secondary_cmd,
20a7e5fd 2615 "show ip pim [vrf NAME] secondary",
12e41d03
DL
2616 SHOW_STR
2617 IP_STR
2618 PIM_STR
c68ba0d7 2619 VRF_CMD_HELP_STR
12e41d03
DL
2620 "PIM neighbor addresses\n")
2621{
5e52c8d5 2622 return pim_show_secondary_helper(vrf, vty);
12e41d03
DL
2623}
2624
2d85c671 2625DEFPY (show_ip_pim_state,
31a21c9c 2626 show_ip_pim_state_cmd,
2d85c671 2627 "show ip pim [vrf NAME] state [A.B.C.D$s_or_g [A.B.C.D$g]] [json$json]",
31a21c9c
DW
2628 SHOW_STR
2629 IP_STR
2630 PIM_STR
c68ba0d7 2631 VRF_CMD_HELP_STR
31a21c9c
DW
2632 "PIM state information\n"
2633 "Unicast or Multicast address\n"
2634 "Multicast address\n"
f5da2cc2 2635 JSON_STR)
31a21c9c 2636{
e7c01c67 2637 return pim_show_state_helper(vrf, vty, s_or_g_str, g_str, !!json);
31a21c9c
DW
2638}
2639
2d85c671 2640DEFPY (show_ip_pim_state_vrf_all,
a25de56b 2641 show_ip_pim_state_vrf_all_cmd,
2d85c671 2642 "show ip pim vrf all state [A.B.C.D$s_or_g [A.B.C.D$g]] [json$json]",
a25de56b
DS
2643 SHOW_STR
2644 IP_STR
2645 PIM_STR
2646 VRF_CMD_HELP_STR
2647 "PIM state information\n"
2648 "Unicast or Multicast address\n"
2649 "Multicast address\n"
f5da2cc2 2650 JSON_STR)
a25de56b 2651{
e7c01c67 2652 return pim_show_state_vrf_all_helper(vty, s_or_g_str, g_str, !!json);
a25de56b
DS
2653}
2654
dff5cedb 2655DEFPY (show_ip_pim_upstream,
12e41d03 2656 show_ip_pim_upstream_cmd,
dff5cedb 2657 "show ip pim [vrf NAME] upstream [A.B.C.D$s_or_g [A.B.C.D$g]] [json$json]",
12e41d03
DL
2658 SHOW_STR
2659 IP_STR
2660 PIM_STR
c68ba0d7 2661 VRF_CMD_HELP_STR
a268493f 2662 "PIM upstream information\n"
dff5cedb
DS
2663 "The Source or Group\n"
2664 "The Group\n"
f5da2cc2 2665 JSON_STR)
12e41d03 2666{
9aa0569d 2667 return pim_show_upstream_helper(vrf, vty, s_or_g, g, !!json);
12e41d03
DL
2668}
2669
95023bd7 2670DEFPY (show_ip_pim_upstream_vrf_all,
a25de56b 2671 show_ip_pim_upstream_vrf_all_cmd,
95023bd7 2672 "show ip pim vrf all upstream [json$json]",
a25de56b
DS
2673 SHOW_STR
2674 IP_STR
2675 PIM_STR
2676 VRF_CMD_HELP_STR
2677 "PIM upstream information\n"
2678 JSON_STR)
2679{
9aa0569d 2680 return pim_show_upstream_vrf_all_helper(vty, !!json);
a25de56b
DS
2681}
2682
bf083b3a 2683DEFPY (show_ip_pim_channel,
5c9a72ef 2684 show_ip_pim_channel_cmd,
bf083b3a 2685 "show ip pim [vrf NAME] channel [json$json]",
12e41d03
DL
2686 SHOW_STR
2687 IP_STR
2688 PIM_STR
c68ba0d7 2689 VRF_CMD_HELP_STR
5c9a72ef 2690 "PIM downstream channel info\n"
f5da2cc2 2691 JSON_STR)
12e41d03 2692{
b6bf3377 2693 return pim_show_channel_cmd_helper(vrf, vty, !!json);
12e41d03
DL
2694}
2695
e577f6e7 2696DEFPY (show_ip_pim_upstream_join_desired,
12e41d03 2697 show_ip_pim_upstream_join_desired_cmd,
e577f6e7 2698 "show ip pim [vrf NAME] upstream-join-desired [json$json]",
12e41d03
DL
2699 SHOW_STR
2700 IP_STR
2701 PIM_STR
c68ba0d7 2702 VRF_CMD_HELP_STR
a268493f 2703 "PIM upstream join-desired\n"
f5da2cc2 2704 JSON_STR)
12e41d03 2705{
622da92f 2706 return pim_show_upstream_join_desired_helper(vrf, vty, !!json);
12e41d03
DL
2707}
2708
b1a419ba 2709DEFPY (show_ip_pim_upstream_rpf,
12e41d03 2710 show_ip_pim_upstream_rpf_cmd,
b1a419ba 2711 "show ip pim [vrf NAME] upstream-rpf [json$json]",
12e41d03
DL
2712 SHOW_STR
2713 IP_STR
2714 PIM_STR
c68ba0d7 2715 VRF_CMD_HELP_STR
a268493f 2716 "PIM upstream source rpf\n"
f5da2cc2 2717 JSON_STR)
12e41d03 2718{
c6309708 2719 return pim_show_upstream_rpf_helper(vrf, vty, !!json);
12e41d03
DL
2720}
2721
0095f482 2722DEFPY (show_ip_pim_rp,
00d07c6f 2723 show_ip_pim_rp_cmd,
0095f482 2724 "show ip pim [vrf NAME] rp-info [A.B.C.D/M$group] [json$json]",
00d07c6f
DS
2725 SHOW_STR
2726 IP_STR
2727 PIM_STR
c68ba0d7 2728 VRF_CMD_HELP_STR
a268493f 2729 "PIM RP information\n"
8c0a7680 2730 "Multicast Group range\n"
f5da2cc2 2731 JSON_STR)
00d07c6f 2732{
e21c4e90
A
2733 return pim_show_rp_helper(vrf, vty, group_str, (struct prefix *)group,
2734 !!json);
00d07c6f
DS
2735}
2736
0095f482 2737DEFPY (show_ip_pim_rp_vrf_all,
a25de56b 2738 show_ip_pim_rp_vrf_all_cmd,
0095f482 2739 "show ip pim vrf all rp-info [A.B.C.D/M$group] [json$json]",
a25de56b
DS
2740 SHOW_STR
2741 IP_STR
2742 PIM_STR
2743 VRF_CMD_HELP_STR
2744 "PIM RP information\n"
8c0a7680 2745 "Multicast Group range\n"
f5da2cc2 2746 JSON_STR)
a25de56b 2747{
e21c4e90
A
2748 return pim_show_rp_vrf_all_helper(vty, group_str,
2749 (struct prefix *)group, !!json);
a25de56b
DS
2750}
2751
1aa8de46 2752DEFPY (show_ip_pim_rpf,
12e41d03 2753 show_ip_pim_rpf_cmd,
1aa8de46 2754 "show ip pim [vrf NAME] rpf [json$json]",
12e41d03
DL
2755 SHOW_STR
2756 IP_STR
2757 PIM_STR
c68ba0d7 2758 VRF_CMD_HELP_STR
a268493f 2759 "PIM cached source rpf information\n"
f5da2cc2 2760 JSON_STR)
12e41d03 2761{
6d1bd8c2 2762 return pim_show_rpf_helper(vrf, vty, !!json);
12e41d03
DL
2763}
2764
1aa8de46 2765DEFPY (show_ip_pim_rpf_vrf_all,
a25de56b 2766 show_ip_pim_rpf_vrf_all_cmd,
1aa8de46 2767 "show ip pim vrf all rpf [json$json]",
a25de56b
DS
2768 SHOW_STR
2769 IP_STR
2770 PIM_STR
2771 VRF_CMD_HELP_STR
2772 "PIM cached source rpf information\n"
f5da2cc2 2773 JSON_STR)
a25de56b 2774{
6d1bd8c2 2775 return pim_show_rpf_vrf_all_helper(vty, !!json);
a25de56b
DS
2776}
2777
9d6d0270 2778DEFPY (show_ip_pim_nexthop,
cba44481 2779 show_ip_pim_nexthop_cmd,
573a01ba 2780 "show ip pim [vrf NAME] nexthop [json$json]",
cba44481
CS
2781 SHOW_STR
2782 IP_STR
2783 PIM_STR
c68ba0d7 2784 VRF_CMD_HELP_STR
573a01ba 2785 "PIM cached nexthop rpf information\n"
2786 JSON_STR)
cba44481 2787{
fc19632f 2788 return pim_show_nexthop_cmd_helper(vrf, vty, !!json);
cba44481
CS
2789}
2790
9d6d0270 2791DEFPY (show_ip_pim_nexthop_lookup,
cba44481 2792 show_ip_pim_nexthop_lookup_cmd,
9d6d0270 2793 "show ip pim [vrf NAME] nexthop-lookup A.B.C.D$source A.B.C.D$group",
cba44481
CS
2794 SHOW_STR
2795 IP_STR
2796 PIM_STR
c68ba0d7 2797 VRF_CMD_HELP_STR
cba44481
CS
2798 "PIM cached nexthop rpf lookup\n"
2799 "Source/RP address\n"
2800 "Multicast Group address\n")
2801{
fe7eaf40 2802 return pim_show_nexthop_lookup_cmd_helper(vrf, vty, source, group);
cba44481
CS
2803}
2804
52770b79 2805DEFPY (show_ip_pim_interface_traffic,
39438188 2806 show_ip_pim_interface_traffic_cmd,
52770b79 2807 "show ip pim [vrf NAME] interface traffic [WORD$if_name] [json$json]",
39438188
CS
2808 SHOW_STR
2809 IP_STR
2810 PIM_STR
c68ba0d7 2811 VRF_CMD_HELP_STR
39438188
CS
2812 "PIM interface information\n"
2813 "Protocol Packet counters\n"
17d86e50 2814 "Interface name\n"
f5da2cc2 2815 JSON_STR)
39438188 2816{
52770b79 2817 return pim_show_interface_traffic_helper(vrf, if_name, vty, !!json);
39438188
CS
2818}
2819
0d1a4e24 2820DEFUN (show_ip_pim_bsm_db,
2821 show_ip_pim_bsm_db_cmd,
2822 "show ip pim bsm-database [vrf NAME] [json]",
2823 SHOW_STR
2824 IP_STR
2825 PIM_STR
0d1a4e24 2826 "PIM cached bsm packets information\n"
33b58e53 2827 VRF_CMD_HELP_STR
0d1a4e24 2828 JSON_STR)
2829{
2830 int idx = 2;
2831 struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
2832 bool uj = use_json(argc, argv);
2833
2834 if (!vrf)
2835 return CMD_WARNING;
2836
2837 pim_show_bsm_db(vrf->info, vty, uj);
2838 return CMD_SUCCESS;
2839}
321295c1 2840
2841DEFUN (show_ip_pim_bsrp,
2842 show_ip_pim_bsrp_cmd,
2843 "show ip pim bsrp-info [vrf NAME] [json]",
2844 SHOW_STR
2845 IP_STR
2846 PIM_STR
321295c1 2847 "PIM cached group-rp mappings information\n"
33b58e53 2848 VRF_CMD_HELP_STR
321295c1 2849 JSON_STR)
2850{
2851 int idx = 2;
2852 struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
2853 bool uj = use_json(argc, argv);
2854
2855 if (!vrf)
2856 return CMD_WARNING;
2857
2858 pim_show_group_rp_mappings_info(vrf->info, vty, uj);
2859
2860 return CMD_SUCCESS;
2861}
2862
4f58b6aa 2863DEFPY (show_ip_pim_statistics,
415f6350 2864 show_ip_pim_statistics_cmd,
4f58b6aa 2865 "show ip pim [vrf NAME] statistics [interface WORD$word] [json$json]",
415f6350 2866 SHOW_STR
2867 IP_STR
2868 PIM_STR
2869 VRF_CMD_HELP_STR
2870 "PIM statistics\n"
33b58e53 2871 INTERFACE_STR
415f6350 2872 "PIM interface\n"
2873 JSON_STR)
2874{
19296b58 2875 return pim_show_statistics_helper(vrf, vty, word, !!json);
415f6350 2876}
2877
ca3b5906 2878DEFPY (show_ip_multicast,
a25de56b
DS
2879 show_ip_multicast_cmd,
2880 "show ip multicast [vrf NAME]",
2881 SHOW_STR
2882 IP_STR
ca3b5906
A
2883 "Multicast global information\n"
2884 VRF_CMD_HELP_STR)
a25de56b 2885{
8e15c9aa 2886 return pim_show_multicast_helper(vrf, vty);
a25de56b
DS
2887}
2888
ca3b5906 2889DEFPY (show_ip_multicast_vrf_all,
a25de56b
DS
2890 show_ip_multicast_vrf_all_cmd,
2891 "show ip multicast vrf all",
2892 SHOW_STR
2893 IP_STR
ca3b5906
A
2894 "Multicast global information\n"
2895 VRF_CMD_HELP_STR)
a25de56b 2896{
8e15c9aa 2897 return pim_show_multicast_vrf_all_helper(vty);
12e41d03
DL
2898}
2899
3e55b3b5
A
2900DEFPY (show_ip_multicast_count,
2901 show_ip_multicast_count_cmd,
2902 "show ip multicast count [vrf NAME] [json$json]",
2903 SHOW_STR
2904 IP_STR
2905 "Multicast global information\n"
2906 "Data packet count\n"
2907 VRF_CMD_HELP_STR
2908 JSON_STR)
8c8d7031 2909{
334d2f8c 2910 return pim_show_multicast_count_helper(vrf, vty, !!json);
8c8d7031
SP
2911}
2912
3e55b3b5
A
2913DEFPY (show_ip_multicast_count_vrf_all,
2914 show_ip_multicast_count_vrf_all_cmd,
2915 "show ip multicast count vrf all [json$json]",
2916 SHOW_STR
2917 IP_STR
2918 "Multicast global information\n"
2919 "Data packet count\n"
2920 VRF_CMD_HELP_STR
2921 JSON_STR)
8c8d7031 2922{
334d2f8c 2923 return pim_show_multicast_count_vrf_all_helper(vty, !!json);
8c8d7031
SP
2924}
2925
c23c1d39 2926DEFPY (show_ip_mroute,
12e41d03 2927 show_ip_mroute_cmd,
c23c1d39 2928 "show ip mroute [vrf NAME] [A.B.C.D$s_or_g [A.B.C.D$g]] [fill$fill] [json$json]",
12e41d03
DL
2929 SHOW_STR
2930 IP_STR
a957a05b 2931 MROUTE_STR
c3169ac7 2932 VRF_CMD_HELP_STR
c23c1d39
DS
2933 "The Source or Group\n"
2934 "The Group\n"
45b7b092 2935 "Fill in Assumed data\n"
a957a05b 2936 JSON_STR)
12e41d03 2937{
4f1f8ff9 2938 return pim_show_mroute_helper(vrf, vty, s_or_g, g, !!fill, !!json);
12e41d03
DL
2939}
2940
50ba39bf 2941DEFPY (show_ip_mroute_vrf_all,
b283a4ca 2942 show_ip_mroute_vrf_all_cmd,
50ba39bf 2943 "show ip mroute vrf all [fill$fill] [json$json]",
b283a4ca
DS
2944 SHOW_STR
2945 IP_STR
2946 MROUTE_STR
2947 VRF_CMD_HELP_STR
45b7b092 2948 "Fill in Assumed data\n"
b283a4ca
DS
2949 JSON_STR)
2950{
4f1f8ff9 2951 return pim_show_mroute_vrf_all_helper(vty, !!fill, !!json);
b283a4ca
DS
2952}
2953
4e65109c 2954DEFPY (clear_ip_mroute_count,
cd333cf9 2955 clear_ip_mroute_count_cmd,
4e65109c 2956 "clear ip mroute [vrf NAME]$name count",
cd333cf9
DS
2957 CLEAR_STR
2958 IP_STR
2959 MROUTE_STR
2960 VRF_CMD_HELP_STR
2961 "Route and packet count data\n")
2962{
4e65109c 2963 return clear_ip_mroute_count_command(vty, name);
cd333cf9
DS
2964}
2965
c41a9dcf 2966DEFPY (show_ip_mroute_count,
12e41d03 2967 show_ip_mroute_count_cmd,
c41a9dcf 2968 "show ip mroute [vrf NAME] count [json$json]",
12e41d03
DL
2969 SHOW_STR
2970 IP_STR
2971 MROUTE_STR
c68ba0d7 2972 VRF_CMD_HELP_STR
922e7544 2973 "Route and packet count data\n"
2974 JSON_STR)
12e41d03 2975{
1c1077c2 2976 return pim_show_mroute_count_helper(vrf, vty, !!json);
12e41d03
DL
2977}
2978
c41a9dcf 2979DEFPY (show_ip_mroute_count_vrf_all,
5c3aac90 2980 show_ip_mroute_count_vrf_all_cmd,
c41a9dcf 2981 "show ip mroute vrf all count [json$json]",
5c3aac90
DS
2982 SHOW_STR
2983 IP_STR
2984 MROUTE_STR
2985 VRF_CMD_HELP_STR
922e7544 2986 "Route and packet count data\n"
2987 JSON_STR)
5c3aac90 2988{
1c1077c2 2989 return pim_show_mroute_count_vrf_all_helper(vty, !!json);
468b6f44
SP
2990}
2991
74e8197b 2992DEFPY (show_ip_mroute_summary,
468b6f44 2993 show_ip_mroute_summary_cmd,
74e8197b 2994 "show ip mroute [vrf NAME] summary [json$json]",
468b6f44
SP
2995 SHOW_STR
2996 IP_STR
2997 MROUTE_STR
2998 VRF_CMD_HELP_STR
922e7544 2999 "Summary of all mroutes\n"
3000 JSON_STR)
468b6f44 3001{
789d0ec4 3002 return pim_show_mroute_summary_helper(vrf, vty, !!json);
468b6f44
SP
3003}
3004
74e8197b 3005DEFPY (show_ip_mroute_summary_vrf_all,
468b6f44 3006 show_ip_mroute_summary_vrf_all_cmd,
74e8197b 3007 "show ip mroute vrf all summary [json$json]",
468b6f44
SP
3008 SHOW_STR
3009 IP_STR
3010 MROUTE_STR
3011 VRF_CMD_HELP_STR
922e7544 3012 "Summary of all mroutes\n"
3013 JSON_STR)
468b6f44 3014{
789d0ec4 3015 return pim_show_mroute_summary_vrf_all_helper(vty, !!json);
468b6f44
SP
3016}
3017
12e41d03
DL
3018DEFUN (show_ip_rib,
3019 show_ip_rib_cmd,
20a7e5fd 3020 "show ip rib [vrf NAME] A.B.C.D",
12e41d03
DL
3021 SHOW_STR
3022 IP_STR
3023 RIB_STR
c68ba0d7 3024 VRF_CMD_HELP_STR
12e41d03
DL
3025 "Unicast address\n")
3026{
c68ba0d7
DS
3027 int idx = 2;
3028 struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
d62a17ae 3029 struct in_addr addr;
3030 const char *addr_str;
3031 struct pim_nexthop nexthop;
d62a17ae 3032 int result;
3033
c68ba0d7
DS
3034 if (!vrf)
3035 return CMD_WARNING;
3036
d62a17ae 3037 memset(&nexthop, 0, sizeof(nexthop));
c68ba0d7
DS
3038 argv_find(argv, argc, "A.B.C.D", &idx);
3039 addr_str = argv[idx]->arg;
d62a17ae 3040 result = inet_pton(AF_INET, addr_str, &addr);
3041 if (result <= 0) {
3042 vty_out(vty, "Bad unicast address %s: errno=%d: %s\n", addr_str,
3043 errno, safe_strerror(errno));
3044 return CMD_WARNING;
3045 }
12e41d03 3046
ade155e1 3047 if (!pim_nexthop_lookup(vrf->info, &nexthop, addr, 0)) {
d62a17ae 3048 vty_out(vty,
3049 "Failure querying RIB nexthop for unicast address %s\n",
3050 addr_str);
3051 return CMD_WARNING;
3052 }
12e41d03 3053
d62a17ae 3054 vty_out(vty,
3055 "Address NextHop Interface Metric Preference\n");
12e41d03 3056
641ac7c7 3057 vty_out(vty, "%-15s %-15pPAs %-9s %6d %10d\n", addr_str,
3058 &nexthop.mrib_nexthop_addr,
d62a17ae 3059 nexthop.interface ? nexthop.interface->name : "<ifname?>",
3060 nexthop.mrib_route_metric, nexthop.mrib_metric_preference);
12e41d03 3061
d62a17ae 3062 return CMD_SUCCESS;
12e41d03
DL
3063}
3064
64c86530 3065static void show_ssmpingd(struct pim_instance *pim, struct vty *vty)
12e41d03 3066{
d62a17ae 3067 struct listnode *node;
3068 struct ssmpingd_sock *ss;
3069 time_t now;
12e41d03 3070
d62a17ae 3071 vty_out(vty,
3072 "Source Socket Address Port Uptime Requests\n");
12e41d03 3073
71ad9915 3074 if (!pim->ssmpingd_list)
d62a17ae 3075 return;
12e41d03 3076
d62a17ae 3077 now = pim_time_monotonic_sec();
12e41d03 3078
71ad9915 3079 for (ALL_LIST_ELEMENTS_RO(pim->ssmpingd_list, node, ss)) {
d62a17ae 3080 char source_str[INET_ADDRSTRLEN];
3081 char ss_uptime[10];
3082 struct sockaddr_in bind_addr;
3083 socklen_t len = sizeof(bind_addr);
3084 char bind_addr_str[INET_ADDRSTRLEN];
12e41d03 3085
d62a17ae 3086 pim_inet4_dump("<src?>", ss->source_addr, source_str,
3087 sizeof(source_str));
12e41d03 3088
d62a17ae 3089 if (pim_socket_getsockname(
3090 ss->sock_fd, (struct sockaddr *)&bind_addr, &len)) {
3091 vty_out(vty,
3092 "%% Failure reading socket name for ssmpingd source %s on fd=%d\n",
3093 source_str, ss->sock_fd);
3094 }
12e41d03 3095
d62a17ae 3096 pim_inet4_dump("<addr?>", bind_addr.sin_addr, bind_addr_str,
3097 sizeof(bind_addr_str));
3098 pim_time_uptime(ss_uptime, sizeof(ss_uptime),
3099 now - ss->creation);
12e41d03 3100
d62a17ae 3101 vty_out(vty, "%-15s %6d %-15s %5d %8s %8lld\n", source_str,
3102 ss->sock_fd, bind_addr_str, ntohs(bind_addr.sin_port),
3103 ss_uptime, (long long)ss->requests);
3104 }
12e41d03
DL
3105}
3106
3107DEFUN (show_ip_ssmpingd,
3108 show_ip_ssmpingd_cmd,
20a7e5fd 3109 "show ip ssmpingd [vrf NAME]",
12e41d03
DL
3110 SHOW_STR
3111 IP_STR
c68ba0d7
DS
3112 SHOW_SSMPINGD_STR
3113 VRF_CMD_HELP_STR)
12e41d03 3114{
c68ba0d7
DS
3115 int idx = 2;
3116 struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
3117
3118 if (!vrf)
3119 return CMD_WARNING;
3120
64c86530 3121 show_ssmpingd(vrf->info, vty);
d62a17ae 3122 return CMD_SUCCESS;
12e41d03
DL
3123}
3124
a7b2b1e2
DS
3125DEFUN (ip_pim_spt_switchover_infinity,
3126 ip_pim_spt_switchover_infinity_cmd,
3127 "ip pim spt-switchover infinity-and-beyond",
3128 IP_STR
3129 PIM_STR
3130 "SPT-Switchover\n"
3131 "Never switch to SPT Tree\n")
3132{
fb991ce9 3133 return pim_process_spt_switchover_infinity_cmd(vty);
df94f9a9 3134}
a7b2b1e2 3135
fb991ce9 3136DEFPY (ip_pim_spt_switchover_infinity_plist,
df94f9a9 3137 ip_pim_spt_switchover_infinity_plist_cmd,
fb991ce9 3138 "ip pim spt-switchover infinity-and-beyond prefix-list WORD$plist",
df94f9a9
DS
3139 IP_STR
3140 PIM_STR
3141 "SPT-Switchover\n"
3142 "Never switch to SPT Tree\n"
3143 "Prefix-List to control which groups to switch\n"
3144 "Prefix-List name\n")
3145{
fb991ce9 3146 return pim_process_spt_switchover_prefixlist_cmd(vty, plist);
a7b2b1e2
DS
3147}
3148
3149DEFUN (no_ip_pim_spt_switchover_infinity,
3150 no_ip_pim_spt_switchover_infinity_cmd,
3151 "no ip pim spt-switchover infinity-and-beyond",
3152 NO_STR
3153 IP_STR
3154 PIM_STR
3155 "SPT_Switchover\n"
3156 "Never switch to SPT Tree\n")
3157{
fb991ce9 3158 return pim_process_no_spt_switchover_cmd(vty);
df94f9a9 3159}
a7b2b1e2 3160
df94f9a9
DS
3161DEFUN (no_ip_pim_spt_switchover_infinity_plist,
3162 no_ip_pim_spt_switchover_infinity_plist_cmd,
3163 "no ip pim spt-switchover infinity-and-beyond prefix-list WORD",
3164 NO_STR
3165 IP_STR
3166 PIM_STR
3167 "SPT_Switchover\n"
3168 "Never switch to SPT Tree\n"
3169 "Prefix-List to control which groups to switch\n"
3170 "Prefix-List name\n")
3171{
fb991ce9 3172 return pim_process_no_spt_switchover_cmd(vty);
a7b2b1e2
DS
3173}
3174
f4e74bd0
DS
3175DEFPY (pim_register_accept_list,
3176 pim_register_accept_list_cmd,
3177 "[no] ip pim register-accept-list WORD$word",
3178 NO_STR
3179 IP_STR
3180 PIM_STR
3181 "Only accept registers from a specific source prefix list\n"
3182 "Prefix-List name\n")
3183{
0c949724
SP
3184 const char *vrfname;
3185 char reg_alist_xpath[XPATH_MAXLEN];
3186
5a1a3920
RZ
3187 vrfname = pim_cli_get_vrf_name(vty);
3188 if (vrfname == NULL)
3189 return CMD_WARNING_CONFIG_FAILED;
0c949724
SP
3190
3191 snprintf(reg_alist_xpath, sizeof(reg_alist_xpath),
698f4147 3192 FRR_PIM_VRF_XPATH, "frr-pim:pimd", "pim", vrfname,
0c949724
SP
3193 "frr-routing:ipv4");
3194 strlcat(reg_alist_xpath, "/register-accept-list",
3195 sizeof(reg_alist_xpath));
f4e74bd0
DS
3196
3197 if (no)
0c949724 3198 nb_cli_enqueue_change(vty, reg_alist_xpath,
521c5b9d 3199 NB_OP_DESTROY, NULL);
0c949724
SP
3200 else
3201 nb_cli_enqueue_change(vty, reg_alist_xpath,
521c5b9d 3202 NB_OP_MODIFY, word);
0c949724
SP
3203
3204 return nb_cli_apply_changes(vty, NULL);
f4e74bd0
DS
3205}
3206
c73113ea 3207DEFPY (ip_pim_joinprune_time,
ee1a0718 3208 ip_pim_joinprune_time_cmd,
c73113ea 3209 "ip pim join-prune-interval (1-65535)$jpi",
ee1a0718
DS
3210 IP_STR
3211 "pim multicast routing\n"
3212 "Join Prune Send Interval\n"
3213 "Seconds\n")
3214{
c73113ea 3215 return pim_process_join_prune_cmd(vty, jpi_str);
ee1a0718
DS
3216}
3217
3218DEFUN (no_ip_pim_joinprune_time,
3219 no_ip_pim_joinprune_time_cmd,
11ca3587 3220 "no ip pim join-prune-interval [(1-65535)]",
ee1a0718
DS
3221 NO_STR
3222 IP_STR
3223 "pim multicast routing\n"
3224 "Join Prune Send Interval\n"
11ca3587 3225 IGNORED_IN_NO_STR)
ee1a0718 3226{
c73113ea 3227 return pim_process_no_join_prune_cmd(vty);
ee1a0718
DS
3228}
3229
18ca7de5 3230DEFPY (ip_pim_register_suppress,
191f5695 3231 ip_pim_register_suppress_cmd,
18ca7de5 3232 "ip pim register-suppress-time (1-65535)$rst",
4304f95c
DS
3233 IP_STR
3234 "pim multicast routing\n"
191f5695
DS
3235 "Register Suppress Timer\n"
3236 "Seconds\n")
4304f95c 3237{
18ca7de5 3238 return pim_process_register_suppress_cmd(vty, rst_str);
4304f95c
DS
3239}
3240
191f5695
DS
3241DEFUN (no_ip_pim_register_suppress,
3242 no_ip_pim_register_suppress_cmd,
11ca3587 3243 "no ip pim register-suppress-time [(1-65535)]",
4304f95c
DS
3244 NO_STR
3245 IP_STR
3246 "pim multicast routing\n"
191f5695 3247 "Register Suppress Timer\n"
11ca3587 3248 IGNORED_IN_NO_STR)
4304f95c 3249{
18ca7de5 3250 return pim_process_no_register_suppress_cmd(vty);
4304f95c
DS
3251}
3252
2322b991 3253DEFPY (ip_pim_rp_keep_alive,
cc14df13 3254 ip_pim_rp_keep_alive_cmd,
2322b991 3255 "ip pim rp keep-alive-timer (1-65535)$kat",
cc14df13
DS
3256 IP_STR
3257 "pim multicast routing\n"
a6324d6a 3258 "Rendezvous Point\n"
cc14df13
DS
3259 "Keep alive Timer\n"
3260 "Seconds\n")
3261{
2322b991 3262 return pim_process_rp_kat_cmd(vty, kat_str);
cc14df13
DS
3263}
3264
3265DEFUN (no_ip_pim_rp_keep_alive,
3266 no_ip_pim_rp_keep_alive_cmd,
11ca3587 3267 "no ip pim rp keep-alive-timer [(1-65535)]",
cc14df13
DS
3268 NO_STR
3269 IP_STR
3270 "pim multicast routing\n"
a6324d6a 3271 "Rendezvous Point\n"
cc14df13 3272 "Keep alive Timer\n"
11ca3587 3273 IGNORED_IN_NO_STR)
cc14df13 3274{
2322b991 3275 return pim_process_no_rp_kat_cmd(vty);
cc14df13
DS
3276}
3277
28e32366 3278DEFPY (ip_pim_keep_alive,
191f5695 3279 ip_pim_keep_alive_cmd,
28e32366 3280 "ip pim keep-alive-timer (1-65535)$kat",
01408ede
DS
3281 IP_STR
3282 "pim multicast routing\n"
01408ede
DS
3283 "Keep alive Timer\n"
3284 "Seconds\n")
3285{
28e32366 3286 return pim_process_keepalivetimer_cmd(vty, kat_str);
01408ede
DS
3287}
3288
191f5695
DS
3289DEFUN (no_ip_pim_keep_alive,
3290 no_ip_pim_keep_alive_cmd,
11ca3587 3291 "no ip pim keep-alive-timer [(1-65535)]",
01408ede
DS
3292 NO_STR
3293 IP_STR
3294 "pim multicast routing\n"
01408ede 3295 "Keep alive Timer\n"
11ca3587 3296 IGNORED_IN_NO_STR)
01408ede 3297{
28e32366 3298 return pim_process_no_keepalivetimer_cmd(vty);
01408ede
DS
3299}
3300
0da72f1f 3301DEFPY (ip_pim_packets,
8e4c9ef3 3302 ip_pim_packets_cmd,
11ca3587 3303 "ip pim packets (1-255)",
8e4c9ef3
DS
3304 IP_STR
3305 "pim multicast routing\n"
a957a05b
DS
3306 "packets to process at one time per fd\n"
3307 "Number of packets\n")
8e4c9ef3 3308{
0da72f1f 3309 return pim_process_pim_packet_cmd(vty, packets_str);
8e4c9ef3
DS
3310}
3311
3312DEFUN (no_ip_pim_packets,
3313 no_ip_pim_packets_cmd,
11ca3587 3314 "no ip pim packets [(1-255)]",
8e4c9ef3
DS
3315 NO_STR
3316 IP_STR
3317 "pim multicast routing\n"
a957a05b 3318 "packets to process at one time per fd\n"
11ca3587 3319 IGNORED_IN_NO_STR)
8e4c9ef3 3320{
0da72f1f 3321 return pim_process_no_pim_packet_cmd(vty);
8e4c9ef3
DS
3322}
3323
fb005412
SG
3324DEFPY (ip_igmp_group_watermark,
3325 ip_igmp_group_watermark_cmd,
11ca3587 3326 "ip igmp watermark-warn (1-65535)$limit",
339f7695 3327 IP_STR
3328 IGMP_STR
3329 "Configure group limit for watermark warning\n"
3330 "Group count to generate watermark warning\n")
3331{
0cbed951 3332 PIM_DECLVAR_CONTEXT_VRF(vrf, pim);
229a20e2 3333 pim->gm_watermark_limit = limit;
339f7695 3334
3335 return CMD_SUCCESS;
3336}
3337
fb005412
SG
3338DEFPY (no_ip_igmp_group_watermark,
3339 no_ip_igmp_group_watermark_cmd,
11ca3587 3340 "no ip igmp watermark-warn [(1-65535)$limit]",
339f7695 3341 NO_STR
3342 IP_STR
3343 IGMP_STR
3344 "Unconfigure group limit for watermark warning\n"
11ca3587 3345 IGNORED_IN_NO_STR)
339f7695 3346{
0cbed951 3347 PIM_DECLVAR_CONTEXT_VRF(vrf, pim);
229a20e2 3348 pim->gm_watermark_limit = 0;
339f7695 3349
3350 return CMD_SUCCESS;
3351}
3352
71bbe73d
DS
3353DEFUN (ip_pim_v6_secondary,
3354 ip_pim_v6_secondary_cmd,
3355 "ip pim send-v6-secondary",
3356 IP_STR
3357 "pim multicast routing\n"
3358 "Send v6 secondary addresses\n")
3359{
db9cca95
SP
3360 const char *vrfname;
3361 char send_v6_secondary_xpath[XPATH_MAXLEN];
71bbe73d 3362
5a1a3920
RZ
3363 vrfname = pim_cli_get_vrf_name(vty);
3364 if (vrfname == NULL)
3365 return CMD_WARNING_CONFIG_FAILED;
db9cca95
SP
3366
3367 snprintf(send_v6_secondary_xpath, sizeof(send_v6_secondary_xpath),
698f4147 3368 FRR_PIM_VRF_XPATH,
db9cca95
SP
3369 "frr-pim:pimd", "pim", vrfname, "frr-routing:ipv4");
3370 strlcat(send_v6_secondary_xpath, "/send-v6-secondary",
3371 sizeof(send_v6_secondary_xpath));
3372
3373 nb_cli_enqueue_change(vty, send_v6_secondary_xpath, NB_OP_MODIFY,
521c5b9d 3374 "true");
db9cca95
SP
3375
3376 return nb_cli_apply_changes(vty, NULL);
71bbe73d
DS
3377}
3378
3379DEFUN (no_ip_pim_v6_secondary,
3380 no_ip_pim_v6_secondary_cmd,
3381 "no ip pim send-v6-secondary",
3382 NO_STR
3383 IP_STR
3384 "pim multicast routing\n"
3385 "Send v6 secondary addresses\n")
3386{
db9cca95
SP
3387 const char *vrfname;
3388 char send_v6_secondary_xpath[XPATH_MAXLEN];
71bbe73d 3389
5a1a3920
RZ
3390 vrfname = pim_cli_get_vrf_name(vty);
3391 if (vrfname == NULL)
3392 return CMD_WARNING_CONFIG_FAILED;
db9cca95
SP
3393
3394 snprintf(send_v6_secondary_xpath, sizeof(send_v6_secondary_xpath),
698f4147 3395 FRR_PIM_VRF_XPATH,
db9cca95
SP
3396 "frr-pim:pimd", "pim", vrfname, "frr-routing:ipv4");
3397 strlcat(send_v6_secondary_xpath, "/send-v6-secondary",
3398 sizeof(send_v6_secondary_xpath));
3399
3400 nb_cli_enqueue_change(vty, send_v6_secondary_xpath, NB_OP_MODIFY,
521c5b9d 3401 "false");
db9cca95
SP
3402
3403 return nb_cli_apply_changes(vty, NULL);
71bbe73d
DS
3404}
3405
13ddf7cf 3406DEFPY (ip_pim_rp,
981d6c7a 3407 ip_pim_rp_cmd,
13ddf7cf 3408 "ip pim rp A.B.C.D$rp [A.B.C.D/M]$gp",
981d6c7a 3409 IP_STR
9b34069d 3410 "pim multicast routing\n"
a6324d6a 3411 "Rendezvous Point\n"
a957a05b
DS
3412 "ip address of RP\n"
3413 "Group Address range to cover\n")
981d6c7a 3414{
13ddf7cf 3415 const char *group_str = (gp_str) ? gp_str : "224.0.0.0/4";
7003f636 3416
13ddf7cf 3417 return pim_process_rp_cmd(vty, rp_str, group_str);
dfe43e25
DW
3418}
3419
f39f3497 3420DEFPY (ip_pim_rp_prefix_list,
dfe43e25 3421 ip_pim_rp_prefix_list_cmd,
f39f3497 3422 "ip pim rp A.B.C.D$rp prefix-list WORD$plist",
dfe43e25
DW
3423 IP_STR
3424 "pim multicast routing\n"
f39f3497 3425 "Rendezvous Point\n"
dfe43e25
DW
3426 "ip address of RP\n"
3427 "group prefix-list filter\n"
3428 "Name of a prefix-list\n")
3429{
f39f3497 3430 return pim_process_rp_plist_cmd(vty, rp_str, plist);
981d6c7a
DS
3431}
3432
13ddf7cf 3433DEFPY (no_ip_pim_rp,
981d6c7a 3434 no_ip_pim_rp_cmd,
13ddf7cf 3435 "no ip pim rp A.B.C.D$rp [A.B.C.D/M]$gp",
981d6c7a
DS
3436 NO_STR
3437 IP_STR
9b34069d 3438 "pim multicast routing\n"
a6324d6a 3439 "Rendezvous Point\n"
a957a05b
DS
3440 "ip address of RP\n"
3441 "Group Address range to cover\n")
981d6c7a 3442{
13ddf7cf 3443 const char *group_str = (gp_str) ? gp_str : "224.0.0.0/4";
7003f636 3444
13ddf7cf 3445 return pim_process_no_rp_cmd(vty, rp_str, group_str);
dfe43e25
DW
3446}
3447
f39f3497 3448DEFPY (no_ip_pim_rp_prefix_list,
dfe43e25 3449 no_ip_pim_rp_prefix_list_cmd,
f39f3497 3450 "no ip pim rp A.B.C.D$rp prefix-list WORD$plist",
dfe43e25
DW
3451 NO_STR
3452 IP_STR
3453 "pim multicast routing\n"
f39f3497 3454 "Rendezvous Point\n"
dfe43e25
DW
3455 "ip address of RP\n"
3456 "group prefix-list filter\n"
3457 "Name of a prefix-list\n")
3458{
f39f3497 3459 return pim_process_no_rp_plist_cmd(vty, rp_str, plist);
15a5dafe 3460}
3461
3462DEFUN (ip_pim_ssm_prefix_list,
3463 ip_pim_ssm_prefix_list_cmd,
3464 "ip pim ssm prefix-list WORD",
3465 IP_STR
3466 "pim multicast routing\n"
3467 "Source Specific Multicast\n"
3468 "group range prefix-list filter\n"
3469 "Name of a prefix-list\n")
3470{
f206085e
SP
3471 const char *vrfname;
3472 char ssm_plist_xpath[XPATH_MAXLEN];
3473
5a1a3920
RZ
3474 vrfname = pim_cli_get_vrf_name(vty);
3475 if (vrfname == NULL)
3476 return CMD_WARNING_CONFIG_FAILED;
f206085e 3477
698f4147 3478 snprintf(ssm_plist_xpath, sizeof(ssm_plist_xpath), FRR_PIM_VRF_XPATH,
f206085e
SP
3479 "frr-pim:pimd", "pim", vrfname, "frr-routing:ipv4");
3480 strlcat(ssm_plist_xpath, "/ssm-prefix-list", sizeof(ssm_plist_xpath));
3481
3482 nb_cli_enqueue_change(vty, ssm_plist_xpath, NB_OP_MODIFY, argv[4]->arg);
3483
3484 return nb_cli_apply_changes(vty, NULL);
15a5dafe 3485}
3486
3487DEFUN (no_ip_pim_ssm_prefix_list,
3488 no_ip_pim_ssm_prefix_list_cmd,
3489 "no ip pim ssm prefix-list",
3490 NO_STR
3491 IP_STR
3492 "pim multicast routing\n"
3493 "Source Specific Multicast\n"
3494 "group range prefix-list filter\n")
3495{
f206085e
SP
3496 const char *vrfname;
3497 char ssm_plist_xpath[XPATH_MAXLEN];
3498
5a1a3920
RZ
3499 vrfname = pim_cli_get_vrf_name(vty);
3500 if (vrfname == NULL)
3501 return CMD_WARNING_CONFIG_FAILED;
f206085e
SP
3502
3503 snprintf(ssm_plist_xpath, sizeof(ssm_plist_xpath),
698f4147 3504 FRR_PIM_VRF_XPATH,
f206085e
SP
3505 "frr-pim:pimd", "pim", vrfname, "frr-routing:ipv4");
3506 strlcat(ssm_plist_xpath, "/ssm-prefix-list", sizeof(ssm_plist_xpath));
3507
3508 nb_cli_enqueue_change(vty, ssm_plist_xpath, NB_OP_DESTROY, NULL);
3509
3510 return nb_cli_apply_changes(vty, NULL);
15a5dafe 3511}
3512
3513DEFUN (no_ip_pim_ssm_prefix_list_name,
3514 no_ip_pim_ssm_prefix_list_name_cmd,
3515 "no ip pim ssm prefix-list WORD",
3516 NO_STR
3517 IP_STR
3518 "pim multicast routing\n"
3519 "Source Specific Multicast\n"
3520 "group range prefix-list filter\n"
3521 "Name of a prefix-list\n")
3522{
f206085e
SP
3523 const char *vrfname;
3524 const struct lyd_node *ssm_plist_dnode;
3525 char ssm_plist_xpath[XPATH_MAXLEN];
3526 const char *ssm_plist_name;
15a5dafe 3527
5a1a3920
RZ
3528 vrfname = pim_cli_get_vrf_name(vty);
3529 if (vrfname == NULL)
3530 return CMD_WARNING_CONFIG_FAILED;
f206085e
SP
3531
3532 snprintf(ssm_plist_xpath, sizeof(ssm_plist_xpath),
698f4147 3533 FRR_PIM_VRF_XPATH,
f206085e
SP
3534 "frr-pim:pimd", "pim", vrfname, "frr-routing:ipv4");
3535 strlcat(ssm_plist_xpath, "/ssm-prefix-list", sizeof(ssm_plist_xpath));
3536 ssm_plist_dnode = yang_dnode_get(vty->candidate_config->dnode,
521c5b9d 3537 ssm_plist_xpath);
f206085e
SP
3538
3539 if (!ssm_plist_dnode) {
3540 vty_out(vty,
3541 "%% pim ssm prefix-list %s doesn't exist\n",
3542 argv[5]->arg);
3543 return CMD_WARNING_CONFIG_FAILED;
3544 }
3545
3546 ssm_plist_name = yang_dnode_get_string(ssm_plist_dnode, ".");
3547
3548 if (ssm_plist_name && !strcmp(ssm_plist_name, argv[5]->arg)) {
3549 nb_cli_enqueue_change(vty, ssm_plist_xpath, NB_OP_DESTROY,
521c5b9d 3550 NULL);
f206085e
SP
3551
3552 return nb_cli_apply_changes(vty, NULL);
3553 }
15a5dafe 3554
9643e2c7 3555 vty_out(vty, "%% pim ssm prefix-list %s doesn't exist\n", argv[5]->arg);
15a5dafe 3556
d62a17ae 3557 return CMD_WARNING_CONFIG_FAILED;
15a5dafe 3558}
3559
15a5dafe 3560DEFUN (show_ip_pim_ssm_range,
3561 show_ip_pim_ssm_range_cmd,
20a7e5fd 3562 "show ip pim [vrf NAME] group-type [json]",
15a5dafe 3563 SHOW_STR
3564 IP_STR
3565 PIM_STR
c68ba0d7 3566 VRF_CMD_HELP_STR
15a5dafe 3567 "PIM group type\n"
f5da2cc2 3568 JSON_STR)
15a5dafe 3569{
c68ba0d7
DS
3570 int idx = 2;
3571 struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
9f049418 3572 bool uj = use_json(argc, argv);
c68ba0d7
DS
3573
3574 if (!vrf)
3575 return CMD_WARNING;
3576
64c86530 3577 ip_pim_ssm_show_group_range(vrf->info, vty, uj);
15a5dafe 3578
d62a17ae 3579 return CMD_SUCCESS;
15a5dafe 3580}
3581
64c86530 3582static void ip_pim_ssm_show_group_type(struct pim_instance *pim,
088f1098 3583 struct vty *vty, bool uj,
d62a17ae 3584 const char *group)
15a5dafe 3585{
d62a17ae 3586 struct in_addr group_addr;
3587 const char *type_str;
3588 int result;
15a5dafe 3589
d62a17ae 3590 result = inet_pton(AF_INET, group, &group_addr);
3591 if (result <= 0)
3592 type_str = "invalid";
3593 else {
3594 if (pim_is_group_224_4(group_addr))
c68ba0d7
DS
3595 type_str =
3596 pim_is_grp_ssm(pim, group_addr) ? "SSM" : "ASM";
d62a17ae 3597 else
3598 type_str = "not-multicast";
3599 }
15a5dafe 3600
d62a17ae 3601 if (uj) {
3602 json_object *json;
3603 json = json_object_new_object();
3604 json_object_string_add(json, "groupType", type_str);
3757f964 3605 vty_json(vty, json);
d62a17ae 3606 } else
3607 vty_out(vty, "Group type : %s\n", type_str);
15a5dafe 3608}
3609
3610DEFUN (show_ip_pim_group_type,
3611 show_ip_pim_group_type_cmd,
20a7e5fd 3612 "show ip pim [vrf NAME] group-type A.B.C.D [json]",
15a5dafe 3613 SHOW_STR
3614 IP_STR
3615 PIM_STR
c68ba0d7 3616 VRF_CMD_HELP_STR
15a5dafe 3617 "multicast group type\n"
3618 "group address\n"
f5da2cc2 3619 JSON_STR)
15a5dafe 3620{
c68ba0d7
DS
3621 int idx = 2;
3622 struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
9f049418 3623 bool uj = use_json(argc, argv);
c68ba0d7
DS
3624
3625 if (!vrf)
3626 return CMD_WARNING;
3627
3628 argv_find(argv, argc, "A.B.C.D", &idx);
64c86530 3629 ip_pim_ssm_show_group_type(vrf->info, vty, uj, argv[idx]->arg);
15a5dafe 3630
d62a17ae 3631 return CMD_SUCCESS;
15a5dafe 3632}
3633
256392eb 3634DEFUN (show_ip_pim_bsr,
3635 show_ip_pim_bsr_cmd,
3636 "show ip pim bsr [json]",
3637 SHOW_STR
3638 IP_STR
3639 PIM_STR
3640 "boot-strap router information\n"
3641 JSON_STR)
3642{
3643 int idx = 2;
3644 struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
3645 bool uj = use_json(argc, argv);
3646
3647 if (!vrf)
3648 return CMD_WARNING;
3649
3650 pim_show_bsr(vrf->info, vty, uj);
3651
3652 return CMD_SUCCESS;
3653}
3654
12e41d03
DL
3655DEFUN (ip_ssmpingd,
3656 ip_ssmpingd_cmd,
3657 "ip ssmpingd [A.B.C.D]",
3658 IP_STR
3659 CONF_SSMPINGD_STR
3660 "Source address\n")
3661{
d62a17ae 3662 int idx_ipv4 = 2;
a8caf78d 3663 const char *src_str = (argc == 3) ? argv[idx_ipv4]->arg : "0.0.0.0";
12e41d03 3664
a8caf78d 3665 return pim_process_ssmpingd_cmd(vty, NB_OP_CREATE, src_str);
12e41d03
DL
3666}
3667
3668DEFUN (no_ip_ssmpingd,
3669 no_ip_ssmpingd_cmd,
3670 "no ip ssmpingd [A.B.C.D]",
3671 NO_STR
3672 IP_STR
3673 CONF_SSMPINGD_STR
3674 "Source address\n")
3675{
d62a17ae 3676 int idx_ipv4 = 3;
a8caf78d 3677 const char *src_str = (argc == 4) ? argv[idx_ipv4]->arg : "0.0.0.0";
12e41d03 3678
a8caf78d 3679 return pim_process_ssmpingd_cmd(vty, NB_OP_DESTROY, src_str);
12e41d03
DL
3680}
3681
cba44481
CS
3682DEFUN (ip_pim_ecmp,
3683 ip_pim_ecmp_cmd,
3684 "ip pim ecmp",
3685 IP_STR
3686 "pim multicast routing\n"
3687 "Enable PIM ECMP \n")
3688{
49c6b2aa
SP
3689 const char *vrfname;
3690 char ecmp_xpath[XPATH_MAXLEN];
cba44481 3691
5a1a3920
RZ
3692 vrfname = pim_cli_get_vrf_name(vty);
3693 if (vrfname == NULL)
3694 return CMD_WARNING_CONFIG_FAILED;
49c6b2aa 3695
698f4147 3696 snprintf(ecmp_xpath, sizeof(ecmp_xpath), FRR_PIM_VRF_XPATH,
3697 "frr-pim:pimd", "pim", vrfname, "frr-routing:ipv4");
49c6b2aa
SP
3698 strlcat(ecmp_xpath, "/ecmp", sizeof(ecmp_xpath));
3699
3700 nb_cli_enqueue_change(vty, ecmp_xpath, NB_OP_MODIFY, "true");
3701 return nb_cli_apply_changes(vty, NULL);
cba44481
CS
3702}
3703
3704DEFUN (no_ip_pim_ecmp,
3705 no_ip_pim_ecmp_cmd,
3706 "no ip pim ecmp",
3707 NO_STR
3708 IP_STR
3709 "pim multicast routing\n"
3710 "Disable PIM ECMP \n")
3711{
49c6b2aa
SP
3712 const char *vrfname;
3713 char ecmp_xpath[XPATH_MAXLEN];
cba44481 3714
5a1a3920
RZ
3715 vrfname = pim_cli_get_vrf_name(vty);
3716 if (vrfname == NULL)
3717 return CMD_WARNING_CONFIG_FAILED;
49c6b2aa 3718
698f4147 3719 snprintf(ecmp_xpath, sizeof(ecmp_xpath), FRR_PIM_VRF_XPATH,
3720 "frr-pim:pimd", "pim", vrfname, "frr-routing:ipv4");
49c6b2aa
SP
3721 strlcat(ecmp_xpath, "/ecmp", sizeof(ecmp_xpath));
3722
3723 nb_cli_enqueue_change(vty, ecmp_xpath, NB_OP_MODIFY, "false");
3724
3725 return nb_cli_apply_changes(vty, NULL);
cba44481
CS
3726}
3727
3728DEFUN (ip_pim_ecmp_rebalance,
3729 ip_pim_ecmp_rebalance_cmd,
3730 "ip pim ecmp rebalance",
3731 IP_STR
3732 "pim multicast routing\n"
3733 "Enable PIM ECMP \n"
3734 "Enable PIM ECMP Rebalance\n")
3735{
49c6b2aa
SP
3736 const char *vrfname;
3737 char ecmp_xpath[XPATH_MAXLEN];
3738 char ecmp_rebalance_xpath[XPATH_MAXLEN];
cba44481 3739
5a1a3920
RZ
3740 vrfname = pim_cli_get_vrf_name(vty);
3741 if (vrfname == NULL)
3742 return CMD_WARNING_CONFIG_FAILED;
49c6b2aa 3743
698f4147 3744 snprintf(ecmp_xpath, sizeof(ecmp_xpath), FRR_PIM_VRF_XPATH,
3745 "frr-pim:pimd", "pim", vrfname, "frr-routing:ipv4");
49c6b2aa
SP
3746 strlcat(ecmp_xpath, "/ecmp", sizeof(ecmp_xpath));
3747 snprintf(ecmp_rebalance_xpath, sizeof(ecmp_rebalance_xpath),
698f4147 3748 FRR_PIM_VRF_XPATH,
3749 "frr-pim:pimd", "pim", vrfname, "frr-routing:ipv4");
49c6b2aa
SP
3750 strlcat(ecmp_rebalance_xpath, "/ecmp-rebalance",
3751 sizeof(ecmp_rebalance_xpath));
3752
3753 nb_cli_enqueue_change(vty, ecmp_xpath, NB_OP_MODIFY, "true");
3754 nb_cli_enqueue_change(vty, ecmp_rebalance_xpath, NB_OP_MODIFY, "true");
3755
3756 return nb_cli_apply_changes(vty, NULL);
cba44481
CS
3757}
3758
3759DEFUN (no_ip_pim_ecmp_rebalance,
3760 no_ip_pim_ecmp_rebalance_cmd,
3761 "no ip pim ecmp rebalance",
3762 NO_STR
3763 IP_STR
3764 "pim multicast routing\n"
3765 "Disable PIM ECMP \n"
3766 "Disable PIM ECMP Rebalance\n")
3767{
49c6b2aa
SP
3768 const char *vrfname;
3769 char ecmp_rebalance_xpath[XPATH_MAXLEN];
cba44481 3770
5a1a3920
RZ
3771 vrfname = pim_cli_get_vrf_name(vty);
3772 if (vrfname == NULL)
3773 return CMD_WARNING_CONFIG_FAILED;
12e41d03 3774
49c6b2aa 3775 snprintf(ecmp_rebalance_xpath, sizeof(ecmp_rebalance_xpath),
698f4147 3776 FRR_PIM_VRF_XPATH,
3777 "frr-pim:pimd", "pim", vrfname, "frr-routing:ipv4");
49c6b2aa
SP
3778 strlcat(ecmp_rebalance_xpath, "/ecmp-rebalance",
3779 sizeof(ecmp_rebalance_xpath));
12e41d03 3780
49c6b2aa
SP
3781 nb_cli_enqueue_change(vty, ecmp_rebalance_xpath, NB_OP_MODIFY, "false");
3782
3783 return nb_cli_apply_changes(vty, NULL);
12e41d03
DL
3784}
3785
21419f59
DS
3786DEFUN (interface_ip_igmp,
3787 interface_ip_igmp_cmd,
3788 "ip igmp",
3789 IP_STR
3790 IFACE_IGMP_STR)
3791{
3051f443 3792 nb_cli_enqueue_change(vty, "./enable", NB_OP_MODIFY, "true");
21419f59 3793
3051f443 3794 return nb_cli_apply_changes(vty, FRR_GMP_INTERFACE_XPATH,
3795 "frr-routing:ipv4");
21419f59
DS
3796}
3797
12e41d03
DL
3798DEFUN (interface_no_ip_igmp,
3799 interface_no_ip_igmp_cmd,
3800 "no ip igmp",
3801 NO_STR
3802 IP_STR
3803 IFACE_IGMP_STR)
3804{
b0475d5a 3805 const struct lyd_node *pim_enable_dnode;
d7073b21 3806 char pim_if_xpath[XPATH_MAXLEN];
12e41d03 3807
d7073b21
QY
3808 int printed =
3809 snprintf(pim_if_xpath, sizeof(pim_if_xpath),
3810 "%s/frr-pim:pim/address-family[address-family='%s']",
3811 VTY_CURR_XPATH, "frr-routing:ipv4");
3812
3813 if (printed >= (int)(sizeof(pim_if_xpath))) {
3814 vty_out(vty, "Xpath too long (%d > %u)", printed + 1,
3815 XPATH_MAXLEN);
3816 return CMD_WARNING_CONFIG_FAILED;
3817 }
12e41d03 3818
3bb513c3 3819 pim_enable_dnode = yang_dnode_getf(vty->candidate_config->dnode,
698f4147 3820 FRR_PIM_ENABLE_XPATH, VTY_CURR_XPATH,
3821 "frr-routing:ipv4");
b0475d5a
SP
3822 if (!pim_enable_dnode) {
3823 nb_cli_enqueue_change(vty, pim_if_xpath, NB_OP_DESTROY, NULL);
3824 nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL);
3825 } else {
3826 if (!yang_dnode_get_bool(pim_enable_dnode, ".")) {
3827 nb_cli_enqueue_change(vty, pim_if_xpath, NB_OP_DESTROY,
5c90f569 3828 NULL);
b0475d5a
SP
3829 nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL);
3830 } else
3051f443 3831 nb_cli_enqueue_change(vty, "./enable",
5c90f569 3832 NB_OP_MODIFY, "false");
d62a17ae 3833 }
12e41d03 3834
3051f443 3835 return nb_cli_apply_changes(vty, FRR_GMP_INTERFACE_XPATH,
3836 "frr-routing:ipv4");
12e41d03
DL
3837}
3838
3839DEFUN (interface_ip_igmp_join,
3840 interface_ip_igmp_join_cmd,
771ce8ad 3841 "ip igmp join A.B.C.D [A.B.C.D]",
12e41d03
DL
3842 IP_STR
3843 IFACE_IGMP_STR
3844 "IGMP join multicast group\n"
3845 "Multicast group address\n"
3846 "Source address\n")
3847{
b0475d5a
SP
3848 int idx_group = 3;
3849 int idx_source = 4;
d62a17ae 3850 const char *source_str;
b0475d5a 3851 char xpath[XPATH_MAXLEN];
d62a17ae 3852
b0475d5a
SP
3853 if (argc == 5) {
3854 source_str = argv[idx_source]->arg;
d62a17ae 3855
b0475d5a
SP
3856 if (strcmp(source_str, "0.0.0.0") == 0) {
3857 vty_out(vty, "Bad source address %s\n",
521c5b9d 3858 argv[idx_source]->arg);
771ce8ad
LM
3859 return CMD_WARNING_CONFIG_FAILED;
3860 }
b0475d5a
SP
3861 } else
3862 source_str = "0.0.0.0";
d62a17ae 3863
3051f443 3864 snprintf(xpath, sizeof(xpath), FRR_GMP_JOIN_XPATH,
521c5b9d 3865 "frr-routing:ipv4", argv[idx_group]->arg, source_str);
d62a17ae 3866
b0475d5a
SP
3867 nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
3868
3869 return nb_cli_apply_changes(vty, NULL);
12e41d03
DL
3870}
3871
3872DEFUN (interface_no_ip_igmp_join,
3873 interface_no_ip_igmp_join_cmd,
771ce8ad 3874 "no ip igmp join A.B.C.D [A.B.C.D]",
12e41d03
DL
3875 NO_STR
3876 IP_STR
3877 IFACE_IGMP_STR
3878 "IGMP join multicast group\n"
3879 "Multicast group address\n"
3880 "Source address\n")
3881{
b0475d5a
SP
3882 int idx_group = 4;
3883 int idx_source = 5;
d62a17ae 3884 const char *source_str;
b0475d5a 3885 char xpath[XPATH_MAXLEN];
d62a17ae 3886
b0475d5a
SP
3887 if (argc == 6) {
3888 source_str = argv[idx_source]->arg;
d62a17ae 3889
b0475d5a
SP
3890 if (strcmp(source_str, "0.0.0.0") == 0) {
3891 vty_out(vty, "Bad source address %s\n",
521c5b9d 3892 argv[idx_source]->arg);
771ce8ad
LM
3893 return CMD_WARNING_CONFIG_FAILED;
3894 }
b0475d5a
SP
3895 } else
3896 source_str = "0.0.0.0";
d62a17ae 3897
3051f443 3898 snprintf(xpath, sizeof(xpath), FRR_GMP_JOIN_XPATH,
521c5b9d 3899 "frr-routing:ipv4", argv[idx_group]->arg, source_str);
d62a17ae 3900
b0475d5a 3901 nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
d62a17ae 3902
b0475d5a 3903 return nb_cli_apply_changes(vty, NULL);
12e41d03
DL
3904}
3905
12e41d03
DL
3906DEFUN (interface_ip_igmp_query_interval,
3907 interface_ip_igmp_query_interval_cmd,
11ca3587 3908 "ip igmp query-interval (1-65535)",
12e41d03
DL
3909 IP_STR
3910 IFACE_IGMP_STR
3911 IFACE_IGMP_QUERY_INTERVAL_STR
3912 "Query interval in seconds\n")
3913{
b0475d5a 3914 const struct lyd_node *pim_enable_dnode;
d62a17ae 3915
3bb513c3
CH
3916 pim_enable_dnode =
3917 yang_dnode_getf(vty->candidate_config->dnode,
698f4147 3918 FRR_PIM_ENABLE_XPATH, VTY_CURR_XPATH,
3919 "frr-routing:ipv4");
b0475d5a 3920 if (!pim_enable_dnode) {
698f4147 3921 nb_cli_enqueue_change(vty, "./enable", NB_OP_MODIFY,
521c5b9d 3922 "true");
b0475d5a
SP
3923 } else {
3924 if (!yang_dnode_get_bool(pim_enable_dnode, "."))
3051f443 3925 nb_cli_enqueue_change(vty, "./enable",
521c5b9d 3926 NB_OP_MODIFY, "true");
d62a17ae 3927 }
3928
b0475d5a 3929 nb_cli_enqueue_change(vty, "./query-interval", NB_OP_MODIFY,
521c5b9d 3930 argv[3]->arg);
d62a17ae 3931
3051f443 3932 return nb_cli_apply_changes(vty, FRR_GMP_INTERFACE_XPATH,
3933 "frr-routing:ipv4");
12e41d03
DL
3934}
3935
3936DEFUN (interface_no_ip_igmp_query_interval,
3937 interface_no_ip_igmp_query_interval_cmd,
11ca3587 3938 "no ip igmp query-interval [(1-65535)]",
12e41d03
DL
3939 NO_STR
3940 IP_STR
3941 IFACE_IGMP_STR
11ca3587
CH
3942 IFACE_IGMP_QUERY_INTERVAL_STR
3943 IGNORED_IN_NO_STR)
12e41d03 3944{
11ca3587 3945 nb_cli_enqueue_change(vty, "./query-interval", NB_OP_DESTROY, NULL);
12e41d03 3946
3051f443 3947 return nb_cli_apply_changes(vty, FRR_GMP_INTERFACE_XPATH,
3948 "frr-routing:ipv4");
12e41d03
DL
3949}
3950
b05b72e8
DW
3951DEFUN (interface_ip_igmp_version,
3952 interface_ip_igmp_version_cmd,
72e81cf4 3953 "ip igmp version (2-3)",
b05b72e8
DW
3954 IP_STR
3955 IFACE_IGMP_STR
3956 "IGMP version\n"
3957 "IGMP version number\n")
3958{
3051f443 3959 nb_cli_enqueue_change(vty, "./enable", NB_OP_MODIFY,
521c5b9d 3960 "true");
3051f443 3961 nb_cli_enqueue_change(vty, "./igmp-version", NB_OP_MODIFY,
3962 argv[3]->arg);
d62a17ae 3963
3051f443 3964 return nb_cli_apply_changes(vty, FRR_GMP_INTERFACE_XPATH,
3965 "frr-routing:ipv4");
b05b72e8
DW
3966}
3967
3968DEFUN (interface_no_ip_igmp_version,
3969 interface_no_ip_igmp_version_cmd,
72e81cf4 3970 "no ip igmp version (2-3)",
b05b72e8
DW
3971 NO_STR
3972 IP_STR
3973 IFACE_IGMP_STR
3974 "IGMP version\n"
3975 "IGMP version number\n")
3976{
3051f443 3977 nb_cli_enqueue_change(vty, "./igmp-version", NB_OP_DESTROY, NULL);
b05b72e8 3978
3051f443 3979 return nb_cli_apply_changes(vty, FRR_GMP_INTERFACE_XPATH,
3980 "frr-routing:ipv4");
b05b72e8
DW
3981}
3982
c8b3d45d 3983DEFPY (interface_ip_igmp_query_max_response_time,
12e41d03 3984 interface_ip_igmp_query_max_response_time_cmd,
c8b3d45d 3985 "ip igmp query-max-response-time (1-65535)$qmrt",
12e41d03
DL
3986 IP_STR
3987 IFACE_IGMP_STR
3988 IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_STR
58344b65 3989 "Query response value in deci-seconds\n")
12e41d03 3990{
c8b3d45d 3991 return gm_process_query_max_response_time_cmd(vty, qmrt_str);
12e41d03
DL
3992}
3993
3994DEFUN (interface_no_ip_igmp_query_max_response_time,
3995 interface_no_ip_igmp_query_max_response_time_cmd,
11ca3587 3996 "no ip igmp query-max-response-time [(1-65535)]",
12e41d03
DL
3997 NO_STR
3998 IP_STR
3999 IFACE_IGMP_STR
a957a05b 4000 IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_STR
11ca3587 4001 IGNORED_IN_NO_STR)
12e41d03 4002{
c8b3d45d 4003 return gm_process_no_query_max_response_time_cmd(vty);
12e41d03
DL
4004}
4005
58344b65
DS
4006DEFUN_HIDDEN (interface_ip_igmp_query_max_response_time_dsec,
4007 interface_ip_igmp_query_max_response_time_dsec_cmd,
11ca3587 4008 "ip igmp query-max-response-time-dsec (1-65535)",
58344b65
DS
4009 IP_STR
4010 IFACE_IGMP_STR
4011 IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC_STR
4012 "Query response value in deciseconds\n")
12e41d03 4013{
b0475d5a 4014 const struct lyd_node *pim_enable_dnode;
d62a17ae 4015
3bb513c3
CH
4016 pim_enable_dnode =
4017 yang_dnode_getf(vty->candidate_config->dnode,
698f4147 4018 FRR_PIM_ENABLE_XPATH, VTY_CURR_XPATH,
4019 "frr-routing:ipv4");
b0475d5a 4020 if (!pim_enable_dnode) {
3051f443 4021 nb_cli_enqueue_change(vty, "./enable", NB_OP_MODIFY,
521c5b9d 4022 "true");
b0475d5a
SP
4023 } else {
4024 if (!yang_dnode_get_bool(pim_enable_dnode, "."))
3051f443 4025 nb_cli_enqueue_change(vty, "./enable",
521c5b9d 4026 NB_OP_MODIFY, "true");
d62a17ae 4027 }
12e41d03 4028
b0475d5a 4029 nb_cli_enqueue_change(vty, "./query-max-response-time", NB_OP_MODIFY,
521c5b9d 4030 argv[3]->arg);
12e41d03 4031
3051f443 4032 return nb_cli_apply_changes(vty, FRR_GMP_INTERFACE_XPATH,
4033 "frr-routing:ipv4");
12e41d03
DL
4034}
4035
58344b65
DS
4036DEFUN_HIDDEN (interface_no_ip_igmp_query_max_response_time_dsec,
4037 interface_no_ip_igmp_query_max_response_time_dsec_cmd,
11ca3587 4038 "no ip igmp query-max-response-time-dsec [(1-65535)]",
58344b65
DS
4039 NO_STR
4040 IP_STR
4041 IFACE_IGMP_STR
11ca3587
CH
4042 IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC_STR
4043 IGNORED_IN_NO_STR)
12e41d03 4044{
11ca3587
CH
4045 nb_cli_enqueue_change(vty, "./query-max-response-time", NB_OP_DESTROY,
4046 NULL);
12e41d03 4047
3051f443 4048 return nb_cli_apply_changes(vty, FRR_GMP_INTERFACE_XPATH,
4049 "frr-routing:ipv4");
12e41d03
DL
4050}
4051
c889adcb 4052DEFPY (interface_ip_igmp_last_member_query_count,
59115451 4053 interface_ip_igmp_last_member_query_count_cmd,
c889adcb 4054 "ip igmp last-member-query-count (1-255)$lmqc",
59115451
SP
4055 IP_STR
4056 IFACE_IGMP_STR
4057 IFACE_IGMP_LAST_MEMBER_QUERY_COUNT_STR
4058 "Last member query count\n")
4059{
c889adcb 4060 return gm_process_last_member_query_count_cmd(vty, lmqc_str);
59115451
SP
4061}
4062
4063DEFUN (interface_no_ip_igmp_last_member_query_count,
4064 interface_no_ip_igmp_last_member_query_count_cmd,
11ca3587 4065 "no ip igmp last-member-query-count [(1-255)]",
59115451
SP
4066 NO_STR
4067 IP_STR
4068 IFACE_IGMP_STR
bb9ff200 4069 IFACE_IGMP_LAST_MEMBER_QUERY_COUNT_STR
11ca3587 4070 IGNORED_IN_NO_STR)
59115451 4071{
c889adcb 4072 return gm_process_no_last_member_query_count_cmd(vty);
59115451
SP
4073}
4074
e7ec758d 4075DEFPY (interface_ip_igmp_last_member_query_interval,
59115451 4076 interface_ip_igmp_last_member_query_interval_cmd,
e7ec758d 4077 "ip igmp last-member-query-interval (1-65535)$lmqi",
59115451
SP
4078 IP_STR
4079 IFACE_IGMP_STR
4080 IFACE_IGMP_LAST_MEMBER_QUERY_INTERVAL_STR
4081 "Last member query interval in deciseconds\n")
4082{
e7ec758d 4083 return gm_process_last_member_query_interval_cmd(vty, lmqi_str);
59115451
SP
4084}
4085
4086DEFUN (interface_no_ip_igmp_last_member_query_interval,
4087 interface_no_ip_igmp_last_member_query_interval_cmd,
11ca3587 4088 "no ip igmp last-member-query-interval [(1-65535)]",
59115451
SP
4089 NO_STR
4090 IP_STR
4091 IFACE_IGMP_STR
bb9ff200 4092 IFACE_IGMP_LAST_MEMBER_QUERY_INTERVAL_STR
11ca3587 4093 IGNORED_IN_NO_STR)
59115451 4094{
e7ec758d 4095 return gm_process_no_last_member_query_interval_cmd(vty);
59115451
SP
4096}
4097
dedccda6
DS
4098DEFUN (interface_ip_pim_drprio,
4099 interface_ip_pim_drprio_cmd,
b181fa04 4100 "ip pim drpriority (1-4294967295)",
dedccda6
DS
4101 IP_STR
4102 PIM_STR
4103 "Set the Designated Router Election Priority\n"
4104 "Value of the new DR Priority\n")
4105{
d62a17ae 4106 int idx_number = 3;
dedccda6 4107
bb387611 4108 return pim_process_ip_pim_drprio_cmd(vty, argv[idx_number]->arg);
dedccda6
DS
4109}
4110
4111DEFUN (interface_no_ip_pim_drprio,
4112 interface_no_ip_pim_drprio_cmd,
b181fa04 4113 "no ip pim drpriority [(1-4294967295)]",
d7fa34c1 4114 NO_STR
dedccda6
DS
4115 IP_STR
4116 PIM_STR
4117 "Revert the Designated Router Priority to default\n"
4118 "Old Value of the Priority\n")
4119{
bb387611 4120 return pim_process_no_ip_pim_drprio_cmd(vty);
dedccda6
DS
4121}
4122
6741a5bb 4123DEFPY_HIDDEN (interface_ip_igmp_query_generate,
521c5b9d
MS
4124 interface_ip_igmp_query_generate_cmd,
4125 "ip igmp generate-query-once [version (2-3)]",
4126 IP_STR
4127 IFACE_IGMP_STR
4128 "Generate igmp general query once\n"
4129 "IGMP version\n"
4130 "IGMP version number\n")
6741a5bb 4131{
5a46a3de 4132#if PIM_IPV == 4
6741a5bb 4133 VTY_DECLVAR_CONTEXT(interface, ifp);
761e4fba 4134 int igmp_version;
4135 struct pim_interface *pim_ifp = ifp->info;
6741a5bb 4136
4137 if (!ifp->info) {
4138 vty_out(vty, "IGMP/PIM is not enabled on the interface %s\n",
4139 ifp->name);
4140 return CMD_WARNING_CONFIG_FAILED;
4141 }
4142
761e4fba 4143 /* It takes the igmp version configured on the interface as default */
dfc26ad1 4144 igmp_version = pim_ifp->igmp_version;
761e4fba 4145
6741a5bb 4146 if (argc > 3)
4147 igmp_version = atoi(argv[4]->arg);
4148
4149 igmp_send_query_on_intf(ifp, igmp_version);
5a46a3de 4150#endif
6741a5bb 4151 return CMD_SUCCESS;
4152}
4153
70fd22bd
DS
4154DEFPY_HIDDEN (pim_test_sg_keepalive,
4155 pim_test_sg_keepalive_cmd,
4156 "test pim [vrf NAME$name] keepalive-reset A.B.C.D$source A.B.C.D$group",
4157 "Test code\n"
4158 PIM_STR
4159 VRF_CMD_HELP_STR
4160 "Reset the Keepalive Timer\n"
4161 "The Source we are resetting\n"
4162 "The Group we are resetting\n")
4163{
4164 struct pim_upstream *up;
af9c8e76 4165 struct vrf *vrf;
70fd22bd 4166 struct pim_instance *pim;
6fff2cc6 4167 pim_sgaddr sg;
70fd22bd
DS
4168
4169 sg.src = source;
4170 sg.grp = group;
4171
af9c8e76
SP
4172 vrf = vrf_lookup_by_name(name ? name : VRF_DEFAULT_NAME);
4173 if (!vrf) {
4174 vty_out(vty, "%% Vrf specified: %s does not exist\n", name);
4175 return CMD_WARNING;
70fd22bd
DS
4176 }
4177
af9c8e76
SP
4178 pim = vrf->info;
4179
70fd22bd
DS
4180 if (!pim) {
4181 vty_out(vty, "%% Unable to find pim instance\n");
4182 return CMD_WARNING;
4183 }
4184
4185 up = pim_upstream_find(pim, &sg);
4186 if (!up) {
98a81d2b 4187 vty_out(vty, "%% Unable to find %pSG specified\n", &sg);
70fd22bd
DS
4188 return CMD_WARNING;
4189 }
4190
98a81d2b
DL
4191 vty_out(vty, "Setting %pSG to current keep alive time: %d\n", &sg,
4192 pim->keep_alive_time);
70fd22bd
DS
4193 pim_upstream_keep_alive_timer_start(up, pim->keep_alive_time);
4194
4195 return CMD_SUCCESS;
4196}
4197
17823cdd
DS
4198DEFPY (interface_ip_pim_activeactive,
4199 interface_ip_pim_activeactive_cmd,
4200 "[no$no] ip pim active-active",
4201 NO_STR
4202 IP_STR
4203 PIM_STR
4204 "Mark interface as Active-Active for MLAG operations, Hidden because not finished yet\n")
414d885a 4205{
7e01b641 4206 return pim_process_ip_pim_activeactive_cmd(vty, no);
414d885a
DS
4207}
4208
d2772e7b 4209DEFUN_HIDDEN (interface_ip_pim_ssm,
521c5b9d
MS
4210 interface_ip_pim_ssm_cmd,
4211 "ip pim ssm",
4212 IP_STR
4213 PIM_STR
4214 IFACE_PIM_STR)
981d6c7a 4215{
50d194f8 4216 int ret;
43e40fdf 4217
dab0ac29 4218 ret = pim_process_ip_pim_cmd(vty);
981d6c7a 4219
50d194f8
SP
4220 if (ret != NB_OK)
4221 return ret;
ecca97ac 4222
50d194f8
SP
4223 vty_out(vty,
4224 "WARN: Enabled PIM SM on interface; configure PIM SSM range if needed\n");
c992c9a0 4225
50d194f8 4226 return NB_OK;
981d6c7a
DS
4227}
4228
2f5e937c 4229DEFUN_HIDDEN (interface_ip_pim_sm,
521c5b9d
MS
4230 interface_ip_pim_sm_cmd,
4231 "ip pim sm",
4232 IP_STR
4233 PIM_STR
4234 IFACE_PIM_SM_STR)
2f5e937c 4235{
2b16b40f 4236 return pim_process_ip_pim_cmd(vty);
2f5e937c 4237}
4238
d017bf3c 4239DEFPY (interface_ip_pim,
2f5e937c 4240 interface_ip_pim_cmd,
d017bf3c 4241 "ip pim [passive$passive]",
2f5e937c 4242 IP_STR
d017bf3c 4243 PIM_STR
4244 "Disable exchange of protocol packets\n")
2f5e937c 4245{
d017bf3c 4246 int ret;
4247
4248 ret = pim_process_ip_pim_cmd(vty);
4249
4250 if (ret != NB_OK)
4251 return ret;
4252
d017bf3c 4253 if (passive)
9726536d 4254 return pim_process_ip_pim_passive_cmd(vty, true);
d017bf3c 4255
4256 return CMD_SUCCESS;
2f5e937c 4257}
4258
d2772e7b 4259DEFUN_HIDDEN (interface_no_ip_pim_ssm,
521c5b9d
MS
4260 interface_no_ip_pim_ssm_cmd,
4261 "no ip pim ssm",
4262 NO_STR
4263 IP_STR
4264 PIM_STR
4265 IFACE_PIM_STR)
981d6c7a 4266{
dab0ac29 4267 return pim_process_no_ip_pim_cmd(vty);
981d6c7a
DS
4268}
4269
2f5e937c 4270DEFUN_HIDDEN (interface_no_ip_pim_sm,
521c5b9d
MS
4271 interface_no_ip_pim_sm_cmd,
4272 "no ip pim sm",
4273 NO_STR
4274 IP_STR
4275 PIM_STR
4276 IFACE_PIM_SM_STR)
981d6c7a 4277{
2b16b40f 4278 return pim_process_no_ip_pim_cmd(vty);
2f5e937c 4279}
981d6c7a 4280
d017bf3c 4281DEFPY (interface_no_ip_pim,
2f5e937c 4282 interface_no_ip_pim_cmd,
d017bf3c 4283 "no ip pim [passive$passive]",
2f5e937c 4284 NO_STR
4285 IP_STR
d017bf3c 4286 PIM_STR
4287 "Disable exchange of protocol packets\n")
2f5e937c 4288{
d017bf3c 4289 if (passive)
9726536d 4290 return pim_process_ip_pim_passive_cmd(vty, false);
d017bf3c 4291
9726536d 4292 return pim_process_no_ip_pim_cmd(vty);
12e41d03
DL
4293}
4294
b0f525a8
QY
4295/* boundaries */
4296DEFUN(interface_ip_pim_boundary_oil,
4297 interface_ip_pim_boundary_oil_cmd,
4298 "ip multicast boundary oil WORD",
4299 IP_STR
4300 "Generic multicast configuration options\n"
4301 "Define multicast boundary\n"
4302 "Filter OIL by group using prefix list\n"
513c8462 4303 "Prefix list to filter OIL with\n")
b0f525a8 4304{
52c52d78 4305 return pim_process_ip_pim_boundary_oil_cmd(vty, argv[4]->arg);
b0f525a8
QY
4306}
4307
4308DEFUN(interface_no_ip_pim_boundary_oil,
4309 interface_no_ip_pim_boundary_oil_cmd,
4310 "no ip multicast boundary oil [WORD]",
4311 NO_STR
4312 IP_STR
4313 "Generic multicast configuration options\n"
4314 "Define multicast boundary\n"
4315 "Filter OIL by group using prefix list\n"
513c8462 4316 "Prefix list to filter OIL with\n")
b0f525a8 4317{
52c52d78 4318 return pim_process_no_ip_pim_boundary_oil_cmd(vty);
b0f525a8
QY
4319}
4320
6250610a
JAG
4321DEFUN (interface_ip_mroute,
4322 interface_ip_mroute_cmd,
e57cc5f0 4323 "ip mroute INTERFACE A.B.C.D [A.B.C.D]",
6250610a
JAG
4324 IP_STR
4325 "Add multicast route\n"
4326 "Outgoing interface name\n"
4327 "Group address\n"
4328 "Source address\n")
4329{
d62a17ae 4330 int idx_interface = 2;
4331 int idx_ipv4 = 3;
675c8fde 4332 const char *source_str;
d62a17ae 4333
675c8fde
SP
4334 if (argc == (idx_ipv4 + 1))
4335 source_str = "0.0.0.0";
4336 else
4337 source_str = argv[idx_ipv4 + 1]->arg;
d62a17ae 4338
63ee25c0 4339 return pim_process_ip_mroute_cmd(vty, argv[idx_interface]->arg,
4340 argv[idx_ipv4]->arg, source_str);
6250610a
JAG
4341}
4342
4343DEFUN (interface_no_ip_mroute,
4344 interface_no_ip_mroute_cmd,
e57cc5f0 4345 "no ip mroute INTERFACE A.B.C.D [A.B.C.D]",
6250610a
JAG
4346 NO_STR
4347 IP_STR
4348 "Add multicast route\n"
4349 "Outgoing interface name\n"
4350 "Group Address\n"
4351 "Source Address\n")
4352{
63ee25c0 4353 int idx_interface = 3;
d62a17ae 4354 int idx_ipv4 = 4;
675c8fde 4355 const char *source_str;
d62a17ae 4356
675c8fde
SP
4357 if (argc == (idx_ipv4 + 1))
4358 source_str = "0.0.0.0";
4359 else
4360 source_str = argv[idx_ipv4 + 1]->arg;
d62a17ae 4361
63ee25c0 4362 return pim_process_no_ip_mroute_cmd(vty, argv[idx_interface]->arg,
4363 argv[idx_ipv4]->arg, source_str);
6250610a
JAG
4364}
4365
7960fa8f
DS
4366DEFUN (interface_ip_pim_hello,
4367 interface_ip_pim_hello_cmd,
11ca3587 4368 "ip pim hello (1-65535) [(1-65535)]",
7960fa8f
DS
4369 IP_STR
4370 PIM_STR
4371 IFACE_PIM_HELLO_STR
80d3d26b
DW
4372 IFACE_PIM_HELLO_TIME_STR
4373 IFACE_PIM_HELLO_HOLD_STR)
7960fa8f 4374{
d62a17ae 4375 int idx_time = 3;
4376 int idx_hold = 4;
7960fa8f 4377
d62a17ae 4378 if (argc == idx_hold + 1)
e6aab613 4379 return pim_process_ip_pim_hello_cmd(vty, argv[idx_time]->arg,
4380 argv[idx_hold]->arg);
7960fa8f 4381
e6aab613 4382 else
4383 return pim_process_ip_pim_hello_cmd(vty, argv[idx_time]->arg,
4384 NULL);
7960fa8f
DS
4385}
4386
7960fa8f
DS
4387DEFUN (interface_no_ip_pim_hello,
4388 interface_no_ip_pim_hello_cmd,
11ca3587 4389 "no ip pim hello [(1-65535) [(1-65535)]]",
7960fa8f
DS
4390 NO_STR
4391 IP_STR
4392 PIM_STR
4393 IFACE_PIM_HELLO_STR
11ca3587
CH
4394 IGNORED_IN_NO_STR
4395 IGNORED_IN_NO_STR)
7960fa8f 4396{
e6aab613 4397 return pim_process_no_ip_pim_hello_cmd(vty);
7960fa8f
DS
4398}
4399
12e41d03
DL
4400DEFUN (debug_igmp,
4401 debug_igmp_cmd,
4402 "debug igmp",
4403 DEBUG_STR
4404 DEBUG_IGMP_STR)
4405{
d62a17ae 4406 PIM_DO_DEBUG_IGMP_EVENTS;
4407 PIM_DO_DEBUG_IGMP_PACKETS;
4408 PIM_DO_DEBUG_IGMP_TRACE;
4409 return CMD_SUCCESS;
12e41d03
DL
4410}
4411
4412DEFUN (no_debug_igmp,
4413 no_debug_igmp_cmd,
4414 "no debug igmp",
4415 NO_STR
4416 DEBUG_STR
4417 DEBUG_IGMP_STR)
4418{
d62a17ae 4419 PIM_DONT_DEBUG_IGMP_EVENTS;
4420 PIM_DONT_DEBUG_IGMP_PACKETS;
4421 PIM_DONT_DEBUG_IGMP_TRACE;
4422 return CMD_SUCCESS;
12e41d03
DL
4423}
4424
12e41d03
DL
4425
4426DEFUN (debug_igmp_events,
4427 debug_igmp_events_cmd,
4428 "debug igmp events",
4429 DEBUG_STR
4430 DEBUG_IGMP_STR
4431 DEBUG_IGMP_EVENTS_STR)
4432{
d62a17ae 4433 PIM_DO_DEBUG_IGMP_EVENTS;
4434 return CMD_SUCCESS;
12e41d03
DL
4435}
4436
4437DEFUN (no_debug_igmp_events,
4438 no_debug_igmp_events_cmd,
4439 "no debug igmp events",
4440 NO_STR
4441 DEBUG_STR
4442 DEBUG_IGMP_STR
4443 DEBUG_IGMP_EVENTS_STR)
4444{
d62a17ae 4445 PIM_DONT_DEBUG_IGMP_EVENTS;
4446 return CMD_SUCCESS;
12e41d03
DL
4447}
4448
12e41d03
DL
4449
4450DEFUN (debug_igmp_packets,
4451 debug_igmp_packets_cmd,
4452 "debug igmp packets",
4453 DEBUG_STR
4454 DEBUG_IGMP_STR
4455 DEBUG_IGMP_PACKETS_STR)
4456{
d62a17ae 4457 PIM_DO_DEBUG_IGMP_PACKETS;
4458 return CMD_SUCCESS;
12e41d03
DL
4459}
4460
4461DEFUN (no_debug_igmp_packets,
4462 no_debug_igmp_packets_cmd,
4463 "no debug igmp packets",
4464 NO_STR
4465 DEBUG_STR
4466 DEBUG_IGMP_STR
4467 DEBUG_IGMP_PACKETS_STR)
4468{
d62a17ae 4469 PIM_DONT_DEBUG_IGMP_PACKETS;
4470 return CMD_SUCCESS;
12e41d03
DL
4471}
4472
12e41d03
DL
4473
4474DEFUN (debug_igmp_trace,
4475 debug_igmp_trace_cmd,
4476 "debug igmp trace",
4477 DEBUG_STR
4478 DEBUG_IGMP_STR
4479 DEBUG_IGMP_TRACE_STR)
4480{
d62a17ae 4481 PIM_DO_DEBUG_IGMP_TRACE;
4482 return CMD_SUCCESS;
12e41d03
DL
4483}
4484
4485DEFUN (no_debug_igmp_trace,
4486 no_debug_igmp_trace_cmd,
4487 "no debug igmp trace",
4488 NO_STR
4489 DEBUG_STR
4490 DEBUG_IGMP_STR
4491 DEBUG_IGMP_TRACE_STR)
4492{
d62a17ae 4493 PIM_DONT_DEBUG_IGMP_TRACE;
4494 return CMD_SUCCESS;
12e41d03
DL
4495}
4496
12e41d03 4497
e9c59240
DL
4498DEFUN (debug_igmp_trace_detail,
4499 debug_igmp_trace_detail_cmd,
4500 "debug igmp trace detail",
4501 DEBUG_STR
4502 DEBUG_IGMP_STR
4503 DEBUG_IGMP_TRACE_STR
4504 "detailed\n")
4505{
4506 PIM_DO_DEBUG_IGMP_TRACE_DETAIL;
4507 return CMD_SUCCESS;
4508}
4509
4510DEFUN (no_debug_igmp_trace_detail,
4511 no_debug_igmp_trace_detail_cmd,
4512 "no debug igmp trace detail",
4513 NO_STR
4514 DEBUG_STR
4515 DEBUG_IGMP_STR
4516 DEBUG_IGMP_TRACE_STR
4517 "detailed\n")
4518{
4519 PIM_DONT_DEBUG_IGMP_TRACE_DETAIL;
4520 return CMD_SUCCESS;
4521}
4522
4523
12e41d03
DL
4524DEFUN (debug_mroute,
4525 debug_mroute_cmd,
4526 "debug mroute",
4527 DEBUG_STR
4528 DEBUG_MROUTE_STR)
4529{
d62a17ae 4530 PIM_DO_DEBUG_MROUTE;
4531 return CMD_SUCCESS;
12e41d03
DL
4532}
4533
6c7197b1
DS
4534DEFUN (debug_mroute_detail,
4535 debug_mroute_detail_cmd,
4536 "debug mroute detail",
4537 DEBUG_STR
4538 DEBUG_MROUTE_STR
4539 "detailed\n")
4540{
d62a17ae 4541 PIM_DO_DEBUG_MROUTE_DETAIL;
4542 return CMD_SUCCESS;
6c7197b1
DS
4543}
4544
12e41d03
DL
4545DEFUN (no_debug_mroute,
4546 no_debug_mroute_cmd,
4547 "no debug mroute",
4548 NO_STR
4549 DEBUG_STR
4550 DEBUG_MROUTE_STR)
4551{
d62a17ae 4552 PIM_DONT_DEBUG_MROUTE;
4553 return CMD_SUCCESS;
12e41d03
DL
4554}
4555
6c7197b1
DS
4556DEFUN (no_debug_mroute_detail,
4557 no_debug_mroute_detail_cmd,
4558 "no debug mroute detail",
4559 NO_STR
4560 DEBUG_STR
4561 DEBUG_MROUTE_STR
4562 "detailed\n")
4563{
d62a17ae 4564 PIM_DONT_DEBUG_MROUTE_DETAIL;
4565 return CMD_SUCCESS;
6c7197b1 4566}
12e41d03 4567
35a12720
MS
4568DEFUN (debug_pim_static,
4569 debug_pim_static_cmd,
4570 "debug pim static",
6250610a 4571 DEBUG_STR
35a12720 4572 DEBUG_PIM_STR
6250610a
JAG
4573 DEBUG_STATIC_STR)
4574{
d62a17ae 4575 PIM_DO_DEBUG_STATIC;
4576 return CMD_SUCCESS;
6250610a
JAG
4577}
4578
35a12720
MS
4579DEFUN (no_debug_pim_static,
4580 no_debug_pim_static_cmd,
4581 "no debug pim static",
6250610a
JAG
4582 NO_STR
4583 DEBUG_STR
35a12720 4584 DEBUG_PIM_STR
6250610a
JAG
4585 DEBUG_STATIC_STR)
4586{
d62a17ae 4587 PIM_DONT_DEBUG_STATIC;
4588 return CMD_SUCCESS;
6250610a
JAG
4589}
4590
6250610a 4591
bf385e26 4592DEFPY (debug_pim,
12e41d03 4593 debug_pim_cmd,
bf385e26 4594 "[no] debug pim",
12e41d03
DL
4595 NO_STR
4596 DEBUG_STR
4597 DEBUG_PIM_STR)
4598{
bf385e26
SG
4599 if (!no)
4600 return pim_debug_pim_cmd();
4601 else
4602 return pim_no_debug_pim_cmd();
12e41d03
DL
4603}
4604
dcfd5abe 4605DEFPY (debug_pim_nht,
40f1f31b 4606 debug_pim_nht_cmd,
dcfd5abe 4607 "[no] debug pim nht",
40f1f31b
DS
4608 NO_STR
4609 DEBUG_STR
4610 DEBUG_PIM_STR
4611 "Nexthop Tracking\n")
4612{
dcfd5abe
SG
4613 if (!no)
4614 PIM_DO_DEBUG_PIM_NHT;
4615 else
4616 PIM_DONT_DEBUG_PIM_NHT;
40f1f31b
DS
4617 return CMD_SUCCESS;
4618}
12e41d03 4619
dcfd5abe 4620DEFPY (debug_pim_nht_det,
6d733f0d 4621 debug_pim_nht_det_cmd,
dcfd5abe 4622 "[no] debug pim nht detail",
6d733f0d
SG
4623 NO_STR
4624 DEBUG_STR
4625 DEBUG_PIM_STR
4626 "Nexthop Tracking\n"
4627 "Detailed Information\n")
4628{
dcfd5abe
SG
4629 if (!no)
4630 PIM_DO_DEBUG_PIM_NHT_DETAIL;
4631 else
4632 PIM_DONT_DEBUG_PIM_NHT_DETAIL;
6d733f0d
SG
4633 return CMD_SUCCESS;
4634}
4635
3d225d48
DS
4636DEFUN (debug_pim_nht_rp,
4637 debug_pim_nht_rp_cmd,
4638 "debug pim nht rp",
4639 DEBUG_STR
4640 DEBUG_PIM_STR
4641 "Nexthop Tracking\n"
4642 "RP Nexthop Tracking\n")
4643{
4644 PIM_DO_DEBUG_PIM_NHT_RP;
4645 return CMD_SUCCESS;
4646}
4647
4648DEFUN (no_debug_pim_nht_rp,
4649 no_debug_pim_nht_rp_cmd,
4650 "no debug pim nht rp",
4651 NO_STR
4652 DEBUG_STR
4653 DEBUG_PIM_STR
4654 "Nexthop Tracking\n"
4655 "RP Nexthop Tracking\n")
4656{
4657 PIM_DONT_DEBUG_PIM_NHT_RP;
4658 return CMD_SUCCESS;
4659}
4660
c51c7de2 4661DEFPY (debug_pim_events,
12e41d03 4662 debug_pim_events_cmd,
c51c7de2 4663 "[no] debug pim events",
12e41d03
DL
4664 NO_STR
4665 DEBUG_STR
4666 DEBUG_PIM_STR
4667 DEBUG_PIM_EVENTS_STR)
4668{
c51c7de2
SG
4669 if (!no)
4670 PIM_DO_DEBUG_PIM_EVENTS;
4671 else
4672 PIM_DONT_DEBUG_PIM_EVENTS;
d62a17ae 4673 return CMD_SUCCESS;
12e41d03
DL
4674}
4675
60940ee2 4676DEFPY (debug_pim_packets,
12e41d03 4677 debug_pim_packets_cmd,
60940ee2
SG
4678 "[no] debug pim packets [<hello$hello|joins$joins|register$registers>]",
4679 NO_STR DEBUG_STR
12e41d03
DL
4680 DEBUG_PIM_STR
4681 DEBUG_PIM_PACKETS_STR
4682 DEBUG_PIM_HELLO_PACKETS_STR
9add3b88
DS
4683 DEBUG_PIM_J_P_PACKETS_STR
4684 DEBUG_PIM_PIM_REG_PACKETS_STR)
12e41d03 4685{
60940ee2
SG
4686 if (!no)
4687 return pim_debug_pim_packets_cmd(hello, joins, registers, vty);
4688 else
4689 return pim_no_debug_pim_packets_cmd(hello, joins, registers,
4690 vty);
12e41d03
DL
4691}
4692
d05746d4 4693DEFPY (debug_pim_packetdump_send,
12e41d03 4694 debug_pim_packetdump_send_cmd,
d05746d4 4695 "[no] debug pim packet-dump send",
12e41d03
DL
4696 NO_STR
4697 DEBUG_STR
4698 DEBUG_PIM_STR
4699 DEBUG_PIM_PACKETDUMP_STR
4700 DEBUG_PIM_PACKETDUMP_SEND_STR)
4701{
d05746d4
SG
4702 if (!no)
4703 PIM_DO_DEBUG_PIM_PACKETDUMP_SEND;
4704 else
4705 PIM_DONT_DEBUG_PIM_PACKETDUMP_SEND;
d62a17ae 4706 return CMD_SUCCESS;
12e41d03
DL
4707}
4708
d05746d4 4709DEFPY (debug_pim_packetdump_recv,
12e41d03 4710 debug_pim_packetdump_recv_cmd,
d05746d4 4711 "[no] debug pim packet-dump receive",
12e41d03
DL
4712 NO_STR
4713 DEBUG_STR
4714 DEBUG_PIM_STR
4715 DEBUG_PIM_PACKETDUMP_STR
4716 DEBUG_PIM_PACKETDUMP_RECV_STR)
4717{
d05746d4
SG
4718 if (!no)
4719 PIM_DO_DEBUG_PIM_PACKETDUMP_RECV;
4720 else
4721 PIM_DONT_DEBUG_PIM_PACKETDUMP_RECV;
d62a17ae 4722 return CMD_SUCCESS;
12e41d03
DL
4723}
4724
904dbf53 4725DEFPY (debug_pim_trace,
12e41d03 4726 debug_pim_trace_cmd,
904dbf53 4727 "[no] debug pim trace",
12e41d03
DL
4728 NO_STR
4729 DEBUG_STR
4730 DEBUG_PIM_STR
4731 DEBUG_PIM_TRACE_STR)
4732{
904dbf53
SG
4733 if (!no)
4734 PIM_DO_DEBUG_PIM_TRACE;
4735 else
4736 PIM_DONT_DEBUG_PIM_TRACE;
d62a17ae 4737 return CMD_SUCCESS;
12e41d03
DL
4738}
4739
904dbf53
SG
4740DEFPY (debug_pim_trace_detail,
4741 debug_pim_trace_detail_cmd,
4742 "[no] debug pim trace detail",
56c238c9
DS
4743 NO_STR
4744 DEBUG_STR
4745 DEBUG_PIM_STR
bd4d05c5
DS
4746 DEBUG_PIM_TRACE_STR
4747 "Detailed Information\n")
56c238c9 4748{
904dbf53
SG
4749 if (!no)
4750 PIM_DO_DEBUG_PIM_TRACE_DETAIL;
4751 else
4752 PIM_DONT_DEBUG_PIM_TRACE_DETAIL;
56c238c9
DS
4753 return CMD_SUCCESS;
4754}
4755
12e41d03
DL
4756DEFUN (debug_ssmpingd,
4757 debug_ssmpingd_cmd,
4758 "debug ssmpingd",
4759 DEBUG_STR
12e41d03
DL
4760 DEBUG_SSMPINGD_STR)
4761{
d62a17ae 4762 PIM_DO_DEBUG_SSMPINGD;
4763 return CMD_SUCCESS;
12e41d03
DL
4764}
4765
4766DEFUN (no_debug_ssmpingd,
4767 no_debug_ssmpingd_cmd,
4768 "no debug ssmpingd",
4769 NO_STR
4770 DEBUG_STR
12e41d03
DL
4771 DEBUG_SSMPINGD_STR)
4772{
d62a17ae 4773 PIM_DONT_DEBUG_SSMPINGD;
4774 return CMD_SUCCESS;
12e41d03
DL
4775}
4776
fa5138d6 4777DEFPY (debug_pim_zebra,
12e41d03 4778 debug_pim_zebra_cmd,
fa5138d6 4779 "[no] debug pim zebra",
12e41d03
DL
4780 NO_STR
4781 DEBUG_STR
4782 DEBUG_PIM_STR
4783 DEBUG_PIM_ZEBRA_STR)
4784{
fa5138d6
SG
4785 if (!no)
4786 PIM_DO_DEBUG_ZEBRA;
4787 else
4788 PIM_DONT_DEBUG_ZEBRA;
d62a17ae 4789 return CMD_SUCCESS;
12e41d03
DL
4790}
4791
36b5b98f
SK
4792DEFUN(debug_pim_mlag, debug_pim_mlag_cmd, "debug pim mlag",
4793 DEBUG_STR DEBUG_PIM_STR DEBUG_PIM_MLAG_STR)
4794{
4795 PIM_DO_DEBUG_MLAG;
4796 return CMD_SUCCESS;
4797}
4798
4799DEFUN(no_debug_pim_mlag, no_debug_pim_mlag_cmd, "no debug pim mlag",
4800 NO_STR DEBUG_STR DEBUG_PIM_STR DEBUG_PIM_MLAG_STR)
4801{
4802 PIM_DONT_DEBUG_MLAG;
4803 return CMD_SUCCESS;
4804}
4805
4d913fa6
AK
4806DEFUN (debug_pim_vxlan,
4807 debug_pim_vxlan_cmd,
4808 "debug pim vxlan",
4809 DEBUG_STR
4810 DEBUG_PIM_STR
4811 DEBUG_PIM_VXLAN_STR)
4812{
4813 PIM_DO_DEBUG_VXLAN;
4814 return CMD_SUCCESS;
4815}
4816
4817DEFUN (no_debug_pim_vxlan,
4818 no_debug_pim_vxlan_cmd,
4819 "no debug pim vxlan",
4820 NO_STR
4821 DEBUG_STR
4822 DEBUG_PIM_STR
4823 DEBUG_PIM_VXLAN_STR)
4824{
4825 PIM_DONT_DEBUG_VXLAN;
4826 return CMD_SUCCESS;
4827}
4828
2a333e0f 4829DEFUN (debug_msdp,
4830 debug_msdp_cmd,
4831 "debug msdp",
4832 DEBUG_STR
4833 DEBUG_MSDP_STR)
4834{
d62a17ae 4835 PIM_DO_DEBUG_MSDP_EVENTS;
4836 PIM_DO_DEBUG_MSDP_PACKETS;
4837 return CMD_SUCCESS;
2a333e0f 4838}
4839
4840DEFUN (no_debug_msdp,
4841 no_debug_msdp_cmd,
4842 "no debug msdp",
4843 NO_STR
4844 DEBUG_STR
4845 DEBUG_MSDP_STR)
4846{
d62a17ae 4847 PIM_DONT_DEBUG_MSDP_EVENTS;
4848 PIM_DONT_DEBUG_MSDP_PACKETS;
4849 return CMD_SUCCESS;
2a333e0f 4850}
4851
2a333e0f 4852DEFUN (debug_msdp_events,
4853 debug_msdp_events_cmd,
4854 "debug msdp events",
4855 DEBUG_STR
4856 DEBUG_MSDP_STR
4857 DEBUG_MSDP_EVENTS_STR)
4858{
d62a17ae 4859 PIM_DO_DEBUG_MSDP_EVENTS;
4860 return CMD_SUCCESS;
2a333e0f 4861}
4862
4863DEFUN (no_debug_msdp_events,
4864 no_debug_msdp_events_cmd,
4865 "no debug msdp events",
4866 NO_STR
4867 DEBUG_STR
4868 DEBUG_MSDP_STR
4869 DEBUG_MSDP_EVENTS_STR)
4870{
d62a17ae 4871 PIM_DONT_DEBUG_MSDP_EVENTS;
4872 return CMD_SUCCESS;
2a333e0f 4873}
4874
2a333e0f 4875DEFUN (debug_msdp_packets,
4876 debug_msdp_packets_cmd,
4877 "debug msdp packets",
4878 DEBUG_STR
4879 DEBUG_MSDP_STR
4880 DEBUG_MSDP_PACKETS_STR)
4881{
d62a17ae 4882 PIM_DO_DEBUG_MSDP_PACKETS;
4883 return CMD_SUCCESS;
2a333e0f 4884}
4885
4886DEFUN (no_debug_msdp_packets,
4887 no_debug_msdp_packets_cmd,
4888 "no debug msdp packets",
4889 NO_STR
4890 DEBUG_STR
4891 DEBUG_MSDP_STR
4892 DEBUG_MSDP_PACKETS_STR)
4893{
d62a17ae 4894 PIM_DONT_DEBUG_MSDP_PACKETS;
4895 return CMD_SUCCESS;
2a333e0f 4896}
4897
4d9ad5dc
MS
4898DEFUN (debug_mtrace,
4899 debug_mtrace_cmd,
4900 "debug mtrace",
4901 DEBUG_STR
4902 DEBUG_MTRACE_STR)
4903{
4904 PIM_DO_DEBUG_MTRACE;
4905 return CMD_SUCCESS;
4906}
4907
4908DEFUN (no_debug_mtrace,
4909 no_debug_mtrace_cmd,
4910 "no debug mtrace",
4911 NO_STR
4912 DEBUG_STR
4913 DEBUG_MTRACE_STR)
4914{
4915 PIM_DONT_DEBUG_MTRACE;
4916 return CMD_SUCCESS;
4917}
4918
09524ccf 4919DEFUN (debug_bsm,
4920 debug_bsm_cmd,
4921 "debug pim bsm",
4922 DEBUG_STR
4923 DEBUG_PIM_STR
4924 DEBUG_PIM_BSM_STR)
4925{
4926 PIM_DO_DEBUG_BSM;
4927 return CMD_SUCCESS;
4928}
4929
4930DEFUN (no_debug_bsm,
4931 no_debug_bsm_cmd,
4932 "no debug pim bsm",
4933 NO_STR
4934 DEBUG_STR
4935 DEBUG_PIM_STR
4936 DEBUG_PIM_BSM_STR)
4937{
4938 PIM_DONT_DEBUG_BSM;
4939 return CMD_SUCCESS;
4940}
4941
4942
87f6dc50
DS
4943DEFUN_NOSH (show_debugging_pim,
4944 show_debugging_pim_cmd,
4945 "show debugging [pim]",
4946 SHOW_STR
4947 DEBUG_STR
4948 PIM_STR)
12e41d03 4949{
87f6dc50
DS
4950 vty_out(vty, "PIM debugging status\n");
4951
d62a17ae 4952 pim_debug_config_write(vty);
87f6dc50 4953
d62a17ae 4954 return CMD_SUCCESS;
12e41d03
DL
4955}
4956
4763cd0e 4957DEFUN (interface_pim_use_source,
4958 interface_pim_use_source_cmd,
4959 "ip pim use-source A.B.C.D",
4960 IP_STR
2f5e937c 4961 PIM_STR
4763cd0e 4962 "Configure primary IP address\n"
4963 "source ip address\n")
4964{
675c8fde
SP
4965 nb_cli_enqueue_change(vty, "./use-source", NB_OP_MODIFY, argv[3]->arg);
4966
4967 return nb_cli_apply_changes(vty,
698f4147 4968 FRR_PIM_INTERFACE_XPATH,
521c5b9d 4969 "frr-routing:ipv4");
4763cd0e 4970}
4971
4972DEFUN (interface_no_pim_use_source,
4973 interface_no_pim_use_source_cmd,
2243bb17 4974 "no ip pim use-source [A.B.C.D]",
4763cd0e 4975 NO_STR
4976 IP_STR
2f5e937c 4977 PIM_STR
2243bb17
DS
4978 "Delete source IP address\n"
4979 "source ip address\n")
4763cd0e 4980{
675c8fde
SP
4981 nb_cli_enqueue_change(vty, "./use-source", NB_OP_MODIFY, "0.0.0.0");
4982
4983 return nb_cli_apply_changes(vty,
698f4147 4984 FRR_PIM_INTERFACE_XPATH,
521c5b9d 4985 "frr-routing:ipv4");
4763cd0e 4986}
4987
745b8d4a 4988DEFPY (ip_pim_bfd,
ba4eb1bc 4989 ip_pim_bfd_cmd,
745b8d4a 4990 "ip pim bfd [profile BFDPROF$prof]",
ba4eb1bc
CS
4991 IP_STR
4992 PIM_STR
745b8d4a
RZ
4993 "Enables BFD support\n"
4994 "Use BFD profile\n"
4995 "Use BFD profile name\n")
ba4eb1bc 4996{
b73779d3 4997 const struct lyd_node *igmp_enable_dnode;
ba4eb1bc 4998
3bb513c3
CH
4999 igmp_enable_dnode =
5000 yang_dnode_getf(vty->candidate_config->dnode,
3051f443 5001 FRR_GMP_ENABLE_XPATH, VTY_CURR_XPATH,
5002 "frr-routing:ipv4");
b73779d3
SP
5003 if (!igmp_enable_dnode)
5004 nb_cli_enqueue_change(vty, "./pim-enable", NB_OP_MODIFY,
5c90f569 5005 "true");
b73779d3
SP
5006 else {
5007 if (!yang_dnode_get_bool(igmp_enable_dnode, "."))
5008 nb_cli_enqueue_change(vty, "./pim-enable", NB_OP_MODIFY,
5c90f569 5009 "true");
2fd8de7d 5010 }
2fd8de7d 5011
1f3e6bf5 5012 nb_cli_enqueue_change(vty, "./bfd", NB_OP_CREATE, NULL);
745b8d4a
RZ
5013 if (prof)
5014 nb_cli_enqueue_change(vty, "./bfd/profile", NB_OP_MODIFY, prof);
5015
698f4147 5016 return nb_cli_apply_changes(vty,
5017 FRR_PIM_INTERFACE_XPATH,
5018 "frr-routing:ipv4");
745b8d4a
RZ
5019}
5020
5021DEFPY(no_ip_pim_bfd_profile, no_ip_pim_bfd_profile_cmd,
5022 "no ip pim bfd profile [BFDPROF]",
5023 NO_STR
5024 IP_STR
5025 PIM_STR
5026 "Enables BFD support\n"
5027 "Disable BFD profile\n"
5028 "BFD Profile name\n")
5029{
5030 nb_cli_enqueue_change(vty, "./bfd/profile", NB_OP_DESTROY, NULL);
ba4eb1bc 5031
698f4147 5032 return nb_cli_apply_changes(vty,
5033 FRR_PIM_INTERFACE_XPATH,
5034 "frr-routing:ipv4");
ba4eb1bc
CS
5035}
5036
5037DEFUN (no_ip_pim_bfd,
5038 no_ip_pim_bfd_cmd,
5039 "no ip pim bfd",
5040 NO_STR
5041 IP_STR
5042 PIM_STR
5043 "Disables BFD support\n")
5044{
b73779d3 5045 nb_cli_enqueue_change(vty, "./bfd", NB_OP_DESTROY, NULL);
ba4eb1bc 5046
698f4147 5047 return nb_cli_apply_changes(vty,
5048 FRR_PIM_INTERFACE_XPATH,
5049 "frr-routing:ipv4");
ba4eb1bc
CS
5050}
5051
16c926c8 5052DEFUN (ip_pim_bsm,
5053 ip_pim_bsm_cmd,
5054 "ip pim bsm",
5055 IP_STR
5056 PIM_STR
5057 "Enables BSM support on the interface\n")
5058{
e3eb2bab 5059 const struct lyd_node *igmp_enable_dnode;
16c926c8 5060
3bb513c3
CH
5061 igmp_enable_dnode =
5062 yang_dnode_getf(vty->candidate_config->dnode,
3051f443 5063 FRR_GMP_ENABLE_XPATH, VTY_CURR_XPATH,
5064 "frr-routing:ipv4");
e3eb2bab
SP
5065 if (!igmp_enable_dnode)
5066 nb_cli_enqueue_change(vty, "./pim-enable", NB_OP_MODIFY,
5067 "true");
5068 else {
5069 if (!yang_dnode_get_bool(igmp_enable_dnode, "."))
5070 nb_cli_enqueue_change(vty, "./pim-enable", NB_OP_MODIFY,
5071 "true");
16c926c8 5072 }
5073
e3eb2bab 5074 nb_cli_enqueue_change(vty, "./bsm", NB_OP_MODIFY, "true");
16c926c8 5075
698f4147 5076 return nb_cli_apply_changes(vty,
5077 FRR_PIM_INTERFACE_XPATH, "frr-routing:ipv4");
16c926c8 5078}
5079
5080DEFUN (no_ip_pim_bsm,
5081 no_ip_pim_bsm_cmd,
5082 "no ip pim bsm",
5083 NO_STR
5084 IP_STR
5085 PIM_STR
5086 "Disables BSM support\n")
5087{
e3eb2bab 5088 nb_cli_enqueue_change(vty, "./bsm", NB_OP_MODIFY, "false");
16c926c8 5089
698f4147 5090 return nb_cli_apply_changes(vty,
5091 FRR_PIM_INTERFACE_XPATH, "frr-routing:ipv4");
16c926c8 5092}
5093
5094DEFUN (ip_pim_ucast_bsm,
5095 ip_pim_ucast_bsm_cmd,
5096 "ip pim unicast-bsm",
5097 IP_STR
5098 PIM_STR
5099 "Accept/Send unicast BSM on the interface\n")
5100{
e3eb2bab 5101 const struct lyd_node *igmp_enable_dnode;
16c926c8 5102
3bb513c3
CH
5103 igmp_enable_dnode =
5104 yang_dnode_getf(vty->candidate_config->dnode,
3051f443 5105 FRR_GMP_ENABLE_XPATH, VTY_CURR_XPATH,
5106 "frr-routing:ipv4");
e3eb2bab
SP
5107 if (!igmp_enable_dnode)
5108 nb_cli_enqueue_change(vty, "./pim-enable", NB_OP_MODIFY,
5109 "true");
5110 else {
5111 if (!yang_dnode_get_bool(igmp_enable_dnode, "."))
5112 nb_cli_enqueue_change(vty, "./pim-enable", NB_OP_MODIFY,
5113 "true");
16c926c8 5114 }
5115
e3eb2bab 5116 nb_cli_enqueue_change(vty, "./unicast-bsm", NB_OP_MODIFY, "true");
16c926c8 5117
698f4147 5118 return nb_cli_apply_changes(vty,
5119 FRR_PIM_INTERFACE_XPATH, "frr-routing:ipv4");
5120
16c926c8 5121}
5122
5123DEFUN (no_ip_pim_ucast_bsm,
5124 no_ip_pim_ucast_bsm_cmd,
5125 "no ip pim unicast-bsm",
5126 NO_STR
5127 IP_STR
5128 PIM_STR
5129 "Block send/receive unicast BSM on this interface\n")
5130{
e3eb2bab 5131 nb_cli_enqueue_change(vty, "./unicast-bsm", NB_OP_MODIFY, "false");
16c926c8 5132
698f4147 5133 return nb_cli_apply_changes(vty,
5134 FRR_PIM_INTERFACE_XPATH, "frr-routing:ipv4");
16c926c8 5135}
5136
64dc4b2d 5137#if HAVE_BFDD > 0
11ca3587 5138DEFUN_HIDDEN (
521c5b9d
MS
5139 ip_pim_bfd_param,
5140 ip_pim_bfd_param_cmd,
11ca3587 5141 "ip pim bfd (2-255) (1-65535) (1-65535)",
521c5b9d
MS
5142 IP_STR
5143 PIM_STR
5144 "Enables BFD support\n"
5145 "Detect Multiplier\n"
5146 "Required min receive interval\n"
5147 "Desired min transmit interval\n")
64dc4b2d 5148#else
521c5b9d
MS
5149 DEFUN(
5150 ip_pim_bfd_param,
5151 ip_pim_bfd_param_cmd,
11ca3587 5152 "ip pim bfd (2-255) (1-65535) (1-65535)",
521c5b9d
MS
5153 IP_STR
5154 PIM_STR
5155 "Enables BFD support\n"
5156 "Detect Multiplier\n"
5157 "Required min receive interval\n"
5158 "Desired min transmit interval\n")
3779776a 5159#endif /* HAVE_BFDD */
ba4eb1bc 5160{
d62a17ae 5161 int idx_number = 3;
5162 int idx_number_2 = 4;
5163 int idx_number_3 = 5;
b73779d3 5164 const struct lyd_node *igmp_enable_dnode;
ba4eb1bc 5165
3bb513c3
CH
5166 igmp_enable_dnode =
5167 yang_dnode_getf(vty->candidate_config->dnode,
3051f443 5168 FRR_GMP_ENABLE_XPATH, VTY_CURR_XPATH,
5169 "frr-routing:ipv4");
b73779d3
SP
5170 if (!igmp_enable_dnode)
5171 nb_cli_enqueue_change(vty, "./pim-enable", NB_OP_MODIFY,
521c5b9d 5172 "true");
b73779d3
SP
5173 else {
5174 if (!yang_dnode_get_bool(igmp_enable_dnode, "."))
5175 nb_cli_enqueue_change(vty, "./pim-enable", NB_OP_MODIFY,
521c5b9d 5176 "true");
b73779d3 5177 }
ba4eb1bc 5178
1f3e6bf5 5179 nb_cli_enqueue_change(vty, "./bfd", NB_OP_CREATE, NULL);
b73779d3 5180 nb_cli_enqueue_change(vty, "./bfd/min-rx-interval", NB_OP_MODIFY,
521c5b9d 5181 argv[idx_number_2]->arg);
b73779d3 5182 nb_cli_enqueue_change(vty, "./bfd/min-tx-interval", NB_OP_MODIFY,
521c5b9d 5183 argv[idx_number_3]->arg);
b73779d3 5184 nb_cli_enqueue_change(vty, "./bfd/detect_mult", NB_OP_MODIFY,
521c5b9d 5185 argv[idx_number]->arg);
b73779d3 5186
698f4147 5187 return nb_cli_apply_changes(vty,
5188 FRR_PIM_INTERFACE_XPATH, "frr-routing:ipv4");
ba4eb1bc
CS
5189}
5190
64dc4b2d 5191#if HAVE_BFDD == 0
d62a17ae 5192ALIAS(no_ip_pim_bfd, no_ip_pim_bfd_param_cmd,
11ca3587
CH
5193 "no ip pim bfd (2-255) (1-65535) (1-65535)",
5194 NO_STR
5195 IP_STR
5196 PIM_STR
d62a17ae 5197 "Enables BFD support\n"
5198 "Detect Multiplier\n"
5199 "Required min receive interval\n"
5200 "Desired min transmit interval\n")
64dc4b2d 5201#endif /* !HAVE_BFDD */
d62a17ae 5202
56697b3e
RZ
5203DEFPY(ip_msdp_peer, ip_msdp_peer_cmd,
5204 "ip msdp peer A.B.C.D$peer source A.B.C.D$source",
5205 IP_STR
5206 CFG_MSDP_STR
5207 "Configure MSDP peer\n"
5208 "Peer IP address\n"
5209 "Source address for TCP connection\n"
5210 "Local IP address\n")
2a333e0f 5211{
cf740d2e
SP
5212 const char *vrfname;
5213 char temp_xpath[XPATH_MAXLEN];
5214 char msdp_peer_source_xpath[XPATH_MAXLEN];
2a333e0f 5215
5a1a3920
RZ
5216 vrfname = pim_cli_get_vrf_name(vty);
5217 if (vrfname == NULL)
5218 return CMD_WARNING_CONFIG_FAILED;
2a333e0f 5219
cf740d2e 5220 snprintf(msdp_peer_source_xpath, sizeof(msdp_peer_source_xpath),
698f4147 5221 FRR_PIM_VRF_XPATH, "frr-pim:pimd", "pim", vrfname,
56697b3e 5222 "frr-routing:ipv4");
cf740d2e 5223 snprintf(temp_xpath, sizeof(temp_xpath),
56697b3e 5224 "/msdp-peer[peer-ip='%s']/source-ip", peer_str);
cf740d2e
SP
5225 strlcat(msdp_peer_source_xpath, temp_xpath,
5226 sizeof(msdp_peer_source_xpath));
2a333e0f 5227
cf740d2e 5228 nb_cli_enqueue_change(vty, msdp_peer_source_xpath, NB_OP_MODIFY,
56697b3e 5229 source_str);
2a333e0f 5230
698f4147 5231 return nb_cli_apply_changes(vty,
5232 FRR_PIM_INTERFACE_XPATH, "frr-routing:ipv4");
2a333e0f 5233}
5234
622fd3f1 5235DEFPY(ip_msdp_timers, ip_msdp_timers_cmd,
11ca3587 5236 "ip msdp timers (1-65535)$keepalive (1-65535)$holdtime [(1-65535)$connretry]",
622fd3f1
RZ
5237 IP_STR
5238 CFG_MSDP_STR
5239 "MSDP timers configuration\n"
5240 "Keep alive period (in seconds)\n"
5241 "Hold time period (in seconds)\n"
5242 "Connection retry period (in seconds)\n")
5243{
5244 const char *vrfname;
5245 char xpath[XPATH_MAXLEN];
5246
5247 vrfname = pim_cli_get_vrf_name(vty);
5248 if (vrfname == NULL)
5249 return CMD_WARNING_CONFIG_FAILED;
5250
5251 snprintf(xpath, sizeof(xpath), FRR_PIM_MSDP_XPATH, "frr-pim:pimd",
5252 "pim", vrfname, "frr-routing:ipv4");
5253 nb_cli_enqueue_change(vty, "./hold-time", NB_OP_MODIFY, holdtime_str);
5254 nb_cli_enqueue_change(vty, "./keep-alive", NB_OP_MODIFY, keepalive_str);
5255 if (connretry_str)
5256 nb_cli_enqueue_change(vty, "./connection-retry", NB_OP_MODIFY,
5257 connretry_str);
5258 else
5259 nb_cli_enqueue_change(vty, "./connection-retry", NB_OP_DESTROY,
5260 NULL);
5261
5262 nb_cli_apply_changes(vty, xpath);
5263
5264 return CMD_SUCCESS;
5265}
5266
11ca3587
CH
5267DEFPY(no_ip_msdp_timers, no_ip_msdp_timers_cmd,
5268 "no ip msdp timers [(1-65535) (1-65535) [(1-65535)]]",
5269 NO_STR
5270 IP_STR
5271 CFG_MSDP_STR
5272 "MSDP timers configuration\n"
5273 IGNORED_IN_NO_STR
5274 IGNORED_IN_NO_STR
5275 IGNORED_IN_NO_STR)
5276{
5277 const char *vrfname;
5278 char xpath[XPATH_MAXLEN];
5279
5280 vrfname = pim_cli_get_vrf_name(vty);
5281 if (vrfname == NULL)
5282 return CMD_WARNING_CONFIG_FAILED;
5283
5284 snprintf(xpath, sizeof(xpath), FRR_PIM_MSDP_XPATH, "frr-pim:pimd",
5285 "pim", vrfname, "frr-routing:ipv4");
5286
5287 nb_cli_enqueue_change(vty, "./hold-time", NB_OP_DESTROY, NULL);
5288 nb_cli_enqueue_change(vty, "./keep-alive", NB_OP_DESTROY, NULL);
5289 nb_cli_enqueue_change(vty, "./connection-retry", NB_OP_DESTROY, NULL);
5290
5291 nb_cli_apply_changes(vty, xpath);
5292
5293 return CMD_SUCCESS;
5294}
5295
9fbd9fc4 5296DEFUN (no_ip_msdp_peer,
2a333e0f 5297 no_ip_msdp_peer_cmd,
5298 "no ip msdp peer A.B.C.D",
977d71cc 5299 NO_STR
2a333e0f 5300 IP_STR
5301 CFG_MSDP_STR
5302 "Delete MSDP peer\n"
5303 "peer ip address\n")
5304{
cf740d2e
SP
5305 const char *vrfname;
5306 char msdp_peer_xpath[XPATH_MAXLEN];
5307 char temp_xpath[XPATH_MAXLEN];
2a333e0f 5308
5a1a3920
RZ
5309 vrfname = pim_cli_get_vrf_name(vty);
5310 if (vrfname == NULL)
5311 return CMD_WARNING_CONFIG_FAILED;
977d71cc 5312
cf740d2e 5313 snprintf(msdp_peer_xpath, sizeof(msdp_peer_xpath),
698f4147 5314 FRR_PIM_VRF_XPATH,
cf740d2e
SP
5315 "frr-pim:pimd", "pim", vrfname, "frr-routing:ipv4");
5316 snprintf(temp_xpath, sizeof(temp_xpath),
5317 "/msdp-peer[peer-ip='%s']",
5318 argv[4]->arg);
977d71cc 5319
cf740d2e
SP
5320 strlcat(msdp_peer_xpath, temp_xpath, sizeof(msdp_peer_xpath));
5321
5322 nb_cli_enqueue_change(vty, msdp_peer_xpath, NB_OP_DESTROY, NULL);
977d71cc 5323
cf740d2e 5324 return nb_cli_apply_changes(vty, NULL);
977d71cc 5325}
5326
e2809e61
RZ
5327DEFPY(ip_msdp_mesh_group_member,
5328 ip_msdp_mesh_group_member_cmd,
5329 "ip msdp mesh-group WORD$gname member A.B.C.D$maddr",
5330 IP_STR
5331 CFG_MSDP_STR
5332 "Configure MSDP mesh-group\n"
5333 "Mesh group name\n"
5334 "Mesh group member\n"
5335 "Peer IP address\n")
977d71cc 5336{
cf740d2e 5337 const char *vrfname;
e2809e61 5338 char xpath_value[XPATH_MAXLEN];
977d71cc 5339
5a1a3920
RZ
5340 vrfname = pim_cli_get_vrf_name(vty);
5341 if (vrfname == NULL)
5342 return CMD_WARNING_CONFIG_FAILED;
977d71cc 5343
e2809e61
RZ
5344 /* Create mesh group. */
5345 snprintf(xpath_value, sizeof(xpath_value),
698f4147 5346 FRR_PIM_VRF_XPATH "/msdp-mesh-groups[name='%s']",
e2809e61
RZ
5347 "frr-pim:pimd", "pim", vrfname, "frr-routing:ipv4", gname);
5348 nb_cli_enqueue_change(vty, xpath_value, NB_OP_CREATE, NULL);
977d71cc 5349
e2809e61
RZ
5350 /* Create mesh group member. */
5351 strlcat(xpath_value, "/members[address='", sizeof(xpath_value));
5352 strlcat(xpath_value, maddr_str, sizeof(xpath_value));
5353 strlcat(xpath_value, "']", sizeof(xpath_value));
5354 nb_cli_enqueue_change(vty, xpath_value, NB_OP_CREATE, NULL);
977d71cc 5355
cf740d2e 5356 return nb_cli_apply_changes(vty, NULL);
977d71cc 5357}
cf740d2e 5358
e2809e61
RZ
5359DEFPY(no_ip_msdp_mesh_group_member,
5360 no_ip_msdp_mesh_group_member_cmd,
5361 "no ip msdp mesh-group WORD$gname member A.B.C.D$maddr",
5362 NO_STR
5363 IP_STR
5364 CFG_MSDP_STR
5365 "Delete MSDP mesh-group member\n"
5366 "Mesh group name\n"
5367 "Mesh group member\n"
5368 "Peer IP address\n")
977d71cc 5369{
cf740d2e 5370 const char *vrfname;
e2809e61
RZ
5371 char xpath_value[XPATH_MAXLEN];
5372 char xpath_member_value[XPATH_MAXLEN];
977d71cc 5373
5a1a3920
RZ
5374 vrfname = pim_cli_get_vrf_name(vty);
5375 if (vrfname == NULL)
5376 return CMD_WARNING_CONFIG_FAILED;
977d71cc 5377
e2809e61
RZ
5378 /* Get mesh group base XPath. */
5379 snprintf(xpath_value, sizeof(xpath_value),
698f4147 5380 FRR_PIM_VRF_XPATH "/msdp-mesh-groups[name='%s']",
e2809e61 5381 "frr-pim:pimd", "pim", vrfname, "frr-routing:ipv4", gname);
cf740d2e 5382
e2809e61
RZ
5383 if (!yang_dnode_exists(vty->candidate_config->dnode, xpath_value)) {
5384 vty_out(vty, "%% mesh-group does not exist\n");
5385 return CMD_WARNING_CONFIG_FAILED;
d62a17ae 5386 }
977d71cc 5387
e2809e61
RZ
5388 /* Remove mesh group member. */
5389 strlcpy(xpath_member_value, xpath_value, sizeof(xpath_member_value));
5390 strlcat(xpath_member_value, "/members[address='",
5391 sizeof(xpath_member_value));
5392 strlcat(xpath_member_value, maddr_str, sizeof(xpath_member_value));
5393 strlcat(xpath_member_value, "']", sizeof(xpath_member_value));
5394 if (!yang_dnode_exists(vty->candidate_config->dnode,
5395 xpath_member_value)) {
5396 vty_out(vty, "%% mesh-group member does not exist\n");
5397 return CMD_WARNING_CONFIG_FAILED;
d62a17ae 5398 }
977d71cc 5399
46877489 5400 nb_cli_enqueue_change(vty, xpath_member_value, NB_OP_DESTROY, NULL);
977d71cc 5401
e2809e61
RZ
5402 /*
5403 * If this is the last member, then we must remove the group altogether
5404 * to not break legacy CLI behaviour.
5405 */
5406 pim_cli_legacy_mesh_group_behavior(vty, gname);
5407
5408 return nb_cli_apply_changes(vty, NULL);
cf740d2e 5409}
977d71cc 5410
e2809e61
RZ
5411DEFPY(ip_msdp_mesh_group_source,
5412 ip_msdp_mesh_group_source_cmd,
5413 "ip msdp mesh-group WORD$gname source A.B.C.D$saddr",
5414 IP_STR
5415 CFG_MSDP_STR
5416 "Configure MSDP mesh-group\n"
5417 "Mesh group name\n"
5418 "Mesh group local address\n"
5419 "Source IP address for the TCP connection\n")
977d71cc 5420{
cf740d2e 5421 const char *vrfname;
e2809e61 5422 char xpath_value[XPATH_MAXLEN];
977d71cc 5423
5a1a3920
RZ
5424 vrfname = pim_cli_get_vrf_name(vty);
5425 if (vrfname == NULL)
5426 return CMD_WARNING_CONFIG_FAILED;
977d71cc 5427
e2809e61
RZ
5428 /* Create mesh group. */
5429 snprintf(xpath_value, sizeof(xpath_value),
698f4147 5430 FRR_PIM_VRF_XPATH "/msdp-mesh-groups[name='%s']",
e2809e61
RZ
5431 "frr-pim:pimd", "pim", vrfname, "frr-routing:ipv4", gname);
5432 nb_cli_enqueue_change(vty, xpath_value, NB_OP_CREATE, NULL);
977d71cc 5433
46877489 5434 /* Create mesh group source. */
e2809e61
RZ
5435 strlcat(xpath_value, "/source", sizeof(xpath_value));
5436 nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, saddr_str);
977d71cc 5437
cf740d2e 5438 return nb_cli_apply_changes(vty, NULL);
977d71cc 5439}
5440
e2809e61
RZ
5441DEFPY(no_ip_msdp_mesh_group_source,
5442 no_ip_msdp_mesh_group_source_cmd,
5443 "no ip msdp mesh-group WORD$gname source [A.B.C.D]",
5444 NO_STR
5445 IP_STR
5446 CFG_MSDP_STR
5447 "Delete MSDP mesh-group source\n"
5448 "Mesh group name\n"
5449 "Mesh group source\n"
5450 "Mesh group local address\n")
977d71cc 5451{
cf740d2e 5452 const char *vrfname;
e2809e61 5453 char xpath_value[XPATH_MAXLEN];
cf740d2e 5454
5a1a3920
RZ
5455 vrfname = pim_cli_get_vrf_name(vty);
5456 if (vrfname == NULL)
5457 return CMD_WARNING_CONFIG_FAILED;
cf740d2e 5458
e2809e61
RZ
5459 /* Get mesh group base XPath. */
5460 snprintf(xpath_value, sizeof(xpath_value),
698f4147 5461 FRR_PIM_VRF_XPATH "/msdp-mesh-groups[name='%s']",
e2809e61
RZ
5462 "frr-pim:pimd", "pim", vrfname, "frr-routing:ipv4", gname);
5463 nb_cli_enqueue_change(vty, xpath_value, NB_OP_CREATE, NULL);
cf740d2e 5464
46877489 5465 /* Create mesh group source. */
e2809e61
RZ
5466 strlcat(xpath_value, "/source", sizeof(xpath_value));
5467 nb_cli_enqueue_change(vty, xpath_value, NB_OP_DESTROY, NULL);
cf740d2e 5468
e2809e61
RZ
5469 /*
5470 * If this is the last member, then we must remove the group altogether
5471 * to not break legacy CLI behaviour.
5472 */
5473 pim_cli_legacy_mesh_group_behavior(vty, gname);
34d86eff 5474
cf740d2e 5475 return nb_cli_apply_changes(vty, NULL);
34d86eff
SP
5476}
5477
e2809e61
RZ
5478DEFPY(no_ip_msdp_mesh_group,
5479 no_ip_msdp_mesh_group_cmd,
5480 "no ip msdp mesh-group WORD$gname",
5481 NO_STR
5482 IP_STR
5483 CFG_MSDP_STR
5484 "Delete MSDP mesh-group\n"
5485 "Mesh group name")
34d86eff 5486{
cf740d2e 5487 const char *vrfname;
e2809e61 5488 char xpath_value[XPATH_MAXLEN];
34d86eff 5489
5a1a3920
RZ
5490 vrfname = pim_cli_get_vrf_name(vty);
5491 if (vrfname == NULL)
5492 return CMD_WARNING_CONFIG_FAILED;
cf740d2e 5493
e2809e61
RZ
5494 /* Get mesh group base XPath. */
5495 snprintf(xpath_value, sizeof(xpath_value),
698f4147 5496 FRR_PIM_VRF_XPATH "/msdp-mesh-groups[name='%s']",
e2809e61
RZ
5497 "frr-pim:pimd", "pim", vrfname, "frr-routing:ipv4", gname);
5498 if (!yang_dnode_exists(vty->candidate_config->dnode, xpath_value))
5499 return CMD_SUCCESS;
cf740d2e 5500
e2809e61 5501 nb_cli_enqueue_change(vty, xpath_value, NB_OP_DESTROY, NULL);
cf740d2e 5502 return nb_cli_apply_changes(vty, NULL);
d62a17ae 5503}
5504
e2809e61
RZ
5505static void ip_msdp_show_mesh_group(struct vty *vty, struct pim_msdp_mg *mg,
5506 struct json_object *json)
d62a17ae 5507{
5508 struct listnode *mbrnode;
5509 struct pim_msdp_mg_mbr *mbr;
d62a17ae 5510 char mbr_str[INET_ADDRSTRLEN];
5511 char src_str[INET_ADDRSTRLEN];
5512 char state_str[PIM_MSDP_STATE_STRLEN];
5513 enum pim_msdp_peer_state state;
d62a17ae 5514 json_object *json_mg_row = NULL;
5515 json_object *json_members = NULL;
5516 json_object *json_row = NULL;
5517
d62a17ae 5518 pim_inet4_dump("<source?>", mg->src_ip, src_str, sizeof(src_str));
e2809e61 5519 if (json) {
d62a17ae 5520 /* currently there is only one mesh group but we should still
5521 * make
5522 * it a dict with mg-name as key */
5523 json_mg_row = json_object_new_object();
5524 json_object_string_add(json_mg_row, "name",
5525 mg->mesh_group_name);
5526 json_object_string_add(json_mg_row, "source", src_str);
5527 } else {
5528 vty_out(vty, "Mesh group : %s\n", mg->mesh_group_name);
5529 vty_out(vty, " Source : %s\n", src_str);
5530 vty_out(vty, " Member State\n");
5531 }
5532
5533 for (ALL_LIST_ELEMENTS_RO(mg->mbr_list, mbrnode, mbr)) {
5534 pim_inet4_dump("<mbr?>", mbr->mbr_ip, mbr_str, sizeof(mbr_str));
5535 if (mbr->mp) {
5536 state = mbr->mp->state;
5537 } else {
5538 state = PIM_MSDP_DISABLED;
5539 }
5540 pim_msdp_state_dump(state, state_str, sizeof(state_str));
e2809e61 5541 if (json) {
d62a17ae 5542 json_row = json_object_new_object();
5543 json_object_string_add(json_row, "member", mbr_str);
5544 json_object_string_add(json_row, "state", state_str);
5545 if (!json_members) {
5546 json_members = json_object_new_object();
5547 json_object_object_add(json_mg_row, "members",
5548 json_members);
5549 }
5550 json_object_object_add(json_members, mbr_str, json_row);
5551 } else {
5552 vty_out(vty, " %-15s %11s\n", mbr_str, state_str);
5553 }
5554 }
5555
e2809e61 5556 if (json)
d62a17ae 5557 json_object_object_add(json, mg->mesh_group_name, json_mg_row);
977d71cc 5558}
5559
5560DEFUN (show_ip_msdp_mesh_group,
5561 show_ip_msdp_mesh_group_cmd,
20a7e5fd 5562 "show ip msdp [vrf NAME] mesh-group [json]",
977d71cc 5563 SHOW_STR
5564 IP_STR
5565 MSDP_STR
f02d59db 5566 VRF_CMD_HELP_STR
977d71cc 5567 "MSDP mesh-group information\n"
f5da2cc2 5568 JSON_STR)
977d71cc 5569{
9f049418 5570 bool uj = use_json(argc, argv);
c68ba0d7 5571 int idx = 2;
e2809e61 5572 struct pim_msdp_mg *mg;
02a16316 5573 struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
e2809e61
RZ
5574 struct pim_instance *pim = vrf->info;
5575 struct json_object *json = NULL;
02a16316
DS
5576
5577 if (!vrf)
5578 return CMD_WARNING;
5579
e2809e61
RZ
5580 /* Quick case: list is empty. */
5581 if (SLIST_EMPTY(&pim->msdp.mglist)) {
5582 if (uj)
5583 vty_out(vty, "{}\n");
5584
5585 return CMD_SUCCESS;
5586 }
5587
5588 if (uj)
5589 json = json_object_new_object();
5590
5591 SLIST_FOREACH (mg, &pim->msdp.mglist, mg_entry)
5592 ip_msdp_show_mesh_group(vty, mg, json);
5593
3757f964
DA
5594 if (uj)
5595 vty_json(vty, json);
d62a17ae 5596
5597 return CMD_SUCCESS;
5598}
5599
a25de56b
DS
5600DEFUN (show_ip_msdp_mesh_group_vrf_all,
5601 show_ip_msdp_mesh_group_vrf_all_cmd,
5602 "show ip msdp vrf all mesh-group [json]",
5603 SHOW_STR
5604 IP_STR
5605 MSDP_STR
5606 VRF_CMD_HELP_STR
5607 "MSDP mesh-group information\n"
f5da2cc2 5608 JSON_STR)
a25de56b 5609{
9f049418 5610 bool uj = use_json(argc, argv);
e2809e61
RZ
5611 struct json_object *json = NULL, *vrf_json = NULL;
5612 struct pim_instance *pim;
5613 struct pim_msdp_mg *mg;
a25de56b 5614 struct vrf *vrf;
a25de56b
DS
5615
5616 if (uj)
e2809e61
RZ
5617 json = json_object_new_object();
5618
a2addae8 5619 RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
a25de56b 5620 if (uj) {
e2809e61
RZ
5621 vrf_json = json_object_new_object();
5622 json_object_object_add(json, vrf->name, vrf_json);
a25de56b
DS
5623 } else
5624 vty_out(vty, "VRF: %s\n", vrf->name);
e2809e61
RZ
5625
5626 pim = vrf->info;
5627 SLIST_FOREACH (mg, &pim->msdp.mglist, mg_entry)
5628 ip_msdp_show_mesh_group(vty, mg, vrf_json);
5629 }
5630
3757f964
DA
5631 if (uj)
5632 vty_json(vty, json);
5633
a25de56b
DS
5634
5635 return CMD_SUCCESS;
5636}
5637
64c86530 5638static void ip_msdp_show_peers(struct pim_instance *pim, struct vty *vty,
088f1098 5639 bool uj)
d62a17ae 5640{
5641 struct listnode *mpnode;
5642 struct pim_msdp_peer *mp;
5643 char peer_str[INET_ADDRSTRLEN];
5644 char local_str[INET_ADDRSTRLEN];
5645 char state_str[PIM_MSDP_STATE_STRLEN];
5646 char timebuf[PIM_MSDP_UPTIME_STRLEN];
5647 int64_t now;
5648 json_object *json = NULL;
5649 json_object *json_row = NULL;
5650
5651
5652 if (uj) {
5653 json = json_object_new_object();
5654 } else {
5655 vty_out(vty,
5656 "Peer Local State Uptime SaCnt\n");
5657 }
5658
02a16316 5659 for (ALL_LIST_ELEMENTS_RO(pim->msdp.peer_list, mpnode, mp)) {
d62a17ae 5660 if (mp->state == PIM_MSDP_ESTABLISHED) {
5661 now = pim_time_monotonic_sec();
5662 pim_time_uptime(timebuf, sizeof(timebuf),
5663 now - mp->uptime);
5664 } else {
c35b7e6b 5665 strlcpy(timebuf, "-", sizeof(timebuf));
d62a17ae 5666 }
5667 pim_inet4_dump("<peer?>", mp->peer, peer_str, sizeof(peer_str));
5668 pim_inet4_dump("<local?>", mp->local, local_str,
5669 sizeof(local_str));
5670 pim_msdp_state_dump(mp->state, state_str, sizeof(state_str));
5671 if (uj) {
5672 json_row = json_object_new_object();
5673 json_object_string_add(json_row, "peer", peer_str);
5674 json_object_string_add(json_row, "local", local_str);
5675 json_object_string_add(json_row, "state", state_str);
5676 json_object_string_add(json_row, "upTime", timebuf);
5677 json_object_int_add(json_row, "saCount", mp->sa_cnt);
5678 json_object_object_add(json, peer_str, json_row);
5679 } else {
5680 vty_out(vty, "%-15s %15s %11s %8s %6d\n", peer_str,
5681 local_str, state_str, timebuf, mp->sa_cnt);
5682 }
5683 }
5684
3757f964
DA
5685 if (uj)
5686 vty_json(vty, json);
d62a17ae 5687}
5688
64c86530 5689static void ip_msdp_show_peers_detail(struct pim_instance *pim, struct vty *vty,
088f1098 5690 const char *peer, bool uj)
d62a17ae 5691{
5692 struct listnode *mpnode;
5693 struct pim_msdp_peer *mp;
5694 char peer_str[INET_ADDRSTRLEN];
5695 char local_str[INET_ADDRSTRLEN];
5696 char state_str[PIM_MSDP_STATE_STRLEN];
5697 char timebuf[PIM_MSDP_UPTIME_STRLEN];
5698 char katimer[PIM_MSDP_TIMER_STRLEN];
5699 char crtimer[PIM_MSDP_TIMER_STRLEN];
5700 char holdtimer[PIM_MSDP_TIMER_STRLEN];
5701 int64_t now;
5702 json_object *json = NULL;
5703 json_object *json_row = NULL;
5704
5705 if (uj) {
5706 json = json_object_new_object();
5707 }
5708
02a16316 5709 for (ALL_LIST_ELEMENTS_RO(pim->msdp.peer_list, mpnode, mp)) {
d62a17ae 5710 pim_inet4_dump("<peer?>", mp->peer, peer_str, sizeof(peer_str));
5711 if (strcmp(peer, "detail") && strcmp(peer, peer_str))
5712 continue;
5713
5714 if (mp->state == PIM_MSDP_ESTABLISHED) {
5715 now = pim_time_monotonic_sec();
5716 pim_time_uptime(timebuf, sizeof(timebuf),
5717 now - mp->uptime);
5718 } else {
c35b7e6b 5719 strlcpy(timebuf, "-", sizeof(timebuf));
d62a17ae 5720 }
5721 pim_inet4_dump("<local?>", mp->local, local_str,
5722 sizeof(local_str));
5723 pim_msdp_state_dump(mp->state, state_str, sizeof(state_str));
5724 pim_time_timer_to_hhmmss(katimer, sizeof(katimer),
5725 mp->ka_timer);
5726 pim_time_timer_to_hhmmss(crtimer, sizeof(crtimer),
5727 mp->cr_timer);
5728 pim_time_timer_to_hhmmss(holdtimer, sizeof(holdtimer),
5729 mp->hold_timer);
5730
5731 if (uj) {
5732 json_row = json_object_new_object();
5733 json_object_string_add(json_row, "peer", peer_str);
5734 json_object_string_add(json_row, "local", local_str);
0ce04a08
RZ
5735 if (mp->flags & PIM_MSDP_PEERF_IN_GROUP)
5736 json_object_string_add(json_row,
5737 "meshGroupName",
5738 mp->mesh_group_name);
d62a17ae 5739 json_object_string_add(json_row, "state", state_str);
5740 json_object_string_add(json_row, "upTime", timebuf);
5741 json_object_string_add(json_row, "keepAliveTimer",
5742 katimer);
5743 json_object_string_add(json_row, "connRetryTimer",
5744 crtimer);
5745 json_object_string_add(json_row, "holdTimer",
5746 holdtimer);
5747 json_object_string_add(json_row, "lastReset",
5748 mp->last_reset);
5749 json_object_int_add(json_row, "connAttempts",
5750 mp->conn_attempts);
5751 json_object_int_add(json_row, "establishedChanges",
5752 mp->est_flaps);
5753 json_object_int_add(json_row, "saCount", mp->sa_cnt);
5754 json_object_int_add(json_row, "kaSent", mp->ka_tx_cnt);
5755 json_object_int_add(json_row, "kaRcvd", mp->ka_rx_cnt);
5756 json_object_int_add(json_row, "saSent", mp->sa_tx_cnt);
5757 json_object_int_add(json_row, "saRcvd", mp->sa_rx_cnt);
5758 json_object_object_add(json, peer_str, json_row);
5759 } else {
5760 vty_out(vty, "Peer : %s\n", peer_str);
5761 vty_out(vty, " Local : %s\n", local_str);
0ce04a08
RZ
5762 if (mp->flags & PIM_MSDP_PEERF_IN_GROUP)
5763 vty_out(vty, " Mesh Group : %s\n",
5764 mp->mesh_group_name);
d62a17ae 5765 vty_out(vty, " State : %s\n", state_str);
5766 vty_out(vty, " Uptime : %s\n", timebuf);
5767
5768 vty_out(vty, " Keepalive Timer : %s\n", katimer);
5769 vty_out(vty, " Conn Retry Timer : %s\n", crtimer);
5770 vty_out(vty, " Hold Timer : %s\n", holdtimer);
5771 vty_out(vty, " Last Reset : %s\n",
5772 mp->last_reset);
5773 vty_out(vty, " Conn Attempts : %d\n",
5774 mp->conn_attempts);
5775 vty_out(vty, " Established Changes : %d\n",
5776 mp->est_flaps);
5777 vty_out(vty, " SA Count : %d\n",
5778 mp->sa_cnt);
5779 vty_out(vty, " Statistics :\n");
5780 vty_out(vty,
5781 " Sent Rcvd\n");
5782 vty_out(vty, " Keepalives : %10d %10d\n",
5783 mp->ka_tx_cnt, mp->ka_rx_cnt);
5784 vty_out(vty, " SAs : %10d %10d\n",
5785 mp->sa_tx_cnt, mp->sa_rx_cnt);
5786 vty_out(vty, "\n");
5787 }
5788 }
5789
3757f964
DA
5790 if (uj)
5791 vty_json(vty, json);
977d71cc 5792}
5793
5794DEFUN (show_ip_msdp_peer_detail,
5795 show_ip_msdp_peer_detail_cmd,
20a7e5fd 5796 "show ip msdp [vrf NAME] peer [detail|A.B.C.D] [json]",
2a333e0f 5797 SHOW_STR
5798 IP_STR
5799 MSDP_STR
f02d59db 5800 VRF_CMD_HELP_STR
2a333e0f 5801 "MSDP peer information\n"
977d71cc 5802 "Detailed output\n"
5803 "peer ip address\n"
f5da2cc2 5804 JSON_STR)
2a333e0f 5805{
9f049418 5806 bool uj = use_json(argc, argv);
c68ba0d7 5807 int idx = 2;
02a16316 5808 struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
d62a17ae 5809
07a29355
QY
5810 if (!vrf)
5811 return CMD_WARNING;
5812
5813 char *arg = NULL;
5814
5815 if (argv_find(argv, argc, "detail", &idx))
5816 arg = argv[idx]->text;
5817 else if (argv_find(argv, argc, "A.B.C.D", &idx))
5818 arg = argv[idx]->arg;
5819
5820 if (arg)
64c86530 5821 ip_msdp_show_peers_detail(vrf->info, vty, argv[idx]->arg, uj);
d62a17ae 5822 else
64c86530 5823 ip_msdp_show_peers(vrf->info, vty, uj);
d62a17ae 5824
5825 return CMD_SUCCESS;
5826}
5827
a25de56b
DS
5828DEFUN (show_ip_msdp_peer_detail_vrf_all,
5829 show_ip_msdp_peer_detail_vrf_all_cmd,
5830 "show ip msdp vrf all peer [detail|A.B.C.D] [json]",
5831 SHOW_STR
5832 IP_STR
5833 MSDP_STR
5834 VRF_CMD_HELP_STR
5835 "MSDP peer information\n"
5836 "Detailed output\n"
5837 "peer ip address\n"
f5da2cc2 5838 JSON_STR)
a25de56b
DS
5839{
5840 int idx = 2;
9f049418 5841 bool uj = use_json(argc, argv);
a25de56b
DS
5842 struct vrf *vrf;
5843 bool first = true;
5844
5845 if (uj)
5846 vty_out(vty, "{ ");
a2addae8 5847 RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
a25de56b
DS
5848 if (uj) {
5849 if (!first)
5850 vty_out(vty, ", ");
5851 vty_out(vty, " \"%s\": ", vrf->name);
5852 first = false;
5853 } else
5854 vty_out(vty, "VRF: %s\n", vrf->name);
5855 if (argv_find(argv, argc, "detail", &idx)
5856 || argv_find(argv, argc, "A.B.C.D", &idx))
5857 ip_msdp_show_peers_detail(vrf->info, vty,
5858 argv[idx]->arg, uj);
5859 else
5860 ip_msdp_show_peers(vrf->info, vty, uj);
5861 }
5862 if (uj)
5863 vty_out(vty, "}\n");
5864
5865 return CMD_SUCCESS;
5866}
5867
088f1098 5868static void ip_msdp_show_sa(struct pim_instance *pim, struct vty *vty, bool uj)
d62a17ae 5869{
5870 struct listnode *sanode;
5871 struct pim_msdp_sa *sa;
d62a17ae 5872 char rp_str[INET_ADDRSTRLEN];
5873 char timebuf[PIM_MSDP_UPTIME_STRLEN];
5874 char spt_str[8];
5875 char local_str[8];
5876 int64_t now;
5877 json_object *json = NULL;
5878 json_object *json_group = NULL;
5879 json_object *json_row = NULL;
5880
5881 if (uj) {
5882 json = json_object_new_object();
5883 } else {
5884 vty_out(vty,
5885 "Source Group RP Local SPT Uptime\n");
5886 }
5887
02a16316 5888 for (ALL_LIST_ELEMENTS_RO(pim->msdp.sa_list, sanode, sa)) {
d62a17ae 5889 now = pim_time_monotonic_sec();
5890 pim_time_uptime(timebuf, sizeof(timebuf), now - sa->uptime);
d62a17ae 5891 if (sa->flags & PIM_MSDP_SAF_PEER) {
5892 pim_inet4_dump("<rp?>", sa->rp, rp_str, sizeof(rp_str));
5893 if (sa->up) {
c35b7e6b 5894 strlcpy(spt_str, "yes", sizeof(spt_str));
d62a17ae 5895 } else {
c35b7e6b 5896 strlcpy(spt_str, "no", sizeof(spt_str));
d62a17ae 5897 }
5898 } else {
c35b7e6b
QY
5899 strlcpy(rp_str, "-", sizeof(rp_str));
5900 strlcpy(spt_str, "-", sizeof(spt_str));
d62a17ae 5901 }
5902 if (sa->flags & PIM_MSDP_SAF_LOCAL) {
c35b7e6b 5903 strlcpy(local_str, "yes", sizeof(local_str));
d62a17ae 5904 } else {
c35b7e6b 5905 strlcpy(local_str, "no", sizeof(local_str));
d62a17ae 5906 }
5907 if (uj) {
8e8be741
DL
5908 char src_str[PIM_ADDRSTRLEN];
5909 char grp_str[PIM_ADDRSTRLEN];
5910
5911 snprintfrr(grp_str, sizeof(grp_str), "%pPAs",
5912 &sa->sg.grp);
5913 snprintfrr(src_str, sizeof(src_str), "%pPAs",
5914 &sa->sg.src);
5915
d62a17ae 5916 json_object_object_get_ex(json, grp_str, &json_group);
5917
5918 if (!json_group) {
5919 json_group = json_object_new_object();
5920 json_object_object_add(json, grp_str,
5921 json_group);
5922 }
5923
5924 json_row = json_object_new_object();
5925 json_object_string_add(json_row, "source", src_str);
5926 json_object_string_add(json_row, "group", grp_str);
5927 json_object_string_add(json_row, "rp", rp_str);
5928 json_object_string_add(json_row, "local", local_str);
5929 json_object_string_add(json_row, "sptSetup", spt_str);
5930 json_object_string_add(json_row, "upTime", timebuf);
5931 json_object_object_add(json_group, src_str, json_row);
5932 } else {
8e8be741
DL
5933 vty_out(vty, "%-15pPAs %15pPAs %15s %5c %3c %8s\n",
5934 &sa->sg.src, &sa->sg.grp, rp_str, local_str[0],
d62a17ae 5935 spt_str[0], timebuf);
5936 }
5937 }
5938
3757f964
DA
5939 if (uj)
5940 vty_json(vty, json);
d62a17ae 5941}
5942
5943static void ip_msdp_show_sa_entry_detail(struct pim_msdp_sa *sa,
5944 const char *src_str,
5945 const char *grp_str, struct vty *vty,
088f1098 5946 bool uj, json_object *json)
d62a17ae 5947{
5948 char rp_str[INET_ADDRSTRLEN];
5949 char peer_str[INET_ADDRSTRLEN];
5950 char timebuf[PIM_MSDP_UPTIME_STRLEN];
5951 char spt_str[8];
5952 char local_str[8];
5953 char statetimer[PIM_MSDP_TIMER_STRLEN];
5954 int64_t now;
5955 json_object *json_group = NULL;
5956 json_object *json_row = NULL;
5957
5958 now = pim_time_monotonic_sec();
5959 pim_time_uptime(timebuf, sizeof(timebuf), now - sa->uptime);
5960 if (sa->flags & PIM_MSDP_SAF_PEER) {
5961 pim_inet4_dump("<rp?>", sa->rp, rp_str, sizeof(rp_str));
5962 pim_inet4_dump("<peer?>", sa->peer, peer_str, sizeof(peer_str));
5963 if (sa->up) {
c35b7e6b 5964 strlcpy(spt_str, "yes", sizeof(spt_str));
d62a17ae 5965 } else {
c35b7e6b 5966 strlcpy(spt_str, "no", sizeof(spt_str));
d62a17ae 5967 }
5968 } else {
c35b7e6b
QY
5969 strlcpy(rp_str, "-", sizeof(rp_str));
5970 strlcpy(peer_str, "-", sizeof(peer_str));
5971 strlcpy(spt_str, "-", sizeof(spt_str));
d62a17ae 5972 }
5973 if (sa->flags & PIM_MSDP_SAF_LOCAL) {
c35b7e6b 5974 strlcpy(local_str, "yes", sizeof(local_str));
d62a17ae 5975 } else {
c35b7e6b 5976 strlcpy(local_str, "no", sizeof(local_str));
d62a17ae 5977 }
5978 pim_time_timer_to_hhmmss(statetimer, sizeof(statetimer),
5979 sa->sa_state_timer);
5980 if (uj) {
5981 json_object_object_get_ex(json, grp_str, &json_group);
5982
5983 if (!json_group) {
5984 json_group = json_object_new_object();
5985 json_object_object_add(json, grp_str, json_group);
5986 }
5987
5988 json_row = json_object_new_object();
5989 json_object_string_add(json_row, "source", src_str);
5990 json_object_string_add(json_row, "group", grp_str);
5991 json_object_string_add(json_row, "rp", rp_str);
5992 json_object_string_add(json_row, "local", local_str);
5993 json_object_string_add(json_row, "sptSetup", spt_str);
5994 json_object_string_add(json_row, "upTime", timebuf);
5995 json_object_string_add(json_row, "stateTimer", statetimer);
5996 json_object_object_add(json_group, src_str, json_row);
5997 } else {
5998 vty_out(vty, "SA : %s\n", sa->sg_str);
5999 vty_out(vty, " RP : %s\n", rp_str);
6000 vty_out(vty, " Peer : %s\n", peer_str);
6001 vty_out(vty, " Local : %s\n", local_str);
6002 vty_out(vty, " SPT Setup : %s\n", spt_str);
6003 vty_out(vty, " Uptime : %s\n", timebuf);
6004 vty_out(vty, " State Timer : %s\n", statetimer);
6005 vty_out(vty, "\n");
6006 }
6007}
6008
64c86530 6009static void ip_msdp_show_sa_detail(struct pim_instance *pim, struct vty *vty,
088f1098 6010 bool uj)
d62a17ae 6011{
6012 struct listnode *sanode;
6013 struct pim_msdp_sa *sa;
d62a17ae 6014 json_object *json = NULL;
6015
6016 if (uj) {
6017 json = json_object_new_object();
6018 }
6019
02a16316 6020 for (ALL_LIST_ELEMENTS_RO(pim->msdp.sa_list, sanode, sa)) {
8e8be741
DL
6021 char src_str[PIM_ADDRSTRLEN];
6022 char grp_str[PIM_ADDRSTRLEN];
6023
6024 snprintfrr(grp_str, sizeof(grp_str), "%pPAs", &sa->sg.grp);
6025 snprintfrr(src_str, sizeof(src_str), "%pPAs", &sa->sg.src);
6026
d62a17ae 6027 ip_msdp_show_sa_entry_detail(sa, src_str, grp_str, vty, uj,
6028 json);
6029 }
6030
3757f964
DA
6031 if (uj)
6032 vty_json(vty, json);
977d71cc 6033}
6034
6035DEFUN (show_ip_msdp_sa_detail,
6036 show_ip_msdp_sa_detail_cmd,
20a7e5fd 6037 "show ip msdp [vrf NAME] sa detail [json]",
3c72d654 6038 SHOW_STR
6039 IP_STR
6040 MSDP_STR
f02d59db 6041 VRF_CMD_HELP_STR
3c72d654 6042 "MSDP active-source information\n"
977d71cc 6043 "Detailed output\n"
f5da2cc2 6044 JSON_STR)
3c72d654 6045{
9f049418 6046 bool uj = use_json(argc, argv);
c68ba0d7 6047 int idx = 2;
02a16316
DS
6048 struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
6049
6050 if (!vrf)
6051 return CMD_WARNING;
6052
64c86530 6053 ip_msdp_show_sa_detail(vrf->info, vty, uj);
977d71cc 6054
d62a17ae 6055 return CMD_SUCCESS;
977d71cc 6056}
6057
a25de56b
DS
6058DEFUN (show_ip_msdp_sa_detail_vrf_all,
6059 show_ip_msdp_sa_detail_vrf_all_cmd,
6060 "show ip msdp vrf all sa detail [json]",
6061 SHOW_STR
6062 IP_STR
6063 MSDP_STR
6064 VRF_CMD_HELP_STR
6065 "MSDP active-source information\n"
6066 "Detailed output\n"
f5da2cc2 6067 JSON_STR)
a25de56b 6068{
9f049418 6069 bool uj = use_json(argc, argv);
a25de56b
DS
6070 struct vrf *vrf;
6071 bool first = true;
6072
6073 if (uj)
6074 vty_out(vty, "{ ");
a2addae8 6075 RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
a25de56b
DS
6076 if (uj) {
6077 if (!first)
6078 vty_out(vty, ", ");
6079 vty_out(vty, " \"%s\": ", vrf->name);
6080 first = false;
6081 } else
6082 vty_out(vty, "VRF: %s\n", vrf->name);
6083 ip_msdp_show_sa_detail(vrf->info, vty, uj);
6084 }
6085 if (uj)
6086 vty_out(vty, "}\n");
6087
6088 return CMD_SUCCESS;
6089}
6090
64c86530 6091static void ip_msdp_show_sa_addr(struct pim_instance *pim, struct vty *vty,
088f1098 6092 const char *addr, bool uj)
977d71cc 6093{
d62a17ae 6094 struct listnode *sanode;
6095 struct pim_msdp_sa *sa;
d62a17ae 6096 json_object *json = NULL;
977d71cc 6097
d62a17ae 6098 if (uj) {
6099 json = json_object_new_object();
6100 }
977d71cc 6101
02a16316 6102 for (ALL_LIST_ELEMENTS_RO(pim->msdp.sa_list, sanode, sa)) {
8e8be741
DL
6103 char src_str[PIM_ADDRSTRLEN];
6104 char grp_str[PIM_ADDRSTRLEN];
6105
6106 snprintfrr(grp_str, sizeof(grp_str), "%pPAs", &sa->sg.grp);
6107 snprintfrr(src_str, sizeof(src_str), "%pPAs", &sa->sg.src);
6108
d62a17ae 6109 if (!strcmp(addr, src_str) || !strcmp(addr, grp_str)) {
6110 ip_msdp_show_sa_entry_detail(sa, src_str, grp_str, vty,
6111 uj, json);
6112 }
6113 }
977d71cc 6114
3757f964
DA
6115 if (uj)
6116 vty_json(vty, json);
977d71cc 6117}
6118
64c86530 6119static void ip_msdp_show_sa_sg(struct pim_instance *pim, struct vty *vty,
088f1098 6120 const char *src, const char *grp, bool uj)
977d71cc 6121{
d62a17ae 6122 struct listnode *sanode;
6123 struct pim_msdp_sa *sa;
d62a17ae 6124 json_object *json = NULL;
977d71cc 6125
d62a17ae 6126 if (uj) {
6127 json = json_object_new_object();
6128 }
977d71cc 6129
02a16316 6130 for (ALL_LIST_ELEMENTS_RO(pim->msdp.sa_list, sanode, sa)) {
8e8be741
DL
6131 char src_str[PIM_ADDRSTRLEN];
6132 char grp_str[PIM_ADDRSTRLEN];
6133
6134 snprintfrr(grp_str, sizeof(grp_str), "%pPAs", &sa->sg.grp);
6135 snprintfrr(src_str, sizeof(src_str), "%pPAs", &sa->sg.src);
6136
d62a17ae 6137 if (!strcmp(src, src_str) && !strcmp(grp, grp_str)) {
6138 ip_msdp_show_sa_entry_detail(sa, src_str, grp_str, vty,
6139 uj, json);
6140 }
6141 }
977d71cc 6142
3757f964
DA
6143 if (uj)
6144 vty_json(vty, json);
977d71cc 6145}
6146
6147DEFUN (show_ip_msdp_sa_sg,
6148 show_ip_msdp_sa_sg_cmd,
20a7e5fd 6149 "show ip msdp [vrf NAME] sa [A.B.C.D [A.B.C.D]] [json]",
977d71cc 6150 SHOW_STR
6151 IP_STR
6152 MSDP_STR
f02d59db 6153 VRF_CMD_HELP_STR
977d71cc 6154 "MSDP active-source information\n"
6155 "source or group ip\n"
a957a05b 6156 "group ip\n"
f5da2cc2 6157 JSON_STR)
977d71cc 6158{
9f049418 6159 bool uj = use_json(argc, argv);
02a16316 6160 struct vrf *vrf;
c68ba0d7 6161 int idx = 2;
02a16316
DS
6162
6163 vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
6164
6165 if (!vrf)
6166 return CMD_WARNING;
6167
d62a17ae 6168 char *src_ip = argv_find(argv, argc, "A.B.C.D", &idx) ? argv[idx++]->arg
521c5b9d 6169 : NULL;
d62a17ae 6170 char *grp_ip = idx < argc && argv_find(argv, argc, "A.B.C.D", &idx)
521c5b9d
MS
6171 ? argv[idx]->arg
6172 : NULL;
9ea49d61 6173
d62a17ae 6174 if (src_ip && grp_ip)
64c86530 6175 ip_msdp_show_sa_sg(vrf->info, vty, src_ip, grp_ip, uj);
d62a17ae 6176 else if (src_ip)
64c86530 6177 ip_msdp_show_sa_addr(vrf->info, vty, src_ip, uj);
d62a17ae 6178 else
64c86530 6179 ip_msdp_show_sa(vrf->info, vty, uj);
3c72d654 6180
d62a17ae 6181 return CMD_SUCCESS;
3c72d654 6182}
6183
47bf9e21
DS
6184DEFUN (show_ip_msdp_sa_sg_vrf_all,
6185 show_ip_msdp_sa_sg_vrf_all_cmd,
6186 "show ip msdp vrf all sa [A.B.C.D [A.B.C.D]] [json]",
6187 SHOW_STR
6188 IP_STR
6189 MSDP_STR
6190 VRF_CMD_HELP_STR
6191 "MSDP active-source information\n"
6192 "source or group ip\n"
6193 "group ip\n"
6194 JSON_STR)
6195{
9f049418 6196 bool uj = use_json(argc, argv);
47bf9e21
DS
6197 struct vrf *vrf;
6198 bool first = true;
6199 int idx = 2;
6200
6201 char *src_ip = argv_find(argv, argc, "A.B.C.D", &idx) ? argv[idx++]->arg
521c5b9d 6202 : NULL;
47bf9e21 6203 char *grp_ip = idx < argc && argv_find(argv, argc, "A.B.C.D", &idx)
521c5b9d
MS
6204 ? argv[idx]->arg
6205 : NULL;
47bf9e21
DS
6206
6207 if (uj)
6208 vty_out(vty, "{ ");
a2addae8 6209 RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
47bf9e21
DS
6210 if (uj) {
6211 if (!first)
6212 vty_out(vty, ", ");
6213 vty_out(vty, " \"%s\": ", vrf->name);
6214 first = false;
6215 } else
6216 vty_out(vty, "VRF: %s\n", vrf->name);
6217
6218 if (src_ip && grp_ip)
6219 ip_msdp_show_sa_sg(vrf->info, vty, src_ip, grp_ip, uj);
6220 else if (src_ip)
6221 ip_msdp_show_sa_addr(vrf->info, vty, src_ip, uj);
6222 else
6223 ip_msdp_show_sa(vrf->info, vty, uj);
6224 }
6225 if (uj)
6226 vty_out(vty, "}\n");
6227
6228 return CMD_SUCCESS;
6229}
6230
f1e2901a
AK
6231struct pim_sg_cache_walk_data {
6232 struct vty *vty;
6233 json_object *json;
6234 json_object *json_group;
6235 struct in_addr addr;
6236 bool addr_match;
6237};
6238
6239static void pim_show_vxlan_sg_entry(struct pim_vxlan_sg *vxlan_sg,
521c5b9d 6240 struct pim_sg_cache_walk_data *cwd)
f1e2901a
AK
6241{
6242 struct vty *vty = cwd->vty;
6243 json_object *json = cwd->json;
f1e2901a 6244 json_object *json_row;
2951a7a4 6245 bool installed = (vxlan_sg->up) ? true : false;
f1e2901a
AK
6246 const char *iif_name = vxlan_sg->iif?vxlan_sg->iif->name:"-";
6247 const char *oif_name;
6248
6249 if (pim_vxlan_is_orig_mroute(vxlan_sg))
6250 oif_name = vxlan_sg->orig_oif?vxlan_sg->orig_oif->name:"";
6251 else
6252 oif_name = vxlan_sg->term_oif?vxlan_sg->term_oif->name:"";
6253
032a7412
DL
6254 if (cwd->addr_match && pim_addr_cmp(vxlan_sg->sg.src, cwd->addr) &&
6255 pim_addr_cmp(vxlan_sg->sg.grp, cwd->addr)) {
f1e2901a
AK
6256 return;
6257 }
f1e2901a 6258 if (json) {
8e8be741
DL
6259 char src_str[PIM_ADDRSTRLEN];
6260 char grp_str[PIM_ADDRSTRLEN];
6261
6262 snprintfrr(grp_str, sizeof(grp_str), "%pPAs",
6263 &vxlan_sg->sg.grp);
6264 snprintfrr(src_str, sizeof(src_str), "%pPAs",
6265 &vxlan_sg->sg.src);
6266
f1e2901a
AK
6267 json_object_object_get_ex(json, grp_str, &cwd->json_group);
6268
6269 if (!cwd->json_group) {
6270 cwd->json_group = json_object_new_object();
6271 json_object_object_add(json, grp_str,
521c5b9d 6272 cwd->json_group);
f1e2901a
AK
6273 }
6274
6275 json_row = json_object_new_object();
6276 json_object_string_add(json_row, "source", src_str);
6277 json_object_string_add(json_row, "group", grp_str);
6278 json_object_string_add(json_row, "input", iif_name);
6279 json_object_string_add(json_row, "output", oif_name);
6280 if (installed)
6281 json_object_boolean_true_add(json_row, "installed");
6282 else
6283 json_object_boolean_false_add(json_row, "installed");
6284 json_object_object_add(cwd->json_group, src_str, json_row);
6285 } else {
8e8be741
DL
6286 vty_out(vty, "%-15pPAs %-15pPAs %-15s %-15s %-5s\n",
6287 &vxlan_sg->sg.src, &vxlan_sg->sg.grp, iif_name,
6288 oif_name, installed ? "I" : "");
f1e2901a
AK
6289 }
6290}
6291
1ac88792 6292static void pim_show_vxlan_sg_hash_entry(struct hash_bucket *bucket, void *arg)
f1e2901a 6293{
1ac88792 6294 pim_show_vxlan_sg_entry((struct pim_vxlan_sg *)bucket->data,
521c5b9d 6295 (struct pim_sg_cache_walk_data *)arg);
f1e2901a
AK
6296}
6297
6298static void pim_show_vxlan_sg(struct pim_instance *pim,
521c5b9d 6299 struct vty *vty, bool uj)
f1e2901a
AK
6300{
6301 json_object *json = NULL;
6302 struct pim_sg_cache_walk_data cwd;
6303
6304 if (uj) {
6305 json = json_object_new_object();
6306 } else {
6307 vty_out(vty, "Codes: I -> installed\n");
6308 vty_out(vty,
6309 "Source Group Input Output Flags\n");
6310 }
6311
6312 memset(&cwd, 0, sizeof(cwd));
6313 cwd.vty = vty;
6314 cwd.json = json;
6315 hash_iterate(pim->vxlan.sg_hash, pim_show_vxlan_sg_hash_entry, &cwd);
6316
3757f964
DA
6317 if (uj)
6318 vty_json(vty, json);
f1e2901a
AK
6319}
6320
6321static void pim_show_vxlan_sg_match_addr(struct pim_instance *pim,
521c5b9d
MS
6322 struct vty *vty, char *addr_str,
6323 bool uj)
f1e2901a
AK
6324{
6325 json_object *json = NULL;
6326 struct pim_sg_cache_walk_data cwd;
6327 int result = 0;
6328
6329 memset(&cwd, 0, sizeof(cwd));
6330 result = inet_pton(AF_INET, addr_str, &cwd.addr);
6331 if (result <= 0) {
6332 vty_out(vty, "Bad address %s: errno=%d: %s\n", addr_str,
521c5b9d 6333 errno, safe_strerror(errno));
f1e2901a
AK
6334 return;
6335 }
6336
6337 if (uj) {
6338 json = json_object_new_object();
6339 } else {
6340 vty_out(vty, "Codes: I -> installed\n");
6341 vty_out(vty,
6342 "Source Group Input Output Flags\n");
6343 }
6344
6345 cwd.vty = vty;
6346 cwd.json = json;
2951a7a4 6347 cwd.addr_match = true;
f1e2901a
AK
6348 hash_iterate(pim->vxlan.sg_hash, pim_show_vxlan_sg_hash_entry, &cwd);
6349
3757f964
DA
6350 if (uj)
6351 vty_json(vty, json);
f1e2901a
AK
6352}
6353
6354static void pim_show_vxlan_sg_one(struct pim_instance *pim,
521c5b9d
MS
6355 struct vty *vty, char *src_str, char *grp_str,
6356 bool uj)
f1e2901a
AK
6357{
6358 json_object *json = NULL;
6fff2cc6 6359 pim_sgaddr sg;
f1e2901a
AK
6360 int result = 0;
6361 struct pim_vxlan_sg *vxlan_sg;
6362 const char *iif_name;
6363 bool installed;
6364 const char *oif_name;
6365
6366 result = inet_pton(AF_INET, src_str, &sg.src);
6367 if (result <= 0) {
6368 vty_out(vty, "Bad src address %s: errno=%d: %s\n", src_str,
521c5b9d 6369 errno, safe_strerror(errno));
f1e2901a
AK
6370 return;
6371 }
6372 result = inet_pton(AF_INET, grp_str, &sg.grp);
6373 if (result <= 0) {
6374 vty_out(vty, "Bad grp address %s: errno=%d: %s\n", grp_str,
521c5b9d 6375 errno, safe_strerror(errno));
f1e2901a
AK
6376 return;
6377 }
6378
f1e2901a
AK
6379 if (uj)
6380 json = json_object_new_object();
6381
6382 vxlan_sg = pim_vxlan_sg_find(pim, &sg);
6383 if (vxlan_sg) {
2951a7a4 6384 installed = (vxlan_sg->up) ? true : false;
f1e2901a
AK
6385 iif_name = vxlan_sg->iif?vxlan_sg->iif->name:"-";
6386
6387 if (pim_vxlan_is_orig_mroute(vxlan_sg))
6388 oif_name =
6389 vxlan_sg->orig_oif?vxlan_sg->orig_oif->name:"";
6390 else
6391 oif_name =
6392 vxlan_sg->term_oif?vxlan_sg->term_oif->name:"";
6393
6394 if (uj) {
6395 json_object_string_add(json, "source", src_str);
6396 json_object_string_add(json, "group", grp_str);
6397 json_object_string_add(json, "input", iif_name);
6398 json_object_string_add(json, "output", oif_name);
6399 if (installed)
6400 json_object_boolean_true_add(json, "installed");
6401 else
6402 json_object_boolean_false_add(json,
521c5b9d 6403 "installed");
f1e2901a
AK
6404 } else {
6405 vty_out(vty, "SG : %s\n", vxlan_sg->sg_str);
6406 vty_out(vty, " Input : %s\n", iif_name);
6407 vty_out(vty, " Output : %s\n", oif_name);
6408 vty_out(vty, " installed : %s\n",
6409 installed?"yes":"no");
6410 }
6411 }
6412
3757f964
DA
6413 if (uj)
6414 vty_json(vty, json);
f1e2901a
AK
6415}
6416
6417DEFUN (show_ip_pim_vxlan_sg,
6418 show_ip_pim_vxlan_sg_cmd,
6419 "show ip pim [vrf NAME] vxlan-groups [A.B.C.D [A.B.C.D]] [json]",
6420 SHOW_STR
6421 IP_STR
6422 PIM_STR
6423 VRF_CMD_HELP_STR
6424 "VxLAN BUM groups\n"
6425 "source or group ip\n"
6426 "group ip\n"
6427 JSON_STR)
6428{
6429 bool uj = use_json(argc, argv);
6430 struct vrf *vrf;
6431 int idx = 2;
6432
6433 vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
6434
6435 if (!vrf)
6436 return CMD_WARNING;
6437
6438 char *src_ip = argv_find(argv, argc, "A.B.C.D", &idx) ?
6439 argv[idx++]->arg:NULL;
6440 char *grp_ip = idx < argc && argv_find(argv, argc, "A.B.C.D", &idx) ?
6441 argv[idx]->arg:NULL;
6442
6443 if (src_ip && grp_ip)
6444 pim_show_vxlan_sg_one(vrf->info, vty, src_ip, grp_ip, uj);
6445 else if (src_ip)
6446 pim_show_vxlan_sg_match_addr(vrf->info, vty, src_ip, uj);
6447 else
6448 pim_show_vxlan_sg(vrf->info, vty, uj);
6449
6450 return CMD_SUCCESS;
6451}
6452
6453static void pim_show_vxlan_sg_work(struct pim_instance *pim,
521c5b9d 6454 struct vty *vty, bool uj)
f1e2901a
AK
6455{
6456 json_object *json = NULL;
6457 struct pim_sg_cache_walk_data cwd;
6458 struct listnode *node;
6459 struct pim_vxlan_sg *vxlan_sg;
6460
6461 if (uj) {
6462 json = json_object_new_object();
6463 } else {
6464 vty_out(vty, "Codes: I -> installed\n");
6465 vty_out(vty,
6466 "Source Group Input Flags\n");
6467 }
6468
6469 memset(&cwd, 0, sizeof(cwd));
6470 cwd.vty = vty;
6471 cwd.json = json;
6472 for (ALL_LIST_ELEMENTS_RO(pim_vxlan_p->work_list, node, vxlan_sg))
6473 pim_show_vxlan_sg_entry(vxlan_sg, &cwd);
6474
3757f964
DA
6475 if (uj)
6476 vty_json(vty, json);
f1e2901a
AK
6477}
6478
6479DEFUN_HIDDEN (show_ip_pim_vxlan_sg_work,
6480 show_ip_pim_vxlan_sg_work_cmd,
6481 "show ip pim [vrf NAME] vxlan-work [json]",
6482 SHOW_STR
6483 IP_STR
6484 PIM_STR
6485 VRF_CMD_HELP_STR
6486 "VxLAN work list\n"
6487 JSON_STR)
6488{
6489 bool uj = use_json(argc, argv);
6490 struct vrf *vrf;
6491 int idx = 2;
6492
6493 vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
6494
6495 if (!vrf)
6496 return CMD_WARNING;
6497
6498 pim_show_vxlan_sg_work(vrf->info, vty, uj);
6499
6500 return CMD_SUCCESS;
6501}
6502
7c85225c 6503DEFUN_HIDDEN (no_ip_pim_mlag,
521c5b9d
MS
6504 no_ip_pim_mlag_cmd,
6505 "no ip pim mlag",
6506 NO_STR
6507 IP_STR
6508 PIM_STR
6509 "MLAG\n")
7c85225c 6510{
0c949724 6511 char mlag_xpath[XPATH_MAXLEN];
7c85225c 6512
698f4147 6513 snprintf(mlag_xpath, sizeof(mlag_xpath), FRR_PIM_VRF_XPATH,
0c949724
SP
6514 "frr-pim:pimd", "pim", "default", "frr-routing:ipv4");
6515 strlcat(mlag_xpath, "/mlag", sizeof(mlag_xpath));
7c85225c 6516
0c949724
SP
6517 nb_cli_enqueue_change(vty, mlag_xpath, NB_OP_DESTROY, NULL);
6518
6519
6520 return nb_cli_apply_changes(vty, NULL);
7c85225c
AK
6521}
6522
6523DEFUN_HIDDEN (ip_pim_mlag,
521c5b9d
MS
6524 ip_pim_mlag_cmd,
6525 "ip pim mlag INTERFACE role [primary|secondary] state [up|down] addr A.B.C.D",
6526 IP_STR
6527 PIM_STR
6528 "MLAG\n"
6529 "peerlink sub interface\n"
6530 "MLAG role\n"
6531 "MLAG role primary\n"
6532 "MLAG role secondary\n"
6533 "peer session state\n"
6534 "peer session state up\n"
6535 "peer session state down\n"
6536 "configure PIP\n"
6537 "unique ip address\n")
7c85225c 6538{
7c85225c 6539 int idx;
0c949724
SP
6540 char mlag_peerlink_rif_xpath[XPATH_MAXLEN];
6541 char mlag_my_role_xpath[XPATH_MAXLEN];
6542 char mlag_peer_state_xpath[XPATH_MAXLEN];
6543 char mlag_reg_address_xpath[XPATH_MAXLEN];
6544
6545 snprintf(mlag_peerlink_rif_xpath, sizeof(mlag_peerlink_rif_xpath),
698f4147 6546 FRR_PIM_VRF_XPATH,
0c949724
SP
6547 "frr-pim:pimd", "pim", "default", "frr-routing:ipv4");
6548 strlcat(mlag_peerlink_rif_xpath, "/mlag/peerlink-rif",
6549 sizeof(mlag_peerlink_rif_xpath));
7c85225c
AK
6550
6551 idx = 3;
0c949724 6552 nb_cli_enqueue_change(vty, mlag_peerlink_rif_xpath, NB_OP_MODIFY,
521c5b9d 6553 argv[idx]->arg);
0c949724
SP
6554
6555 snprintf(mlag_my_role_xpath, sizeof(mlag_my_role_xpath),
698f4147 6556 FRR_PIM_VRF_XPATH,
0c949724
SP
6557 "frr-pim:pimd", "pim", "default", "frr-routing:ipv4");
6558 strlcat(mlag_my_role_xpath, "/mlag/my-role",
6559 sizeof(mlag_my_role_xpath));
7c85225c
AK
6560
6561 idx += 2;
6562 if (!strcmp(argv[idx]->arg, "primary")) {
0c949724 6563 nb_cli_enqueue_change(vty, mlag_my_role_xpath, NB_OP_MODIFY,
521c5b9d 6564 "MLAG_ROLE_PRIMARY");
0c949724 6565
7c85225c 6566 } else if (!strcmp(argv[idx]->arg, "secondary")) {
0c949724 6567 nb_cli_enqueue_change(vty, mlag_my_role_xpath, NB_OP_MODIFY,
521c5b9d 6568 "MLAG_ROLE_SECONDARY");
0c949724 6569
7c85225c
AK
6570 } else {
6571 vty_out(vty, "unknown MLAG role %s\n", argv[idx]->arg);
6572 return CMD_WARNING;
6573 }
6574
0c949724 6575 snprintf(mlag_peer_state_xpath, sizeof(mlag_peer_state_xpath),
698f4147 6576 FRR_PIM_VRF_XPATH,
0c949724
SP
6577 "frr-pim:pimd", "pim", "default", "frr-routing:ipv4");
6578 strlcat(mlag_peer_state_xpath, "/mlag/peer-state",
6579 sizeof(mlag_peer_state_xpath));
6580
7c85225c
AK
6581 idx += 2;
6582 if (!strcmp(argv[idx]->arg, "up")) {
0c949724 6583 nb_cli_enqueue_change(vty, mlag_peer_state_xpath, NB_OP_MODIFY,
521c5b9d 6584 "true");
0c949724 6585
7c85225c 6586 } else if (strcmp(argv[idx]->arg, "down")) {
0c949724 6587 nb_cli_enqueue_change(vty, mlag_peer_state_xpath, NB_OP_MODIFY,
521c5b9d 6588 "false");
0c949724 6589
7c85225c
AK
6590 } else {
6591 vty_out(vty, "unknown MLAG state %s\n", argv[idx]->arg);
6592 return CMD_WARNING;
6593 }
6594
0c949724 6595 snprintf(mlag_reg_address_xpath, sizeof(mlag_reg_address_xpath),
698f4147 6596 FRR_PIM_VRF_XPATH,
0c949724
SP
6597 "frr-pim:pimd", "pim", "default", "frr-routing:ipv4");
6598 strlcat(mlag_reg_address_xpath, "/mlag/reg-address",
6599 sizeof(mlag_reg_address_xpath));
6600
7c85225c 6601 idx += 2;
0c949724 6602 nb_cli_enqueue_change(vty, mlag_reg_address_xpath, NB_OP_MODIFY,
521c5b9d 6603 argv[idx]->arg);
7c85225c 6604
0c949724 6605 return nb_cli_apply_changes(vty, NULL);
7c85225c
AK
6606}
6607
c68ba0d7 6608void pim_cmd_init(void)
12e41d03 6609{
9da01b0b 6610 if_cmd_init(pim_interface_config_write);
d62a17ae 6611
612c2c15 6612 install_node(&debug_node);
d62a17ae 6613
70fd22bd
DS
6614 install_element(ENABLE_NODE, &pim_test_sg_keepalive_cmd);
6615
d62a17ae 6616 install_element(CONFIG_NODE, &ip_pim_rp_cmd);
9ecb7b77 6617 install_element(VRF_NODE, &ip_pim_rp_cmd);
d62a17ae 6618 install_element(CONFIG_NODE, &no_ip_pim_rp_cmd);
9ecb7b77 6619 install_element(VRF_NODE, &no_ip_pim_rp_cmd);
d62a17ae 6620 install_element(CONFIG_NODE, &ip_pim_rp_prefix_list_cmd);
4f9f3925 6621 install_element(VRF_NODE, &ip_pim_rp_prefix_list_cmd);
d62a17ae 6622 install_element(CONFIG_NODE, &no_ip_pim_rp_prefix_list_cmd);
4f9f3925 6623 install_element(VRF_NODE, &no_ip_pim_rp_prefix_list_cmd);
d62a17ae 6624 install_element(CONFIG_NODE, &no_ip_pim_ssm_prefix_list_cmd);
4f9f3925 6625 install_element(VRF_NODE, &no_ip_pim_ssm_prefix_list_cmd);
d62a17ae 6626 install_element(CONFIG_NODE, &no_ip_pim_ssm_prefix_list_name_cmd);
4f9f3925 6627 install_element(VRF_NODE, &no_ip_pim_ssm_prefix_list_name_cmd);
d62a17ae 6628 install_element(CONFIG_NODE, &ip_pim_ssm_prefix_list_cmd);
4f9f3925 6629 install_element(VRF_NODE, &ip_pim_ssm_prefix_list_cmd);
d62a17ae 6630 install_element(CONFIG_NODE, &ip_pim_register_suppress_cmd);
6631 install_element(CONFIG_NODE, &no_ip_pim_register_suppress_cmd);
6632 install_element(CONFIG_NODE, &ip_pim_spt_switchover_infinity_cmd);
4f9f3925 6633 install_element(VRF_NODE, &ip_pim_spt_switchover_infinity_cmd);
d62a17ae 6634 install_element(CONFIG_NODE, &ip_pim_spt_switchover_infinity_plist_cmd);
4f9f3925 6635 install_element(VRF_NODE, &ip_pim_spt_switchover_infinity_plist_cmd);
d62a17ae 6636 install_element(CONFIG_NODE, &no_ip_pim_spt_switchover_infinity_cmd);
4f9f3925 6637 install_element(VRF_NODE, &no_ip_pim_spt_switchover_infinity_cmd);
d62a17ae 6638 install_element(CONFIG_NODE,
6639 &no_ip_pim_spt_switchover_infinity_plist_cmd);
4f9f3925 6640 install_element(VRF_NODE, &no_ip_pim_spt_switchover_infinity_plist_cmd);
f4e74bd0
DS
6641 install_element(CONFIG_NODE, &pim_register_accept_list_cmd);
6642 install_element(VRF_NODE, &pim_register_accept_list_cmd);
d62a17ae 6643 install_element(CONFIG_NODE, &ip_pim_joinprune_time_cmd);
6644 install_element(CONFIG_NODE, &no_ip_pim_joinprune_time_cmd);
6645 install_element(CONFIG_NODE, &ip_pim_keep_alive_cmd);
4f9f3925 6646 install_element(VRF_NODE, &ip_pim_keep_alive_cmd);
cc14df13
DS
6647 install_element(CONFIG_NODE, &ip_pim_rp_keep_alive_cmd);
6648 install_element(VRF_NODE, &ip_pim_rp_keep_alive_cmd);
d62a17ae 6649 install_element(CONFIG_NODE, &no_ip_pim_keep_alive_cmd);
4f9f3925 6650 install_element(VRF_NODE, &no_ip_pim_keep_alive_cmd);
cc14df13
DS
6651 install_element(CONFIG_NODE, &no_ip_pim_rp_keep_alive_cmd);
6652 install_element(VRF_NODE, &no_ip_pim_rp_keep_alive_cmd);
d62a17ae 6653 install_element(CONFIG_NODE, &ip_pim_packets_cmd);
6654 install_element(CONFIG_NODE, &no_ip_pim_packets_cmd);
6655 install_element(CONFIG_NODE, &ip_pim_v6_secondary_cmd);
4f9f3925 6656 install_element(VRF_NODE, &ip_pim_v6_secondary_cmd);
d62a17ae 6657 install_element(CONFIG_NODE, &no_ip_pim_v6_secondary_cmd);
4f9f3925 6658 install_element(VRF_NODE, &no_ip_pim_v6_secondary_cmd);
d62a17ae 6659 install_element(CONFIG_NODE, &ip_ssmpingd_cmd);
4f9f3925 6660 install_element(VRF_NODE, &ip_ssmpingd_cmd);
d62a17ae 6661 install_element(CONFIG_NODE, &no_ip_ssmpingd_cmd);
4f9f3925 6662 install_element(VRF_NODE, &no_ip_ssmpingd_cmd);
d62a17ae 6663 install_element(CONFIG_NODE, &ip_msdp_peer_cmd);
4f9f3925 6664 install_element(VRF_NODE, &ip_msdp_peer_cmd);
d62a17ae 6665 install_element(CONFIG_NODE, &no_ip_msdp_peer_cmd);
4f9f3925 6666 install_element(VRF_NODE, &no_ip_msdp_peer_cmd);
d62a17ae 6667 install_element(CONFIG_NODE, &ip_pim_ecmp_cmd);
4f9f3925 6668 install_element(VRF_NODE, &ip_pim_ecmp_cmd);
d62a17ae 6669 install_element(CONFIG_NODE, &no_ip_pim_ecmp_cmd);
4f9f3925 6670 install_element(VRF_NODE, &no_ip_pim_ecmp_cmd);
d62a17ae 6671 install_element(CONFIG_NODE, &ip_pim_ecmp_rebalance_cmd);
4f9f3925 6672 install_element(VRF_NODE, &ip_pim_ecmp_rebalance_cmd);
d62a17ae 6673 install_element(CONFIG_NODE, &no_ip_pim_ecmp_rebalance_cmd);
4f9f3925 6674 install_element(VRF_NODE, &no_ip_pim_ecmp_rebalance_cmd);
7c85225c
AK
6675 install_element(CONFIG_NODE, &ip_pim_mlag_cmd);
6676 install_element(CONFIG_NODE, &no_ip_pim_mlag_cmd);
fb005412
SG
6677 install_element(CONFIG_NODE, &ip_igmp_group_watermark_cmd);
6678 install_element(VRF_NODE, &ip_igmp_group_watermark_cmd);
6679 install_element(CONFIG_NODE, &no_ip_igmp_group_watermark_cmd);
6680 install_element(VRF_NODE, &no_ip_igmp_group_watermark_cmd);
d62a17ae 6681
6682 install_element(INTERFACE_NODE, &interface_ip_igmp_cmd);
6683 install_element(INTERFACE_NODE, &interface_no_ip_igmp_cmd);
6684 install_element(INTERFACE_NODE, &interface_ip_igmp_join_cmd);
6685 install_element(INTERFACE_NODE, &interface_no_ip_igmp_join_cmd);
6686 install_element(INTERFACE_NODE, &interface_ip_igmp_version_cmd);
6687 install_element(INTERFACE_NODE, &interface_no_ip_igmp_version_cmd);
6688 install_element(INTERFACE_NODE, &interface_ip_igmp_query_interval_cmd);
6689 install_element(INTERFACE_NODE,
6690 &interface_no_ip_igmp_query_interval_cmd);
6691 install_element(INTERFACE_NODE,
6692 &interface_ip_igmp_query_max_response_time_cmd);
6693 install_element(INTERFACE_NODE,
6694 &interface_no_ip_igmp_query_max_response_time_cmd);
6695 install_element(INTERFACE_NODE,
6696 &interface_ip_igmp_query_max_response_time_dsec_cmd);
6697 install_element(INTERFACE_NODE,
6698 &interface_no_ip_igmp_query_max_response_time_dsec_cmd);
59115451
SP
6699 install_element(INTERFACE_NODE,
6700 &interface_ip_igmp_last_member_query_count_cmd);
6701 install_element(INTERFACE_NODE,
6702 &interface_no_ip_igmp_last_member_query_count_cmd);
6703 install_element(INTERFACE_NODE,
6704 &interface_ip_igmp_last_member_query_interval_cmd);
6705 install_element(INTERFACE_NODE,
6706 &interface_no_ip_igmp_last_member_query_interval_cmd);
414d885a 6707 install_element(INTERFACE_NODE, &interface_ip_pim_activeactive_cmd);
d62a17ae 6708 install_element(INTERFACE_NODE, &interface_ip_pim_ssm_cmd);
6709 install_element(INTERFACE_NODE, &interface_no_ip_pim_ssm_cmd);
6710 install_element(INTERFACE_NODE, &interface_ip_pim_sm_cmd);
6711 install_element(INTERFACE_NODE, &interface_no_ip_pim_sm_cmd);
2f5e937c 6712 install_element(INTERFACE_NODE, &interface_ip_pim_cmd);
6713 install_element(INTERFACE_NODE, &interface_no_ip_pim_cmd);
d62a17ae 6714 install_element(INTERFACE_NODE, &interface_ip_pim_drprio_cmd);
6715 install_element(INTERFACE_NODE, &interface_no_ip_pim_drprio_cmd);
6716 install_element(INTERFACE_NODE, &interface_ip_pim_hello_cmd);
6717 install_element(INTERFACE_NODE, &interface_no_ip_pim_hello_cmd);
b0f525a8
QY
6718 install_element(INTERFACE_NODE, &interface_ip_pim_boundary_oil_cmd);
6719 install_element(INTERFACE_NODE, &interface_no_ip_pim_boundary_oil_cmd);
6741a5bb 6720 install_element(INTERFACE_NODE, &interface_ip_igmp_query_generate_cmd);
d62a17ae 6721
6722 // Static mroutes NEB
6723 install_element(INTERFACE_NODE, &interface_ip_mroute_cmd);
d62a17ae 6724 install_element(INTERFACE_NODE, &interface_no_ip_mroute_cmd);
d62a17ae 6725
6726 install_element(VIEW_NODE, &show_ip_igmp_interface_cmd);
a25de56b 6727 install_element(VIEW_NODE, &show_ip_igmp_interface_vrf_all_cmd);
d62a17ae 6728 install_element(VIEW_NODE, &show_ip_igmp_join_cmd);
a25de56b 6729 install_element(VIEW_NODE, &show_ip_igmp_join_vrf_all_cmd);
d62a17ae 6730 install_element(VIEW_NODE, &show_ip_igmp_groups_cmd);
a25de56b 6731 install_element(VIEW_NODE, &show_ip_igmp_groups_vrf_all_cmd);
d62a17ae 6732 install_element(VIEW_NODE, &show_ip_igmp_groups_retransmissions_cmd);
6733 install_element(VIEW_NODE, &show_ip_igmp_sources_cmd);
6734 install_element(VIEW_NODE, &show_ip_igmp_sources_retransmissions_cmd);
21313cbf 6735 install_element(VIEW_NODE, &show_ip_igmp_statistics_cmd);
d62a17ae 6736 install_element(VIEW_NODE, &show_ip_pim_assert_cmd);
6737 install_element(VIEW_NODE, &show_ip_pim_assert_internal_cmd);
6738 install_element(VIEW_NODE, &show_ip_pim_assert_metric_cmd);
6739 install_element(VIEW_NODE, &show_ip_pim_assert_winner_metric_cmd);
6740 install_element(VIEW_NODE, &show_ip_pim_interface_traffic_cmd);
6741 install_element(VIEW_NODE, &show_ip_pim_interface_cmd);
a25de56b 6742 install_element(VIEW_NODE, &show_ip_pim_interface_vrf_all_cmd);
d62a17ae 6743 install_element(VIEW_NODE, &show_ip_pim_join_cmd);
a25de56b 6744 install_element(VIEW_NODE, &show_ip_pim_join_vrf_all_cmd);
87b7cd5b 6745 install_element(VIEW_NODE, &show_ip_pim_jp_agg_cmd);
d62a17ae 6746 install_element(VIEW_NODE, &show_ip_pim_local_membership_cmd);
f80427e9
AK
6747 install_element(VIEW_NODE, &show_ip_pim_mlag_summary_cmd);
6748 install_element(VIEW_NODE, &show_ip_pim_mlag_up_cmd);
6749 install_element(VIEW_NODE, &show_ip_pim_mlag_up_vrf_all_cmd);
d62a17ae 6750 install_element(VIEW_NODE, &show_ip_pim_neighbor_cmd);
a25de56b 6751 install_element(VIEW_NODE, &show_ip_pim_neighbor_vrf_all_cmd);
d62a17ae 6752 install_element(VIEW_NODE, &show_ip_pim_rpf_cmd);
a25de56b 6753 install_element(VIEW_NODE, &show_ip_pim_rpf_vrf_all_cmd);
d62a17ae 6754 install_element(VIEW_NODE, &show_ip_pim_secondary_cmd);
6755 install_element(VIEW_NODE, &show_ip_pim_state_cmd);
a25de56b 6756 install_element(VIEW_NODE, &show_ip_pim_state_vrf_all_cmd);
d62a17ae 6757 install_element(VIEW_NODE, &show_ip_pim_upstream_cmd);
a25de56b 6758 install_element(VIEW_NODE, &show_ip_pim_upstream_vrf_all_cmd);
5c9a72ef 6759 install_element(VIEW_NODE, &show_ip_pim_channel_cmd);
d62a17ae 6760 install_element(VIEW_NODE, &show_ip_pim_upstream_join_desired_cmd);
6761 install_element(VIEW_NODE, &show_ip_pim_upstream_rpf_cmd);
6762 install_element(VIEW_NODE, &show_ip_pim_rp_cmd);
a25de56b 6763 install_element(VIEW_NODE, &show_ip_pim_rp_vrf_all_cmd);
256392eb 6764 install_element(VIEW_NODE, &show_ip_pim_bsr_cmd);
d62a17ae 6765 install_element(VIEW_NODE, &show_ip_multicast_cmd);
a25de56b 6766 install_element(VIEW_NODE, &show_ip_multicast_vrf_all_cmd);
8c8d7031
SP
6767 install_element(VIEW_NODE, &show_ip_multicast_count_cmd);
6768 install_element(VIEW_NODE, &show_ip_multicast_count_vrf_all_cmd);
d62a17ae 6769 install_element(VIEW_NODE, &show_ip_mroute_cmd);
b283a4ca 6770 install_element(VIEW_NODE, &show_ip_mroute_vrf_all_cmd);
d62a17ae 6771 install_element(VIEW_NODE, &show_ip_mroute_count_cmd);
5c3aac90 6772 install_element(VIEW_NODE, &show_ip_mroute_count_vrf_all_cmd);
468b6f44
SP
6773 install_element(VIEW_NODE, &show_ip_mroute_summary_cmd);
6774 install_element(VIEW_NODE, &show_ip_mroute_summary_vrf_all_cmd);
d62a17ae 6775 install_element(VIEW_NODE, &show_ip_rib_cmd);
6776 install_element(VIEW_NODE, &show_ip_ssmpingd_cmd);
d62a17ae 6777 install_element(VIEW_NODE, &show_ip_pim_nexthop_cmd);
6778 install_element(VIEW_NODE, &show_ip_pim_nexthop_lookup_cmd);
321295c1 6779 install_element(VIEW_NODE, &show_ip_pim_bsrp_cmd);
0d1a4e24 6780 install_element(VIEW_NODE, &show_ip_pim_bsm_db_cmd);
415f6350 6781 install_element(VIEW_NODE, &show_ip_pim_statistics_cmd);
d62a17ae 6782
cd333cf9 6783 install_element(ENABLE_NODE, &clear_ip_mroute_count_cmd);
d62a17ae 6784 install_element(ENABLE_NODE, &clear_ip_interfaces_cmd);
6785 install_element(ENABLE_NODE, &clear_ip_igmp_interfaces_cmd);
6786 install_element(ENABLE_NODE, &clear_ip_mroute_cmd);
6787 install_element(ENABLE_NODE, &clear_ip_pim_interfaces_cmd);
6788 install_element(ENABLE_NODE, &clear_ip_pim_interface_traffic_cmd);
6789 install_element(ENABLE_NODE, &clear_ip_pim_oil_cmd);
415f6350 6790 install_element(ENABLE_NODE, &clear_ip_pim_statistics_cmd);
e7016ceb 6791 install_element(ENABLE_NODE, &clear_ip_pim_bsr_db_cmd);
d62a17ae 6792
dd73744d
IR
6793 install_element(ENABLE_NODE, &show_debugging_pim_cmd);
6794
d62a17ae 6795 install_element(ENABLE_NODE, &debug_igmp_cmd);
6796 install_element(ENABLE_NODE, &no_debug_igmp_cmd);
6797 install_element(ENABLE_NODE, &debug_igmp_events_cmd);
6798 install_element(ENABLE_NODE, &no_debug_igmp_events_cmd);
6799 install_element(ENABLE_NODE, &debug_igmp_packets_cmd);
6800 install_element(ENABLE_NODE, &no_debug_igmp_packets_cmd);
6801 install_element(ENABLE_NODE, &debug_igmp_trace_cmd);
6802 install_element(ENABLE_NODE, &no_debug_igmp_trace_cmd);
e9c59240
DL
6803 install_element(ENABLE_NODE, &debug_igmp_trace_detail_cmd);
6804 install_element(ENABLE_NODE, &no_debug_igmp_trace_detail_cmd);
d62a17ae 6805 install_element(ENABLE_NODE, &debug_mroute_cmd);
6806 install_element(ENABLE_NODE, &debug_mroute_detail_cmd);
6807 install_element(ENABLE_NODE, &no_debug_mroute_cmd);
6808 install_element(ENABLE_NODE, &no_debug_mroute_detail_cmd);
35a12720
MS
6809 install_element(ENABLE_NODE, &debug_pim_static_cmd);
6810 install_element(ENABLE_NODE, &no_debug_pim_static_cmd);
d62a17ae 6811 install_element(ENABLE_NODE, &debug_pim_cmd);
40f1f31b 6812 install_element(ENABLE_NODE, &debug_pim_nht_cmd);
6d733f0d 6813 install_element(ENABLE_NODE, &debug_pim_nht_det_cmd);
3d225d48
DS
6814 install_element(ENABLE_NODE, &debug_pim_nht_rp_cmd);
6815 install_element(ENABLE_NODE, &no_debug_pim_nht_rp_cmd);
d62a17ae 6816 install_element(ENABLE_NODE, &debug_pim_events_cmd);
d62a17ae 6817 install_element(ENABLE_NODE, &debug_pim_packets_cmd);
d62a17ae 6818 install_element(ENABLE_NODE, &debug_pim_packetdump_send_cmd);
d62a17ae 6819 install_element(ENABLE_NODE, &debug_pim_packetdump_recv_cmd);
d62a17ae 6820 install_element(ENABLE_NODE, &debug_pim_trace_cmd);
56c238c9 6821 install_element(ENABLE_NODE, &debug_pim_trace_detail_cmd);
d62a17ae 6822 install_element(ENABLE_NODE, &debug_ssmpingd_cmd);
6823 install_element(ENABLE_NODE, &no_debug_ssmpingd_cmd);
6824 install_element(ENABLE_NODE, &debug_pim_zebra_cmd);
36b5b98f
SK
6825 install_element(ENABLE_NODE, &debug_pim_mlag_cmd);
6826 install_element(ENABLE_NODE, &no_debug_pim_mlag_cmd);
4d913fa6
AK
6827 install_element(ENABLE_NODE, &debug_pim_vxlan_cmd);
6828 install_element(ENABLE_NODE, &no_debug_pim_vxlan_cmd);
d62a17ae 6829 install_element(ENABLE_NODE, &debug_msdp_cmd);
6830 install_element(ENABLE_NODE, &no_debug_msdp_cmd);
d62a17ae 6831 install_element(ENABLE_NODE, &debug_msdp_events_cmd);
6832 install_element(ENABLE_NODE, &no_debug_msdp_events_cmd);
d62a17ae 6833 install_element(ENABLE_NODE, &debug_msdp_packets_cmd);
6834 install_element(ENABLE_NODE, &no_debug_msdp_packets_cmd);
4d9ad5dc
MS
6835 install_element(ENABLE_NODE, &debug_mtrace_cmd);
6836 install_element(ENABLE_NODE, &no_debug_mtrace_cmd);
09524ccf 6837 install_element(ENABLE_NODE, &debug_bsm_cmd);
6838 install_element(ENABLE_NODE, &no_debug_bsm_cmd);
d62a17ae 6839
6840 install_element(CONFIG_NODE, &debug_igmp_cmd);
6841 install_element(CONFIG_NODE, &no_debug_igmp_cmd);
6842 install_element(CONFIG_NODE, &debug_igmp_events_cmd);
6843 install_element(CONFIG_NODE, &no_debug_igmp_events_cmd);
6844 install_element(CONFIG_NODE, &debug_igmp_packets_cmd);
6845 install_element(CONFIG_NODE, &no_debug_igmp_packets_cmd);
6846 install_element(CONFIG_NODE, &debug_igmp_trace_cmd);
6847 install_element(CONFIG_NODE, &no_debug_igmp_trace_cmd);
e9c59240
DL
6848 install_element(CONFIG_NODE, &debug_igmp_trace_detail_cmd);
6849 install_element(CONFIG_NODE, &no_debug_igmp_trace_detail_cmd);
d62a17ae 6850 install_element(CONFIG_NODE, &debug_mroute_cmd);
6851 install_element(CONFIG_NODE, &debug_mroute_detail_cmd);
6852 install_element(CONFIG_NODE, &no_debug_mroute_cmd);
6853 install_element(CONFIG_NODE, &no_debug_mroute_detail_cmd);
35a12720
MS
6854 install_element(CONFIG_NODE, &debug_pim_static_cmd);
6855 install_element(CONFIG_NODE, &no_debug_pim_static_cmd);
d62a17ae 6856 install_element(CONFIG_NODE, &debug_pim_cmd);
40f1f31b 6857 install_element(CONFIG_NODE, &debug_pim_nht_cmd);
6d733f0d 6858 install_element(CONFIG_NODE, &debug_pim_nht_det_cmd);
3d225d48
DS
6859 install_element(CONFIG_NODE, &debug_pim_nht_rp_cmd);
6860 install_element(CONFIG_NODE, &no_debug_pim_nht_rp_cmd);
d62a17ae 6861 install_element(CONFIG_NODE, &debug_pim_events_cmd);
d62a17ae 6862 install_element(CONFIG_NODE, &debug_pim_packets_cmd);
5c4508cb 6863 install_element(CONFIG_NODE, &debug_pim_packetdump_send_cmd);
5c4508cb 6864 install_element(CONFIG_NODE, &debug_pim_packetdump_recv_cmd);
d62a17ae 6865 install_element(CONFIG_NODE, &debug_pim_trace_cmd);
56c238c9 6866 install_element(CONFIG_NODE, &debug_pim_trace_detail_cmd);
d62a17ae 6867 install_element(CONFIG_NODE, &debug_ssmpingd_cmd);
6868 install_element(CONFIG_NODE, &no_debug_ssmpingd_cmd);
6869 install_element(CONFIG_NODE, &debug_pim_zebra_cmd);
f80427e9
AK
6870 install_element(CONFIG_NODE, &debug_pim_mlag_cmd);
6871 install_element(CONFIG_NODE, &no_debug_pim_mlag_cmd);
4d913fa6
AK
6872 install_element(CONFIG_NODE, &debug_pim_vxlan_cmd);
6873 install_element(CONFIG_NODE, &no_debug_pim_vxlan_cmd);
d62a17ae 6874 install_element(CONFIG_NODE, &debug_msdp_cmd);
6875 install_element(CONFIG_NODE, &no_debug_msdp_cmd);
d62a17ae 6876 install_element(CONFIG_NODE, &debug_msdp_events_cmd);
6877 install_element(CONFIG_NODE, &no_debug_msdp_events_cmd);
d62a17ae 6878 install_element(CONFIG_NODE, &debug_msdp_packets_cmd);
6879 install_element(CONFIG_NODE, &no_debug_msdp_packets_cmd);
4d9ad5dc
MS
6880 install_element(CONFIG_NODE, &debug_mtrace_cmd);
6881 install_element(CONFIG_NODE, &no_debug_mtrace_cmd);
09524ccf 6882 install_element(CONFIG_NODE, &debug_bsm_cmd);
6883 install_element(CONFIG_NODE, &no_debug_bsm_cmd);
02a16316 6884
622fd3f1
RZ
6885 install_element(CONFIG_NODE, &ip_msdp_timers_cmd);
6886 install_element(VRF_NODE, &ip_msdp_timers_cmd);
11ca3587
CH
6887 install_element(CONFIG_NODE, &no_ip_msdp_timers_cmd);
6888 install_element(VRF_NODE, &no_ip_msdp_timers_cmd);
d62a17ae 6889 install_element(CONFIG_NODE, &ip_msdp_mesh_group_member_cmd);
02a16316 6890 install_element(VRF_NODE, &ip_msdp_mesh_group_member_cmd);
d62a17ae 6891 install_element(CONFIG_NODE, &no_ip_msdp_mesh_group_member_cmd);
1b973cb7 6892 install_element(VRF_NODE, &no_ip_msdp_mesh_group_member_cmd);
d62a17ae 6893 install_element(CONFIG_NODE, &ip_msdp_mesh_group_source_cmd);
02a16316 6894 install_element(VRF_NODE, &ip_msdp_mesh_group_source_cmd);
d62a17ae 6895 install_element(CONFIG_NODE, &no_ip_msdp_mesh_group_source_cmd);
02a16316 6896 install_element(VRF_NODE, &no_ip_msdp_mesh_group_source_cmd);
34d86eff
SP
6897 install_element(CONFIG_NODE, &no_ip_msdp_mesh_group_cmd);
6898 install_element(VRF_NODE, &no_ip_msdp_mesh_group_cmd);
d62a17ae 6899 install_element(VIEW_NODE, &show_ip_msdp_peer_detail_cmd);
a25de56b 6900 install_element(VIEW_NODE, &show_ip_msdp_peer_detail_vrf_all_cmd);
d62a17ae 6901 install_element(VIEW_NODE, &show_ip_msdp_sa_detail_cmd);
a25de56b 6902 install_element(VIEW_NODE, &show_ip_msdp_sa_detail_vrf_all_cmd);
d62a17ae 6903 install_element(VIEW_NODE, &show_ip_msdp_sa_sg_cmd);
47bf9e21 6904 install_element(VIEW_NODE, &show_ip_msdp_sa_sg_vrf_all_cmd);
d62a17ae 6905 install_element(VIEW_NODE, &show_ip_msdp_mesh_group_cmd);
a25de56b 6906 install_element(VIEW_NODE, &show_ip_msdp_mesh_group_vrf_all_cmd);
d62a17ae 6907 install_element(VIEW_NODE, &show_ip_pim_ssm_range_cmd);
6908 install_element(VIEW_NODE, &show_ip_pim_group_type_cmd);
f1e2901a
AK
6909 install_element(VIEW_NODE, &show_ip_pim_vxlan_sg_cmd);
6910 install_element(VIEW_NODE, &show_ip_pim_vxlan_sg_work_cmd);
d62a17ae 6911 install_element(INTERFACE_NODE, &interface_pim_use_source_cmd);
6912 install_element(INTERFACE_NODE, &interface_no_pim_use_source_cmd);
16c926c8 6913 /* Install BSM command */
6914 install_element(INTERFACE_NODE, &ip_pim_bsm_cmd);
6915 install_element(INTERFACE_NODE, &no_ip_pim_bsm_cmd);
6916 install_element(INTERFACE_NODE, &ip_pim_ucast_bsm_cmd);
6917 install_element(INTERFACE_NODE, &no_ip_pim_ucast_bsm_cmd);
d62a17ae 6918 /* Install BFD command */
6919 install_element(INTERFACE_NODE, &ip_pim_bfd_cmd);
6920 install_element(INTERFACE_NODE, &ip_pim_bfd_param_cmd);
745b8d4a 6921 install_element(INTERFACE_NODE, &no_ip_pim_bfd_profile_cmd);
d62a17ae 6922 install_element(INTERFACE_NODE, &no_ip_pim_bfd_cmd);
64dc4b2d 6923#if HAVE_BFDD == 0
d62a17ae 6924 install_element(INTERFACE_NODE, &no_ip_pim_bfd_param_cmd);
64dc4b2d 6925#endif /* !HAVE_BFDD */
12e41d03 6926}