3 * Copyright (C) 2022 Vmware, Inc.
4 * Mobashshera Rasool <mrasool@vmware.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
33 #include "lib/srcdest_table.h"
34 #include "lib/linklist.h"
35 #include "termtable.h"
38 #include "pim_instance.h"
40 #include "lib/northbound_cli.h"
41 #include "pim_errors.h"
43 #include "pim_mroute.h"
46 #include "pim_cmd_common.h"
48 #include "pim_zebra.h"
49 #include "pim_zlookup.h"
50 #include "pim_iface.h"
51 #include "pim_macro.h"
52 #include "pim_neighbor.h"
56 #include "pim_static.h"
58 #include "pim_static.h"
63 * Get current node VRF name.
66 * In case of failure it will print error message to user.
68 * \returns name or NULL if failed to get VRF.
70 const char *pim_cli_get_vrf_name(struct vty
*vty
)
72 const struct lyd_node
*vrf_node
;
74 /* Not inside any VRF context. */
75 if (vty
->xpath_index
== 0)
76 return VRF_DEFAULT_NAME
;
78 vrf_node
= yang_dnode_get(vty
->candidate_config
->dnode
, VTY_CURR_XPATH
);
79 if (vrf_node
== NULL
) {
80 vty_out(vty
, "%% Failed to get vrf dnode in configuration\n");
84 return yang_dnode_get_string(vrf_node
, "./name");
87 int pim_process_join_prune_cmd(struct vty
*vty
, const char *jpi_str
)
89 char xpath
[XPATH_MAXLEN
];
91 snprintf(xpath
, sizeof(xpath
), FRR_PIM_ROUTER_XPATH
,
92 FRR_PIM_AF_XPATH_VAL
);
93 strlcat(xpath
, "/join-prune-interval", sizeof(xpath
));
95 nb_cli_enqueue_change(vty
, xpath
, NB_OP_MODIFY
, jpi_str
);
97 return nb_cli_apply_changes(vty
, NULL
);
100 int pim_process_no_join_prune_cmd(struct vty
*vty
)
102 char xpath
[XPATH_MAXLEN
];
104 snprintf(xpath
, sizeof(xpath
), FRR_PIM_ROUTER_XPATH
,
105 FRR_PIM_AF_XPATH_VAL
);
106 strlcat(xpath
, "/join-prune-interval", sizeof(xpath
));
108 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
110 return nb_cli_apply_changes(vty
, NULL
);
113 int pim_process_spt_switchover_infinity_cmd(struct vty
*vty
)
116 char spt_plist_xpath
[XPATH_MAXLEN
];
117 char spt_action_xpath
[XPATH_MAXLEN
];
119 vrfname
= pim_cli_get_vrf_name(vty
);
121 return CMD_WARNING_CONFIG_FAILED
;
123 snprintf(spt_plist_xpath
, sizeof(spt_plist_xpath
),
124 FRR_PIM_VRF_XPATH
, "frr-pim:pimd", "pim", vrfname
,
125 FRR_PIM_AF_XPATH_VAL
);
126 strlcat(spt_plist_xpath
, "/spt-switchover/spt-infinity-prefix-list",
127 sizeof(spt_plist_xpath
));
129 snprintf(spt_action_xpath
, sizeof(spt_action_xpath
),
130 FRR_PIM_VRF_XPATH
, "frr-pim:pimd", "pim", vrfname
,
131 FRR_PIM_AF_XPATH_VAL
);
132 strlcat(spt_action_xpath
, "/spt-switchover/spt-action",
133 sizeof(spt_action_xpath
));
135 if (yang_dnode_exists(vty
->candidate_config
->dnode
, spt_plist_xpath
))
136 nb_cli_enqueue_change(vty
, spt_plist_xpath
, NB_OP_DESTROY
,
138 nb_cli_enqueue_change(vty
, spt_action_xpath
, NB_OP_MODIFY
,
141 return nb_cli_apply_changes(vty
, NULL
);
144 int pim_process_spt_switchover_prefixlist_cmd(struct vty
*vty
,
148 char spt_plist_xpath
[XPATH_MAXLEN
];
149 char spt_action_xpath
[XPATH_MAXLEN
];
151 vrfname
= pim_cli_get_vrf_name(vty
);
153 return CMD_WARNING_CONFIG_FAILED
;
155 snprintf(spt_plist_xpath
, sizeof(spt_plist_xpath
),
156 FRR_PIM_VRF_XPATH
, "frr-pim:pimd", "pim", vrfname
,
157 FRR_PIM_AF_XPATH_VAL
);
158 strlcat(spt_plist_xpath
, "/spt-switchover/spt-infinity-prefix-list",
159 sizeof(spt_plist_xpath
));
161 snprintf(spt_action_xpath
, sizeof(spt_action_xpath
),
162 FRR_PIM_VRF_XPATH
, "frr-pim:pimd", "pim", vrfname
,
163 FRR_PIM_AF_XPATH_VAL
);
164 strlcat(spt_action_xpath
, "/spt-switchover/spt-action",
165 sizeof(spt_action_xpath
));
167 nb_cli_enqueue_change(vty
, spt_action_xpath
, NB_OP_MODIFY
,
169 nb_cli_enqueue_change(vty
, spt_plist_xpath
, NB_OP_MODIFY
,
172 return nb_cli_apply_changes(vty
, NULL
);
175 int pim_process_no_spt_switchover_cmd(struct vty
*vty
)
178 char spt_plist_xpath
[XPATH_MAXLEN
];
179 char spt_action_xpath
[XPATH_MAXLEN
];
181 vrfname
= pim_cli_get_vrf_name(vty
);
183 return CMD_WARNING_CONFIG_FAILED
;
185 snprintf(spt_plist_xpath
, sizeof(spt_plist_xpath
),
186 FRR_PIM_VRF_XPATH
, "frr-pim:pimd", "pim", vrfname
,
187 FRR_PIM_AF_XPATH_VAL
);
188 strlcat(spt_plist_xpath
, "/spt-switchover/spt-infinity-prefix-list",
189 sizeof(spt_plist_xpath
));
191 snprintf(spt_action_xpath
, sizeof(spt_action_xpath
),
192 FRR_PIM_VRF_XPATH
, "frr-pim:pimd", "pim", vrfname
,
193 FRR_PIM_AF_XPATH_VAL
);
194 strlcat(spt_action_xpath
, "/spt-switchover/spt-action",
195 sizeof(spt_action_xpath
));
197 nb_cli_enqueue_change(vty
, spt_plist_xpath
, NB_OP_DESTROY
, NULL
);
198 nb_cli_enqueue_change(vty
, spt_action_xpath
, NB_OP_MODIFY
,
199 "PIM_SPT_IMMEDIATE");
201 return nb_cli_apply_changes(vty
, NULL
);
204 int pim_process_pim_packet_cmd(struct vty
*vty
, const char *packet
)
206 char xpath
[XPATH_MAXLEN
];
208 snprintf(xpath
, sizeof(xpath
), FRR_PIM_ROUTER_XPATH
,
209 FRR_PIM_AF_XPATH_VAL
);
210 strlcat(xpath
, "/packets", sizeof(xpath
));
212 nb_cli_enqueue_change(vty
, xpath
, NB_OP_MODIFY
, packet
);
214 return nb_cli_apply_changes(vty
, NULL
);
217 int pim_process_no_pim_packet_cmd(struct vty
*vty
)
219 char xpath
[XPATH_MAXLEN
];
221 snprintf(xpath
, sizeof(xpath
), FRR_PIM_ROUTER_XPATH
,
222 FRR_PIM_AF_XPATH_VAL
);
223 strlcat(xpath
, "/packets", sizeof(xpath
));
225 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
227 return nb_cli_apply_changes(vty
, NULL
);
230 int pim_process_keepalivetimer_cmd(struct vty
*vty
, const char *kat
)
233 char ka_timer_xpath
[XPATH_MAXLEN
];
235 vrfname
= pim_cli_get_vrf_name(vty
);
237 return CMD_WARNING_CONFIG_FAILED
;
239 snprintf(ka_timer_xpath
, sizeof(ka_timer_xpath
), FRR_PIM_VRF_XPATH
,
240 "frr-pim:pimd", "pim", vrfname
, FRR_PIM_AF_XPATH_VAL
);
241 strlcat(ka_timer_xpath
, "/keep-alive-timer", sizeof(ka_timer_xpath
));
243 nb_cli_enqueue_change(vty
, ka_timer_xpath
, NB_OP_MODIFY
,
246 return nb_cli_apply_changes(vty
, NULL
);
249 int pim_process_no_keepalivetimer_cmd(struct vty
*vty
)
252 char ka_timer_xpath
[XPATH_MAXLEN
];
254 vrfname
= pim_cli_get_vrf_name(vty
);
256 return CMD_WARNING_CONFIG_FAILED
;
258 snprintf(ka_timer_xpath
, sizeof(ka_timer_xpath
), FRR_PIM_VRF_XPATH
,
259 "frr-pim:pimd", "pim", vrfname
, FRR_PIM_AF_XPATH_VAL
);
260 strlcat(ka_timer_xpath
, "/keep-alive-timer", sizeof(ka_timer_xpath
));
262 nb_cli_enqueue_change(vty
, ka_timer_xpath
, NB_OP_DESTROY
, NULL
);
264 return nb_cli_apply_changes(vty
, NULL
);
267 int pim_process_rp_kat_cmd(struct vty
*vty
, const char *rpkat
)
270 char rp_ka_timer_xpath
[XPATH_MAXLEN
];
272 vrfname
= pim_cli_get_vrf_name(vty
);
274 return CMD_WARNING_CONFIG_FAILED
;
276 snprintf(rp_ka_timer_xpath
, sizeof(rp_ka_timer_xpath
),
277 FRR_PIM_VRF_XPATH
, "frr-pim:pimd", "pim", vrfname
,
278 FRR_PIM_AF_XPATH_VAL
);
279 strlcat(rp_ka_timer_xpath
, "/rp-keep-alive-timer",
280 sizeof(rp_ka_timer_xpath
));
282 nb_cli_enqueue_change(vty
, rp_ka_timer_xpath
, NB_OP_MODIFY
,
285 return nb_cli_apply_changes(vty
, NULL
);
288 int pim_process_no_rp_kat_cmd(struct vty
*vty
)
292 char rp_ka_timer_xpath
[XPATH_MAXLEN
];
294 char rs_timer_xpath
[XPATH_MAXLEN
];
296 snprintf(rs_timer_xpath
, sizeof(rs_timer_xpath
),
297 FRR_PIM_ROUTER_XPATH
, FRR_PIM_AF_XPATH_VAL
);
298 strlcat(rs_timer_xpath
, "/register-suppress-time",
299 sizeof(rs_timer_xpath
));
302 v
= yang_dnode_get_uint16(vty
->candidate_config
->dnode
,
304 v
= 3 * v
+ PIM_REGISTER_PROBE_TIME_DEFAULT
;
307 snprintf(rp_ka_timer
, sizeof(rp_ka_timer
), "%u", v
);
309 vrfname
= pim_cli_get_vrf_name(vty
);
311 return CMD_WARNING_CONFIG_FAILED
;
313 snprintf(rp_ka_timer_xpath
, sizeof(rp_ka_timer_xpath
),
314 FRR_PIM_VRF_XPATH
, "frr-pim:pimd", "pim", vrfname
,
315 FRR_PIM_AF_XPATH_VAL
);
316 strlcat(rp_ka_timer_xpath
, "/rp-keep-alive-timer",
317 sizeof(rp_ka_timer_xpath
));
319 nb_cli_enqueue_change(vty
, rp_ka_timer_xpath
, NB_OP_MODIFY
,
322 return nb_cli_apply_changes(vty
, NULL
);
325 int pim_process_register_suppress_cmd(struct vty
*vty
, const char *rst
)
327 char xpath
[XPATH_MAXLEN
];
329 snprintf(xpath
, sizeof(xpath
), FRR_PIM_ROUTER_XPATH
,
330 FRR_PIM_AF_XPATH_VAL
);
331 strlcat(xpath
, "/register-suppress-time", sizeof(xpath
));
333 nb_cli_enqueue_change(vty
, xpath
, NB_OP_MODIFY
, rst
);
335 return nb_cli_apply_changes(vty
, NULL
);
338 int pim_process_no_register_suppress_cmd(struct vty
*vty
)
340 char xpath
[XPATH_MAXLEN
];
342 snprintf(xpath
, sizeof(xpath
), FRR_PIM_ROUTER_XPATH
,
343 FRR_PIM_AF_XPATH_VAL
);
344 strlcat(xpath
, "/register-suppress-time", sizeof(xpath
));
346 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
348 return nb_cli_apply_changes(vty
, NULL
);
351 int pim_process_ip_pim_cmd(struct vty
*vty
)
353 nb_cli_enqueue_change(vty
, "./pim-enable", NB_OP_MODIFY
, "true");
355 return nb_cli_apply_changes(vty
, FRR_PIM_INTERFACE_XPATH
,
356 FRR_PIM_AF_XPATH_VAL
);
359 int pim_process_ip_pim_passive_cmd(struct vty
*vty
, bool enable
)
362 nb_cli_enqueue_change(vty
, "./pim-passive-enable", NB_OP_MODIFY
,
365 nb_cli_enqueue_change(vty
, "./pim-passive-enable", NB_OP_MODIFY
,
368 return nb_cli_apply_changes(vty
, FRR_PIM_INTERFACE_XPATH
,
369 FRR_PIM_AF_XPATH_VAL
);
372 int pim_process_no_ip_pim_cmd(struct vty
*vty
)
374 const struct lyd_node
*mld_enable_dnode
;
375 char mld_if_xpath
[XPATH_MAXLEN
];
378 snprintf(mld_if_xpath
, sizeof(mld_if_xpath
),
379 "%s/frr-gmp:gmp/address-family[address-family='%s']",
380 VTY_CURR_XPATH
, FRR_PIM_AF_XPATH_VAL
);
382 if (printed
>= (int)(sizeof(mld_if_xpath
))) {
383 vty_out(vty
, "Xpath too long (%d > %u)", printed
+ 1,
385 return CMD_WARNING_CONFIG_FAILED
;
388 mld_enable_dnode
= yang_dnode_getf(vty
->candidate_config
->dnode
,
389 FRR_GMP_ENABLE_XPATH
, VTY_CURR_XPATH
,
390 FRR_PIM_AF_XPATH_VAL
);
392 if (!mld_enable_dnode
) {
393 nb_cli_enqueue_change(vty
, mld_if_xpath
, NB_OP_DESTROY
, NULL
);
394 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
396 if (!yang_dnode_get_bool(mld_enable_dnode
, ".")) {
397 nb_cli_enqueue_change(vty
, mld_if_xpath
, NB_OP_DESTROY
,
399 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
401 nb_cli_enqueue_change(vty
, "./pim-enable", NB_OP_MODIFY
,
405 return nb_cli_apply_changes(vty
, FRR_PIM_INTERFACE_XPATH
,
406 FRR_PIM_AF_XPATH_VAL
);
409 int pim_process_ip_pim_drprio_cmd(struct vty
*vty
, const char *drpriority_str
)
411 nb_cli_enqueue_change(vty
, "./dr-priority", NB_OP_MODIFY
,
414 return nb_cli_apply_changes(vty
, FRR_PIM_INTERFACE_XPATH
,
415 FRR_PIM_AF_XPATH_VAL
);
418 int pim_process_no_ip_pim_drprio_cmd(struct vty
*vty
)
420 nb_cli_enqueue_change(vty
, "./dr-priority", NB_OP_DESTROY
, NULL
);
422 return nb_cli_apply_changes(vty
, FRR_PIM_INTERFACE_XPATH
,
423 FRR_PIM_AF_XPATH_VAL
);
426 int pim_process_ip_pim_hello_cmd(struct vty
*vty
, const char *hello_str
,
427 const char *hold_str
)
429 const struct lyd_node
*mld_enable_dnode
;
431 mld_enable_dnode
= yang_dnode_getf(vty
->candidate_config
->dnode
,
432 FRR_GMP_ENABLE_XPATH
, VTY_CURR_XPATH
,
433 FRR_PIM_AF_XPATH_VAL
);
435 if (!mld_enable_dnode
) {
436 nb_cli_enqueue_change(vty
, "./pim-enable", NB_OP_MODIFY
,
439 if (!yang_dnode_get_bool(mld_enable_dnode
, "."))
440 nb_cli_enqueue_change(vty
, "./pim-enable", NB_OP_MODIFY
,
444 nb_cli_enqueue_change(vty
, "./hello-interval", NB_OP_MODIFY
, hello_str
);
447 nb_cli_enqueue_change(vty
, "./hello-holdtime", NB_OP_MODIFY
,
450 return nb_cli_apply_changes(vty
, FRR_PIM_INTERFACE_XPATH
,
451 FRR_PIM_AF_XPATH_VAL
);
454 int pim_process_no_ip_pim_hello_cmd(struct vty
*vty
)
456 nb_cli_enqueue_change(vty
, "./hello-interval", NB_OP_DESTROY
, NULL
);
457 nb_cli_enqueue_change(vty
, "./hello-holdtime", NB_OP_DESTROY
, NULL
);
459 return nb_cli_apply_changes(vty
, FRR_PIM_INTERFACE_XPATH
,
460 FRR_PIM_AF_XPATH_VAL
);
463 int pim_process_ip_pim_activeactive_cmd(struct vty
*vty
, const char *no
)
466 nb_cli_enqueue_change(vty
, "./active-active", NB_OP_MODIFY
,
469 nb_cli_enqueue_change(vty
, "./pim-enable", NB_OP_MODIFY
,
472 nb_cli_enqueue_change(vty
, "./active-active", NB_OP_MODIFY
,
476 return nb_cli_apply_changes(vty
, FRR_PIM_INTERFACE_XPATH
,
477 FRR_PIM_AF_XPATH_VAL
);
480 int pim_process_ip_pim_boundary_oil_cmd(struct vty
*vty
, const char *oil
)
482 nb_cli_enqueue_change(vty
, "./multicast-boundary-oil", NB_OP_MODIFY
,
485 return nb_cli_apply_changes(vty
, FRR_PIM_INTERFACE_XPATH
,
486 FRR_PIM_AF_XPATH_VAL
);
489 int pim_process_no_ip_pim_boundary_oil_cmd(struct vty
*vty
)
491 nb_cli_enqueue_change(vty
, "./multicast-boundary-oil", NB_OP_DESTROY
,
494 return nb_cli_apply_changes(vty
, FRR_PIM_INTERFACE_XPATH
,
495 FRR_PIM_AF_XPATH_VAL
);
498 int pim_process_ip_mroute_cmd(struct vty
*vty
, const char *interface
,
499 const char *group_str
, const char *source_str
)
501 nb_cli_enqueue_change(vty
, "./oif", NB_OP_MODIFY
, interface
);
504 char buf
[SRCDEST2STR_BUFFER
];
506 inet_ntop(AF_INET6
, &in6addr_any
, buf
, sizeof(buf
));
507 return nb_cli_apply_changes(vty
, FRR_PIM_MROUTE_XPATH
,
508 FRR_PIM_AF_XPATH_VAL
, buf
,
512 return nb_cli_apply_changes(vty
, FRR_PIM_MROUTE_XPATH
,
513 FRR_PIM_AF_XPATH_VAL
, source_str
,
517 int pim_process_no_ip_mroute_cmd(struct vty
*vty
, const char *interface
,
518 const char *group_str
, const char *source_str
)
520 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
523 char buf
[SRCDEST2STR_BUFFER
];
525 inet_ntop(AF_INET6
, &in6addr_any
, buf
, sizeof(buf
));
526 return nb_cli_apply_changes(vty
, FRR_PIM_MROUTE_XPATH
,
527 FRR_PIM_AF_XPATH_VAL
, buf
,
531 return nb_cli_apply_changes(vty
, FRR_PIM_MROUTE_XPATH
,
532 FRR_PIM_AF_XPATH_VAL
, source_str
,
536 int pim_process_rp_cmd(struct vty
*vty
, const char *rp_str
,
537 const char *group_str
)
540 char rp_group_xpath
[XPATH_MAXLEN
];
545 result
= str2prefix(group_str
, &group
);
549 prefix_copy(&temp
, &group
);
551 if (!prefix_same(&group
, &temp
)) {
552 vty_out(vty
, "%% Inconsistent address and mask: %s\n",
554 return CMD_WARNING_CONFIG_FAILED
;
559 vty_out(vty
, "%% Bad group address specified: %s\n", group_str
);
560 return CMD_WARNING_CONFIG_FAILED
;
563 result
= inet_pton(PIM_AF
, rp_str
, &rp_addr
);
565 vty_out(vty
, "%% Bad RP address specified: %s\n", rp_str
);
566 return CMD_WARNING_CONFIG_FAILED
;
569 vrfname
= pim_cli_get_vrf_name(vty
);
571 return CMD_WARNING_CONFIG_FAILED
;
573 snprintf(rp_group_xpath
, sizeof(rp_group_xpath
),
574 FRR_PIM_STATIC_RP_XPATH
, "frr-pim:pimd", "pim", vrfname
,
575 FRR_PIM_AF_XPATH_VAL
, rp_str
);
576 strlcat(rp_group_xpath
, "/group-list", sizeof(rp_group_xpath
));
578 nb_cli_enqueue_change(vty
, rp_group_xpath
, NB_OP_CREATE
, group_str
);
580 return nb_cli_apply_changes(vty
, NULL
);
583 int pim_process_no_rp_cmd(struct vty
*vty
, const char *rp_str
,
584 const char *group_str
)
586 char group_list_xpath
[XPATH_MAXLEN
];
587 char group_xpath
[XPATH_MAXLEN
];
588 char rp_xpath
[XPATH_MAXLEN
];
591 const struct lyd_node
*group_dnode
;
593 vrfname
= pim_cli_get_vrf_name(vty
);
595 return CMD_WARNING_CONFIG_FAILED
;
597 snprintf(rp_xpath
, sizeof(rp_xpath
), FRR_PIM_STATIC_RP_XPATH
,
598 "frr-pim:pimd", "pim", vrfname
, FRR_PIM_AF_XPATH_VAL
, rp_str
);
600 printed
= snprintf(group_list_xpath
, sizeof(group_list_xpath
),
601 "%s/group-list", rp_xpath
);
603 if (printed
>= (int)(sizeof(group_list_xpath
))) {
604 vty_out(vty
, "Xpath too long (%d > %u)", printed
+ 1,
606 return CMD_WARNING_CONFIG_FAILED
;
609 printed
= snprintf(group_xpath
, sizeof(group_xpath
), "%s[.='%s']",
610 group_list_xpath
, group_str
);
612 if (printed
>= (int)(sizeof(group_xpath
))) {
613 vty_out(vty
, "Xpath too long (%d > %u)", printed
+ 1,
615 return CMD_WARNING_CONFIG_FAILED
;
618 group_dnode
= yang_dnode_get(vty
->candidate_config
->dnode
, group_xpath
);
620 vty_out(vty
, "%% Unable to find specified RP\n");
624 if (yang_is_last_list_dnode(group_dnode
))
625 nb_cli_enqueue_change(vty
, rp_xpath
, NB_OP_DESTROY
, NULL
);
627 nb_cli_enqueue_change(vty
, group_list_xpath
, NB_OP_DESTROY
,
630 return nb_cli_apply_changes(vty
, NULL
);
633 int pim_process_rp_plist_cmd(struct vty
*vty
, const char *rp_str
,
634 const char *prefix_list
)
637 char rp_plist_xpath
[XPATH_MAXLEN
];
639 vrfname
= pim_cli_get_vrf_name(vty
);
641 return CMD_WARNING_CONFIG_FAILED
;
643 snprintf(rp_plist_xpath
, sizeof(rp_plist_xpath
),
644 FRR_PIM_STATIC_RP_XPATH
, "frr-pim:pimd", "pim", vrfname
,
645 FRR_PIM_AF_XPATH_VAL
, rp_str
);
646 strlcat(rp_plist_xpath
, "/prefix-list", sizeof(rp_plist_xpath
));
648 nb_cli_enqueue_change(vty
, rp_plist_xpath
, NB_OP_MODIFY
, prefix_list
);
650 return nb_cli_apply_changes(vty
, NULL
);
653 int pim_process_no_rp_plist_cmd(struct vty
*vty
, const char *rp_str
,
654 const char *prefix_list
)
656 char rp_xpath
[XPATH_MAXLEN
];
657 char plist_xpath
[XPATH_MAXLEN
];
659 const struct lyd_node
*plist_dnode
;
662 vrfname
= pim_cli_get_vrf_name(vty
);
664 return CMD_WARNING_CONFIG_FAILED
;
666 snprintf(rp_xpath
, sizeof(rp_xpath
), FRR_PIM_STATIC_RP_XPATH
,
667 "frr-pim:pimd", "pim", vrfname
, FRR_PIM_AF_XPATH_VAL
, rp_str
);
669 snprintf(plist_xpath
, sizeof(plist_xpath
), FRR_PIM_STATIC_RP_XPATH
,
670 "frr-pim:pimd", "pim", vrfname
, FRR_PIM_AF_XPATH_VAL
, rp_str
);
671 strlcat(plist_xpath
, "/prefix-list", sizeof(plist_xpath
));
673 plist_dnode
= yang_dnode_get(vty
->candidate_config
->dnode
, plist_xpath
);
675 vty_out(vty
, "%% Unable to find specified RP\n");
679 plist
= yang_dnode_get_string(plist_dnode
, plist_xpath
);
680 if (strcmp(prefix_list
, plist
)) {
681 vty_out(vty
, "%% Unable to find specified RP\n");
685 nb_cli_enqueue_change(vty
, rp_xpath
, NB_OP_DESTROY
, NULL
);
687 return nb_cli_apply_changes(vty
, NULL
);
690 bool pim_sgaddr_match(pim_sgaddr item
, pim_sgaddr match
)
692 return (pim_addr_is_any(match
.grp
) ||
693 !pim_addr_cmp(match
.grp
, item
.grp
)) &&
694 (pim_addr_is_any(match
.src
) ||
695 !pim_addr_cmp(match
.src
, item
.src
));
698 void json_object_pim_ifp_add(struct json_object
*json
, struct interface
*ifp
)
700 struct pim_interface
*pim_ifp
;
703 json_object_string_add(json
, "name", ifp
->name
);
704 json_object_string_add(json
, "state", if_is_up(ifp
) ? "up" : "down");
705 json_object_string_addf(json
, "address", "%pPA",
706 &pim_ifp
->primary_address
);
707 json_object_int_add(json
, "index", ifp
->ifindex
);
709 if (if_is_multicast(ifp
))
710 json_object_boolean_true_add(json
, "flagMulticast");
712 if (if_is_broadcast(ifp
))
713 json_object_boolean_true_add(json
, "flagBroadcast");
715 if (ifp
->flags
& IFF_ALLMULTI
)
716 json_object_boolean_true_add(json
, "flagAllMulticast");
718 if (ifp
->flags
& IFF_PROMISC
)
719 json_object_boolean_true_add(json
, "flagPromiscuous");
721 if (PIM_IF_IS_DELETED(ifp
))
722 json_object_boolean_true_add(json
, "flagDeleted");
724 if (pim_if_lan_delay_enabled(ifp
))
725 json_object_boolean_true_add(json
, "lanDelayEnabled");
728 void pim_print_ifp_flags(struct vty
*vty
, struct interface
*ifp
)
730 vty_out(vty
, "Flags\n");
731 vty_out(vty
, "-----\n");
732 vty_out(vty
, "All Multicast : %s\n",
733 (ifp
->flags
& IFF_ALLMULTI
) ? "yes" : "no");
734 vty_out(vty
, "Broadcast : %s\n",
735 if_is_broadcast(ifp
) ? "yes" : "no");
736 vty_out(vty
, "Deleted : %s\n",
737 PIM_IF_IS_DELETED(ifp
) ? "yes" : "no");
738 vty_out(vty
, "Interface Index : %d\n", ifp
->ifindex
);
739 vty_out(vty
, "Multicast : %s\n",
740 if_is_multicast(ifp
) ? "yes" : "no");
741 vty_out(vty
, "Promiscuous : %s\n",
742 (ifp
->flags
& IFF_PROMISC
) ? "yes" : "no");
747 void json_object_pim_upstream_add(json_object
*json
, struct pim_upstream
*up
)
749 json_object_boolean_add(
750 json
, "drJoinDesired",
751 CHECK_FLAG(up
->flags
, PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED
));
752 json_object_boolean_add(
753 json
, "drJoinDesiredUpdated",
754 CHECK_FLAG(up
->flags
,
755 PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED_UPDATED
));
756 json_object_boolean_add(
757 json
, "firstHopRouter",
758 CHECK_FLAG(up
->flags
, PIM_UPSTREAM_FLAG_MASK_FHR
));
759 json_object_boolean_add(
761 CHECK_FLAG(up
->flags
, PIM_UPSTREAM_FLAG_MASK_SRC_IGMP
));
762 json_object_boolean_add(
764 CHECK_FLAG(up
->flags
, PIM_UPSTREAM_FLAG_MASK_SRC_PIM
));
765 json_object_boolean_add(
766 json
, "sourceStream",
767 CHECK_FLAG(up
->flags
, PIM_UPSTREAM_FLAG_MASK_SRC_STREAM
));
768 /* XXX: need to print ths flag in the plain text display as well */
769 json_object_boolean_add(
771 CHECK_FLAG(up
->flags
, PIM_UPSTREAM_FLAG_MASK_SRC_MSDP
));
772 json_object_boolean_add(
773 json
, "sendSGRptPrune",
774 CHECK_FLAG(up
->flags
,
775 PIM_UPSTREAM_FLAG_MASK_SEND_SG_RPT_PRUNE
));
776 json_object_boolean_add(
777 json
, "lastHopRouter",
778 CHECK_FLAG(up
->flags
, PIM_UPSTREAM_FLAG_MASK_SRC_LHR
));
779 json_object_boolean_add(
780 json
, "disableKATExpiry",
781 CHECK_FLAG(up
->flags
,
782 PIM_UPSTREAM_FLAG_MASK_DISABLE_KAT_EXPIRY
));
783 json_object_boolean_add(
784 json
, "staticIncomingInterface",
785 CHECK_FLAG(up
->flags
, PIM_UPSTREAM_FLAG_MASK_STATIC_IIF
));
786 json_object_boolean_add(
787 json
, "allowIncomingInterfaceinOil",
788 CHECK_FLAG(up
->flags
, PIM_UPSTREAM_FLAG_MASK_ALLOW_IIF_IN_OIL
));
789 json_object_boolean_add(
790 json
, "noPimRegistrationData",
791 CHECK_FLAG(up
->flags
, PIM_UPSTREAM_FLAG_MASK_NO_PIMREG_DATA
));
792 json_object_boolean_add(
793 json
, "forcePimRegistration",
794 CHECK_FLAG(up
->flags
, PIM_UPSTREAM_FLAG_MASK_FORCE_PIMREG
));
795 json_object_boolean_add(
796 json
, "sourceVxlanOrigination",
797 CHECK_FLAG(up
->flags
, PIM_UPSTREAM_FLAG_MASK_SRC_VXLAN_ORIG
));
798 json_object_boolean_add(
799 json
, "sourceVxlanTermination",
800 CHECK_FLAG(up
->flags
, PIM_UPSTREAM_FLAG_MASK_SRC_VXLAN_TERM
));
801 json_object_boolean_add(
803 CHECK_FLAG(up
->flags
, PIM_UPSTREAM_FLAG_MASK_MLAG_VXLAN
));
804 json_object_boolean_add(
805 json
, "mlagNonDesignatedForwarder",
806 CHECK_FLAG(up
->flags
, PIM_UPSTREAM_FLAG_MASK_MLAG_NON_DF
));
810 pim_upstream_state2brief_str(enum pim_upstream_state join_state
,
811 char *state_str
, size_t state_str_len
)
813 switch (join_state
) {
814 case PIM_UPSTREAM_NOTJOINED
:
815 strlcpy(state_str
, "NotJ", state_str_len
);
817 case PIM_UPSTREAM_JOINED
:
818 strlcpy(state_str
, "J", state_str_len
);
821 strlcpy(state_str
, "Unk", state_str_len
);
826 static const char *pim_reg_state2brief_str(enum pim_reg_state reg_state
,
828 size_t state_str_len
)
832 strlcpy(state_str
, "RegNI", state_str_len
);
835 strlcpy(state_str
, "RegJ", state_str_len
);
837 case PIM_REG_JOIN_PENDING
:
839 strlcpy(state_str
, "RegP", state_str_len
);
845 void pim_show_rpf_refresh_stats(struct vty
*vty
, struct pim_instance
*pim
,
846 time_t now
, json_object
*json
)
848 char refresh_uptime
[10];
850 pim_time_uptime_begin(refresh_uptime
, sizeof(refresh_uptime
), now
,
851 pim
->rpf_cache_refresh_last
);
854 json_object_int_add(json
, "rpfCacheRefreshDelayMsecs",
855 router
->rpf_cache_refresh_delay_msec
);
857 json
, "rpfCacheRefreshTimer",
858 pim_time_timer_remain_msec(pim
->rpf_cache_refresher
));
859 json_object_int_add(json
, "rpfCacheRefreshRequests",
860 pim
->rpf_cache_refresh_requests
);
861 json_object_int_add(json
, "rpfCacheRefreshEvents",
862 pim
->rpf_cache_refresh_events
);
863 json_object_string_add(json
, "rpfCacheRefreshLast",
865 json_object_int_add(json
, "nexthopLookups",
866 pim
->nexthop_lookups
);
867 json_object_int_add(json
, "nexthopLookupsAvoided",
868 pim
->nexthop_lookups_avoided
);
871 "RPF Cache Refresh Delay: %ld msecs\n"
872 "RPF Cache Refresh Timer: %ld msecs\n"
873 "RPF Cache Refresh Requests: %lld\n"
874 "RPF Cache Refresh Events: %lld\n"
875 "RPF Cache Refresh Last: %s\n"
876 "Nexthop Lookups: %lld\n"
877 "Nexthop Lookups Avoided: %lld\n",
878 router
->rpf_cache_refresh_delay_msec
,
879 pim_time_timer_remain_msec(pim
->rpf_cache_refresher
),
880 (long long)pim
->rpf_cache_refresh_requests
,
881 (long long)pim
->rpf_cache_refresh_events
,
882 refresh_uptime
, (long long)pim
->nexthop_lookups
,
883 (long long)pim
->nexthop_lookups_avoided
);
887 void pim_show_rpf(struct pim_instance
*pim
, struct vty
*vty
, json_object
*json
)
889 struct pim_upstream
*up
;
890 time_t now
= pim_time_monotonic_sec();
891 struct ttable
*tt
= NULL
;
893 json_object
*json_group
= NULL
;
894 json_object
*json_row
= NULL
;
896 pim_show_rpf_refresh_stats(vty
, pim
, now
, json
);
902 tt
= ttable_new(&ttable_styles
[TTSTYLE_BLANK
]);
905 "Source|Group|RpfIface|RpfAddress|RibNextHop|Metric|Pref");
906 tt
->style
.cell
.rpad
= 2;
907 tt
->style
.corner
= '+';
911 frr_each (rb_pim_upstream
, &pim
->upstream_head
, up
) {
912 const char *rpf_ifname
;
913 struct pim_rpf
*rpf
= &up
->rpf
;
916 rpf
->source_nexthop
.interface
? rpf
->source_nexthop
921 char grp_str
[PIM_ADDRSTRLEN
];
922 char src_str
[PIM_ADDRSTRLEN
];
924 snprintfrr(grp_str
, sizeof(grp_str
), "%pPAs",
926 snprintfrr(src_str
, sizeof(src_str
), "%pPAs",
929 json_object_object_get_ex(json
, grp_str
, &json_group
);
932 json_group
= json_object_new_object();
933 json_object_object_add(json
, grp_str
,
937 json_row
= json_object_new_object();
938 json_object_string_add(json_row
, "source", src_str
);
939 json_object_string_add(json_row
, "group", grp_str
);
940 json_object_string_add(json_row
, "rpfInterface",
942 json_object_string_addf(json_row
, "rpfAddress", "%pPA",
944 json_object_string_addf(
945 json_row
, "ribNexthop", "%pPAs",
946 &rpf
->source_nexthop
.mrib_nexthop_addr
);
948 json_row
, "routeMetric",
949 rpf
->source_nexthop
.mrib_route_metric
);
951 json_row
, "routePreference",
952 rpf
->source_nexthop
.mrib_metric_preference
);
953 json_object_object_add(json_group
, src_str
, json_row
);
957 tt
, "%pPAs|%pPAs|%s|%pPA|%pPAs|%d|%d",
958 &up
->sg
.src
, &up
->sg
.grp
, rpf_ifname
,
960 &rpf
->source_nexthop
.mrib_nexthop_addr
,
961 rpf
->source_nexthop
.mrib_route_metric
,
962 rpf
->source_nexthop
.mrib_metric_preference
);
965 /* Dump the generated table. */
967 table
= ttable_dump(tt
, "\n");
968 vty_out(vty
, "%s\n", table
);
969 XFREE(MTYPE_TMP
, table
);
974 void pim_show_neighbors_secondary(struct pim_instance
*pim
, struct vty
*vty
)
976 struct interface
*ifp
;
977 struct ttable
*tt
= NULL
;
981 tt
= ttable_new(&ttable_styles
[TTSTYLE_BLANK
]);
982 ttable_add_row(tt
, "Interface|Address|Neighbor|Secondary");
983 tt
->style
.cell
.rpad
= 2;
984 tt
->style
.corner
= '+';
987 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
988 struct pim_interface
*pim_ifp
;
990 struct listnode
*neighnode
;
991 struct pim_neighbor
*neigh
;
998 if (pim_ifp
->pim_sock_fd
< 0)
1001 ifaddr
= pim_ifp
->primary_address
;
1003 for (ALL_LIST_ELEMENTS_RO(pim_ifp
->pim_neighbor_list
, neighnode
,
1005 struct listnode
*prefix_node
;
1008 if (!neigh
->prefix_list
)
1011 for (ALL_LIST_ELEMENTS_RO(neigh
->prefix_list
,
1013 ttable_add_row(tt
, "%s|%pPAs|%pPAs|%pFX",
1015 &neigh
->source_addr
, p
);
1018 /* Dump the generated table. */
1019 table
= ttable_dump(tt
, "\n");
1020 vty_out(vty
, "%s\n", table
);
1021 XFREE(MTYPE_TMP
, table
);
1025 void pim_show_state(struct pim_instance
*pim
, struct vty
*vty
,
1026 const char *src_or_group
, const char *group
,
1029 struct channel_oil
*c_oil
;
1031 struct ttable
*tt
= NULL
;
1035 json_object
*json_group
= NULL
;
1036 json_object
*json_ifp_in
= NULL
;
1037 json_object
*json_ifp_out
= NULL
;
1038 json_object
*json_source
= NULL
;
1042 now
= pim_time_monotonic_sec();
1046 "Codes: J -> Pim Join, I -> " GM
" Report, S -> Source, * -> Inherited from (*,G), V -> VxLAN, M -> Muted\n");
1049 "Active Source Group RPT IIF OIL\n");
1051 /* Prepare table. */
1052 tt
= ttable_new(&ttable_styles
[TTSTYLE_BLANK
]);
1053 ttable_add_row(tt
, "Active|Source|Group|RPT|IIF|OIL");
1054 tt
->style
.cell
.rpad
= 2;
1055 tt
->style
.corner
= '+';
1060 frr_each (rb_pim_oil
, &pim
->channel_oil_head
, c_oil
) {
1061 char src_str
[PIM_ADDRSTRLEN
];
1062 char grp_str
[PIM_ADDRSTRLEN
];
1063 char in_ifname
[INTERFACE_NAMSIZ
+ 1];
1064 char out_ifname
[INTERFACE_NAMSIZ
+ 1];
1066 struct interface
*ifp_in
;
1072 PIM_UPSTREAM_FLAG_TEST_USE_RPT(c_oil
->up
->flags
)) ||
1073 pim_addr_is_any(*oil_origin(c_oil
)))
1078 snprintfrr(grp_str
, sizeof(grp_str
), "%pPAs",
1079 oil_mcastgrp(c_oil
));
1080 snprintfrr(src_str
, sizeof(src_str
), "%pPAs",
1082 ifp_in
= pim_if_find_by_vif_index(pim
, *oil_parent(c_oil
));
1085 strlcpy(in_ifname
, ifp_in
->name
, sizeof(in_ifname
));
1087 strlcpy(in_ifname
, "<iif?>", sizeof(in_ifname
));
1090 if (strcmp(src_or_group
, src_str
) &&
1091 strcmp(src_or_group
, grp_str
))
1094 if (group
&& strcmp(group
, grp_str
))
1100 /* Find the group, create it if it doesn't exist */
1101 json_object_object_get_ex(json
, grp_str
, &json_group
);
1104 json_group
= json_object_new_object();
1105 json_object_object_add(json
, grp_str
,
1109 /* Find the source nested under the group, create it if
1112 json_object_object_get_ex(json_group
, src_str
,
1116 json_source
= json_object_new_object();
1117 json_object_object_add(json_group
, src_str
,
1121 /* Find the inbound interface nested under the source,
1122 * create it if it doesn't exist
1124 json_object_object_get_ex(json_source
, in_ifname
,
1128 json_ifp_in
= json_object_new_object();
1129 json_object_object_add(json_source
, in_ifname
,
1131 json_object_int_add(json_source
, "Installed",
1133 json_object_int_add(json_source
, "installed",
1135 json_object_boolean_add(json_source
, "isRpt",
1137 json_object_int_add(json_source
, "RefCount",
1138 c_oil
->oil_ref_count
);
1139 json_object_int_add(json_source
, "refCount",
1140 c_oil
->oil_ref_count
);
1141 json_object_int_add(json_source
, "OilListSize",
1143 json_object_int_add(json_source
, "oilListSize",
1145 json_object_int_add(
1146 json_source
, "OilRescan",
1147 c_oil
->oil_inherited_rescan
);
1148 json_object_int_add(
1149 json_source
, "oilRescan",
1150 c_oil
->oil_inherited_rescan
);
1151 json_object_int_add(json_source
, "LastUsed",
1152 c_oil
->cc
.lastused
);
1153 json_object_int_add(json_source
, "lastUsed",
1154 c_oil
->cc
.lastused
);
1155 json_object_int_add(json_source
, "PacketCount",
1157 json_object_int_add(json_source
, "packetCount",
1159 json_object_int_add(json_source
, "ByteCount",
1161 json_object_int_add(json_source
, "byteCount",
1163 json_object_int_add(json_source
,
1165 c_oil
->cc
.wrong_if
);
1166 json_object_int_add(json_source
,
1168 c_oil
->cc
.wrong_if
);
1173 vty_out(vty
, "%-6d %-15pPAs %-15pPAs %-3s %-16s ",
1174 c_oil
->installed
, oil_origin(c_oil
),
1175 oil_mcastgrp(c_oil
), isRpt
? "y" : "n",
1179 for (oif_vif_index
= 0; oif_vif_index
< MAXVIFS
;
1181 struct interface
*ifp_out
;
1182 char oif_uptime
[10];
1185 ttl
= oil_if_has(c_oil
, oif_vif_index
);
1189 ifp_out
= pim_if_find_by_vif_index(pim
, oif_vif_index
);
1191 oif_uptime
, sizeof(oif_uptime
),
1192 now
- c_oil
->oif_creation
[oif_vif_index
]);
1195 strlcpy(out_ifname
, ifp_out
->name
,
1196 sizeof(out_ifname
));
1198 strlcpy(out_ifname
, "<oif?>",
1199 sizeof(out_ifname
));
1202 json_ifp_out
= json_object_new_object();
1203 json_object_string_add(json_ifp_out
, "source",
1205 json_object_string_add(json_ifp_out
, "group",
1207 json_object_string_add(json_ifp_out
,
1210 json_object_string_add(json_ifp_out
,
1211 "outboundInterface",
1213 json_object_int_add(json_ifp_out
, "installed",
1216 json_object_object_add(json_ifp_in
, out_ifname
,
1220 snprintf(flag
, sizeof(flag
), "(%c%c%c%c%c)",
1221 (c_oil
->oif_flags
[oif_vif_index
] &
1222 PIM_OIF_FLAG_PROTO_GM
)
1225 (c_oil
->oif_flags
[oif_vif_index
] &
1226 PIM_OIF_FLAG_PROTO_PIM
)
1229 (c_oil
->oif_flags
[oif_vif_index
] &
1230 PIM_OIF_FLAG_PROTO_VXLAN
)
1233 (c_oil
->oif_flags
[oif_vif_index
] &
1234 PIM_OIF_FLAG_PROTO_STAR
)
1237 (c_oil
->oif_flags
[oif_vif_index
] &
1245 vty_out(vty
, "%s%s", out_ifname
, flag
);
1248 tt
, "%d|%pPAs|%pPAs|%s|%s|%s%s",
1251 oil_mcastgrp(c_oil
),
1252 isRpt
? "y" : "n", in_ifname
,
1257 vty_out(vty
, ", %s%s", out_ifname
,
1261 "%c|%c|%c|%c|%c|%s%s",
1262 ' ', ' ', ' ', ' ', ' ',
1274 /* Dump the generated table. */
1279 table
= ttable_dump(tt
, "\n");
1280 vty_out(vty
, "%s\n", table
);
1281 XFREE(MTYPE_TMP
, table
);
1287 /* pim statistics - just adding only bsm related now.
1288 * We can continue to add all pim related stats here.
1290 void pim_show_statistics(struct pim_instance
*pim
, struct vty
*vty
,
1291 const char *ifname
, bool uj
)
1293 json_object
*json
= NULL
;
1294 struct interface
*ifp
;
1297 json
= json_object_new_object();
1298 json_object_int_add(json
, "bsmRx", pim
->bsm_rcvd
);
1299 json_object_int_add(json
, "bsmTx", pim
->bsm_sent
);
1300 json_object_int_add(json
, "bsmDropped", pim
->bsm_dropped
);
1302 vty_out(vty
, "BSM Statistics :\n");
1303 vty_out(vty
, "----------------\n");
1304 vty_out(vty
, "Number of Received BSMs : %" PRIu64
"\n",
1306 vty_out(vty
, "Number of Forwared BSMs : %" PRIu64
"\n",
1308 vty_out(vty
, "Number of Dropped BSMs : %" PRIu64
"\n",
1314 /* scan interfaces */
1315 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
1316 struct pim_interface
*pim_ifp
= ifp
->info
;
1318 if (ifname
&& strcmp(ifname
, ifp
->name
))
1325 vty_out(vty
, "Interface : %s\n", ifp
->name
);
1326 vty_out(vty
, "-------------------\n");
1328 "Number of BSMs dropped due to config miss : %u\n",
1329 pim_ifp
->pim_ifstat_bsm_cfg_miss
);
1330 vty_out(vty
, "Number of unicast BSMs dropped : %u\n",
1331 pim_ifp
->pim_ifstat_ucast_bsm_cfg_miss
);
1333 "Number of BSMs dropped due to invalid scope zone : %u\n",
1334 pim_ifp
->pim_ifstat_bsm_invalid_sz
);
1337 json_object
*json_row
= NULL
;
1339 json_row
= json_object_new_object();
1341 json_object_string_add(json_row
, "If Name", ifp
->name
);
1342 json_object_int_add(json_row
, "bsmDroppedConfig",
1343 pim_ifp
->pim_ifstat_bsm_cfg_miss
);
1344 json_object_int_add(
1345 json_row
, "bsmDroppedUnicast",
1346 pim_ifp
->pim_ifstat_ucast_bsm_cfg_miss
);
1347 json_object_int_add(json_row
,
1348 "bsmDroppedInvalidScopeZone",
1349 pim_ifp
->pim_ifstat_bsm_invalid_sz
);
1350 json_object_object_add(json
, ifp
->name
, json_row
);
1356 vty_json(vty
, json
);
1359 void pim_show_upstream(struct pim_instance
*pim
, struct vty
*vty
,
1360 pim_sgaddr
*sg
, json_object
*json
)
1362 struct pim_upstream
*up
;
1363 struct ttable
*tt
= NULL
;
1366 json_object
*json_group
= NULL
;
1367 json_object
*json_row
= NULL
;
1369 now
= pim_time_monotonic_sec();
1372 /* Prepare table. */
1373 tt
= ttable_new(&ttable_styles
[TTSTYLE_BLANK
]);
1376 "Iif|Source|Group|State|Uptime|JoinTimer|RSTimer|KATimer|RefCnt");
1377 tt
->style
.cell
.rpad
= 2;
1378 tt
->style
.corner
= '+';
1382 frr_each (rb_pim_upstream
, &pim
->upstream_head
, up
) {
1384 char join_timer
[10];
1387 char msdp_reg_timer
[10];
1388 char state_str
[PIM_REG_STATE_STR_LEN
];
1390 if (!pim_sgaddr_match(up
->sg
, *sg
))
1393 pim_time_uptime(uptime
, sizeof(uptime
),
1394 now
- up
->state_transition
);
1395 pim_time_timer_to_hhmmss(join_timer
, sizeof(join_timer
),
1399 * If the upstream is not dummy and it has a J/P timer for the
1400 * neighbor display that
1402 if (!up
->t_join_timer
&& up
->rpf
.source_nexthop
.interface
) {
1403 struct pim_neighbor
*nbr
;
1405 nbr
= pim_neighbor_find(
1406 up
->rpf
.source_nexthop
.interface
,
1409 pim_time_timer_to_hhmmss(join_timer
,
1414 pim_time_timer_to_hhmmss(rs_timer
, sizeof(rs_timer
),
1416 pim_time_timer_to_hhmmss(ka_timer
, sizeof(ka_timer
),
1418 pim_time_timer_to_hhmmss(msdp_reg_timer
, sizeof(msdp_reg_timer
),
1419 up
->t_msdp_reg_timer
);
1421 pim_upstream_state2brief_str(up
->join_state
, state_str
,
1423 if (up
->reg_state
!= PIM_REG_NOINFO
) {
1424 char tmp_str
[PIM_REG_STATE_STR_LEN
];
1425 char tmp
[sizeof(state_str
) + 1];
1427 snprintf(tmp
, sizeof(tmp
), ",%s",
1428 pim_reg_state2brief_str(up
->reg_state
, tmp_str
,
1430 strlcat(state_str
, tmp
, sizeof(state_str
));
1434 char grp_str
[PIM_ADDRSTRLEN
];
1435 char src_str
[PIM_ADDRSTRLEN
];
1437 snprintfrr(grp_str
, sizeof(grp_str
), "%pPAs",
1439 snprintfrr(src_str
, sizeof(src_str
), "%pPAs",
1442 json_object_object_get_ex(json
, grp_str
, &json_group
);
1445 json_group
= json_object_new_object();
1446 json_object_object_add(json
, grp_str
,
1450 json_row
= json_object_new_object();
1451 json_object_pim_upstream_add(json_row
, up
);
1452 json_object_string_add(
1453 json_row
, "inboundInterface",
1454 up
->rpf
.source_nexthop
.interface
1455 ? up
->rpf
.source_nexthop
.interface
->name
1459 * The RPF address we use is slightly different
1460 * based upon what we are looking up.
1461 * If we have a S, list that unless
1462 * we are the FHR, else we just put
1463 * the RP as the rpfAddress
1465 if (up
->flags
& PIM_UPSTREAM_FLAG_MASK_FHR
||
1466 pim_addr_is_any(up
->sg
.src
)) {
1467 struct pim_rpf
*rpg
;
1469 rpg
= RP(pim
, up
->sg
.grp
);
1470 json_object_string_addf(json_row
, "rpfAddress",
1471 "%pPA", &rpg
->rpf_addr
);
1473 json_object_string_add(json_row
, "rpfAddress",
1477 json_object_string_add(json_row
, "source", src_str
);
1478 json_object_string_add(json_row
, "group", grp_str
);
1479 json_object_string_add(json_row
, "state", state_str
);
1480 json_object_string_add(
1481 json_row
, "joinState",
1482 pim_upstream_state2str(up
->join_state
));
1483 json_object_string_add(
1484 json_row
, "regState",
1485 pim_reg_state2str(up
->reg_state
, state_str
,
1486 sizeof(state_str
)));
1487 json_object_string_add(json_row
, "upTime", uptime
);
1488 json_object_string_add(json_row
, "joinTimer",
1490 json_object_string_add(json_row
, "resetTimer",
1492 json_object_string_add(json_row
, "keepaliveTimer",
1494 json_object_string_add(json_row
, "msdpRegTimer",
1496 json_object_int_add(json_row
, "refCount",
1498 json_object_int_add(json_row
, "sptBit", up
->sptbit
);
1499 json_object_object_add(json_group
, src_str
, json_row
);
1502 "%s|%pPAs|%pPAs|%s|%s|%s|%s|%s|%d",
1503 up
->rpf
.source_nexthop
.interface
1504 ? up
->rpf
.source_nexthop
.interface
->name
1506 &up
->sg
.src
, &up
->sg
.grp
, state_str
, uptime
,
1507 join_timer
, rs_timer
, ka_timer
, up
->ref_count
);
1510 /* Dump the generated table. */
1512 table
= ttable_dump(tt
, "\n");
1513 vty_out(vty
, "%s\n", table
);
1514 XFREE(MTYPE_TMP
, table
);
1519 static void pim_show_join_desired_helper(struct pim_instance
*pim
,
1521 struct pim_upstream
*up
,
1522 json_object
*json
, bool uj
,
1525 json_object
*json_group
= NULL
;
1526 json_object
*json_row
= NULL
;
1529 char grp_str
[PIM_ADDRSTRLEN
];
1530 char src_str
[PIM_ADDRSTRLEN
];
1532 snprintfrr(grp_str
, sizeof(grp_str
), "%pPAs", &up
->sg
.grp
);
1533 snprintfrr(src_str
, sizeof(src_str
), "%pPAs", &up
->sg
.src
);
1535 json_object_object_get_ex(json
, grp_str
, &json_group
);
1538 json_group
= json_object_new_object();
1539 json_object_object_add(json
, grp_str
, json_group
);
1542 json_row
= json_object_new_object();
1543 json_object_pim_upstream_add(json_row
, up
);
1544 json_object_string_add(json_row
, "source", src_str
);
1545 json_object_string_add(json_row
, "group", grp_str
);
1547 if (pim_upstream_evaluate_join_desired(pim
, up
))
1548 json_object_boolean_true_add(json_row
,
1549 "evaluateJoinDesired");
1551 json_object_object_add(json_group
, src_str
, json_row
);
1554 ttable_add_row(tt
, "%pPAs|%pPAs|%s", &up
->sg
.src
, &up
->sg
.grp
,
1555 pim_upstream_evaluate_join_desired(pim
, up
)
1561 void pim_show_join_desired(struct pim_instance
*pim
, struct vty
*vty
, bool uj
)
1563 struct pim_upstream
*up
;
1564 struct ttable
*tt
= NULL
;
1567 json_object
*json
= NULL
;
1570 json
= json_object_new_object();
1572 /* Prepare table. */
1573 tt
= ttable_new(&ttable_styles
[TTSTYLE_BLANK
]);
1574 ttable_add_row(tt
, "Source|Group|EvalJD");
1575 tt
->style
.cell
.rpad
= 2;
1576 tt
->style
.corner
= '+';
1580 frr_each (rb_pim_upstream
, &pim
->upstream_head
, up
) {
1581 /* scan all interfaces */
1582 pim_show_join_desired_helper(pim
, vty
, up
, json
, uj
, tt
);
1586 vty_json(vty
, json
);
1588 /* Dump the generated table. */
1589 table
= ttable_dump(tt
, "\n");
1590 vty_out(vty
, "%s\n", table
);
1591 XFREE(MTYPE_TMP
, table
);
1596 void pim_show_upstream_rpf(struct pim_instance
*pim
, struct vty
*vty
, bool uj
)
1598 struct pim_upstream
*up
;
1599 struct ttable
*tt
= NULL
;
1601 json_object
*json
= NULL
;
1602 json_object
*json_group
= NULL
;
1603 json_object
*json_row
= NULL
;
1606 json
= json_object_new_object();
1608 /* Prepare table. */
1609 tt
= ttable_new(&ttable_styles
[TTSTYLE_BLANK
]);
1611 "Source|Group|RpfIface|RibNextHop|RpfAddress");
1612 tt
->style
.cell
.rpad
= 2;
1613 tt
->style
.corner
= '+';
1617 frr_each (rb_pim_upstream
, &pim
->upstream_head
, up
) {
1618 struct pim_rpf
*rpf
;
1619 const char *rpf_ifname
;
1624 rpf
->source_nexthop
.interface
? rpf
->source_nexthop
1629 char grp_str
[PIM_ADDRSTRLEN
];
1630 char src_str
[PIM_ADDRSTRLEN
];
1632 snprintfrr(grp_str
, sizeof(grp_str
), "%pPAs",
1634 snprintfrr(src_str
, sizeof(src_str
), "%pPAs",
1636 json_object_object_get_ex(json
, grp_str
, &json_group
);
1639 json_group
= json_object_new_object();
1640 json_object_object_add(json
, grp_str
,
1644 json_row
= json_object_new_object();
1645 json_object_pim_upstream_add(json_row
, up
);
1646 json_object_string_add(json_row
, "source", src_str
);
1647 json_object_string_add(json_row
, "group", grp_str
);
1648 json_object_string_add(json_row
, "rpfInterface",
1650 json_object_string_addf(
1651 json_row
, "ribNexthop", "%pPAs",
1652 &rpf
->source_nexthop
.mrib_nexthop_addr
);
1653 json_object_string_addf(json_row
, "rpfAddress", "%pPA",
1655 json_object_object_add(json_group
, src_str
, json_row
);
1657 ttable_add_row(tt
, "%pPAs|%pPAs|%s|%pPA|%pPA",
1658 &up
->sg
.src
, &up
->sg
.grp
, rpf_ifname
,
1659 &rpf
->source_nexthop
.mrib_nexthop_addr
,
1665 vty_json(vty
, json
);
1667 /* Dump the generated table. */
1668 table
= ttable_dump(tt
, "\n");
1669 vty_out(vty
, "%s\n", table
);
1670 XFREE(MTYPE_TMP
, table
);
1675 static void pim_show_join_helper(struct pim_interface
*pim_ifp
,
1676 struct pim_ifchannel
*ch
, json_object
*json
,
1677 time_t now
, struct ttable
*tt
)
1679 json_object
*json_iface
= NULL
;
1680 json_object
*json_row
= NULL
;
1681 json_object
*json_grp
= NULL
;
1687 ifaddr
= pim_ifp
->primary_address
;
1689 pim_time_uptime_begin(uptime
, sizeof(uptime
), now
, ch
->ifjoin_creation
);
1690 pim_time_timer_to_mmss(expire
, sizeof(expire
),
1691 ch
->t_ifjoin_expiry_timer
);
1692 pim_time_timer_to_mmss(prune
, sizeof(prune
),
1693 ch
->t_ifjoin_prune_pending_timer
);
1696 char ch_grp_str
[PIM_ADDRSTRLEN
];
1698 json_object_object_get_ex(json
, ch
->interface
->name
,
1702 json_iface
= json_object_new_object();
1703 json_object_pim_ifp_add(json_iface
, ch
->interface
);
1704 json_object_object_add(json
, ch
->interface
->name
,
1708 json_row
= json_object_new_object();
1709 json_object_string_addf(json_row
, "source", "%pPAs",
1711 json_object_string_addf(json_row
, "group", "%pPAs",
1713 json_object_string_add(json_row
, "upTime", uptime
);
1714 json_object_string_add(json_row
, "expire", expire
);
1715 json_object_string_add(json_row
, "prune", prune
);
1716 json_object_string_add(
1717 json_row
, "channelJoinName",
1718 pim_ifchannel_ifjoin_name(ch
->ifjoin_state
, ch
->flags
));
1719 if (PIM_IF_FLAG_TEST_S_G_RPT(ch
->flags
)) {
1720 #if CONFDATE > 20230131
1722 "Remove JSON object commands with keys starting with capital")
1724 json_object_int_add(json_row
, "SGRpt", 1);
1725 json_object_int_add(json_row
, "sgRpt", 1);
1727 if (PIM_IF_FLAG_TEST_PROTO_PIM(ch
->flags
))
1728 json_object_int_add(json_row
, "protocolPim", 1);
1729 if (PIM_IF_FLAG_TEST_PROTO_IGMP(ch
->flags
))
1730 json_object_int_add(json_row
, "protocolIgmp", 1);
1731 snprintfrr(ch_grp_str
, sizeof(ch_grp_str
), "%pPAs",
1733 json_object_object_get_ex(json_iface
, ch_grp_str
, &json_grp
);
1735 json_grp
= json_object_new_object();
1736 json_object_object_addf(json_grp
, json_row
, "%pPAs",
1738 json_object_object_addf(json_iface
, json_grp
, "%pPAs",
1741 json_object_object_addf(json_grp
, json_row
, "%pPAs",
1745 tt
, "%s|%pPAs|%pPAs|%pPAs|%s|%s|%s|%s",
1746 ch
->interface
->name
, &ifaddr
, &ch
->sg
.src
, &ch
->sg
.grp
,
1747 pim_ifchannel_ifjoin_name(ch
->ifjoin_state
, ch
->flags
),
1748 uptime
, expire
, prune
);
1752 int pim_show_join_cmd_helper(const char *vrf
, struct vty
*vty
, pim_addr s_or_g
,
1753 pim_addr g
, const char *json
)
1757 struct pim_instance
*pim
;
1758 json_object
*json_parent
= NULL
;
1760 v
= vrf_lookup_by_name(vrf
? vrf
: VRF_DEFAULT_NAME
);
1763 vty_out(vty
, "%% Vrf specified: %s does not exist\n", vrf
);
1769 vty_out(vty
, "%% Unable to find pim instance\n");
1773 if (!pim_addr_is_any(s_or_g
)) {
1774 if (!pim_addr_is_any(g
)) {
1782 json_parent
= json_object_new_object();
1784 pim_show_join(pim
, vty
, &sg
, json_parent
);
1787 vty_json(vty
, json_parent
);
1792 int pim_show_join_vrf_all_cmd_helper(struct vty
*vty
, const char *json
)
1794 pim_sgaddr sg
= {0};
1795 struct vrf
*vrf_struct
;
1796 json_object
*json_parent
= NULL
;
1797 json_object
*json_vrf
= NULL
;
1800 json_parent
= json_object_new_object();
1802 RB_FOREACH (vrf_struct
, vrf_name_head
, &vrfs_by_name
) {
1804 vty_out(vty
, "VRF: %s\n", vrf_struct
->name
);
1806 json_vrf
= json_object_new_object();
1807 pim_show_join(vrf_struct
->info
, vty
, &sg
, json_vrf
);
1810 json_object_object_add(json_parent
, vrf_struct
->name
,
1814 vty_json(vty
, json_parent
);
1819 void pim_show_join(struct pim_instance
*pim
, struct vty
*vty
, pim_sgaddr
*sg
,
1822 struct pim_interface
*pim_ifp
;
1823 struct pim_ifchannel
*ch
;
1824 struct interface
*ifp
;
1826 struct ttable
*tt
= NULL
;
1829 now
= pim_time_monotonic_sec();
1832 /* Prepare table. */
1833 tt
= ttable_new(&ttable_styles
[TTSTYLE_BLANK
]);
1836 "Interface|Address|Source|Group|State|Uptime|Expire|Prune");
1837 tt
->style
.cell
.rpad
= 2;
1838 tt
->style
.corner
= '+';
1842 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
1843 pim_ifp
= ifp
->info
;
1847 RB_FOREACH (ch
, pim_ifchannel_rb
, &pim_ifp
->ifchannel_rb
) {
1848 if (!pim_sgaddr_match(ch
->sg
, *sg
))
1851 pim_show_join_helper(pim_ifp
, ch
, json
, now
, tt
);
1852 } /* scan interface channels */
1854 /* Dump the generated table. */
1856 table
= ttable_dump(tt
, "\n");
1857 vty_out(vty
, "%s\n", table
);
1858 XFREE(MTYPE_TMP
, table
);
1863 static void pim_show_jp_agg_helper(struct interface
*ifp
,
1864 struct pim_neighbor
*neigh
,
1865 struct pim_upstream
*up
, int is_join
,
1868 ttable_add_row(tt
, "%s|%pPAs|%pPAs|%pPAs|%s", ifp
->name
,
1869 &neigh
->source_addr
, &up
->sg
.src
, &up
->sg
.grp
,
1870 is_join
? "J" : "P");
1873 int pim_show_jp_agg_list_cmd_helper(const char *vrf
, struct vty
*vty
)
1876 struct pim_instance
*pim
;
1878 v
= vrf_lookup_by_name(vrf
? vrf
: VRF_DEFAULT_NAME
);
1881 vty_out(vty
, "%% Vrf specified: %s does not exist\n", vrf
);
1887 vty_out(vty
, "%% Unable to find pim instance\n");
1891 pim_show_jp_agg_list(pim
, vty
);
1896 void pim_show_jp_agg_list(struct pim_instance
*pim
, struct vty
*vty
)
1898 struct interface
*ifp
;
1899 struct pim_interface
*pim_ifp
;
1900 struct listnode
*n_node
;
1901 struct pim_neighbor
*neigh
;
1902 struct listnode
*jag_node
;
1903 struct pim_jp_agg_group
*jag
;
1904 struct listnode
*js_node
;
1905 struct pim_jp_sources
*js
;
1909 /* Prepare table. */
1910 tt
= ttable_new(&ttable_styles
[TTSTYLE_BLANK
]);
1911 ttable_add_row(tt
, "Interface|RPF Nbr|Source|Group|State");
1912 tt
->style
.cell
.rpad
= 2;
1913 tt
->style
.corner
= '+';
1916 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
1917 pim_ifp
= ifp
->info
;
1921 for (ALL_LIST_ELEMENTS_RO(pim_ifp
->pim_neighbor_list
, n_node
,
1923 for (ALL_LIST_ELEMENTS_RO(neigh
->upstream_jp_agg
,
1925 for (ALL_LIST_ELEMENTS_RO(jag
->sources
, js_node
,
1927 pim_show_jp_agg_helper(ifp
, neigh
,
1935 /* Dump the generated table. */
1936 table
= ttable_dump(tt
, "\n");
1937 vty_out(vty
, "%s\n", table
);
1938 XFREE(MTYPE_TMP
, table
);
1942 int pim_show_membership_cmd_helper(const char *vrf
, struct vty
*vty
, bool uj
)
1946 v
= vrf_lookup_by_name(vrf
? vrf
: VRF_DEFAULT_NAME
);
1951 pim_show_membership(v
->info
, vty
, uj
);
1956 static void pim_show_membership_helper(struct vty
*vty
,
1957 struct pim_interface
*pim_ifp
,
1958 struct pim_ifchannel
*ch
,
1959 struct json_object
*json
)
1961 json_object
*json_iface
= NULL
;
1962 json_object
*json_row
= NULL
;
1964 json_object_object_get_ex(json
, ch
->interface
->name
, &json_iface
);
1966 json_iface
= json_object_new_object();
1967 json_object_pim_ifp_add(json_iface
, ch
->interface
);
1968 json_object_object_add(json
, ch
->interface
->name
, json_iface
);
1971 json_row
= json_object_new_object();
1972 json_object_string_addf(json_row
, "source", "%pPAs", &ch
->sg
.src
);
1973 json_object_string_addf(json_row
, "group", "%pPAs", &ch
->sg
.grp
);
1974 json_object_string_add(json_row
, "localMembership",
1975 ch
->local_ifmembership
== PIM_IFMEMBERSHIP_NOINFO
1978 json_object_object_addf(json_iface
, json_row
, "%pPAs", &ch
->sg
.grp
);
1981 void pim_show_membership(struct pim_instance
*pim
, struct vty
*vty
, bool uj
)
1983 struct pim_interface
*pim_ifp
;
1984 struct pim_ifchannel
*ch
;
1985 struct interface
*ifp
;
1986 enum json_type type
;
1987 json_object
*json
= NULL
;
1988 json_object
*json_tmp
= NULL
;
1989 struct ttable
*tt
= NULL
;
1992 json
= json_object_new_object();
1994 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
1995 pim_ifp
= ifp
->info
;
1999 RB_FOREACH (ch
, pim_ifchannel_rb
, &pim_ifp
->ifchannel_rb
) {
2000 pim_show_membership_helper(vty
, pim_ifp
, ch
, json
);
2001 } /* scan interface channels */
2005 vty_json(vty
, json
);
2007 /* Prepare table. */
2008 tt
= ttable_new(&ttable_styles
[TTSTYLE_BLANK
]);
2009 ttable_add_row(tt
, "Interface|Address|Source|Group|Membership");
2010 tt
->style
.cell
.rpad
= 2;
2011 tt
->style
.corner
= '+';
2015 * Example of the json data we are traversing
2021 * "address":"10.1.20.1",
2023 * "flagMulticast":true,
2024 * "flagBroadcast":true,
2025 * "lanDelayEnabled":true,
2028 * "group":"226.10.10.10",
2029 * "localMembership":"INCLUDE"
2035 /* foreach interface */
2036 json_object_object_foreach(json
, key
, val
)
2039 /* Find all of the keys where the val is an object. In
2041 * above the only one is 226.10.10.10
2043 json_object_object_foreach(val
, if_field_key
,
2046 type
= json_object_get_type(if_field_val
);
2048 if (type
== json_type_object
) {
2049 const char *address
, *source
,
2052 json_object_object_get_ex(
2053 val
, "address", &json_tmp
);
2054 address
= json_object_get_string(
2057 json_object_object_get_ex(if_field_val
,
2060 source
= json_object_get_string(
2063 json_object_object_get_ex(
2064 if_field_val
, "localMembership",
2067 json_object_get_string(
2070 ttable_add_row(tt
, "%s|%s|%s|%s|%s",
2071 key
, address
, source
,
2077 json_object_free(json
);
2078 /* Dump the generated table. */
2079 table
= ttable_dump(tt
, "\n");
2080 vty_out(vty
, "%s\n", table
);
2081 XFREE(MTYPE_TMP
, table
);
2086 static void pim_show_channel_helper(struct pim_instance
*pim
,
2087 struct pim_interface
*pim_ifp
,
2088 struct pim_ifchannel
*ch
, json_object
*json
,
2089 bool uj
, struct ttable
*tt
)
2091 struct pim_upstream
*up
= ch
->upstream
;
2092 json_object
*json_group
= NULL
;
2093 json_object
*json_row
= NULL
;
2096 char grp_str
[PIM_ADDRSTRLEN
];
2098 snprintfrr(grp_str
, sizeof(grp_str
), "%pPAs", &up
->sg
.grp
);
2099 json_object_object_get_ex(json
, grp_str
, &json_group
);
2102 json_group
= json_object_new_object();
2103 json_object_object_add(json
, grp_str
, json_group
);
2106 json_row
= json_object_new_object();
2107 json_object_pim_upstream_add(json_row
, up
);
2108 json_object_string_add(json_row
, "interface",
2109 ch
->interface
->name
);
2110 json_object_string_addf(json_row
, "source", "%pPAs",
2112 json_object_string_addf(json_row
, "group", "%pPAs",
2115 if (pim_macro_ch_lost_assert(ch
))
2116 json_object_boolean_true_add(json_row
, "lostAssert");
2118 if (pim_macro_chisin_joins(ch
))
2119 json_object_boolean_true_add(json_row
, "joins");
2121 if (pim_macro_chisin_pim_include(ch
))
2122 json_object_boolean_true_add(json_row
, "pimInclude");
2124 if (pim_upstream_evaluate_join_desired(pim
, up
))
2125 json_object_boolean_true_add(json_row
,
2126 "evaluateJoinDesired");
2128 json_object_object_addf(json_group
, json_row
, "%pPAs",
2132 ttable_add_row(tt
, "%s|%pPAs|%pPAs|%s|%s|%s|%s|%s",
2133 ch
->interface
->name
, &up
->sg
.src
, &up
->sg
.grp
,
2134 pim_macro_ch_lost_assert(ch
) ? "yes" : "no",
2135 pim_macro_chisin_joins(ch
) ? "yes" : "no",
2136 pim_macro_chisin_pim_include(ch
) ? "yes" : "no",
2137 PIM_UPSTREAM_FLAG_TEST_DR_JOIN_DESIRED(up
->flags
)
2140 pim_upstream_evaluate_join_desired(pim
, up
)
2146 void pim_show_channel(struct pim_instance
*pim
, struct vty
*vty
, bool uj
)
2148 struct pim_interface
*pim_ifp
;
2149 struct pim_ifchannel
*ch
;
2150 struct interface
*ifp
;
2151 struct ttable
*tt
= NULL
;
2152 json_object
*json
= NULL
;
2156 json
= json_object_new_object();
2158 /* Prepare table. */
2159 tt
= ttable_new(&ttable_styles
[TTSTYLE_BLANK
]);
2162 "Interface|Source|Group|LostAssert|Joins|PimInclude|JoinDesired|EvalJD");
2163 tt
->style
.cell
.rpad
= 2;
2164 tt
->style
.corner
= '+';
2168 /* scan per-interface (S,G) state */
2169 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
2170 pim_ifp
= ifp
->info
;
2174 RB_FOREACH (ch
, pim_ifchannel_rb
, &pim_ifp
->ifchannel_rb
) {
2175 /* scan all interfaces */
2176 pim_show_channel_helper(pim
, pim_ifp
, ch
, json
, uj
, tt
);
2181 vty_json(vty
, json
);
2183 /* Dump the generated table. */
2184 table
= ttable_dump(tt
, "\n");
2185 vty_out(vty
, "%s\n", table
);
2186 XFREE(MTYPE_TMP
, table
);
2191 int pim_show_channel_cmd_helper(const char *vrf
, struct vty
*vty
, bool uj
)
2195 v
= vrf_lookup_by_name(vrf
? vrf
: VRF_DEFAULT_NAME
);
2200 pim_show_channel(v
->info
, vty
, uj
);
2205 int pim_show_interface_cmd_helper(const char *vrf
, struct vty
*vty
, bool uj
,
2206 bool mlag
, const char *interface
)
2209 json_object
*json_parent
= NULL
;
2211 v
= vrf_lookup_by_name(vrf
? vrf
: VRF_DEFAULT_NAME
);
2217 json_parent
= json_object_new_object();
2220 pim_show_interfaces_single(v
->info
, vty
, interface
, mlag
,
2223 pim_show_interfaces(v
->info
, vty
, mlag
, json_parent
);
2226 vty_json(vty
, json_parent
);
2231 int pim_show_interface_vrf_all_cmd_helper(struct vty
*vty
, bool uj
, bool mlag
,
2232 const char *interface
)
2235 json_object
*json_parent
= NULL
;
2236 json_object
*json_vrf
= NULL
;
2239 json_parent
= json_object_new_object();
2241 RB_FOREACH (v
, vrf_name_head
, &vrfs_by_name
) {
2243 vty_out(vty
, "VRF: %s\n", v
->name
);
2245 json_vrf
= json_object_new_object();
2248 pim_show_interfaces_single(v
->info
, vty
, interface
,
2251 pim_show_interfaces(v
->info
, vty
, mlag
, json_vrf
);
2254 json_object_object_add(json_parent
, v
->name
, json_vrf
);
2257 vty_json(vty
, json_parent
);
2262 void pim_show_interfaces(struct pim_instance
*pim
, struct vty
*vty
, bool mlag
,
2265 struct interface
*ifp
;
2266 struct pim_interface
*pim_ifp
;
2267 struct pim_upstream
*up
;
2270 int pim_ifchannels
= 0;
2272 struct ttable
*tt
= NULL
;
2274 json_object
*json_row
= NULL
;
2275 json_object
*json_tmp
;
2279 json
= json_object_new_object();
2282 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
2283 pim_ifp
= ifp
->info
;
2288 if (mlag
== true && pim_ifp
->activeactive
== false)
2291 pim_nbrs
= pim_ifp
->pim_neighbor_list
->count
;
2292 pim_ifchannels
= pim_if_ifchannel_count(pim_ifp
);
2295 frr_each (rb_pim_upstream
, &pim
->upstream_head
, up
)
2296 if (ifp
== up
->rpf
.source_nexthop
.interface
)
2297 if (up
->flags
& PIM_UPSTREAM_FLAG_MASK_FHR
)
2300 json_row
= json_object_new_object();
2301 json_object_pim_ifp_add(json_row
, ifp
);
2302 json_object_int_add(json_row
, "pimNeighbors", pim_nbrs
);
2303 json_object_int_add(json_row
, "pimIfChannels", pim_ifchannels
);
2304 json_object_int_add(json_row
, "firstHopRouterCount", fhr
);
2305 json_object_string_addf(json_row
, "pimDesignatedRouter",
2306 "%pPAs", &pim_ifp
->pim_dr_addr
);
2308 if (!pim_addr_cmp(pim_ifp
->pim_dr_addr
,
2309 pim_ifp
->primary_address
))
2310 json_object_boolean_true_add(
2311 json_row
, "pimDesignatedRouterLocal");
2313 json_object_object_add(json
, ifp
->name
, json_row
);
2318 /* Prepare table. */
2319 tt
= ttable_new(&ttable_styles
[TTSTYLE_BLANK
]);
2322 "Interface|State|Address|PIM Nbrs|PIM DR|FHR|IfChannels");
2323 tt
->style
.cell
.rpad
= 2;
2324 tt
->style
.corner
= '+';
2327 json_object_object_foreach(json
, key
, val
)
2329 const char *state
, *address
, *pimdr
;
2330 int neighbors
, firsthpr
, pimifchnl
;
2332 json_object_object_get_ex(val
, "state", &json_tmp
);
2333 state
= json_object_get_string(json_tmp
);
2335 json_object_object_get_ex(val
, "address", &json_tmp
);
2336 address
= json_object_get_string(json_tmp
);
2338 json_object_object_get_ex(val
, "pimNeighbors",
2340 neighbors
= json_object_get_int(json_tmp
);
2342 if (json_object_object_get_ex(
2343 val
, "pimDesignatedRouterLocal",
2347 json_object_object_get_ex(
2348 val
, "pimDesignatedRouter", &json_tmp
);
2349 pimdr
= json_object_get_string(json_tmp
);
2352 json_object_object_get_ex(val
, "firstHopRouter",
2354 firsthpr
= json_object_get_int(json_tmp
);
2356 json_object_object_get_ex(val
, "pimIfChannels",
2358 pimifchnl
= json_object_get_int(json_tmp
);
2360 ttable_add_row(tt
, "%s|%s|%s|%d|%s|%d|%d", key
, state
,
2361 address
, neighbors
, pimdr
, firsthpr
,
2364 json_object_free(json
);
2366 /* Dump the generated table. */
2367 table
= ttable_dump(tt
, "\n");
2368 vty_out(vty
, "%s\n", table
);
2369 XFREE(MTYPE_TMP
, table
);
2375 void pim_show_interfaces_single(struct pim_instance
*pim
, struct vty
*vty
,
2376 const char *ifname
, bool mlag
,
2380 struct interface
*ifp
;
2381 struct listnode
*neighnode
;
2382 struct pim_interface
*pim_ifp
;
2383 struct pim_neighbor
*neigh
;
2384 struct pim_upstream
*up
;
2386 char dr_str
[PIM_ADDRSTRLEN
];
2389 char grp_str
[PIM_ADDRSTRLEN
];
2390 char hello_period
[10];
2391 char hello_timer
[10];
2392 char neigh_src_str
[PIM_ADDRSTRLEN
];
2393 char src_str
[PIM_ADDRSTRLEN
];
2394 char stat_uptime
[10];
2396 int found_ifname
= 0;
2398 json_object
*json_row
= NULL
;
2399 json_object
*json_pim_neighbor
= NULL
;
2400 json_object
*json_pim_neighbors
= NULL
;
2401 json_object
*json_group
= NULL
;
2402 json_object
*json_group_source
= NULL
;
2403 json_object
*json_fhr_sources
= NULL
;
2404 struct pim_secondary_addr
*sec_addr
;
2405 struct listnode
*sec_node
;
2407 now
= pim_time_monotonic_sec();
2409 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
2410 pim_ifp
= ifp
->info
;
2415 if (mlag
== true && pim_ifp
->activeactive
== false)
2418 if (strcmp(ifname
, "detail") && strcmp(ifname
, ifp
->name
))
2422 ifaddr
= pim_ifp
->primary_address
;
2423 snprintfrr(dr_str
, sizeof(dr_str
), "%pPAs",
2424 &pim_ifp
->pim_dr_addr
);
2425 pim_time_uptime_begin(dr_uptime
, sizeof(dr_uptime
), now
,
2426 pim_ifp
->pim_dr_election_last
);
2427 pim_time_timer_to_hhmmss(hello_timer
, sizeof(hello_timer
),
2428 pim_ifp
->t_pim_hello_timer
);
2429 pim_time_mmss(hello_period
, sizeof(hello_period
),
2430 pim_ifp
->pim_hello_period
);
2431 pim_time_uptime(stat_uptime
, sizeof(stat_uptime
),
2432 now
- pim_ifp
->pim_ifstat_start
);
2435 json_row
= json_object_new_object();
2436 json_object_pim_ifp_add(json_row
, ifp
);
2438 if (!pim_addr_is_any(pim_ifp
->update_source
)) {
2439 json_object_string_addf(
2440 json_row
, "useSource", "%pPAs",
2441 &pim_ifp
->update_source
);
2443 if (pim_ifp
->sec_addr_list
) {
2444 json_object
*sec_list
= NULL
;
2446 sec_list
= json_object_new_array();
2447 for (ALL_LIST_ELEMENTS_RO(
2448 pim_ifp
->sec_addr_list
, sec_node
,
2450 json_object_array_add(
2452 json_object_new_stringf(
2456 json_object_object_add(json_row
,
2457 "secondaryAddressList",
2461 if (pim_ifp
->pim_passive_enable
)
2462 json_object_boolean_true_add(json_row
,
2466 if (pim_ifp
->pim_neighbor_list
->count
) {
2467 json_pim_neighbors
= json_object_new_object();
2469 for (ALL_LIST_ELEMENTS_RO(
2470 pim_ifp
->pim_neighbor_list
,
2471 neighnode
, neigh
)) {
2473 json_object_new_object();
2474 snprintfrr(neigh_src_str
,
2475 sizeof(neigh_src_str
),
2477 &neigh
->source_addr
);
2478 pim_time_uptime(uptime
, sizeof(uptime
),
2479 now
- neigh
->creation
);
2480 pim_time_timer_to_hhmmss(
2481 expire
, sizeof(expire
),
2482 neigh
->t_expire_timer
);
2484 json_object_string_add(
2485 json_pim_neighbor
, "address",
2487 json_object_string_add(
2488 json_pim_neighbor
, "upTime",
2490 json_object_string_add(
2491 json_pim_neighbor
, "holdtime",
2494 json_object_object_add(
2500 json_object_object_add(json_row
, "neighbors",
2501 json_pim_neighbors
);
2504 json_object_string_add(json_row
, "drAddress", dr_str
);
2505 json_object_int_add(json_row
, "drPriority",
2506 pim_ifp
->pim_dr_priority
);
2507 json_object_string_add(json_row
, "drUptime", dr_uptime
);
2508 json_object_int_add(json_row
, "drElections",
2509 pim_ifp
->pim_dr_election_count
);
2510 json_object_int_add(json_row
, "drChanges",
2511 pim_ifp
->pim_dr_election_changes
);
2514 frr_each (rb_pim_upstream
, &pim
->upstream_head
, up
) {
2515 if (ifp
!= up
->rpf
.source_nexthop
.interface
)
2518 if (!(up
->flags
& PIM_UPSTREAM_FLAG_MASK_FHR
))
2521 if (!json_fhr_sources
)
2523 json_object_new_object();
2525 snprintfrr(grp_str
, sizeof(grp_str
), "%pPAs",
2527 snprintfrr(src_str
, sizeof(src_str
), "%pPAs",
2529 pim_time_uptime(uptime
, sizeof(uptime
),
2530 now
- up
->state_transition
);
2533 * Does this group live in json_fhr_sources?
2536 json_object_object_get_ex(json_fhr_sources
,
2537 grp_str
, &json_group
);
2540 json_group
= json_object_new_object();
2541 json_object_object_add(json_fhr_sources
,
2546 json_group_source
= json_object_new_object();
2547 json_object_string_add(json_group_source
,
2549 json_object_string_add(json_group_source
,
2551 json_object_string_add(json_group_source
,
2553 json_object_object_add(json_group
, src_str
,
2557 if (json_fhr_sources
) {
2558 json_object_object_add(json_row
,
2563 json_object_int_add(json_row
, "helloPeriod",
2564 pim_ifp
->pim_hello_period
);
2565 json_object_int_add(json_row
, "holdTime",
2566 PIM_IF_DEFAULT_HOLDTIME(pim_ifp
));
2567 json_object_string_add(json_row
, "helloTimer",
2569 json_object_string_add(json_row
, "helloStatStart",
2571 json_object_int_add(json_row
, "helloReceived",
2572 pim_ifp
->pim_ifstat_hello_recv
);
2573 json_object_int_add(json_row
, "helloReceivedFailed",
2574 pim_ifp
->pim_ifstat_hello_recvfail
);
2575 json_object_int_add(json_row
, "helloSend",
2576 pim_ifp
->pim_ifstat_hello_sent
);
2577 json_object_int_add(json_row
, "hellosendFailed",
2578 pim_ifp
->pim_ifstat_hello_sendfail
);
2579 json_object_int_add(json_row
, "helloGenerationId",
2580 pim_ifp
->pim_generation_id
);
2582 json_object_int_add(
2583 json_row
, "effectivePropagationDelay",
2584 pim_if_effective_propagation_delay_msec(ifp
));
2585 json_object_int_add(
2586 json_row
, "effectiveOverrideInterval",
2587 pim_if_effective_override_interval_msec(ifp
));
2588 json_object_int_add(
2589 json_row
, "joinPruneOverrideInterval",
2590 pim_if_jp_override_interval_msec(ifp
));
2592 json_object_int_add(
2593 json_row
, "propagationDelay",
2594 pim_ifp
->pim_propagation_delay_msec
);
2595 json_object_int_add(
2596 json_row
, "propagationDelayHighest",
2597 pim_ifp
->pim_neighbors_highest_propagation_delay_msec
);
2598 json_object_int_add(
2599 json_row
, "overrideInterval",
2600 pim_ifp
->pim_override_interval_msec
);
2601 json_object_int_add(
2602 json_row
, "overrideIntervalHighest",
2603 pim_ifp
->pim_neighbors_highest_override_interval_msec
);
2604 if (pim_ifp
->bsm_enable
)
2605 json_object_boolean_true_add(json_row
,
2607 if (pim_ifp
->ucast_bsm_accept
)
2608 json_object_boolean_true_add(json_row
,
2610 json_object_object_add(json
, ifp
->name
, json_row
);
2613 vty_out(vty
, "Interface : %s\n", ifp
->name
);
2614 vty_out(vty
, "State : %s\n",
2615 if_is_up(ifp
) ? "up" : "down");
2616 if (!pim_addr_is_any(pim_ifp
->update_source
)) {
2617 vty_out(vty
, "Use Source : %pPAs\n",
2618 &pim_ifp
->update_source
);
2620 if (pim_ifp
->sec_addr_list
) {
2621 vty_out(vty
, "Address : %pPAs (primary)\n",
2623 for (ALL_LIST_ELEMENTS_RO(
2624 pim_ifp
->sec_addr_list
, sec_node
,
2626 vty_out(vty
, " %pFX\n",
2629 vty_out(vty
, "Address : %pPAs\n", &ifaddr
);
2632 if (pim_ifp
->pim_passive_enable
)
2633 vty_out(vty
, "Passive : %s\n",
2634 (pim_ifp
->pim_passive_enable
) ? "yes"
2642 for (ALL_LIST_ELEMENTS_RO(pim_ifp
->pim_neighbor_list
,
2643 neighnode
, neigh
)) {
2646 vty_out(vty
, "PIM Neighbors\n");
2647 vty_out(vty
, "-------------\n");
2651 snprintfrr(neigh_src_str
, sizeof(neigh_src_str
),
2652 "%pPAs", &neigh
->source_addr
);
2653 pim_time_uptime(uptime
, sizeof(uptime
),
2654 now
- neigh
->creation
);
2655 pim_time_timer_to_hhmmss(expire
, sizeof(expire
),
2656 neigh
->t_expire_timer
);
2658 "%-15s : up for %s, holdtime expires in %s\n",
2659 neigh_src_str
, uptime
, expire
);
2662 if (!print_header
) {
2667 vty_out(vty
, "Designated Router\n");
2668 vty_out(vty
, "-----------------\n");
2669 vty_out(vty
, "Address : %s\n", dr_str
);
2670 vty_out(vty
, "Priority : %u(%d)\n",
2671 pim_ifp
->pim_dr_priority
,
2672 pim_ifp
->pim_dr_num_nondrpri_neighbors
);
2673 vty_out(vty
, "Uptime : %s\n", dr_uptime
);
2674 vty_out(vty
, "Elections : %d\n",
2675 pim_ifp
->pim_dr_election_count
);
2676 vty_out(vty
, "Changes : %d\n",
2677 pim_ifp
->pim_dr_election_changes
);
2683 frr_each (rb_pim_upstream
, &pim
->upstream_head
, up
) {
2684 if (!up
->rpf
.source_nexthop
.interface
)
2687 if (strcmp(ifp
->name
,
2688 up
->rpf
.source_nexthop
2689 .interface
->name
) != 0)
2692 if (!(up
->flags
& PIM_UPSTREAM_FLAG_MASK_FHR
))
2697 "FHR - First Hop Router\n");
2699 "----------------------\n");
2703 pim_time_uptime(uptime
, sizeof(uptime
),
2704 now
- up
->state_transition
);
2706 "%pPAs : %pPAs is a source, uptime is %s\n",
2707 &up
->sg
.grp
, &up
->sg
.src
, uptime
);
2710 if (!print_header
) {
2715 vty_out(vty
, "Hellos\n");
2716 vty_out(vty
, "------\n");
2717 vty_out(vty
, "Period : %d\n",
2718 pim_ifp
->pim_hello_period
);
2719 vty_out(vty
, "HoldTime : %d\n",
2720 PIM_IF_DEFAULT_HOLDTIME(pim_ifp
));
2721 vty_out(vty
, "Timer : %s\n", hello_timer
);
2722 vty_out(vty
, "StatStart : %s\n", stat_uptime
);
2723 vty_out(vty
, "Receive : %d\n",
2724 pim_ifp
->pim_ifstat_hello_recv
);
2725 vty_out(vty
, "Receive Failed : %d\n",
2726 pim_ifp
->pim_ifstat_hello_recvfail
);
2727 vty_out(vty
, "Send : %d\n",
2728 pim_ifp
->pim_ifstat_hello_sent
);
2729 vty_out(vty
, "Send Failed : %d\n",
2730 pim_ifp
->pim_ifstat_hello_sendfail
);
2731 vty_out(vty
, "Generation ID : %08x\n",
2732 pim_ifp
->pim_generation_id
);
2736 pim_print_ifp_flags(vty
, ifp
);
2738 vty_out(vty
, "Join Prune Interval\n");
2739 vty_out(vty
, "-------------------\n");
2740 vty_out(vty
, "LAN Delay : %s\n",
2741 pim_if_lan_delay_enabled(ifp
) ? "yes" : "no");
2742 vty_out(vty
, "Effective Propagation Delay : %d msec\n",
2743 pim_if_effective_propagation_delay_msec(ifp
));
2744 vty_out(vty
, "Effective Override Interval : %d msec\n",
2745 pim_if_effective_override_interval_msec(ifp
));
2746 vty_out(vty
, "Join Prune Override Interval : %d msec\n",
2747 pim_if_jp_override_interval_msec(ifp
));
2751 vty_out(vty
, "LAN Prune Delay\n");
2752 vty_out(vty
, "---------------\n");
2753 vty_out(vty
, "Propagation Delay : %d msec\n",
2754 pim_ifp
->pim_propagation_delay_msec
);
2755 vty_out(vty
, "Propagation Delay (Highest) : %d msec\n",
2756 pim_ifp
->pim_neighbors_highest_propagation_delay_msec
);
2757 vty_out(vty
, "Override Interval : %d msec\n",
2758 pim_ifp
->pim_override_interval_msec
);
2759 vty_out(vty
, "Override Interval (Highest) : %d msec\n",
2760 pim_ifp
->pim_neighbors_highest_override_interval_msec
);
2764 vty_out(vty
, "BSM Status\n");
2765 vty_out(vty
, "----------\n");
2766 vty_out(vty
, "Bsm Enabled : %s\n",
2767 pim_ifp
->bsm_enable
? "yes" : "no");
2768 vty_out(vty
, "Unicast Bsm Enabled : %s\n",
2769 pim_ifp
->ucast_bsm_accept
? "yes" : "no");
2776 vty_out(vty
, "%% No such interface\n");
2779 void ip_pim_ssm_show_group_range(struct pim_instance
*pim
, struct vty
*vty
,
2782 struct pim_ssm
*ssm
= pim
->ssm_info
;
2783 const char *range_str
=
2784 ssm
->plist_name
? ssm
->plist_name
: PIM_SSM_STANDARD_RANGE
;
2789 json
= json_object_new_object();
2790 json_object_string_add(json
, "ssmGroups", range_str
);
2791 vty_json(vty
, json
);
2793 vty_out(vty
, "SSM group range : %s\n", range_str
);
2796 struct vty_pnc_cache_walk_data
{
2798 struct pim_instance
*pim
;
2801 struct json_pnc_cache_walk_data
{
2802 json_object
*json_obj
;
2803 struct pim_instance
*pim
;
2806 static int pim_print_vty_pnc_cache_walkcb(struct hash_bucket
*bucket
, void *arg
)
2808 struct pim_nexthop_cache
*pnc
= bucket
->data
;
2809 struct vty_pnc_cache_walk_data
*cwd
= arg
;
2810 struct vty
*vty
= cwd
->vty
;
2811 struct pim_instance
*pim
= cwd
->pim
;
2812 struct nexthop
*nh_node
= NULL
;
2813 ifindex_t first_ifindex
;
2814 struct interface
*ifp
= NULL
;
2816 for (nh_node
= pnc
->nexthop
; nh_node
; nh_node
= nh_node
->next
) {
2817 first_ifindex
= nh_node
->ifindex
;
2819 ifp
= if_lookup_by_index(first_ifindex
, pim
->vrf
->vrf_id
);
2821 vty_out(vty
, "%-15pPA ", &pnc
->rpf
.rpf_addr
);
2822 vty_out(vty
, "%-16s ", ifp
? ifp
->name
: "NULL");
2824 vty_out(vty
, "%pI4 ", &nh_node
->gate
.ipv4
);
2826 vty_out(vty
, "%pI6 ", &nh_node
->gate
.ipv6
);
2833 static int pim_print_json_pnc_cache_walkcb(struct hash_bucket
*backet
,
2836 struct pim_nexthop_cache
*pnc
= backet
->data
;
2837 struct json_pnc_cache_walk_data
*cwd
= arg
;
2838 struct pim_instance
*pim
= cwd
->pim
;
2839 struct nexthop
*nh_node
= NULL
;
2840 ifindex_t first_ifindex
;
2841 struct interface
*ifp
= NULL
;
2842 char addr_str
[PIM_ADDRSTRLEN
];
2843 json_object
*json_row
= NULL
;
2844 json_object
*json_ifp
= NULL
;
2845 json_object
*json_arr
= NULL
;
2847 for (nh_node
= pnc
->nexthop
; nh_node
; nh_node
= nh_node
->next
) {
2848 first_ifindex
= nh_node
->ifindex
;
2849 ifp
= if_lookup_by_index(first_ifindex
, pim
->vrf
->vrf_id
);
2850 snprintfrr(addr_str
, sizeof(addr_str
), "%pPA",
2851 &pnc
->rpf
.rpf_addr
);
2852 json_object_object_get_ex(cwd
->json_obj
, addr_str
, &json_row
);
2854 json_row
= json_object_new_object();
2855 json_object_string_addf(json_row
, "address", "%pPA",
2856 &pnc
->rpf
.rpf_addr
);
2857 json_object_object_addf(cwd
->json_obj
, json_row
, "%pPA",
2858 &pnc
->rpf
.rpf_addr
);
2859 json_arr
= json_object_new_array();
2860 json_object_object_add(json_row
, "nexthops", json_arr
);
2862 json_ifp
= json_object_new_object();
2863 json_object_string_add(json_ifp
, "interface",
2864 ifp
? ifp
->name
: "NULL");
2866 json_object_string_addf(json_ifp
, "nexthop", "%pI4",
2867 &nh_node
->gate
.ipv4
);
2869 json_object_string_addf(json_ifp
, "nexthop", "%pI6",
2870 &nh_node
->gate
.ipv6
);
2872 json_object_array_add(json_arr
, json_ifp
);
2877 int pim_show_nexthop_lookup_cmd_helper(const char *vrf
, struct vty
*vty
,
2878 pim_addr source
, pim_addr group
)
2881 pim_addr vif_source
;
2883 struct pim_nexthop nexthop
;
2885 char grp_str
[PREFIX_STRLEN
];
2887 v
= vrf_lookup_by_name(vrf
? vrf
: VRF_DEFAULT_NAME
);
2893 if (pim_is_group_224_4(source
)) {
2895 "Invalid argument. Expected Valid Source Address.\n");
2899 if (!pim_is_group_224_4(group
)) {
2901 "Invalid argument. Expected Valid Multicast Group Address.\n");
2906 if (!pim_rp_set_upstream_addr(v
->info
, &vif_source
, source
, group
))
2909 pim_addr_to_prefix(&grp
, group
);
2910 memset(&nexthop
, 0, sizeof(nexthop
));
2913 pim_ecmp_nexthop_lookup(v
->info
, &nexthop
, vif_source
, &grp
, 0);
2917 "Nexthop Lookup failed, no usable routes returned.\n");
2921 pim_addr_dump("<grp?>", &grp
, grp_str
, sizeof(grp_str
));
2923 vty_out(vty
, "Group %s --- Nexthop %pPAs Interface %s\n", grp_str
,
2924 &nexthop
.mrib_nexthop_addr
, nexthop
.interface
->name
);
2929 int pim_show_nexthop_cmd_helper(const char *vrf
, struct vty
*vty
, bool uj
)
2933 v
= vrf_lookup_by_name(vrf
? vrf
: VRF_DEFAULT_NAME
);
2938 pim_show_nexthop(v
->info
, vty
, uj
);
2943 void pim_show_nexthop(struct pim_instance
*pim
, struct vty
*vty
, bool uj
)
2945 struct vty_pnc_cache_walk_data cwd
;
2946 struct json_pnc_cache_walk_data jcwd
;
2953 jcwd
.json_obj
= json_object_new_object();
2955 vty_out(vty
, "Number of registered addresses: %lu\n",
2956 pim
->rpf_hash
->count
);
2957 vty_out(vty
, "Address Interface Nexthop\n");
2958 vty_out(vty
, "---------------------------------------------\n");
2962 hash_walk(pim
->rpf_hash
, pim_print_json_pnc_cache_walkcb
,
2964 vty_json(vty
, jcwd
.json_obj
);
2966 hash_walk(pim
->rpf_hash
, pim_print_vty_pnc_cache_walkcb
, &cwd
);
2969 int pim_show_neighbors_cmd_helper(const char *vrf
, struct vty
*vty
,
2970 const char *json
, const char *interface
)
2973 json_object
*json_parent
= NULL
;
2975 v
= vrf_lookup_by_name(vrf
? vrf
: VRF_DEFAULT_NAME
);
2981 json_parent
= json_object_new_object();
2984 pim_show_neighbors_single(v
->info
, vty
, interface
, json_parent
);
2986 pim_show_neighbors(v
->info
, vty
, json_parent
);
2989 vty_json(vty
, json_parent
);
2994 int pim_show_neighbors_vrf_all_cmd_helper(struct vty
*vty
, const char *json
,
2995 const char *interface
)
2998 json_object
*json_parent
= NULL
;
2999 json_object
*json_vrf
= NULL
;
3002 json_parent
= json_object_new_object();
3003 RB_FOREACH (v
, vrf_name_head
, &vrfs_by_name
) {
3005 vty_out(vty
, "VRF: %s\n", v
->name
);
3007 json_vrf
= json_object_new_object();
3010 pim_show_neighbors_single(v
->info
, vty
, interface
,
3013 pim_show_neighbors(v
->info
, vty
, json_vrf
);
3016 json_object_object_add(json_parent
, v
->name
, json_vrf
);
3019 vty_json(vty
, json_parent
);
3024 void pim_show_neighbors_single(struct pim_instance
*pim
, struct vty
*vty
,
3025 const char *neighbor
, json_object
*json
)
3027 struct listnode
*neighnode
;
3028 struct interface
*ifp
;
3029 struct pim_interface
*pim_ifp
;
3030 struct pim_neighbor
*neigh
;
3032 int found_neighbor
= 0;
3033 int option_address_list
;
3034 int option_dr_priority
;
3035 int option_generation_id
;
3036 int option_holdtime
;
3037 int option_lan_prune_delay
;
3041 char neigh_src_str
[PIM_ADDRSTRLEN
];
3043 json_object
*json_ifp
= NULL
;
3044 json_object
*json_row
= NULL
;
3046 now
= pim_time_monotonic_sec();
3048 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
3049 pim_ifp
= ifp
->info
;
3054 if (pim_ifp
->pim_sock_fd
< 0)
3057 for (ALL_LIST_ELEMENTS_RO(pim_ifp
->pim_neighbor_list
, neighnode
,
3059 snprintfrr(neigh_src_str
, sizeof(neigh_src_str
),
3060 "%pPAs", &neigh
->source_addr
);
3063 * The user can specify either the interface name or the
3065 * If this pim_ifp matches neither then skip.
3067 if (strcmp(neighbor
, "detail") &&
3068 strcmp(neighbor
, ifp
->name
) &&
3069 strcmp(neighbor
, neigh_src_str
))
3073 pim_time_uptime(uptime
, sizeof(uptime
),
3074 now
- neigh
->creation
);
3075 pim_time_timer_to_hhmmss(expire
, sizeof(expire
),
3076 neigh
->t_expire_timer
);
3078 option_address_list
= 0;
3079 option_dr_priority
= 0;
3080 option_generation_id
= 0;
3081 option_holdtime
= 0;
3082 option_lan_prune_delay
= 0;
3085 if (PIM_OPTION_IS_SET(neigh
->hello_options
,
3086 PIM_OPTION_MASK_ADDRESS_LIST
))
3087 option_address_list
= 1;
3089 if (PIM_OPTION_IS_SET(neigh
->hello_options
,
3090 PIM_OPTION_MASK_DR_PRIORITY
))
3091 option_dr_priority
= 1;
3093 if (PIM_OPTION_IS_SET(neigh
->hello_options
,
3094 PIM_OPTION_MASK_GENERATION_ID
))
3095 option_generation_id
= 1;
3097 if (PIM_OPTION_IS_SET(neigh
->hello_options
,
3098 PIM_OPTION_MASK_HOLDTIME
))
3099 option_holdtime
= 1;
3101 if (PIM_OPTION_IS_SET(neigh
->hello_options
,
3102 PIM_OPTION_MASK_LAN_PRUNE_DELAY
))
3103 option_lan_prune_delay
= 1;
3105 if (PIM_OPTION_IS_SET(
3106 neigh
->hello_options
,
3107 PIM_OPTION_MASK_CAN_DISABLE_JOIN_SUPPRESSION
))
3112 /* Does this ifp live in json? If not create it
3114 json_object_object_get_ex(json
, ifp
->name
,
3118 json_ifp
= json_object_new_object();
3119 json_object_pim_ifp_add(json_ifp
, ifp
);
3120 json_object_object_add(json
, ifp
->name
,
3124 json_row
= json_object_new_object();
3125 json_object_string_add(json_row
, "interface",
3127 json_object_string_add(json_row
, "address",
3129 json_object_string_add(json_row
, "upTime",
3131 json_object_string_add(json_row
, "holdtime",
3133 json_object_int_add(json_row
, "drPriority",
3134 neigh
->dr_priority
);
3135 json_object_int_add(json_row
, "generationId",
3136 neigh
->generation_id
);
3138 if (option_address_list
)
3139 json_object_boolean_true_add(
3141 "helloOptionAddressList");
3143 if (option_dr_priority
)
3144 json_object_boolean_true_add(
3146 "helloOptionDrPriority");
3148 if (option_generation_id
)
3149 json_object_boolean_true_add(
3151 "helloOptionGenerationId");
3153 if (option_holdtime
)
3154 json_object_boolean_true_add(
3156 "helloOptionHoldtime");
3158 if (option_lan_prune_delay
)
3159 json_object_boolean_true_add(
3161 "helloOptionLanPruneDelay");
3164 json_object_boolean_true_add(
3165 json_row
, "helloOptionTBit");
3167 json_object_object_add(json_ifp
, neigh_src_str
,
3171 vty_out(vty
, "Interface : %s\n", ifp
->name
);
3172 vty_out(vty
, "Neighbor : %s\n", neigh_src_str
);
3180 " DR Priority : %d\n",
3181 neigh
->dr_priority
);
3183 " Generation ID : %08x\n",
3184 neigh
->generation_id
);
3186 " Override Interval (msec) : %d\n",
3187 neigh
->override_interval_msec
);
3189 " Propagation Delay (msec) : %d\n",
3190 neigh
->propagation_delay_msec
);
3192 " Hello Option - Address List : %s\n",
3193 option_address_list
? "yes" : "no");
3195 " Hello Option - DR Priority : %s\n",
3196 option_dr_priority
? "yes" : "no");
3198 " Hello Option - Generation ID : %s\n",
3199 option_generation_id
? "yes" : "no");
3201 " Hello Option - Holdtime : %s\n",
3202 option_holdtime
? "yes" : "no");
3204 " Hello Option - LAN Prune Delay : %s\n",
3205 option_lan_prune_delay
? "yes" : "no");
3207 " Hello Option - T-bit : %s\n",
3208 option_t_bit
? "yes" : "no");
3209 bfd_sess_show(vty
, json_ifp
,
3210 neigh
->bfd_session
);
3216 if (!found_neighbor
)
3217 vty_out(vty
, "%% No such interface or neighbor\n");
3220 void pim_show_neighbors(struct pim_instance
*pim
, struct vty
*vty
,
3223 struct listnode
*neighnode
;
3224 struct interface
*ifp
;
3225 struct pim_interface
*pim_ifp
;
3226 struct pim_neighbor
*neigh
;
3227 struct ttable
*tt
= NULL
;
3232 char neigh_src_str
[PIM_ADDRSTRLEN
];
3233 json_object
*json_ifp_rows
= NULL
;
3234 json_object
*json_row
= NULL
;
3236 now
= pim_time_monotonic_sec();
3239 /* Prepare table. */
3240 tt
= ttable_new(&ttable_styles
[TTSTYLE_BLANK
]);
3241 ttable_add_row(tt
, "Interface|Neighbor|Uptime|Holdtime|DR Pri");
3242 tt
->style
.cell
.rpad
= 2;
3243 tt
->style
.corner
= '+';
3247 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
3248 pim_ifp
= ifp
->info
;
3253 if (pim_ifp
->pim_sock_fd
< 0)
3257 json_ifp_rows
= json_object_new_object();
3259 for (ALL_LIST_ELEMENTS_RO(pim_ifp
->pim_neighbor_list
, neighnode
,
3261 snprintfrr(neigh_src_str
, sizeof(neigh_src_str
),
3262 "%pPAs", &neigh
->source_addr
);
3263 pim_time_uptime(uptime
, sizeof(uptime
),
3264 now
- neigh
->creation
);
3265 pim_time_timer_to_hhmmss(expire
, sizeof(expire
),
3266 neigh
->t_expire_timer
);
3269 json_row
= json_object_new_object();
3270 json_object_string_add(json_row
, "interface",
3272 json_object_string_add(json_row
, "neighbor",
3274 json_object_string_add(json_row
, "upTime",
3276 json_object_string_add(json_row
, "holdTime",
3278 json_object_int_add(json_row
, "holdTimeMax",
3280 json_object_int_add(json_row
, "drPriority",
3281 neigh
->dr_priority
);
3282 json_object_object_add(json_ifp_rows
,
3283 neigh_src_str
, json_row
);
3286 ttable_add_row(tt
, "%s|%pPAs|%s|%s|%d",
3287 ifp
->name
, &neigh
->source_addr
,
3289 neigh
->dr_priority
);
3294 json_object_object_add(json
, ifp
->name
, json_ifp_rows
);
3295 json_ifp_rows
= NULL
;
3298 /* Dump the generated table. */
3300 table
= ttable_dump(tt
, "\n");
3301 vty_out(vty
, "%s\n", table
);
3302 XFREE(MTYPE_TMP
, table
);
3307 int gm_process_query_max_response_time_cmd(struct vty
*vty
,
3308 const char *qmrt_str
)
3310 const struct lyd_node
*pim_enable_dnode
;
3312 pim_enable_dnode
= yang_dnode_getf(vty
->candidate_config
->dnode
,
3313 FRR_PIM_ENABLE_XPATH
, VTY_CURR_XPATH
,
3314 FRR_PIM_AF_XPATH_VAL
);
3316 if (!pim_enable_dnode
) {
3317 nb_cli_enqueue_change(vty
, "./enable", NB_OP_MODIFY
, "true");
3319 if (!yang_dnode_get_bool(pim_enable_dnode
, "."))
3320 nb_cli_enqueue_change(vty
, "./enable", NB_OP_MODIFY
,
3324 nb_cli_enqueue_change(vty
, "./query-max-response-time", NB_OP_MODIFY
,
3326 return nb_cli_apply_changes(vty
, FRR_GMP_INTERFACE_XPATH
,
3327 FRR_PIM_AF_XPATH_VAL
);
3330 int gm_process_no_query_max_response_time_cmd(struct vty
*vty
)
3332 nb_cli_enqueue_change(vty
, "./query-max-response-time", NB_OP_DESTROY
,
3334 return nb_cli_apply_changes(vty
, FRR_GMP_INTERFACE_XPATH
,
3335 FRR_PIM_AF_XPATH_VAL
);
3338 int gm_process_last_member_query_count_cmd(struct vty
*vty
,
3339 const char *lmqc_str
)
3341 const struct lyd_node
*pim_enable_dnode
;
3343 pim_enable_dnode
= yang_dnode_getf(vty
->candidate_config
->dnode
,
3344 FRR_PIM_ENABLE_XPATH
, VTY_CURR_XPATH
,
3345 FRR_PIM_AF_XPATH_VAL
);
3346 if (!pim_enable_dnode
) {
3347 nb_cli_enqueue_change(vty
, "./enable", NB_OP_MODIFY
, "true");
3349 if (!yang_dnode_get_bool(pim_enable_dnode
, "."))
3350 nb_cli_enqueue_change(vty
, "./enable", NB_OP_MODIFY
,
3354 nb_cli_enqueue_change(vty
, "./robustness-variable", NB_OP_MODIFY
,
3356 return nb_cli_apply_changes(vty
, FRR_GMP_INTERFACE_XPATH
,
3357 FRR_PIM_AF_XPATH_VAL
);
3360 int gm_process_no_last_member_query_count_cmd(struct vty
*vty
)
3362 nb_cli_enqueue_change(vty
, "./robustness-variable", NB_OP_DESTROY
,
3364 return nb_cli_apply_changes(vty
, FRR_GMP_INTERFACE_XPATH
,
3365 FRR_PIM_AF_XPATH_VAL
);
3368 int gm_process_last_member_query_interval_cmd(struct vty
*vty
,
3369 const char *lmqi_str
)
3371 const struct lyd_node
*pim_enable_dnode
;
3373 pim_enable_dnode
= yang_dnode_getf(vty
->candidate_config
->dnode
,
3374 FRR_PIM_ENABLE_XPATH
, VTY_CURR_XPATH
,
3375 FRR_PIM_AF_XPATH_VAL
);
3376 if (!pim_enable_dnode
) {
3377 nb_cli_enqueue_change(vty
, "./enable", NB_OP_MODIFY
, "true");
3379 if (!yang_dnode_get_bool(pim_enable_dnode
, "."))
3380 nb_cli_enqueue_change(vty
, "./enable", NB_OP_MODIFY
,
3384 nb_cli_enqueue_change(vty
, "./last-member-query-interval", NB_OP_MODIFY
,
3386 return nb_cli_apply_changes(vty
, FRR_GMP_INTERFACE_XPATH
,
3387 FRR_PIM_AF_XPATH_VAL
);
3390 int gm_process_no_last_member_query_interval_cmd(struct vty
*vty
)
3392 nb_cli_enqueue_change(vty
, "./last-member-query-interval",
3393 NB_OP_DESTROY
, NULL
);
3394 return nb_cli_apply_changes(vty
, FRR_GMP_INTERFACE_XPATH
,
3395 FRR_PIM_AF_XPATH_VAL
);
3398 int pim_process_ssmpingd_cmd(struct vty
*vty
, enum nb_operation operation
,
3399 const char *src_str
)
3401 const char *vrfname
;
3402 char ssmpingd_ip_xpath
[XPATH_MAXLEN
];
3404 vrfname
= pim_cli_get_vrf_name(vty
);
3405 if (vrfname
== NULL
)
3406 return CMD_WARNING_CONFIG_FAILED
;
3408 snprintf(ssmpingd_ip_xpath
, sizeof(ssmpingd_ip_xpath
),
3409 FRR_PIM_VRF_XPATH
, "frr-pim:pimd", "pim", vrfname
,
3410 FRR_PIM_AF_XPATH_VAL
);
3411 strlcat(ssmpingd_ip_xpath
, "/ssm-pingd-source-ip",
3412 sizeof(ssmpingd_ip_xpath
));
3414 nb_cli_enqueue_change(vty
, ssmpingd_ip_xpath
, operation
, src_str
);
3416 return nb_cli_apply_changes(vty
, NULL
);
3419 int pim_process_bsm_cmd(struct vty
*vty
)
3421 const struct lyd_node
*gm_enable_dnode
;
3423 gm_enable_dnode
= yang_dnode_getf(vty
->candidate_config
->dnode
,
3424 FRR_GMP_ENABLE_XPATH
, VTY_CURR_XPATH
,
3425 FRR_PIM_AF_XPATH_VAL
);
3426 if (!gm_enable_dnode
)
3427 nb_cli_enqueue_change(vty
, "./pim-enable", NB_OP_MODIFY
,
3430 if (!yang_dnode_get_bool(gm_enable_dnode
, "."))
3431 nb_cli_enqueue_change(vty
, "./pim-enable", NB_OP_MODIFY
,
3435 nb_cli_enqueue_change(vty
, "./bsm", NB_OP_MODIFY
, "true");
3437 return nb_cli_apply_changes(vty
, FRR_PIM_INTERFACE_XPATH
,
3438 FRR_PIM_AF_XPATH_VAL
);
3441 int pim_process_no_bsm_cmd(struct vty
*vty
)
3443 nb_cli_enqueue_change(vty
, "./bsm", NB_OP_MODIFY
, "false");
3445 return nb_cli_apply_changes(vty
, FRR_PIM_INTERFACE_XPATH
,
3446 FRR_PIM_AF_XPATH_VAL
);
3449 int pim_process_unicast_bsm_cmd(struct vty
*vty
)
3451 const struct lyd_node
*gm_enable_dnode
;
3453 gm_enable_dnode
= yang_dnode_getf(vty
->candidate_config
->dnode
,
3454 FRR_GMP_ENABLE_XPATH
, VTY_CURR_XPATH
,
3455 FRR_PIM_AF_XPATH_VAL
);
3456 if (!gm_enable_dnode
)
3457 nb_cli_enqueue_change(vty
, "./pim-enable", NB_OP_MODIFY
,
3460 if (!yang_dnode_get_bool(gm_enable_dnode
, "."))
3461 nb_cli_enqueue_change(vty
, "./pim-enable", NB_OP_MODIFY
,
3465 nb_cli_enqueue_change(vty
, "./unicast-bsm", NB_OP_MODIFY
, "true");
3467 return nb_cli_apply_changes(vty
, FRR_PIM_INTERFACE_XPATH
,
3468 FRR_PIM_AF_XPATH_VAL
);
3471 int pim_process_no_unicast_bsm_cmd(struct vty
*vty
)
3473 nb_cli_enqueue_change(vty
, "./unicast-bsm", NB_OP_MODIFY
, "false");
3475 return nb_cli_apply_changes(vty
, FRR_PIM_INTERFACE_XPATH
,
3476 FRR_PIM_AF_XPATH_VAL
);
3479 static void show_scan_oil_stats(struct pim_instance
*pim
, struct vty
*vty
,
3482 char uptime_scan_oil
[10];
3483 char uptime_mroute_add
[10];
3484 char uptime_mroute_del
[10];
3486 pim_time_uptime_begin(uptime_scan_oil
, sizeof(uptime_scan_oil
), now
,
3487 pim
->scan_oil_last
);
3488 pim_time_uptime_begin(uptime_mroute_add
, sizeof(uptime_mroute_add
), now
,
3489 pim
->mroute_add_last
);
3490 pim_time_uptime_begin(uptime_mroute_del
, sizeof(uptime_mroute_del
), now
,
3491 pim
->mroute_del_last
);
3494 "Scan OIL - Last: %s Events: %lld\n"
3495 "MFC Add - Last: %s Events: %lld\n"
3496 "MFC Del - Last: %s Events: %lld\n",
3497 uptime_scan_oil
, (long long)pim
->scan_oil_events
,
3498 uptime_mroute_add
, (long long)pim
->mroute_add_events
,
3499 uptime_mroute_del
, (long long)pim
->mroute_del_events
);
3502 void show_multicast_interfaces(struct pim_instance
*pim
, struct vty
*vty
,
3505 struct interface
*ifp
;
3506 struct ttable
*tt
= NULL
;
3508 json_object
*json_row
= NULL
;
3513 /* Prepare table. */
3514 tt
= ttable_new(&ttable_styles
[TTSTYLE_BLANK
]);
3517 "Interface|Address|ifi|Vif|PktsIn|PktsOut|BytesIn|BytesOut");
3518 tt
->style
.cell
.rpad
= 2;
3519 tt
->style
.corner
= '+';
3523 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
3524 struct pim_interface
*pim_ifp
;
3526 struct sioc_vif_req vreq
;
3528 struct sioc_mif_req6 vreq
;
3531 pim_ifp
= ifp
->info
;
3536 memset(&vreq
, 0, sizeof(vreq
));
3538 vreq
.vifi
= pim_ifp
->mroute_vif_index
;
3539 if (ioctl(pim
->mroute_socket
, SIOCGETVIFCNT
, &vreq
)) {
3541 "ioctl(SIOCGETVIFCNT=%lu) failure for interface %s vif_index=%d: errno=%d: %s",
3542 (unsigned long)SIOCGETVIFCNT
, ifp
->name
,
3543 pim_ifp
->mroute_vif_index
, errno
,
3544 safe_strerror(errno
));
3547 vreq
.mifi
= pim_ifp
->mroute_vif_index
;
3548 if (ioctl(pim
->mroute_socket
, SIOCGETMIFCNT_IN6
, &vreq
)) {
3550 "ioctl(SIOCGETMIFCNT_IN6=%lu) failure for interface %s vif_index=%d: errno=%d: %s",
3551 (unsigned long)SIOCGETMIFCNT_IN6
, ifp
->name
,
3552 pim_ifp
->mroute_vif_index
, errno
,
3553 safe_strerror(errno
));
3558 json_row
= json_object_new_object();
3559 json_object_string_add(json_row
, "name", ifp
->name
);
3560 json_object_string_add(json_row
, "state",
3561 if_is_up(ifp
) ? "up" : "down");
3562 json_object_string_addf(json_row
, "address", "%pPA",
3563 &pim_ifp
->primary_address
);
3564 json_object_int_add(json_row
, "ifIndex", ifp
->ifindex
);
3565 json_object_int_add(json_row
, "vif",
3566 pim_ifp
->mroute_vif_index
);
3567 json_object_int_add(json_row
, "pktsIn",
3568 (unsigned long)vreq
.icount
);
3569 json_object_int_add(json_row
, "pktsOut",
3570 (unsigned long)vreq
.ocount
);
3571 json_object_int_add(json_row
, "bytesIn",
3572 (unsigned long)vreq
.ibytes
);
3573 json_object_int_add(json_row
, "bytesOut",
3574 (unsigned long)vreq
.obytes
);
3575 json_object_object_add(json
, ifp
->name
, json_row
);
3577 ttable_add_row(tt
, "%s|%pPAs|%d|%d|%lu|%lu|%lu|%lu",
3578 ifp
->name
, &pim_ifp
->primary_address
,
3579 ifp
->ifindex
, pim_ifp
->mroute_vif_index
,
3580 (unsigned long)vreq
.icount
,
3581 (unsigned long)vreq
.ocount
,
3582 (unsigned long)vreq
.ibytes
,
3583 (unsigned long)vreq
.obytes
);
3586 /* Dump the generated table. */
3588 table
= ttable_dump(tt
, "\n");
3589 vty_out(vty
, "%s\n", table
);
3590 XFREE(MTYPE_TMP
, table
);
3595 void pim_cmd_show_ip_multicast_helper(struct pim_instance
*pim
, struct vty
*vty
)
3597 struct vrf
*vrf
= pim
->vrf
;
3598 time_t now
= pim_time_monotonic_sec();
3604 vty_out(vty
, "Router MLAG Role: %s\n",
3605 mlag_role2str(router
->mlag_role
, mlag_role
, sizeof(mlag_role
)));
3606 vty_out(vty
, "Mroute socket descriptor:");
3608 vty_out(vty
, " %d(%s)\n", pim
->mroute_socket
, vrf
->name
);
3609 vty_out(vty
, "PIM Register socket descriptor:");
3610 vty_out(vty
, " %d(%s)\n", pim
->reg_sock
, vrf
->name
);
3612 pim_time_uptime(uptime
, sizeof(uptime
),
3613 now
- pim
->mroute_socket_creation
);
3614 vty_out(vty
, "Mroute socket uptime: %s\n", uptime
);
3618 pim_zebra_zclient_update(vty
);
3619 pim_zlookup_show_ip_multicast(vty
);
3622 vty_out(vty
, "Maximum highest VifIndex: %d\n", PIM_MAX_USABLE_VIFS
);
3625 vty_out(vty
, "Upstream Join Timer: %d secs\n", router
->t_periodic
);
3626 vty_out(vty
, "Join/Prune Holdtime: %d secs\n", PIM_JP_HOLDTIME
);
3627 vty_out(vty
, "PIM ECMP: %s\n", pim
->ecmp_enable
? "Enable" : "Disable");
3628 vty_out(vty
, "PIM ECMP Rebalance: %s\n",
3629 pim
->ecmp_rebalance_enable
? "Enable" : "Disable");
3633 pim_show_rpf_refresh_stats(vty
, pim
, now
, NULL
);
3637 show_scan_oil_stats(pim
, vty
, now
);
3639 show_multicast_interfaces(pim
, vty
, NULL
);
3642 void show_mroute(struct pim_instance
*pim
, struct vty
*vty
, pim_sgaddr
*sg
,
3643 bool fill
, json_object
*json
)
3645 struct listnode
*node
;
3646 struct channel_oil
*c_oil
;
3647 struct static_route
*s_route
;
3648 struct ttable
*tt
= NULL
;
3651 json_object
*json_group
= NULL
;
3652 json_object
*json_source
= NULL
;
3653 json_object
*json_oil
= NULL
;
3654 json_object
*json_ifp_out
= NULL
;
3657 char grp_str
[PIM_ADDRSTRLEN
];
3658 char src_str
[PIM_ADDRSTRLEN
];
3659 char in_ifname
[INTERFACE_NAMSIZ
+ 1];
3660 char out_ifname
[INTERFACE_NAMSIZ
+ 1];
3662 struct interface
*ifp_in
;
3664 char state_str
[PIM_REG_STATE_STR_LEN
];
3665 char mroute_uptime
[10];
3668 vty_out(vty
, "IP Multicast Routing Table\n");
3669 vty_out(vty
, "Flags: S - Sparse, C - Connected, P - Pruned\n");
3671 " R - SGRpt Pruned, F - Register flag, T - SPT-bit set\n");
3673 /* Prepare table. */
3674 tt
= ttable_new(&ttable_styles
[TTSTYLE_BLANK
]);
3676 tt
, "Source|Group|Flags|Proto|Input|Output|TTL|Uptime");
3677 tt
->style
.cell
.rpad
= 2;
3678 tt
->style
.corner
= '+';
3682 now
= pim_time_monotonic_sec();
3684 /* print list of PIM and IGMP routes */
3685 frr_each (rb_pim_oil
, &pim
->channel_oil_head
, c_oil
) {
3688 if (!c_oil
->installed
)
3691 if (!pim_addr_is_any(sg
->grp
) &&
3692 pim_addr_cmp(sg
->grp
, *oil_mcastgrp(c_oil
)))
3694 if (!pim_addr_is_any(sg
->src
) &&
3695 pim_addr_cmp(sg
->src
, *oil_origin(c_oil
)))
3698 snprintfrr(grp_str
, sizeof(grp_str
), "%pPAs",
3699 oil_mcastgrp(c_oil
));
3700 snprintfrr(src_str
, sizeof(src_str
), "%pPAs",
3703 strlcpy(state_str
, "S", sizeof(state_str
));
3704 /* When a non DR receives a igmp join, it creates a (*,G)
3705 * channel_oil without any upstream creation
3708 if (PIM_UPSTREAM_FLAG_TEST_SRC_IGMP(c_oil
->up
->flags
))
3709 strlcat(state_str
, "C", sizeof(state_str
));
3710 if (pim_upstream_is_sg_rpt(c_oil
->up
))
3711 strlcat(state_str
, "R", sizeof(state_str
));
3712 if (PIM_UPSTREAM_FLAG_TEST_FHR(c_oil
->up
->flags
))
3713 strlcat(state_str
, "F", sizeof(state_str
));
3714 if (c_oil
->up
->sptbit
== PIM_UPSTREAM_SPTBIT_TRUE
)
3715 strlcat(state_str
, "T", sizeof(state_str
));
3717 if (pim_channel_oil_empty(c_oil
))
3718 strlcat(state_str
, "P", sizeof(state_str
));
3720 ifp_in
= pim_if_find_by_vif_index(pim
, *oil_parent(c_oil
));
3723 strlcpy(in_ifname
, ifp_in
->name
, sizeof(in_ifname
));
3725 strlcpy(in_ifname
, "<iif?>", sizeof(in_ifname
));
3728 pim_time_uptime(mroute_uptime
, sizeof(mroute_uptime
),
3729 now
- c_oil
->mroute_creation
);
3733 /* Find the group, create it if it doesn't exist */
3734 json_object_object_get_ex(json
, grp_str
, &json_group
);
3737 json_group
= json_object_new_object();
3738 json_object_object_add(json
, grp_str
,
3742 /* Find the source nested under the group, create it if
3745 json_object_object_get_ex(json_group
, src_str
,
3749 json_source
= json_object_new_object();
3750 json_object_object_add(json_group
, src_str
,
3754 /* Find the inbound interface nested under the source,
3755 * create it if it doesn't exist
3757 json_object_string_add(json_source
, "source", src_str
);
3758 json_object_string_add(json_source
, "group", grp_str
);
3759 json_object_int_add(json_source
, "installed",
3761 json_object_int_add(json_source
, "refCount",
3762 c_oil
->oil_ref_count
);
3763 json_object_int_add(json_source
, "oilSize",
3765 json_object_int_add(json_source
, "OilInheritedRescan",
3766 c_oil
->oil_inherited_rescan
);
3767 json_object_int_add(json_source
, "oilInheritedRescan",
3768 c_oil
->oil_inherited_rescan
);
3769 json_object_string_add(json_source
, "iif", in_ifname
);
3770 json_object_string_add(json_source
, "upTime",
3775 for (oif_vif_index
= 0; oif_vif_index
< MAXVIFS
;
3777 struct interface
*ifp_out
;
3780 ttl
= oil_if_has(c_oil
, oif_vif_index
);
3784 /* do not display muted OIFs */
3785 if (c_oil
->oif_flags
[oif_vif_index
] & PIM_OIF_FLAG_MUTE
)
3788 if (*oil_parent(c_oil
) == oif_vif_index
&&
3789 !pim_mroute_allow_iif_in_oil(c_oil
, oif_vif_index
))
3792 ifp_out
= pim_if_find_by_vif_index(pim
, oif_vif_index
);
3796 strlcpy(out_ifname
, ifp_out
->name
,
3797 sizeof(out_ifname
));
3799 strlcpy(out_ifname
, "<oif?>",
3800 sizeof(out_ifname
));
3803 json_ifp_out
= json_object_new_object();
3804 json_object_string_add(json_ifp_out
, "source",
3806 json_object_string_add(json_ifp_out
, "group",
3809 if (c_oil
->oif_flags
[oif_vif_index
] &
3810 PIM_OIF_FLAG_PROTO_PIM
)
3811 json_object_boolean_true_add(
3812 json_ifp_out
, "protocolPim");
3814 if (c_oil
->oif_flags
[oif_vif_index
] &
3815 PIM_OIF_FLAG_PROTO_GM
)
3817 json_object_boolean_true_add(
3818 json_ifp_out
, "protocolIgmp");
3820 json_object_boolean_true_add(
3821 json_ifp_out
, "protocolMld");
3824 if (c_oil
->oif_flags
[oif_vif_index
] &
3825 PIM_OIF_FLAG_PROTO_VXLAN
)
3826 json_object_boolean_true_add(
3827 json_ifp_out
, "protocolVxlan");
3829 if (c_oil
->oif_flags
[oif_vif_index
] &
3830 PIM_OIF_FLAG_PROTO_STAR
)
3831 json_object_boolean_true_add(
3833 "protocolInherited");
3835 json_object_string_add(json_ifp_out
,
3838 json_object_int_add(json_ifp_out
, "iVifI",
3839 *oil_parent(c_oil
));
3840 json_object_string_add(json_ifp_out
,
3841 "outboundInterface",
3843 json_object_int_add(json_ifp_out
, "oVifI",
3845 json_object_int_add(json_ifp_out
, "ttl", ttl
);
3846 json_object_string_add(json_ifp_out
, "upTime",
3848 json_object_string_add(json_source
, "flags",
3851 json_oil
= json_object_new_object();
3852 json_object_object_add(json_source
,
3855 json_object_object_add(json_oil
, out_ifname
,
3859 if (c_oil
->oif_flags
[oif_vif_index
] &
3860 PIM_OIF_FLAG_PROTO_PIM
) {
3861 strlcpy(proto
, "PIM", sizeof(proto
));
3864 if (c_oil
->oif_flags
[oif_vif_index
] &
3865 PIM_OIF_FLAG_PROTO_GM
) {
3867 strlcpy(proto
, "IGMP", sizeof(proto
));
3869 strlcpy(proto
, "MLD", sizeof(proto
));
3873 if (c_oil
->oif_flags
[oif_vif_index
] &
3874 PIM_OIF_FLAG_PROTO_VXLAN
) {
3875 strlcpy(proto
, "VxLAN", sizeof(proto
));
3878 if (c_oil
->oif_flags
[oif_vif_index
] &
3879 PIM_OIF_FLAG_PROTO_STAR
) {
3880 strlcpy(proto
, "STAR", sizeof(proto
));
3883 ttable_add_row(tt
, "%s|%s|%s|%s|%s|%s|%d|%s",
3884 src_str
, grp_str
, state_str
,
3885 proto
, in_ifname
, out_ifname
,
3886 ttl
, mroute_uptime
);
3891 in_ifname
[0] = '\0';
3892 state_str
[0] = '\0';
3893 mroute_uptime
[0] = '\0';
3899 if (!json
&& !found_oif
) {
3900 ttable_add_row(tt
, "%pPAs|%pPAs|%s|%s|%s|%s|%d|%s",
3901 oil_origin(c_oil
), oil_mcastgrp(c_oil
),
3902 state_str
, "none", in_ifname
, "none", 0,
3907 /* Print list of static routes */
3908 for (ALL_LIST_ELEMENTS_RO(pim
->static_routes
, node
, s_route
)) {
3911 if (!s_route
->c_oil
.installed
)
3914 snprintfrr(grp_str
, sizeof(grp_str
), "%pPAs", &s_route
->group
);
3915 snprintfrr(src_str
, sizeof(src_str
), "%pPAs", &s_route
->source
);
3916 ifp_in
= pim_if_find_by_vif_index(pim
, s_route
->iif
);
3920 strlcpy(in_ifname
, ifp_in
->name
, sizeof(in_ifname
));
3922 strlcpy(in_ifname
, "<iif?>", sizeof(in_ifname
));
3926 /* Find the group, create it if it doesn't exist */
3927 json_object_object_get_ex(json
, grp_str
, &json_group
);
3930 json_group
= json_object_new_object();
3931 json_object_object_add(json
, grp_str
,
3935 /* Find the source nested under the group, create it if
3938 json_object_object_get_ex(json_group
, src_str
,
3942 json_source
= json_object_new_object();
3943 json_object_object_add(json_group
, src_str
,
3947 json_object_string_add(json_source
, "iif", in_ifname
);
3950 strlcpy(proto
, "STATIC", sizeof(proto
));
3953 for (oif_vif_index
= 0; oif_vif_index
< MAXVIFS
;
3955 struct interface
*ifp_out
;
3956 char oif_uptime
[10];
3959 ttl
= s_route
->oif_ttls
[oif_vif_index
];
3963 ifp_out
= pim_if_find_by_vif_index(pim
, oif_vif_index
);
3965 oif_uptime
, sizeof(oif_uptime
),
3966 now
- s_route
->c_oil
3967 .oif_creation
[oif_vif_index
]);
3971 strlcpy(out_ifname
, ifp_out
->name
,
3972 sizeof(out_ifname
));
3974 strlcpy(out_ifname
, "<oif?>",
3975 sizeof(out_ifname
));
3978 json_ifp_out
= json_object_new_object();
3979 json_object_string_add(json_ifp_out
, "source",
3981 json_object_string_add(json_ifp_out
, "group",
3983 json_object_boolean_true_add(json_ifp_out
,
3985 json_object_string_add(json_ifp_out
,
3988 json_object_int_add(
3989 json_ifp_out
, "iVifI",
3990 *oil_parent(&s_route
->c_oil
));
3991 json_object_string_add(json_ifp_out
,
3992 "outboundInterface",
3994 json_object_int_add(json_ifp_out
, "oVifI",
3996 json_object_int_add(json_ifp_out
, "ttl", ttl
);
3997 json_object_string_add(json_ifp_out
, "upTime",
4000 json_oil
= json_object_new_object();
4001 json_object_object_add(json_source
,
4004 json_object_object_add(json_oil
, out_ifname
,
4008 tt
, "%pPAs|%pPAs|%s|%s|%s|%s|%d|%s",
4009 &s_route
->source
, &s_route
->group
, "-",
4010 proto
, in_ifname
, out_ifname
, ttl
,
4012 if (first
&& !fill
) {
4015 in_ifname
[0] = '\0';
4021 if (!json
&& !found_oif
) {
4022 ttable_add_row(tt
, "%pPAs|%pPAs|%s|%s|%s|%s|%d|%s",
4023 &s_route
->source
, &s_route
->group
, "-",
4024 proto
, in_ifname
, "none", 0, "--:--:--");
4027 /* Dump the generated table. */
4029 table
= ttable_dump(tt
, "\n");
4030 vty_out(vty
, "%s\n", table
);
4031 XFREE(MTYPE_TMP
, table
);
4036 static void show_mroute_count_per_channel_oil(struct channel_oil
*c_oil
,
4040 json_object
*json_group
= NULL
;
4041 json_object
*json_source
= NULL
;
4043 if (!c_oil
->installed
)
4046 pim_mroute_update_counters(c_oil
);
4049 char group_str
[PIM_ADDRSTRLEN
];
4050 char source_str
[PIM_ADDRSTRLEN
];
4052 snprintfrr(group_str
, sizeof(group_str
), "%pPAs",
4053 oil_mcastgrp(c_oil
));
4054 snprintfrr(source_str
, sizeof(source_str
), "%pPAs",
4057 json_object_object_get_ex(json
, group_str
, &json_group
);
4060 json_group
= json_object_new_object();
4061 json_object_object_add(json
, group_str
, json_group
);
4064 json_source
= json_object_new_object();
4065 json_object_object_add(json_group
, source_str
, json_source
);
4066 json_object_int_add(json_source
, "lastUsed",
4067 c_oil
->cc
.lastused
/ 100);
4068 json_object_int_add(json_source
, "packets", c_oil
->cc
.pktcnt
);
4069 json_object_int_add(json_source
, "bytes", c_oil
->cc
.bytecnt
);
4070 json_object_int_add(json_source
, "wrongIf", c_oil
->cc
.wrong_if
);
4073 ttable_add_row(tt
, "%pPAs|%pPAs|%llu|%ld|%ld|%ld",
4074 oil_origin(c_oil
), oil_mcastgrp(c_oil
),
4075 c_oil
->cc
.lastused
/ 100,
4076 c_oil
->cc
.pktcnt
- c_oil
->cc
.origpktcnt
,
4077 c_oil
->cc
.bytecnt
- c_oil
->cc
.origbytecnt
,
4078 c_oil
->cc
.wrong_if
- c_oil
->cc
.origwrong_if
);
4082 void show_mroute_count(struct pim_instance
*pim
, struct vty
*vty
,
4085 struct listnode
*node
;
4086 struct channel_oil
*c_oil
;
4087 struct static_route
*sr
;
4088 struct ttable
*tt
= NULL
;
4094 /* Prepare table. */
4095 tt
= ttable_new(&ttable_styles
[TTSTYLE_BLANK
]);
4097 "Source|Group|LastUsed|Packets|Bytes|WrongIf");
4098 tt
->style
.cell
.rpad
= 2;
4099 tt
->style
.corner
= '+';
4103 /* Print PIM and IGMP route counts */
4104 frr_each (rb_pim_oil
, &pim
->channel_oil_head
, c_oil
)
4105 show_mroute_count_per_channel_oil(c_oil
, json
, tt
);
4107 for (ALL_LIST_ELEMENTS_RO(pim
->static_routes
, node
, sr
))
4108 show_mroute_count_per_channel_oil(&sr
->c_oil
, json
, tt
);
4110 /* Dump the generated table. */
4112 table
= ttable_dump(tt
, "\n");
4113 vty_out(vty
, "%s\n", table
);
4114 XFREE(MTYPE_TMP
, table
);
4119 void show_mroute_summary(struct pim_instance
*pim
, struct vty
*vty
,
4122 struct listnode
*node
;
4123 struct channel_oil
*c_oil
;
4124 struct static_route
*s_route
;
4125 uint32_t starg_sw_mroute_cnt
= 0;
4126 uint32_t sg_sw_mroute_cnt
= 0;
4127 uint32_t starg_hw_mroute_cnt
= 0;
4128 uint32_t sg_hw_mroute_cnt
= 0;
4129 json_object
*json_starg
= NULL
;
4130 json_object
*json_sg
= NULL
;
4133 vty_out(vty
, "Mroute Type Installed/Total\n");
4135 frr_each (rb_pim_oil
, &pim
->channel_oil_head
, c_oil
) {
4136 if (!c_oil
->installed
) {
4137 if (pim_addr_is_any(*oil_origin(c_oil
)))
4138 starg_sw_mroute_cnt
++;
4142 if (pim_addr_is_any(*oil_origin(c_oil
)))
4143 starg_hw_mroute_cnt
++;
4149 for (ALL_LIST_ELEMENTS_RO(pim
->static_routes
, node
, s_route
)) {
4150 if (!s_route
->c_oil
.installed
) {
4151 if (pim_addr_is_any(*oil_origin(&s_route
->c_oil
)))
4152 starg_sw_mroute_cnt
++;
4156 if (pim_addr_is_any(*oil_origin(&s_route
->c_oil
)))
4157 starg_hw_mroute_cnt
++;
4164 vty_out(vty
, "%-20s %u/%u\n", "(*, G)", starg_hw_mroute_cnt
,
4165 starg_sw_mroute_cnt
+ starg_hw_mroute_cnt
);
4166 vty_out(vty
, "%-20s %u/%u\n", "(S, G)", sg_hw_mroute_cnt
,
4167 sg_sw_mroute_cnt
+ sg_hw_mroute_cnt
);
4168 vty_out(vty
, "------\n");
4169 vty_out(vty
, "%-20s %u/%u\n", "Total",
4170 (starg_hw_mroute_cnt
+ sg_hw_mroute_cnt
),
4171 (starg_sw_mroute_cnt
+ starg_hw_mroute_cnt
+
4172 sg_sw_mroute_cnt
+ sg_hw_mroute_cnt
));
4174 /* (*,G) route details */
4175 json_starg
= json_object_new_object();
4176 json_object_object_add(json
, "wildcardGroup", json_starg
);
4178 json_object_int_add(json_starg
, "installed",
4179 starg_hw_mroute_cnt
);
4180 json_object_int_add(json_starg
, "total",
4181 starg_sw_mroute_cnt
+ starg_hw_mroute_cnt
);
4183 /* (S, G) route details */
4184 json_sg
= json_object_new_object();
4185 json_object_object_add(json
, "sourceGroup", json_sg
);
4187 json_object_int_add(json_sg
, "installed", sg_hw_mroute_cnt
);
4188 json_object_int_add(json_sg
, "total",
4189 sg_sw_mroute_cnt
+ sg_hw_mroute_cnt
);
4191 json_object_int_add(json
, "totalNumOfInstalledMroutes",
4192 starg_hw_mroute_cnt
+ sg_hw_mroute_cnt
);
4193 json_object_int_add(json
, "totalNumOfMroutes",
4194 starg_sw_mroute_cnt
+ starg_hw_mroute_cnt
+
4200 int clear_ip_mroute_count_command(struct vty
*vty
, const char *name
)
4202 struct listnode
*node
;
4203 struct channel_oil
*c_oil
;
4204 struct static_route
*sr
;
4205 struct vrf
*v
= pim_cmd_lookup(vty
, name
);
4206 struct pim_instance
*pim
;
4212 frr_each (rb_pim_oil
, &pim
->channel_oil_head
, c_oil
) {
4213 if (!c_oil
->installed
)
4216 pim_mroute_update_counters(c_oil
);
4217 c_oil
->cc
.origpktcnt
= c_oil
->cc
.pktcnt
;
4218 c_oil
->cc
.origbytecnt
= c_oil
->cc
.bytecnt
;
4219 c_oil
->cc
.origwrong_if
= c_oil
->cc
.wrong_if
;
4222 for (ALL_LIST_ELEMENTS_RO(pim
->static_routes
, node
, sr
)) {
4223 if (!sr
->c_oil
.installed
)
4226 pim_mroute_update_counters(&sr
->c_oil
);
4228 sr
->c_oil
.cc
.origpktcnt
= sr
->c_oil
.cc
.pktcnt
;
4229 sr
->c_oil
.cc
.origbytecnt
= sr
->c_oil
.cc
.bytecnt
;
4230 sr
->c_oil
.cc
.origwrong_if
= sr
->c_oil
.cc
.wrong_if
;
4235 struct vrf
*pim_cmd_lookup(struct vty
*vty
, const char *name
)
4240 vrf
= vrf_lookup_by_name(name
);
4242 vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
4245 vty_out(vty
, "Specified VRF: %s does not exist\n", name
);
4250 void clear_mroute(struct pim_instance
*pim
)
4252 struct pim_upstream
*up
;
4253 struct interface
*ifp
;
4255 /* scan interfaces */
4256 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
4257 struct pim_interface
*pim_ifp
= ifp
->info
;
4258 struct pim_ifchannel
*ch
;
4263 /* deleting all ifchannels */
4264 while (!RB_EMPTY(pim_ifchannel_rb
, &pim_ifp
->ifchannel_rb
)) {
4265 ch
= RB_ROOT(pim_ifchannel_rb
, &pim_ifp
->ifchannel_rb
);
4267 pim_ifchannel_delete(ch
);
4271 /* clean up all igmp groups */
4272 struct gm_group
*grp
;
4274 if (pim_ifp
->gm_group_list
) {
4275 while (pim_ifp
->gm_group_list
->count
) {
4276 grp
= listnode_head(pim_ifp
->gm_group_list
);
4277 igmp_group_delete(grp
);
4281 struct gm_if
*gm_ifp
;
4283 gm_ifp
= pim_ifp
->mld
;
4285 gm_group_delete(gm_ifp
);
4289 /* clean up all upstreams*/
4290 while ((up
= rb_pim_upstream_first(&pim
->upstream_head
)))
4291 pim_upstream_del(pim
, up
, __func__
);
4294 void clear_pim_statistics(struct pim_instance
*pim
)
4296 struct interface
*ifp
;
4300 pim
->bsm_dropped
= 0;
4302 /* scan interfaces */
4303 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
4304 struct pim_interface
*pim_ifp
= ifp
->info
;
4309 pim_ifp
->pim_ifstat_bsm_cfg_miss
= 0;
4310 pim_ifp
->pim_ifstat_ucast_bsm_cfg_miss
= 0;
4311 pim_ifp
->pim_ifstat_bsm_invalid_sz
= 0;
4315 int clear_pim_interface_traffic(const char *vrf
, struct vty
*vty
)
4317 struct interface
*ifp
= NULL
;
4318 struct pim_interface
*pim_ifp
= NULL
;
4320 struct vrf
*v
= pim_cmd_lookup(vty
, vrf
);
4325 FOR_ALL_INTERFACES (v
, ifp
) {
4326 pim_ifp
= ifp
->info
;
4331 pim_ifp
->pim_ifstat_hello_recv
= 0;
4332 pim_ifp
->pim_ifstat_hello_sent
= 0;
4333 pim_ifp
->pim_ifstat_join_recv
= 0;
4334 pim_ifp
->pim_ifstat_join_send
= 0;
4335 pim_ifp
->pim_ifstat_prune_recv
= 0;
4336 pim_ifp
->pim_ifstat_prune_send
= 0;
4337 pim_ifp
->pim_ifstat_reg_recv
= 0;
4338 pim_ifp
->pim_ifstat_reg_send
= 0;
4339 pim_ifp
->pim_ifstat_reg_stop_recv
= 0;
4340 pim_ifp
->pim_ifstat_reg_stop_send
= 0;
4341 pim_ifp
->pim_ifstat_assert_recv
= 0;
4342 pim_ifp
->pim_ifstat_assert_send
= 0;
4343 pim_ifp
->pim_ifstat_bsm_rx
= 0;
4344 pim_ifp
->pim_ifstat_bsm_tx
= 0;
4346 pim_ifp
->igmp_ifstat_joins_sent
= 0;
4347 pim_ifp
->igmp_ifstat_joins_failed
= 0;
4348 pim_ifp
->igmp_peak_group_count
= 0;
4355 int pim_debug_pim_cmd(void)
4357 PIM_DO_DEBUG_PIM_EVENTS
;
4358 PIM_DO_DEBUG_PIM_PACKETS
;
4359 PIM_DO_DEBUG_PIM_TRACE
;
4360 PIM_DO_DEBUG_MSDP_EVENTS
;
4361 PIM_DO_DEBUG_MSDP_PACKETS
;
4367 int pim_no_debug_pim_cmd(void)
4369 PIM_DONT_DEBUG_PIM_EVENTS
;
4370 PIM_DONT_DEBUG_PIM_PACKETS
;
4371 PIM_DONT_DEBUG_PIM_TRACE
;
4372 PIM_DONT_DEBUG_MSDP_EVENTS
;
4373 PIM_DONT_DEBUG_MSDP_PACKETS
;
4375 PIM_DONT_DEBUG_PIM_PACKETDUMP_SEND
;
4376 PIM_DONT_DEBUG_PIM_PACKETDUMP_RECV
;
4378 PIM_DONT_DEBUG_VXLAN
;
4382 int pim_debug_pim_packets_cmd(const char *hello
, const char *joins
,
4383 const char *registers
, struct vty
*vty
)
4386 PIM_DO_DEBUG_PIM_HELLO
;
4387 vty_out(vty
, "PIM Hello debugging is on\n");
4389 PIM_DO_DEBUG_PIM_J_P
;
4390 vty_out(vty
, "PIM Join/Prune debugging is on\n");
4391 } else if (registers
) {
4392 PIM_DO_DEBUG_PIM_REG
;
4393 vty_out(vty
, "PIM Register debugging is on\n");
4395 PIM_DO_DEBUG_PIM_PACKETS
;
4396 vty_out(vty
, "PIM Packet debugging is on\n");
4401 int pim_no_debug_pim_packets_cmd(const char *hello
, const char *joins
,
4402 const char *registers
, struct vty
*vty
)
4405 PIM_DONT_DEBUG_PIM_HELLO
;
4406 vty_out(vty
, "PIM Hello debugging is off\n");
4408 PIM_DONT_DEBUG_PIM_J_P
;
4409 vty_out(vty
, "PIM Join/Prune debugging is off\n");
4410 } else if (registers
) {
4411 PIM_DONT_DEBUG_PIM_REG
;
4412 vty_out(vty
, "PIM Register debugging is off\n");
4414 PIM_DONT_DEBUG_PIM_PACKETS
;
4415 vty_out(vty
, "PIM Packet debugging is off\n");
4421 int pim_show_rpf_helper(const char *vrf
, struct vty
*vty
, bool json
)
4423 struct pim_instance
*pim
;
4425 json_object
*json_parent
= NULL
;
4427 v
= vrf_lookup_by_name(vrf
? vrf
: VRF_DEFAULT_NAME
);
4435 vty_out(vty
, "%% Unable to find pim instance\n");
4440 json_parent
= json_object_new_object();
4442 pim_show_rpf(pim
, vty
, json_parent
);
4445 vty_json(vty
, json_parent
);
4450 int pim_show_rpf_vrf_all_helper(struct vty
*vty
, bool json
)
4453 json_object
*json_parent
= NULL
;
4454 json_object
*json_vrf
= NULL
;
4457 json_parent
= json_object_new_object();
4459 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
4461 vty_out(vty
, "VRF: %s\n", vrf
->name
);
4463 json_vrf
= json_object_new_object();
4464 pim_show_rpf(vrf
->info
, vty
, json_vrf
);
4466 json_object_object_add(json_parent
, vrf
->name
,
4470 vty_json(vty
, json_parent
);
4475 int pim_show_rp_helper(const char *vrf
, struct vty
*vty
, const char *group_str
,
4476 const struct prefix
*group
, bool json
)
4478 struct pim_instance
*pim
;
4480 json_object
*json_parent
= NULL
;
4481 struct prefix
*range
= NULL
;
4483 v
= vrf_lookup_by_name(vrf
? vrf
: VRF_DEFAULT_NAME
);
4491 vty_out(vty
, "%% Unable to find pim instance\n");
4496 range
= prefix_new();
4497 prefix_copy(range
, group
);
4502 json_parent
= json_object_new_object();
4504 pim_rp_show_information(pim
, range
, vty
, json_parent
);
4507 vty_json(vty
, json_parent
);
4509 prefix_free(&range
);
4514 int pim_show_rp_vrf_all_helper(struct vty
*vty
, const char *group_str
,
4515 const struct prefix
*group
, bool json
)
4518 json_object
*json_parent
= NULL
;
4519 json_object
*json_vrf
= NULL
;
4520 struct prefix
*range
= NULL
;
4523 range
= prefix_new();
4524 prefix_copy(range
, group
);
4529 json_parent
= json_object_new_object();
4531 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
4533 vty_out(vty
, "VRF: %s\n", vrf
->name
);
4535 json_vrf
= json_object_new_object();
4536 pim_rp_show_information(vrf
->info
, range
, vty
, json_vrf
);
4538 json_object_object_add(json_parent
, vrf
->name
,
4542 vty_json(vty
, json_parent
);
4544 prefix_free(&range
);
4549 int pim_show_secondary_helper(const char *vrf
, struct vty
*vty
)
4551 struct pim_instance
*pim
;
4554 v
= vrf_lookup_by_name(vrf
? vrf
: VRF_DEFAULT_NAME
);
4562 vty_out(vty
, "%% Unable to find pim instance\n");
4566 pim_show_neighbors_secondary(pim
, vty
);
4571 int pim_show_statistics_helper(const char *vrf
, struct vty
*vty
,
4572 const char *word
, bool uj
)
4574 struct pim_instance
*pim
;
4577 v
= vrf_lookup_by_name(vrf
? vrf
: VRF_DEFAULT_NAME
);
4585 vty_out(vty
, "%% Unable to find pim instance\n");
4590 pim_show_statistics(pim
, vty
, word
, uj
);
4592 pim_show_statistics(pim
, vty
, NULL
, uj
);
4597 int pim_show_upstream_helper(const char *vrf
, struct vty
*vty
, pim_addr s_or_g
,
4598 pim_addr g
, bool json
)
4600 pim_sgaddr sg
= {0};
4602 struct pim_instance
*pim
;
4603 json_object
*json_parent
= NULL
;
4605 v
= vrf_lookup_by_name(vrf
? vrf
: VRF_DEFAULT_NAME
);
4608 vty_out(vty
, "%% Vrf specified: %s does not exist\n", vrf
);
4614 vty_out(vty
, "%% Unable to find pim instance\n");
4619 json_parent
= json_object_new_object();
4621 if (!pim_addr_is_any(s_or_g
)) {
4622 if (!pim_addr_is_any(g
)) {
4629 pim_show_upstream(pim
, vty
, &sg
, json_parent
);
4632 vty_json(vty
, json_parent
);
4637 int pim_show_upstream_vrf_all_helper(struct vty
*vty
, bool json
)
4639 pim_sgaddr sg
= {0};
4641 json_object
*json_parent
= NULL
;
4642 json_object
*json_vrf
= NULL
;
4645 json_parent
= json_object_new_object();
4647 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
4649 vty_out(vty
, "VRF: %s\n", vrf
->name
);
4651 json_vrf
= json_object_new_object();
4652 pim_show_upstream(vrf
->info
, vty
, &sg
, json_vrf
);
4654 json_object_object_add(json_parent
, vrf
->name
,
4659 vty_json(vty
, json_parent
);
4664 int pim_show_upstream_join_desired_helper(const char *vrf
, struct vty
*vty
,
4667 struct pim_instance
*pim
;
4670 v
= vrf_lookup_by_name(vrf
? vrf
: VRF_DEFAULT_NAME
);
4678 vty_out(vty
, "%% Unable to find pim instance\n");
4682 pim_show_join_desired(pim
, vty
, uj
);
4687 int pim_show_upstream_rpf_helper(const char *vrf
, struct vty
*vty
, bool uj
)
4689 struct pim_instance
*pim
;
4692 v
= vrf_lookup_by_name(vrf
? vrf
: VRF_DEFAULT_NAME
);
4700 vty_out(vty
, "%% Unable to find pim instance\n");
4704 pim_show_upstream_rpf(pim
, vty
, uj
);
4709 int pim_show_state_helper(const char *vrf
, struct vty
*vty
,
4710 const char *s_or_g_str
, const char *g_str
, bool json
)
4712 struct pim_instance
*pim
;
4714 json_object
*json_parent
= NULL
;
4716 v
= vrf_lookup_by_name(vrf
? vrf
: VRF_DEFAULT_NAME
);
4724 vty_out(vty
, "%% Unable to find pim instance\n");
4729 json_parent
= json_object_new_object();
4731 pim_show_state(pim
, vty
, s_or_g_str
, g_str
, json_parent
);
4734 vty_json(vty
, json_parent
);
4739 int pim_show_state_vrf_all_helper(struct vty
*vty
, const char *s_or_g_str
,
4740 const char *g_str
, bool json
)
4743 json_object
*json_parent
= NULL
;
4744 json_object
*json_vrf
= NULL
;
4747 json_parent
= json_object_new_object();
4749 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
4751 vty_out(vty
, "VRF: %s\n", vrf
->name
);
4753 json_vrf
= json_object_new_object();
4754 pim_show_state(vrf
->info
, vty
, s_or_g_str
, g_str
, json_vrf
);
4756 json_object_object_add(json_parent
, vrf
->name
,
4760 vty_json(vty
, json_parent
);
4765 int pim_show_multicast_helper(const char *vrf
, struct vty
*vty
)
4768 struct pim_instance
*pim
;
4770 v
= vrf_lookup_by_name(vrf
? vrf
: VRF_DEFAULT_NAME
);
4778 vty_out(vty
, "%% Unable to find pim instance\n");
4782 pim_cmd_show_ip_multicast_helper(pim
, vty
);
4787 int pim_show_multicast_vrf_all_helper(struct vty
*vty
)
4791 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
4792 vty_out(vty
, "VRF: %s\n", vrf
->name
);
4793 pim_cmd_show_ip_multicast_helper(vrf
->info
, vty
);
4799 int pim_show_multicast_count_helper(const char *vrf
, struct vty
*vty
, bool json
)
4801 struct pim_instance
*pim
;
4803 json_object
*json_parent
= NULL
;
4805 v
= vrf_lookup_by_name(vrf
? vrf
: VRF_DEFAULT_NAME
);
4813 vty_out(vty
, "%% Unable to find pim instance\n");
4818 json_parent
= json_object_new_object();
4820 show_multicast_interfaces(pim
, vty
, json_parent
);
4823 vty_json(vty
, json_parent
);
4828 int pim_show_multicast_count_vrf_all_helper(struct vty
*vty
, bool json
)
4831 json_object
*json_parent
= NULL
;
4832 json_object
*json_vrf
= NULL
;
4835 json_parent
= json_object_new_object();
4837 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
4839 vty_out(vty
, "VRF: %s\n", vrf
->name
);
4841 json_vrf
= json_object_new_object();
4843 show_multicast_interfaces(vrf
->info
, vty
, json_vrf
);
4845 json_object_object_add(json_parent
, vrf
->name
,
4849 vty_json(vty
, json_parent
);
4854 int pim_show_mroute_helper(const char *vrf
, struct vty
*vty
, pim_addr s_or_g
,
4855 pim_addr g
, bool fill
, bool json
)
4857 pim_sgaddr sg
= {0};
4858 struct pim_instance
*pim
;
4860 json_object
*json_parent
= NULL
;
4862 v
= vrf_lookup_by_name(vrf
? vrf
: VRF_DEFAULT_NAME
);
4870 vty_out(vty
, "%% Unable to find pim instance\n");
4875 json_parent
= json_object_new_object();
4877 if (!pim_addr_is_any(s_or_g
)) {
4878 if (!pim_addr_is_any(g
)) {
4885 show_mroute(pim
, vty
, &sg
, fill
, json_parent
);
4888 vty_json(vty
, json_parent
);
4893 int pim_show_mroute_vrf_all_helper(struct vty
*vty
, bool fill
, bool json
)
4895 pim_sgaddr sg
= {0};
4897 json_object
*json_parent
= NULL
;
4898 json_object
*json_vrf
= NULL
;
4901 json_parent
= json_object_new_object();
4903 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
4905 vty_out(vty
, "VRF: %s\n", vrf
->name
);
4907 json_vrf
= json_object_new_object();
4908 show_mroute(vrf
->info
, vty
, &sg
, fill
, json_vrf
);
4910 json_object_object_add(json_parent
, vrf
->name
,
4914 vty_json(vty
, json_parent
);
4919 int pim_show_mroute_count_helper(const char *vrf
, struct vty
*vty
, bool json
)
4921 struct pim_instance
*pim
;
4923 json_object
*json_parent
= NULL
;
4925 v
= vrf_lookup_by_name(vrf
? vrf
: VRF_DEFAULT_NAME
);
4933 vty_out(vty
, "%% Unable to find pim instance\n");
4938 json_parent
= json_object_new_object();
4940 show_mroute_count(pim
, vty
, json_parent
);
4943 vty_json(vty
, json_parent
);
4948 int pim_show_mroute_count_vrf_all_helper(struct vty
*vty
, bool json
)
4951 json_object
*json_parent
= NULL
;
4952 json_object
*json_vrf
= NULL
;
4955 json_parent
= json_object_new_object();
4957 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
4959 vty_out(vty
, "VRF: %s\n", vrf
->name
);
4961 json_vrf
= json_object_new_object();
4963 show_mroute_count(vrf
->info
, vty
, json_vrf
);
4966 json_object_object_add(json_parent
, vrf
->name
,
4970 vty_json(vty
, json_parent
);
4975 int pim_show_mroute_summary_helper(const char *vrf
, struct vty
*vty
, bool json
)
4977 struct pim_instance
*pim
;
4979 json_object
*json_parent
= NULL
;
4981 v
= vrf_lookup_by_name(vrf
? vrf
: VRF_DEFAULT_NAME
);
4989 vty_out(vty
, "%% Unable to find pim instance\n");
4994 json_parent
= json_object_new_object();
4996 show_mroute_summary(pim
, vty
, json_parent
);
4999 vty_json(vty
, json_parent
);
5004 int pim_show_mroute_summary_vrf_all_helper(struct vty
*vty
, bool json
)
5007 json_object
*json_parent
= NULL
;
5008 json_object
*json_vrf
= NULL
;
5011 json_parent
= json_object_new_object();
5013 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
5015 vty_out(vty
, "VRF: %s\n", vrf
->name
);
5017 json_vrf
= json_object_new_object();
5019 show_mroute_summary(vrf
->info
, vty
, json_vrf
);
5022 json_object_object_add(json_parent
, vrf
->name
,
5027 vty_json(vty
, json_parent
);
5032 void pim_show_interface_traffic(struct pim_instance
*pim
, struct vty
*vty
,
5035 struct interface
*ifp
= NULL
;
5036 struct pim_interface
*pim_ifp
= NULL
;
5037 json_object
*json
= NULL
;
5038 json_object
*json_row
= NULL
;
5041 json
= json_object_new_object();
5044 vty_out(vty
, "%-16s%-17s%-17s%-17s%-17s%-17s%-17s%-17s\n",
5045 "Interface", " HELLO", " JOIN",
5046 " PRUNE", " REGISTER", "REGISTER-STOP",
5048 vty_out(vty
, "%-16s%-17s%-17s%-17s%-17s%-17s%-17s%-17s\n", "",
5049 " Rx/Tx", " Rx/Tx", " Rx/Tx",
5050 " Rx/Tx", " Rx/Tx", " Rx/Tx", " Rx/Tx");
5052 "---------------------------------------------------------------------------------------------------------------\n");
5055 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
5056 pim_ifp
= ifp
->info
;
5062 json_row
= json_object_new_object();
5063 json_object_pim_ifp_add(json_row
, ifp
);
5064 json_object_int_add(json_row
, "helloRx",
5065 pim_ifp
->pim_ifstat_hello_recv
);
5066 json_object_int_add(json_row
, "helloTx",
5067 pim_ifp
->pim_ifstat_hello_sent
);
5068 json_object_int_add(json_row
, "joinRx",
5069 pim_ifp
->pim_ifstat_join_recv
);
5070 json_object_int_add(json_row
, "joinTx",
5071 pim_ifp
->pim_ifstat_join_send
);
5072 json_object_int_add(json_row
, "pruneRx",
5073 pim_ifp
->pim_ifstat_prune_recv
);
5074 json_object_int_add(json_row
, "pruneTx",
5075 pim_ifp
->pim_ifstat_prune_send
);
5076 json_object_int_add(json_row
, "registerRx",
5077 pim_ifp
->pim_ifstat_reg_recv
);
5078 json_object_int_add(json_row
, "registerTx",
5079 pim_ifp
->pim_ifstat_reg_send
);
5080 json_object_int_add(json_row
, "registerStopRx",
5081 pim_ifp
->pim_ifstat_reg_stop_recv
);
5082 json_object_int_add(json_row
, "registerStopTx",
5083 pim_ifp
->pim_ifstat_reg_stop_send
);
5084 json_object_int_add(json_row
, "assertRx",
5085 pim_ifp
->pim_ifstat_assert_recv
);
5086 json_object_int_add(json_row
, "assertTx",
5087 pim_ifp
->pim_ifstat_assert_send
);
5088 json_object_int_add(json_row
, "bsmRx",
5089 pim_ifp
->pim_ifstat_bsm_rx
);
5090 json_object_int_add(json_row
, "bsmTx",
5091 pim_ifp
->pim_ifstat_bsm_tx
);
5092 json_object_object_add(json
, ifp
->name
, json_row
);
5095 "%-16s %8u/%-8u %7u/%-7u %7u/%-7u %7u/%-7u %7u/%-7u %7u/%-7u %7" PRIu64
5097 ifp
->name
, pim_ifp
->pim_ifstat_hello_recv
,
5098 pim_ifp
->pim_ifstat_hello_sent
,
5099 pim_ifp
->pim_ifstat_join_recv
,
5100 pim_ifp
->pim_ifstat_join_send
,
5101 pim_ifp
->pim_ifstat_prune_recv
,
5102 pim_ifp
->pim_ifstat_prune_send
,
5103 pim_ifp
->pim_ifstat_reg_recv
,
5104 pim_ifp
->pim_ifstat_reg_send
,
5105 pim_ifp
->pim_ifstat_reg_stop_recv
,
5106 pim_ifp
->pim_ifstat_reg_stop_send
,
5107 pim_ifp
->pim_ifstat_assert_recv
,
5108 pim_ifp
->pim_ifstat_assert_send
,
5109 pim_ifp
->pim_ifstat_bsm_rx
,
5110 pim_ifp
->pim_ifstat_bsm_tx
);
5114 vty_json(vty
, json
);
5117 void pim_show_interface_traffic_single(struct pim_instance
*pim
,
5118 struct vty
*vty
, const char *ifname
,
5121 struct interface
*ifp
= NULL
;
5122 struct pim_interface
*pim_ifp
= NULL
;
5123 json_object
*json
= NULL
;
5124 json_object
*json_row
= NULL
;
5125 uint8_t found_ifname
= 0;
5128 json
= json_object_new_object();
5131 vty_out(vty
, "%-16s%-17s%-17s%-17s%-17s%-17s%-17s%-17s\n",
5132 "Interface", " HELLO", " JOIN", " PRUNE",
5133 " REGISTER", " REGISTER-STOP", " ASSERT",
5135 vty_out(vty
, "%-14s%-18s%-17s%-17s%-17s%-17s%-17s%-17s\n", "",
5136 " Rx/Tx", " Rx/Tx", " Rx/Tx", " Rx/Tx",
5137 " Rx/Tx", " Rx/Tx", " Rx/Tx");
5139 "-------------------------------------------------------------------------------------------------------------------------------\n");
5142 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
5143 if (strcmp(ifname
, ifp
->name
))
5146 pim_ifp
= ifp
->info
;
5153 json_row
= json_object_new_object();
5154 json_object_pim_ifp_add(json_row
, ifp
);
5155 json_object_int_add(json_row
, "helloRx",
5156 pim_ifp
->pim_ifstat_hello_recv
);
5157 json_object_int_add(json_row
, "helloTx",
5158 pim_ifp
->pim_ifstat_hello_sent
);
5159 json_object_int_add(json_row
, "joinRx",
5160 pim_ifp
->pim_ifstat_join_recv
);
5161 json_object_int_add(json_row
, "joinTx",
5162 pim_ifp
->pim_ifstat_join_send
);
5163 json_object_int_add(json_row
, "pruneRx",
5164 pim_ifp
->pim_ifstat_prune_recv
);
5165 json_object_int_add(json_row
, "pruneTx",
5166 pim_ifp
->pim_ifstat_prune_send
);
5167 json_object_int_add(json_row
, "registerRx",
5168 pim_ifp
->pim_ifstat_reg_recv
);
5169 json_object_int_add(json_row
, "registerTx",
5170 pim_ifp
->pim_ifstat_reg_send
);
5171 json_object_int_add(json_row
, "registerStopRx",
5172 pim_ifp
->pim_ifstat_reg_stop_recv
);
5173 json_object_int_add(json_row
, "registerStopTx",
5174 pim_ifp
->pim_ifstat_reg_stop_send
);
5175 json_object_int_add(json_row
, "assertRx",
5176 pim_ifp
->pim_ifstat_assert_recv
);
5177 json_object_int_add(json_row
, "assertTx",
5178 pim_ifp
->pim_ifstat_assert_send
);
5179 json_object_int_add(json_row
, "bsmRx",
5180 pim_ifp
->pim_ifstat_bsm_rx
);
5181 json_object_int_add(json_row
, "bsmTx",
5182 pim_ifp
->pim_ifstat_bsm_tx
);
5184 json_object_object_add(json
, ifp
->name
, json_row
);
5187 "%-16s %8u/%-8u %7u/%-7u %7u/%-7u %7u/%-7u %7u/%-7u %7u/%-7u %7" PRIu64
5189 ifp
->name
, pim_ifp
->pim_ifstat_hello_recv
,
5190 pim_ifp
->pim_ifstat_hello_sent
,
5191 pim_ifp
->pim_ifstat_join_recv
,
5192 pim_ifp
->pim_ifstat_join_send
,
5193 pim_ifp
->pim_ifstat_prune_recv
,
5194 pim_ifp
->pim_ifstat_prune_send
,
5195 pim_ifp
->pim_ifstat_reg_recv
,
5196 pim_ifp
->pim_ifstat_reg_send
,
5197 pim_ifp
->pim_ifstat_reg_stop_recv
,
5198 pim_ifp
->pim_ifstat_reg_stop_send
,
5199 pim_ifp
->pim_ifstat_assert_recv
,
5200 pim_ifp
->pim_ifstat_assert_send
,
5201 pim_ifp
->pim_ifstat_bsm_rx
,
5202 pim_ifp
->pim_ifstat_bsm_tx
);
5206 vty_json(vty
, json
);
5207 else if (!found_ifname
)
5208 vty_out(vty
, "%% No such interface\n");
5211 int pim_show_interface_traffic_helper(const char *vrf
, const char *if_name
,
5212 struct vty
*vty
, bool uj
)
5214 struct pim_instance
*pim
;
5217 v
= vrf_lookup_by_name(vrf
? vrf
: VRF_DEFAULT_NAME
);
5225 vty_out(vty
, "%% Unable to find pim instance\n");
5230 pim_show_interface_traffic_single(v
->info
, vty
, if_name
, uj
);
5232 pim_show_interface_traffic(v
->info
, vty
, uj
);
5237 void clear_pim_interfaces(struct pim_instance
*pim
)
5239 struct interface
*ifp
;
5241 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
5243 pim_neighbor_delete_all(ifp
, "interface cleared");