3 * Copyright (C) 2008 Everton da Silva Marques
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; see the file COPYING; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
34 #include "pim_mroute.h"
36 #include "pim_iface.h"
38 #include "pim_mroute.h"
41 #include "pim_igmpv3.h"
46 #include "pim_neighbor.h"
48 #include "pim_ifchannel.h"
49 #include "pim_hello.h"
51 #include "pim_upstream.h"
53 #include "pim_macro.h"
54 #include "pim_ssmpingd.h"
55 #include "pim_zebra.h"
56 #include "pim_static.h"
58 #include "pim_zlookup.h"
63 #include "pim_vxlan.h"
68 #ifndef VTYSH_EXTRACT_PL
69 #include "pimd/pim_cmd_clippy.c"
72 static struct cmd_node interface_node
= {
73 INTERFACE_NODE
, "%s(config-if)# ", 1 /* vtysh ? yes */
76 static struct cmd_node debug_node
= {DEBUG_NODE
, "", 1};
78 static struct vrf
*pim_cmd_lookup_vrf(struct vty
*vty
, struct cmd_token
*argv
[],
79 const int argc
, int *idx
)
83 if (argv_find(argv
, argc
, "NAME", idx
))
84 vrf
= vrf_lookup_by_name(argv
[*idx
]->arg
);
86 vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
89 vty_out(vty
, "Specified VRF: %s does not exist\n",
95 static void pim_if_membership_clear(struct interface
*ifp
)
97 struct pim_interface
*pim_ifp
;
102 if (PIM_IF_TEST_PIM(pim_ifp
->options
)
103 && PIM_IF_TEST_IGMP(pim_ifp
->options
)) {
107 pim_ifchannel_membership_clear(ifp
);
111 When PIM is disabled on interface, IGMPv3 local membership
112 information is not injected into PIM interface state.
114 The function pim_if_membership_refresh() fetches all IGMPv3 local
115 membership information into PIM. It is intented to be called
116 whenever PIM is enabled on the interface in order to collect missed
117 local membership information.
119 static void pim_if_membership_refresh(struct interface
*ifp
)
121 struct pim_interface
*pim_ifp
;
122 struct listnode
*sock_node
;
123 struct igmp_sock
*igmp
;
128 if (!PIM_IF_TEST_PIM(pim_ifp
->options
))
130 if (!PIM_IF_TEST_IGMP(pim_ifp
->options
))
134 First clear off membership from all PIM (S,G) entries on the
138 pim_ifchannel_membership_clear(ifp
);
141 Then restore PIM (S,G) membership from all IGMPv3 (S,G) entries on
145 /* scan igmp sockets */
146 for (ALL_LIST_ELEMENTS_RO(pim_ifp
->igmp_socket_list
, sock_node
, igmp
)) {
147 struct listnode
*grpnode
;
148 struct igmp_group
*grp
;
150 /* scan igmp groups */
151 for (ALL_LIST_ELEMENTS_RO(igmp
->igmp_group_list
, grpnode
,
153 struct listnode
*srcnode
;
154 struct igmp_source
*src
;
156 /* scan group sources */
157 for (ALL_LIST_ELEMENTS_RO(grp
->group_source_list
,
160 if (IGMP_SOURCE_TEST_FORWARDING(
161 src
->source_flags
)) {
165 sizeof(struct prefix_sg
));
166 sg
.src
= src
->source_addr
;
167 sg
.grp
= grp
->group_addr
;
168 pim_ifchannel_local_membership_add(ifp
,
169 &sg
, false /*is_vxlan*/);
172 } /* scan group sources */
173 } /* scan igmp groups */
174 } /* scan igmp sockets */
177 Finally delete every PIM (S,G) entry lacking all state info
180 pim_ifchannel_delete_on_noinfo(ifp
);
183 static void pim_show_assert_helper(struct vty
*vty
,
184 struct pim_interface
*pim_ifp
,
185 struct pim_ifchannel
*ch
, time_t now
)
187 char ch_src_str
[INET_ADDRSTRLEN
];
188 char ch_grp_str
[INET_ADDRSTRLEN
];
189 char winner_str
[INET_ADDRSTRLEN
];
190 struct in_addr ifaddr
;
194 ifaddr
= pim_ifp
->primary_address
;
196 pim_inet4_dump("<ch_src?>", ch
->sg
.src
, ch_src_str
, sizeof(ch_src_str
));
197 pim_inet4_dump("<ch_grp?>", ch
->sg
.grp
, ch_grp_str
, sizeof(ch_grp_str
));
198 pim_inet4_dump("<assrt_win?>", ch
->ifassert_winner
, winner_str
,
201 pim_time_uptime(uptime
, sizeof(uptime
), now
- ch
->ifassert_creation
);
202 pim_time_timer_to_mmss(timer
, sizeof(timer
), ch
->t_ifassert_timer
);
204 vty_out(vty
, "%-16s %-15s %-15s %-15s %-6s %-15s %-8s %-5s\n",
205 ch
->interface
->name
, inet_ntoa(ifaddr
), ch_src_str
, ch_grp_str
,
206 pim_ifchannel_ifassert_name(ch
->ifassert_state
), winner_str
,
210 static void pim_show_assert(struct pim_instance
*pim
, struct vty
*vty
)
212 struct pim_interface
*pim_ifp
;
213 struct pim_ifchannel
*ch
;
214 struct interface
*ifp
;
217 now
= pim_time_monotonic_sec();
220 "Interface Address Source Group State Winner Uptime Timer\n");
222 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
227 RB_FOREACH (ch
, pim_ifchannel_rb
, &pim_ifp
->ifchannel_rb
) {
228 pim_show_assert_helper(vty
, pim_ifp
, ch
, now
);
229 } /* scan interface channels */
233 static void pim_show_assert_internal_helper(struct vty
*vty
,
234 struct pim_interface
*pim_ifp
,
235 struct pim_ifchannel
*ch
)
237 char ch_src_str
[INET_ADDRSTRLEN
];
238 char ch_grp_str
[INET_ADDRSTRLEN
];
239 struct in_addr ifaddr
;
241 ifaddr
= pim_ifp
->primary_address
;
243 pim_inet4_dump("<ch_src?>", ch
->sg
.src
, ch_src_str
, sizeof(ch_src_str
));
244 pim_inet4_dump("<ch_grp?>", ch
->sg
.grp
, ch_grp_str
, sizeof(ch_grp_str
));
245 vty_out(vty
, "%-16s %-15s %-15s %-15s %-3s %-3s %-3s %-4s\n",
246 ch
->interface
->name
, inet_ntoa(ifaddr
), ch_src_str
, ch_grp_str
,
247 PIM_IF_FLAG_TEST_COULD_ASSERT(ch
->flags
) ? "yes" : "no",
248 pim_macro_ch_could_assert_eval(ch
) ? "yes" : "no",
249 PIM_IF_FLAG_TEST_ASSERT_TRACKING_DESIRED(ch
->flags
) ? "yes"
251 pim_macro_assert_tracking_desired_eval(ch
) ? "yes" : "no");
254 static void pim_show_assert_internal(struct pim_instance
*pim
, struct vty
*vty
)
256 struct pim_interface
*pim_ifp
;
257 struct pim_ifchannel
*ch
;
258 struct interface
*ifp
;
262 "ECA: Evaluate CouldAssert\n"
263 "ATD: AssertTrackingDesired\n"
264 "eATD: Evaluate AssertTrackingDesired\n\n");
267 "Interface Address Source Group CA eCA ATD eATD\n");
268 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
273 RB_FOREACH (ch
, pim_ifchannel_rb
, &pim_ifp
->ifchannel_rb
) {
274 pim_show_assert_internal_helper(vty
, pim_ifp
, ch
);
275 } /* scan interface channels */
279 static void pim_show_assert_metric_helper(struct vty
*vty
,
280 struct pim_interface
*pim_ifp
,
281 struct pim_ifchannel
*ch
)
283 char ch_src_str
[INET_ADDRSTRLEN
];
284 char ch_grp_str
[INET_ADDRSTRLEN
];
285 char addr_str
[INET_ADDRSTRLEN
];
286 struct pim_assert_metric am
;
287 struct in_addr ifaddr
;
289 ifaddr
= pim_ifp
->primary_address
;
291 am
= pim_macro_spt_assert_metric(&ch
->upstream
->rpf
,
292 pim_ifp
->primary_address
);
294 pim_inet4_dump("<ch_src?>", ch
->sg
.src
, ch_src_str
, sizeof(ch_src_str
));
295 pim_inet4_dump("<ch_grp?>", ch
->sg
.grp
, ch_grp_str
, sizeof(ch_grp_str
));
296 pim_inet4_dump("<addr?>", am
.ip_address
, addr_str
, sizeof(addr_str
));
298 vty_out(vty
, "%-16s %-15s %-15s %-15s %-3s %4u %6u %-15s\n",
299 ch
->interface
->name
, inet_ntoa(ifaddr
), ch_src_str
, ch_grp_str
,
300 am
.rpt_bit_flag
? "yes" : "no", am
.metric_preference
,
301 am
.route_metric
, addr_str
);
304 static void pim_show_assert_metric(struct pim_instance
*pim
, struct vty
*vty
)
306 struct pim_interface
*pim_ifp
;
307 struct pim_ifchannel
*ch
;
308 struct interface
*ifp
;
311 "Interface Address Source Group RPT Pref Metric Address \n");
313 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
318 RB_FOREACH (ch
, pim_ifchannel_rb
, &pim_ifp
->ifchannel_rb
) {
319 pim_show_assert_metric_helper(vty
, pim_ifp
, ch
);
320 } /* scan interface channels */
324 static void pim_show_assert_winner_metric_helper(struct vty
*vty
,
325 struct pim_interface
*pim_ifp
,
326 struct pim_ifchannel
*ch
)
328 char ch_src_str
[INET_ADDRSTRLEN
];
329 char ch_grp_str
[INET_ADDRSTRLEN
];
330 char addr_str
[INET_ADDRSTRLEN
];
331 struct pim_assert_metric
*am
;
332 struct in_addr ifaddr
;
336 ifaddr
= pim_ifp
->primary_address
;
338 am
= &ch
->ifassert_winner_metric
;
340 pim_inet4_dump("<ch_src?>", ch
->sg
.src
, ch_src_str
, sizeof(ch_src_str
));
341 pim_inet4_dump("<ch_grp?>", ch
->sg
.grp
, ch_grp_str
, sizeof(ch_grp_str
));
342 pim_inet4_dump("<addr?>", am
->ip_address
, addr_str
, sizeof(addr_str
));
344 if (am
->metric_preference
== PIM_ASSERT_METRIC_PREFERENCE_MAX
)
345 snprintf(pref_str
, sizeof(pref_str
), "INFI");
347 snprintf(pref_str
, sizeof(pref_str
), "%4u",
348 am
->metric_preference
);
350 if (am
->route_metric
== PIM_ASSERT_ROUTE_METRIC_MAX
)
351 snprintf(metr_str
, sizeof(metr_str
), "INFI");
353 snprintf(metr_str
, sizeof(metr_str
), "%6u", am
->route_metric
);
355 vty_out(vty
, "%-16s %-15s %-15s %-15s %-3s %-4s %-6s %-15s\n",
356 ch
->interface
->name
, inet_ntoa(ifaddr
), ch_src_str
, ch_grp_str
,
357 am
->rpt_bit_flag
? "yes" : "no", pref_str
, metr_str
, addr_str
);
360 static void pim_show_assert_winner_metric(struct pim_instance
*pim
,
363 struct pim_interface
*pim_ifp
;
364 struct pim_ifchannel
*ch
;
365 struct interface
*ifp
;
368 "Interface Address Source Group RPT Pref Metric Address \n");
370 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
375 RB_FOREACH (ch
, pim_ifchannel_rb
, &pim_ifp
->ifchannel_rb
) {
376 pim_show_assert_winner_metric_helper(vty
, pim_ifp
, ch
);
377 } /* scan interface channels */
381 static void json_object_pim_ifp_add(struct json_object
*json
,
382 struct interface
*ifp
)
384 struct pim_interface
*pim_ifp
;
387 json_object_string_add(json
, "name", ifp
->name
);
388 json_object_string_add(json
, "state", if_is_up(ifp
) ? "up" : "down");
389 json_object_string_add(json
, "address",
390 inet_ntoa(pim_ifp
->primary_address
));
391 json_object_int_add(json
, "index", ifp
->ifindex
);
393 if (if_is_multicast(ifp
))
394 json_object_boolean_true_add(json
, "flagMulticast");
396 if (if_is_broadcast(ifp
))
397 json_object_boolean_true_add(json
, "flagBroadcast");
399 if (ifp
->flags
& IFF_ALLMULTI
)
400 json_object_boolean_true_add(json
, "flagAllMulticast");
402 if (ifp
->flags
& IFF_PROMISC
)
403 json_object_boolean_true_add(json
, "flagPromiscuous");
405 if (PIM_IF_IS_DELETED(ifp
))
406 json_object_boolean_true_add(json
, "flagDeleted");
408 if (pim_if_lan_delay_enabled(ifp
))
409 json_object_boolean_true_add(json
, "lanDelayEnabled");
412 static void pim_show_membership_helper(struct vty
*vty
,
413 struct pim_interface
*pim_ifp
,
414 struct pim_ifchannel
*ch
,
415 struct json_object
*json
)
417 char ch_src_str
[INET_ADDRSTRLEN
];
418 char ch_grp_str
[INET_ADDRSTRLEN
];
419 json_object
*json_iface
= NULL
;
420 json_object
*json_row
= NULL
;
422 pim_inet4_dump("<ch_src?>", ch
->sg
.src
, ch_src_str
, sizeof(ch_src_str
));
423 pim_inet4_dump("<ch_grp?>", ch
->sg
.grp
, ch_grp_str
, sizeof(ch_grp_str
));
425 json_object_object_get_ex(json
, ch
->interface
->name
, &json_iface
);
427 json_iface
= json_object_new_object();
428 json_object_pim_ifp_add(json_iface
, ch
->interface
);
429 json_object_object_add(json
, ch
->interface
->name
, json_iface
);
432 json_row
= json_object_new_object();
433 json_object_string_add(json_row
, "source", ch_src_str
);
434 json_object_string_add(json_row
, "group", ch_grp_str
);
435 json_object_string_add(json_row
, "localMembership",
436 ch
->local_ifmembership
== PIM_IFMEMBERSHIP_NOINFO
439 json_object_object_add(json_iface
, ch_grp_str
, json_row
);
441 static void pim_show_membership(struct pim_instance
*pim
, struct vty
*vty
,
444 struct pim_interface
*pim_ifp
;
445 struct pim_ifchannel
*ch
;
446 struct interface
*ifp
;
448 json_object
*json
= NULL
;
449 json_object
*json_tmp
= NULL
;
451 json
= json_object_new_object();
453 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
458 RB_FOREACH (ch
, pim_ifchannel_rb
, &pim_ifp
->ifchannel_rb
) {
459 pim_show_membership_helper(vty
, pim_ifp
, ch
, json
);
460 } /* scan interface channels */
464 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
465 json
, JSON_C_TO_STRING_PRETTY
));
468 "Interface Address Source Group Membership\n");
471 * Example of the json data we are traversing
477 * "address":"10.1.20.1",
479 * "flagMulticast":true,
480 * "flagBroadcast":true,
481 * "lanDelayEnabled":true,
484 * "group":"226.10.10.10",
485 * "localMembership":"INCLUDE"
491 /* foreach interface */
492 json_object_object_foreach(json
, key
, val
)
495 /* Find all of the keys where the val is an object. In
497 * above the only one is 226.10.10.10
499 json_object_object_foreach(val
, if_field_key
,
502 type
= json_object_get_type(if_field_val
);
504 if (type
== json_type_object
) {
505 vty_out(vty
, "%-16s ", key
);
507 json_object_object_get_ex(
508 val
, "address", &json_tmp
);
509 vty_out(vty
, "%-15s ",
510 json_object_get_string(
513 json_object_object_get_ex(if_field_val
,
516 vty_out(vty
, "%-15s ",
517 json_object_get_string(
521 vty_out(vty
, "%-15s ", if_field_key
);
523 json_object_object_get_ex(
524 if_field_val
, "localMembership",
526 vty_out(vty
, "%-10s\n",
527 json_object_get_string(
534 json_object_free(json
);
537 static void pim_print_ifp_flags(struct vty
*vty
, struct interface
*ifp
,
540 vty_out(vty
, "Flags\n");
541 vty_out(vty
, "-----\n");
542 vty_out(vty
, "All Multicast : %s\n",
543 (ifp
->flags
& IFF_ALLMULTI
) ? "yes" : "no");
544 vty_out(vty
, "Broadcast : %s\n",
545 if_is_broadcast(ifp
) ? "yes" : "no");
546 vty_out(vty
, "Deleted : %s\n",
547 PIM_IF_IS_DELETED(ifp
) ? "yes" : "no");
548 vty_out(vty
, "Interface Index : %d\n", ifp
->ifindex
);
549 vty_out(vty
, "Multicast : %s\n",
550 if_is_multicast(ifp
) ? "yes" : "no");
551 vty_out(vty
, "Multicast Loop : %d\n", mloop
);
552 vty_out(vty
, "Promiscuous : %s\n",
553 (ifp
->flags
& IFF_PROMISC
) ? "yes" : "no");
558 static void igmp_show_interfaces(struct pim_instance
*pim
, struct vty
*vty
,
561 struct interface
*ifp
;
563 json_object
*json
= NULL
;
564 json_object
*json_row
= NULL
;
566 now
= pim_time_monotonic_sec();
569 json
= json_object_new_object();
572 "Interface State Address V Querier Query Timer Uptime\n");
574 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
575 struct pim_interface
*pim_ifp
;
576 struct listnode
*sock_node
;
577 struct igmp_sock
*igmp
;
584 for (ALL_LIST_ELEMENTS_RO(pim_ifp
->igmp_socket_list
, sock_node
,
587 char query_hhmmss
[10];
589 pim_time_uptime(uptime
, sizeof(uptime
),
590 now
- igmp
->sock_creation
);
591 pim_time_timer_to_hhmmss(query_hhmmss
,
592 sizeof(query_hhmmss
),
593 igmp
->t_igmp_query_timer
);
596 json_row
= json_object_new_object();
597 json_object_pim_ifp_add(json_row
, ifp
);
598 json_object_string_add(json_row
, "upTime",
600 json_object_int_add(json_row
, "version",
601 pim_ifp
->igmp_version
);
603 if (igmp
->t_igmp_query_timer
) {
604 json_object_boolean_true_add(json_row
,
606 json_object_string_add(json_row
,
611 json_object_object_add(json
, ifp
->name
,
614 if (igmp
->mtrace_only
) {
615 json_object_boolean_true_add(
616 json_row
, "mtraceOnly");
620 "%-16s %5s %15s %d %7s %11s %8s\n",
623 ? (igmp
->mtrace_only
? "mtrc"
626 inet_ntoa(igmp
->ifaddr
),
627 pim_ifp
->igmp_version
,
628 igmp
->t_igmp_query_timer
? "local"
630 query_hhmmss
, uptime
);
636 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
637 json
, JSON_C_TO_STRING_PRETTY
));
638 json_object_free(json
);
642 static void igmp_show_interfaces_single(struct pim_instance
*pim
,
643 struct vty
*vty
, const char *ifname
,
646 struct igmp_sock
*igmp
;
647 struct interface
*ifp
;
648 struct listnode
*sock_node
;
649 struct pim_interface
*pim_ifp
;
651 char query_hhmmss
[10];
652 char other_hhmmss
[10];
653 int found_ifname
= 0;
656 long gmi_msec
; /* Group Membership Interval */
659 long oqpi_msec
; /* Other Querier Present Interval */
664 json_object
*json
= NULL
;
665 json_object
*json_row
= NULL
;
668 json
= json_object_new_object();
670 now
= pim_time_monotonic_sec();
672 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
678 if (strcmp(ifname
, "detail") && strcmp(ifname
, ifp
->name
))
681 for (ALL_LIST_ELEMENTS_RO(pim_ifp
->igmp_socket_list
, sock_node
,
684 pim_time_uptime(uptime
, sizeof(uptime
),
685 now
- igmp
->sock_creation
);
686 pim_time_timer_to_hhmmss(query_hhmmss
,
687 sizeof(query_hhmmss
),
688 igmp
->t_igmp_query_timer
);
689 pim_time_timer_to_hhmmss(other_hhmmss
,
690 sizeof(other_hhmmss
),
691 igmp
->t_other_querier_timer
);
693 gmi_msec
= PIM_IGMP_GMI_MSEC(
694 igmp
->querier_robustness_variable
,
695 igmp
->querier_query_interval
,
696 pim_ifp
->igmp_query_max_response_time_dsec
);
699 pim_ifp
->igmp_default_query_interval
);
701 oqpi_msec
= PIM_IGMP_OQPI_MSEC(
702 igmp
->querier_robustness_variable
,
703 igmp
->querier_query_interval
,
704 pim_ifp
->igmp_query_max_response_time_dsec
);
706 lmqt_msec
= PIM_IGMP_LMQT_MSEC(
707 pim_ifp
->igmp_specific_query_max_response_time_dsec
,
708 pim_ifp
->igmp_last_member_query_count
);
712 igmp
->querier_robustness_variable
,
713 igmp
->querier_query_interval
,
714 pim_ifp
->igmp_query_max_response_time_dsec
)
717 qri_msec
= pim_ifp
->igmp_query_max_response_time_dsec
719 if (pim_ifp
->pim_sock_fd
>= 0)
720 mloop
= pim_socket_mcastloop_get(
721 pim_ifp
->pim_sock_fd
);
724 lmqc
= pim_ifp
->igmp_last_member_query_count
;
727 json_row
= json_object_new_object();
728 json_object_pim_ifp_add(json_row
, ifp
);
729 json_object_string_add(json_row
, "upTime",
731 json_object_string_add(json_row
, "querier",
732 igmp
->t_igmp_query_timer
735 json_object_int_add(json_row
, "queryStartCount",
736 igmp
->startup_query_count
);
737 json_object_string_add(json_row
,
740 json_object_string_add(json_row
,
743 json_object_int_add(json_row
, "version",
744 pim_ifp
->igmp_version
);
747 "timerGroupMembershipIntervalMsec",
749 json_object_int_add(json_row
,
750 "lastMemberQueryCount",
752 json_object_int_add(json_row
,
753 "timerLastMemberQueryMsec",
757 "timerOlderHostPresentIntervalMsec",
761 "timerOtherQuerierPresentIntervalMsec",
764 json_row
, "timerQueryInterval",
765 igmp
->querier_query_interval
);
768 "timerQueryResponseIntervalMsec",
771 json_row
, "timerRobustnessVariable",
772 igmp
->querier_robustness_variable
);
773 json_object_int_add(json_row
,
774 "timerStartupQueryInterval",
777 json_object_object_add(json
, ifp
->name
,
780 if (igmp
->mtrace_only
) {
781 json_object_boolean_true_add(
782 json_row
, "mtraceOnly");
785 vty_out(vty
, "Interface : %s\n", ifp
->name
);
786 vty_out(vty
, "State : %s\n",
788 ? (igmp
->mtrace_only
? "mtrace"
791 vty_out(vty
, "Address : %s\n",
792 inet_ntoa(pim_ifp
->primary_address
));
793 vty_out(vty
, "Uptime : %s\n", uptime
);
794 vty_out(vty
, "Version : %d\n",
795 pim_ifp
->igmp_version
);
799 vty_out(vty
, "Querier\n");
800 vty_out(vty
, "-------\n");
801 vty_out(vty
, "Querier : %s\n",
802 igmp
->t_igmp_query_timer
? "local"
804 vty_out(vty
, "Start Count : %d\n",
805 igmp
->startup_query_count
);
806 vty_out(vty
, "Query Timer : %s\n",
808 vty_out(vty
, "Other Timer : %s\n",
813 vty_out(vty
, "Timers\n");
814 vty_out(vty
, "------\n");
816 "Group Membership Interval : %lis\n",
819 "Last Member Query Count : %d\n",
822 "Last Member Query Time : %lis\n",
825 "Older Host Present Interval : %lis\n",
828 "Other Querier Present Interval : %lis\n",
831 "Query Interval : %ds\n",
832 igmp
->querier_query_interval
);
834 "Query Response Interval : %lis\n",
837 "Robustness Variable : %d\n",
838 igmp
->querier_robustness_variable
);
840 "Startup Query Interval : %ds\n",
845 pim_print_ifp_flags(vty
, ifp
, mloop
);
851 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
852 json
, JSON_C_TO_STRING_PRETTY
));
853 json_object_free(json
);
856 vty_out(vty
, "%% No such interface\n");
860 static void igmp_show_interface_join(struct pim_instance
*pim
, struct vty
*vty
)
862 struct interface
*ifp
;
865 now
= pim_time_monotonic_sec();
868 "Interface Address Source Group Socket Uptime \n");
870 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
871 struct pim_interface
*pim_ifp
;
872 struct listnode
*join_node
;
873 struct igmp_join
*ij
;
874 struct in_addr pri_addr
;
875 char pri_addr_str
[INET_ADDRSTRLEN
];
882 if (!pim_ifp
->igmp_join_list
)
885 pri_addr
= pim_find_primary_addr(ifp
);
886 pim_inet4_dump("<pri?>", pri_addr
, pri_addr_str
,
887 sizeof(pri_addr_str
));
889 for (ALL_LIST_ELEMENTS_RO(pim_ifp
->igmp_join_list
, join_node
,
891 char group_str
[INET_ADDRSTRLEN
];
892 char source_str
[INET_ADDRSTRLEN
];
895 pim_time_uptime(uptime
, sizeof(uptime
),
896 now
- ij
->sock_creation
);
897 pim_inet4_dump("<grp?>", ij
->group_addr
, group_str
,
899 pim_inet4_dump("<src?>", ij
->source_addr
, source_str
,
902 vty_out(vty
, "%-16s %-15s %-15s %-15s %6d %8s\n",
903 ifp
->name
, pri_addr_str
, source_str
, group_str
,
904 ij
->sock_fd
, uptime
);
905 } /* for (pim_ifp->igmp_join_list) */
910 static void pim_show_interfaces_single(struct pim_instance
*pim
,
911 struct vty
*vty
, const char *ifname
,
914 struct in_addr ifaddr
;
915 struct interface
*ifp
;
916 struct listnode
*neighnode
;
917 struct pim_interface
*pim_ifp
;
918 struct pim_neighbor
*neigh
;
919 struct pim_upstream
*up
;
921 char dr_str
[INET_ADDRSTRLEN
];
924 char grp_str
[INET_ADDRSTRLEN
];
925 char hello_period
[10];
926 char hello_timer
[10];
927 char neigh_src_str
[INET_ADDRSTRLEN
];
928 char src_str
[INET_ADDRSTRLEN
];
929 char stat_uptime
[10];
932 int found_ifname
= 0;
934 json_object
*json
= NULL
;
935 json_object
*json_row
= NULL
;
936 json_object
*json_pim_neighbor
= NULL
;
937 json_object
*json_pim_neighbors
= NULL
;
938 json_object
*json_group
= NULL
;
939 json_object
*json_group_source
= NULL
;
940 json_object
*json_fhr_sources
= NULL
;
941 struct pim_secondary_addr
*sec_addr
;
942 struct listnode
*sec_node
;
944 now
= pim_time_monotonic_sec();
947 json
= json_object_new_object();
949 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
955 if (mlag
== true && pim_ifp
->activeactive
== false)
958 if (strcmp(ifname
, "detail") && strcmp(ifname
, ifp
->name
))
962 ifaddr
= pim_ifp
->primary_address
;
963 pim_inet4_dump("<dr?>", pim_ifp
->pim_dr_addr
, dr_str
,
965 pim_time_uptime_begin(dr_uptime
, sizeof(dr_uptime
), now
,
966 pim_ifp
->pim_dr_election_last
);
967 pim_time_timer_to_hhmmss(hello_timer
, sizeof(hello_timer
),
968 pim_ifp
->t_pim_hello_timer
);
969 pim_time_mmss(hello_period
, sizeof(hello_period
),
970 pim_ifp
->pim_hello_period
);
971 pim_time_uptime(stat_uptime
, sizeof(stat_uptime
),
972 now
- pim_ifp
->pim_ifstat_start
);
973 if (pim_ifp
->pim_sock_fd
>= 0)
974 mloop
= pim_socket_mcastloop_get(pim_ifp
->pim_sock_fd
);
979 char pbuf
[PREFIX2STR_BUFFER
];
980 json_row
= json_object_new_object();
981 json_object_pim_ifp_add(json_row
, ifp
);
983 if (pim_ifp
->update_source
.s_addr
!= INADDR_ANY
) {
984 json_object_string_add(
985 json_row
, "useSource",
986 inet_ntoa(pim_ifp
->update_source
));
988 if (pim_ifp
->sec_addr_list
) {
989 json_object
*sec_list
= NULL
;
991 sec_list
= json_object_new_array();
992 for (ALL_LIST_ELEMENTS_RO(
993 pim_ifp
->sec_addr_list
, sec_node
,
995 json_object_array_add(
997 json_object_new_string(
1003 json_object_object_add(json_row
,
1004 "secondaryAddressList",
1009 if (pim_ifp
->pim_neighbor_list
->count
) {
1010 json_pim_neighbors
= json_object_new_object();
1012 for (ALL_LIST_ELEMENTS_RO(
1013 pim_ifp
->pim_neighbor_list
,
1014 neighnode
, neigh
)) {
1016 json_object_new_object();
1017 pim_inet4_dump("<src?>",
1020 sizeof(neigh_src_str
));
1021 pim_time_uptime(uptime
, sizeof(uptime
),
1022 now
- neigh
->creation
);
1023 pim_time_timer_to_hhmmss(
1024 expire
, sizeof(expire
),
1025 neigh
->t_expire_timer
);
1027 json_object_string_add(
1028 json_pim_neighbor
, "address",
1030 json_object_string_add(
1031 json_pim_neighbor
, "upTime",
1033 json_object_string_add(
1034 json_pim_neighbor
, "holdtime",
1037 json_object_object_add(
1043 json_object_object_add(json_row
, "neighbors",
1044 json_pim_neighbors
);
1047 json_object_string_add(json_row
, "drAddress", dr_str
);
1048 json_object_int_add(json_row
, "drPriority",
1049 pim_ifp
->pim_dr_priority
);
1050 json_object_string_add(json_row
, "drUptime", dr_uptime
);
1051 json_object_int_add(json_row
, "drElections",
1052 pim_ifp
->pim_dr_election_count
);
1053 json_object_int_add(json_row
, "drChanges",
1054 pim_ifp
->pim_dr_election_changes
);
1057 frr_each (rb_pim_upstream
, &pim
->upstream_head
, up
) {
1058 if (ifp
!= up
->rpf
.source_nexthop
.interface
)
1061 if (!(up
->flags
& PIM_UPSTREAM_FLAG_MASK_FHR
))
1064 if (!json_fhr_sources
)
1066 json_object_new_object();
1068 pim_inet4_dump("<src?>", up
->sg
.src
, src_str
,
1070 pim_inet4_dump("<grp?>", up
->sg
.grp
, grp_str
,
1072 pim_time_uptime(uptime
, sizeof(uptime
),
1073 now
- up
->state_transition
);
1076 * Does this group live in json_fhr_sources?
1079 json_object_object_get_ex(json_fhr_sources
,
1080 grp_str
, &json_group
);
1083 json_group
= json_object_new_object();
1084 json_object_object_add(json_fhr_sources
,
1089 json_group_source
= json_object_new_object();
1090 json_object_string_add(json_group_source
,
1092 json_object_string_add(json_group_source
,
1094 json_object_string_add(json_group_source
,
1096 json_object_object_add(json_group
, src_str
,
1100 if (json_fhr_sources
) {
1101 json_object_object_add(json_row
,
1106 json_object_int_add(json_row
, "helloPeriod",
1107 pim_ifp
->pim_hello_period
);
1108 json_object_string_add(json_row
, "helloTimer",
1110 json_object_string_add(json_row
, "helloStatStart",
1112 json_object_int_add(json_row
, "helloReceived",
1113 pim_ifp
->pim_ifstat_hello_recv
);
1114 json_object_int_add(json_row
, "helloReceivedFailed",
1115 pim_ifp
->pim_ifstat_hello_recvfail
);
1116 json_object_int_add(json_row
, "helloSend",
1117 pim_ifp
->pim_ifstat_hello_sent
);
1118 json_object_int_add(json_row
, "hellosendFailed",
1119 pim_ifp
->pim_ifstat_hello_sendfail
);
1120 json_object_int_add(json_row
, "helloGenerationId",
1121 pim_ifp
->pim_generation_id
);
1122 json_object_int_add(json_row
, "flagMulticastLoop",
1125 json_object_int_add(
1126 json_row
, "effectivePropagationDelay",
1127 pim_if_effective_propagation_delay_msec(ifp
));
1128 json_object_int_add(
1129 json_row
, "effectiveOverrideInterval",
1130 pim_if_effective_override_interval_msec(ifp
));
1131 json_object_int_add(
1132 json_row
, "joinPruneOverrideInterval",
1133 pim_if_jp_override_interval_msec(ifp
));
1135 json_object_int_add(
1136 json_row
, "propagationDelay",
1137 pim_ifp
->pim_propagation_delay_msec
);
1138 json_object_int_add(
1139 json_row
, "propagationDelayHighest",
1140 pim_ifp
->pim_neighbors_highest_propagation_delay_msec
);
1141 json_object_int_add(
1142 json_row
, "overrideInterval",
1143 pim_ifp
->pim_override_interval_msec
);
1144 json_object_int_add(
1145 json_row
, "overrideIntervalHighest",
1146 pim_ifp
->pim_neighbors_highest_override_interval_msec
);
1147 json_object_object_add(json
, ifp
->name
, json_row
);
1150 vty_out(vty
, "Interface : %s\n", ifp
->name
);
1151 vty_out(vty
, "State : %s\n",
1152 if_is_up(ifp
) ? "up" : "down");
1153 if (pim_ifp
->update_source
.s_addr
!= INADDR_ANY
) {
1154 vty_out(vty
, "Use Source : %s\n",
1155 inet_ntoa(pim_ifp
->update_source
));
1157 if (pim_ifp
->sec_addr_list
) {
1158 char pbuf
[PREFIX2STR_BUFFER
];
1159 vty_out(vty
, "Address : %s (primary)\n",
1161 for (ALL_LIST_ELEMENTS_RO(
1162 pim_ifp
->sec_addr_list
, sec_node
,
1164 vty_out(vty
, " %s\n",
1165 prefix2str(&sec_addr
->addr
,
1166 pbuf
, sizeof(pbuf
)));
1169 vty_out(vty
, "Address : %s\n",
1177 for (ALL_LIST_ELEMENTS_RO(pim_ifp
->pim_neighbor_list
,
1178 neighnode
, neigh
)) {
1181 vty_out(vty
, "PIM Neighbors\n");
1182 vty_out(vty
, "-------------\n");
1186 pim_inet4_dump("<src?>", neigh
->source_addr
,
1188 sizeof(neigh_src_str
));
1189 pim_time_uptime(uptime
, sizeof(uptime
),
1190 now
- neigh
->creation
);
1191 pim_time_timer_to_hhmmss(expire
, sizeof(expire
),
1192 neigh
->t_expire_timer
);
1194 "%-15s : up for %s, holdtime expires in %s\n",
1195 neigh_src_str
, uptime
, expire
);
1198 if (!print_header
) {
1203 vty_out(vty
, "Designated Router\n");
1204 vty_out(vty
, "-----------------\n");
1205 vty_out(vty
, "Address : %s\n", dr_str
);
1206 vty_out(vty
, "Priority : %u(%d)\n",
1207 pim_ifp
->pim_dr_priority
,
1208 pim_ifp
->pim_dr_num_nondrpri_neighbors
);
1209 vty_out(vty
, "Uptime : %s\n", dr_uptime
);
1210 vty_out(vty
, "Elections : %d\n",
1211 pim_ifp
->pim_dr_election_count
);
1212 vty_out(vty
, "Changes : %d\n",
1213 pim_ifp
->pim_dr_election_changes
);
1219 frr_each (rb_pim_upstream
, &pim
->upstream_head
, up
) {
1220 if (!up
->rpf
.source_nexthop
.interface
)
1223 if (strcmp(ifp
->name
,
1224 up
->rpf
.source_nexthop
1229 if (!(up
->flags
& PIM_UPSTREAM_FLAG_MASK_FHR
))
1234 "FHR - First Hop Router\n");
1236 "----------------------\n");
1240 pim_inet4_dump("<src?>", up
->sg
.src
, src_str
,
1242 pim_inet4_dump("<grp?>", up
->sg
.grp
, grp_str
,
1244 pim_time_uptime(uptime
, sizeof(uptime
),
1245 now
- up
->state_transition
);
1247 "%s : %s is a source, uptime is %s\n",
1248 grp_str
, src_str
, uptime
);
1251 if (!print_header
) {
1256 vty_out(vty
, "Hellos\n");
1257 vty_out(vty
, "------\n");
1258 vty_out(vty
, "Period : %d\n",
1259 pim_ifp
->pim_hello_period
);
1260 vty_out(vty
, "Timer : %s\n", hello_timer
);
1261 vty_out(vty
, "StatStart : %s\n", stat_uptime
);
1262 vty_out(vty
, "Receive : %d\n",
1263 pim_ifp
->pim_ifstat_hello_recv
);
1264 vty_out(vty
, "Receive Failed : %d\n",
1265 pim_ifp
->pim_ifstat_hello_recvfail
);
1266 vty_out(vty
, "Send : %d\n",
1267 pim_ifp
->pim_ifstat_hello_sent
);
1268 vty_out(vty
, "Send Failed : %d\n",
1269 pim_ifp
->pim_ifstat_hello_sendfail
);
1270 vty_out(vty
, "Generation ID : %08x\n",
1271 pim_ifp
->pim_generation_id
);
1275 pim_print_ifp_flags(vty
, ifp
, mloop
);
1277 vty_out(vty
, "Join Prune Interval\n");
1278 vty_out(vty
, "-------------------\n");
1279 vty_out(vty
, "LAN Delay : %s\n",
1280 pim_if_lan_delay_enabled(ifp
) ? "yes" : "no");
1281 vty_out(vty
, "Effective Propagation Delay : %d msec\n",
1282 pim_if_effective_propagation_delay_msec(ifp
));
1283 vty_out(vty
, "Effective Override Interval : %d msec\n",
1284 pim_if_effective_override_interval_msec(ifp
));
1285 vty_out(vty
, "Join Prune Override Interval : %d msec\n",
1286 pim_if_jp_override_interval_msec(ifp
));
1290 vty_out(vty
, "LAN Prune Delay\n");
1291 vty_out(vty
, "---------------\n");
1292 vty_out(vty
, "Propagation Delay : %d msec\n",
1293 pim_ifp
->pim_propagation_delay_msec
);
1294 vty_out(vty
, "Propagation Delay (Highest) : %d msec\n",
1295 pim_ifp
->pim_neighbors_highest_propagation_delay_msec
);
1296 vty_out(vty
, "Override Interval : %d msec\n",
1297 pim_ifp
->pim_override_interval_msec
);
1298 vty_out(vty
, "Override Interval (Highest) : %d msec\n",
1299 pim_ifp
->pim_neighbors_highest_override_interval_msec
);
1306 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
1307 json
, JSON_C_TO_STRING_PRETTY
));
1308 json_object_free(json
);
1311 vty_out(vty
, "%% No such interface\n");
1315 static void igmp_show_statistics(struct pim_instance
*pim
, struct vty
*vty
,
1316 const char *ifname
, bool uj
)
1318 struct interface
*ifp
;
1319 struct igmp_stats rx_stats
;
1321 igmp_stats_init(&rx_stats
);
1323 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
1324 struct pim_interface
*pim_ifp
;
1325 struct listnode
*sock_node
;
1326 struct igmp_sock
*igmp
;
1328 pim_ifp
= ifp
->info
;
1333 if (ifname
&& strcmp(ifname
, ifp
->name
))
1336 for (ALL_LIST_ELEMENTS_RO(pim_ifp
->igmp_socket_list
, sock_node
,
1338 igmp_stats_add(&rx_stats
, &igmp
->rx_stats
);
1342 json_object
*json
= NULL
;
1343 json_object
*json_row
= NULL
;
1345 json
= json_object_new_object();
1346 json_row
= json_object_new_object();
1348 json_object_string_add(json_row
, "name", ifname
? ifname
:
1350 json_object_int_add(json_row
, "queryV1", rx_stats
.query_v1
);
1351 json_object_int_add(json_row
, "queryV2", rx_stats
.query_v2
);
1352 json_object_int_add(json_row
, "queryV3", rx_stats
.query_v3
);
1353 json_object_int_add(json_row
, "leaveV3", rx_stats
.leave_v2
);
1354 json_object_int_add(json_row
, "reportV1", rx_stats
.report_v1
);
1355 json_object_int_add(json_row
, "reportV2", rx_stats
.report_v2
);
1356 json_object_int_add(json_row
, "reportV3", rx_stats
.report_v3
);
1357 json_object_int_add(json_row
, "mtraceResponse",
1358 rx_stats
.mtrace_rsp
);
1359 json_object_int_add(json_row
, "mtraceRequest",
1360 rx_stats
.mtrace_req
);
1361 json_object_int_add(json_row
, "unsupported",
1362 rx_stats
.unsupported
);
1363 json_object_object_add(json
, ifname
? ifname
: "global",
1365 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
1366 json
, JSON_C_TO_STRING_PRETTY
));
1367 json_object_free(json
);
1369 vty_out(vty
, "IGMP RX statistics\n");
1370 vty_out(vty
, "Interface : %s\n",
1371 ifname
? ifname
: "global");
1372 vty_out(vty
, "V1 query : %u\n", rx_stats
.query_v1
);
1373 vty_out(vty
, "V2 query : %u\n", rx_stats
.query_v2
);
1374 vty_out(vty
, "V3 query : %u\n", rx_stats
.query_v3
);
1375 vty_out(vty
, "V2 leave : %u\n", rx_stats
.leave_v2
);
1376 vty_out(vty
, "V1 report : %u\n", rx_stats
.report_v1
);
1377 vty_out(vty
, "V2 report : %u\n", rx_stats
.report_v2
);
1378 vty_out(vty
, "V3 report : %u\n", rx_stats
.report_v3
);
1379 vty_out(vty
, "mtrace response : %u\n", rx_stats
.mtrace_rsp
);
1380 vty_out(vty
, "mtrace request : %u\n", rx_stats
.mtrace_req
);
1381 vty_out(vty
, "unsupported : %u\n", rx_stats
.unsupported
);
1385 static void pim_show_interfaces(struct pim_instance
*pim
, struct vty
*vty
,
1388 struct interface
*ifp
;
1389 struct pim_interface
*pim_ifp
;
1390 struct pim_upstream
*up
;
1393 int pim_ifchannels
= 0;
1394 json_object
*json
= NULL
;
1395 json_object
*json_row
= NULL
;
1396 json_object
*json_tmp
;
1398 json
= json_object_new_object();
1400 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
1401 pim_ifp
= ifp
->info
;
1406 if (mlag
== true && pim_ifp
->activeactive
== false)
1409 pim_nbrs
= pim_ifp
->pim_neighbor_list
->count
;
1410 pim_ifchannels
= pim_if_ifchannel_count(pim_ifp
);
1413 frr_each (rb_pim_upstream
, &pim
->upstream_head
, up
)
1414 if (ifp
== up
->rpf
.source_nexthop
.interface
)
1415 if (up
->flags
& PIM_UPSTREAM_FLAG_MASK_FHR
)
1418 json_row
= json_object_new_object();
1419 json_object_pim_ifp_add(json_row
, ifp
);
1420 json_object_int_add(json_row
, "pimNeighbors", pim_nbrs
);
1421 json_object_int_add(json_row
, "pimIfChannels", pim_ifchannels
);
1422 json_object_int_add(json_row
, "firstHopRouterCount", fhr
);
1423 json_object_string_add(json_row
, "pimDesignatedRouter",
1424 inet_ntoa(pim_ifp
->pim_dr_addr
));
1426 if (pim_ifp
->pim_dr_addr
.s_addr
1427 == pim_ifp
->primary_address
.s_addr
)
1428 json_object_boolean_true_add(
1429 json_row
, "pimDesignatedRouterLocal");
1431 json_object_object_add(json
, ifp
->name
, json_row
);
1435 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
1436 json
, JSON_C_TO_STRING_PRETTY
));
1439 "Interface State Address PIM Nbrs PIM DR FHR IfChannels\n");
1441 json_object_object_foreach(json
, key
, val
)
1443 vty_out(vty
, "%-16s ", key
);
1445 json_object_object_get_ex(val
, "state", &json_tmp
);
1446 vty_out(vty
, "%5s ", json_object_get_string(json_tmp
));
1448 json_object_object_get_ex(val
, "address", &json_tmp
);
1449 vty_out(vty
, "%15s ",
1450 json_object_get_string(json_tmp
));
1452 json_object_object_get_ex(val
, "pimNeighbors",
1454 vty_out(vty
, "%8d ", json_object_get_int(json_tmp
));
1456 if (json_object_object_get_ex(
1457 val
, "pimDesignatedRouterLocal",
1459 vty_out(vty
, "%15s ", "local");
1461 json_object_object_get_ex(
1462 val
, "pimDesignatedRouter", &json_tmp
);
1463 vty_out(vty
, "%15s ",
1464 json_object_get_string(json_tmp
));
1467 json_object_object_get_ex(val
, "firstHopRouter",
1469 vty_out(vty
, "%3d ", json_object_get_int(json_tmp
));
1471 json_object_object_get_ex(val
, "pimIfChannels",
1473 vty_out(vty
, "%9d\n", json_object_get_int(json_tmp
));
1477 json_object_free(json
);
1480 static void pim_show_interface_traffic(struct pim_instance
*pim
,
1481 struct vty
*vty
, bool uj
)
1483 struct interface
*ifp
= NULL
;
1484 struct pim_interface
*pim_ifp
= NULL
;
1485 json_object
*json
= NULL
;
1486 json_object
*json_row
= NULL
;
1489 json
= json_object_new_object();
1492 vty_out(vty
, "%-16s%-17s%-17s%-17s%-17s%-17s%-17s%-17s\n",
1493 "Interface", " HELLO", " JOIN",
1494 " PRUNE", " REGISTER", "REGISTER-STOP",
1496 vty_out(vty
, "%-16s%-17s%-17s%-17s%-17s%-17s%-17s%-17s\n", "",
1497 " Rx/Tx", " Rx/Tx", " Rx/Tx",
1498 " Rx/Tx", " Rx/Tx", " Rx/Tx",
1501 "---------------------------------------------------------------------------------------------------------------\n");
1504 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
1505 pim_ifp
= ifp
->info
;
1510 if (pim_ifp
->pim_sock_fd
< 0)
1513 json_row
= json_object_new_object();
1514 json_object_pim_ifp_add(json_row
, ifp
);
1515 json_object_int_add(json_row
, "helloRx",
1516 pim_ifp
->pim_ifstat_hello_recv
);
1517 json_object_int_add(json_row
, "helloTx",
1518 pim_ifp
->pim_ifstat_hello_sent
);
1519 json_object_int_add(json_row
, "joinRx",
1520 pim_ifp
->pim_ifstat_join_recv
);
1521 json_object_int_add(json_row
, "joinTx",
1522 pim_ifp
->pim_ifstat_join_send
);
1523 json_object_int_add(json_row
, "registerRx",
1524 pim_ifp
->pim_ifstat_reg_recv
);
1525 json_object_int_add(json_row
, "registerTx",
1526 pim_ifp
->pim_ifstat_reg_recv
);
1527 json_object_int_add(json_row
, "registerStopRx",
1528 pim_ifp
->pim_ifstat_reg_stop_recv
);
1529 json_object_int_add(json_row
, "registerStopTx",
1530 pim_ifp
->pim_ifstat_reg_stop_send
);
1531 json_object_int_add(json_row
, "assertRx",
1532 pim_ifp
->pim_ifstat_assert_recv
);
1533 json_object_int_add(json_row
, "assertTx",
1534 pim_ifp
->pim_ifstat_assert_send
);
1535 json_object_int_add(json_row
, "bsmRx",
1536 pim_ifp
->pim_ifstat_bsm_rx
);
1537 json_object_int_add(json_row
, "bsmTx",
1538 pim_ifp
->pim_ifstat_bsm_tx
);
1539 json_object_object_add(json
, ifp
->name
, json_row
);
1542 "%-16s %8u/%-8u %7u/%-7u %7u/%-7u %7u/%-7u %7u/%-7u %7u/%-7u %7" PRIu64
"/%-7" PRIu64
"\n",
1543 ifp
->name
, pim_ifp
->pim_ifstat_hello_recv
,
1544 pim_ifp
->pim_ifstat_hello_sent
,
1545 pim_ifp
->pim_ifstat_join_recv
,
1546 pim_ifp
->pim_ifstat_join_send
,
1547 pim_ifp
->pim_ifstat_prune_recv
,
1548 pim_ifp
->pim_ifstat_prune_send
,
1549 pim_ifp
->pim_ifstat_reg_recv
,
1550 pim_ifp
->pim_ifstat_reg_send
,
1551 pim_ifp
->pim_ifstat_reg_stop_recv
,
1552 pim_ifp
->pim_ifstat_reg_stop_send
,
1553 pim_ifp
->pim_ifstat_assert_recv
,
1554 pim_ifp
->pim_ifstat_assert_send
,
1555 pim_ifp
->pim_ifstat_bsm_rx
,
1556 pim_ifp
->pim_ifstat_bsm_tx
);
1560 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
1561 json
, JSON_C_TO_STRING_PRETTY
));
1562 json_object_free(json
);
1566 static void pim_show_interface_traffic_single(struct pim_instance
*pim
,
1568 const char *ifname
, bool uj
)
1570 struct interface
*ifp
= NULL
;
1571 struct pim_interface
*pim_ifp
= NULL
;
1572 json_object
*json
= NULL
;
1573 json_object
*json_row
= NULL
;
1574 uint8_t found_ifname
= 0;
1577 json
= json_object_new_object();
1580 vty_out(vty
, "%-16s%-17s%-17s%-17s%-17s%-17s%-17s%-17s\n",
1581 "Interface", " HELLO", " JOIN", " PRUNE",
1582 " REGISTER", " REGISTER-STOP", " ASSERT",
1584 vty_out(vty
, "%-14s%-18s%-17s%-17s%-17s%-17s%-17s%-17s\n", "",
1585 " Rx/Tx", " Rx/Tx", " Rx/Tx", " Rx/Tx",
1586 " Rx/Tx", " Rx/Tx", " Rx/Tx");
1588 "-------------------------------------------------------------------------------------------------------------------------------\n");
1591 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
1592 if (strcmp(ifname
, ifp
->name
))
1595 pim_ifp
= ifp
->info
;
1600 if (pim_ifp
->pim_sock_fd
< 0)
1605 json_row
= json_object_new_object();
1606 json_object_pim_ifp_add(json_row
, ifp
);
1607 json_object_int_add(json_row
, "helloRx",
1608 pim_ifp
->pim_ifstat_hello_recv
);
1609 json_object_int_add(json_row
, "helloTx",
1610 pim_ifp
->pim_ifstat_hello_sent
);
1611 json_object_int_add(json_row
, "joinRx",
1612 pim_ifp
->pim_ifstat_join_recv
);
1613 json_object_int_add(json_row
, "joinTx",
1614 pim_ifp
->pim_ifstat_join_send
);
1615 json_object_int_add(json_row
, "registerRx",
1616 pim_ifp
->pim_ifstat_reg_recv
);
1617 json_object_int_add(json_row
, "registerTx",
1618 pim_ifp
->pim_ifstat_reg_recv
);
1619 json_object_int_add(json_row
, "registerStopRx",
1620 pim_ifp
->pim_ifstat_reg_stop_recv
);
1621 json_object_int_add(json_row
, "registerStopTx",
1622 pim_ifp
->pim_ifstat_reg_stop_send
);
1623 json_object_int_add(json_row
, "assertRx",
1624 pim_ifp
->pim_ifstat_assert_recv
);
1625 json_object_int_add(json_row
, "assertTx",
1626 pim_ifp
->pim_ifstat_assert_send
);
1627 json_object_int_add(json_row
, "bsmRx",
1628 pim_ifp
->pim_ifstat_bsm_rx
);
1629 json_object_int_add(json_row
, "bsmTx",
1630 pim_ifp
->pim_ifstat_bsm_tx
);
1632 json_object_object_add(json
, ifp
->name
, json_row
);
1635 "%-16s %8u/%-8u %7u/%-7u %7u/%-7u %7u/%-7u %7u/%-7u %7u/%-7u %7" PRIu64
"/%-7" PRIu64
"\n",
1636 ifp
->name
, pim_ifp
->pim_ifstat_hello_recv
,
1637 pim_ifp
->pim_ifstat_hello_sent
,
1638 pim_ifp
->pim_ifstat_join_recv
,
1639 pim_ifp
->pim_ifstat_join_send
,
1640 pim_ifp
->pim_ifstat_prune_recv
,
1641 pim_ifp
->pim_ifstat_prune_send
,
1642 pim_ifp
->pim_ifstat_reg_recv
,
1643 pim_ifp
->pim_ifstat_reg_send
,
1644 pim_ifp
->pim_ifstat_reg_stop_recv
,
1645 pim_ifp
->pim_ifstat_reg_stop_send
,
1646 pim_ifp
->pim_ifstat_assert_recv
,
1647 pim_ifp
->pim_ifstat_assert_send
,
1648 pim_ifp
->pim_ifstat_bsm_rx
,
1649 pim_ifp
->pim_ifstat_bsm_tx
);
1653 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
1654 json
, JSON_C_TO_STRING_PRETTY
));
1655 json_object_free(json
);
1658 vty_out(vty
, "%% No such interface\n");
1662 static void pim_show_join_helper(struct vty
*vty
, struct pim_interface
*pim_ifp
,
1663 struct pim_ifchannel
*ch
, json_object
*json
,
1664 time_t now
, bool uj
)
1666 char ch_src_str
[INET_ADDRSTRLEN
];
1667 char ch_grp_str
[INET_ADDRSTRLEN
];
1668 json_object
*json_iface
= NULL
;
1669 json_object
*json_row
= NULL
;
1670 json_object
*json_grp
= NULL
;
1671 struct in_addr ifaddr
;
1676 ifaddr
= pim_ifp
->primary_address
;
1678 pim_inet4_dump("<ch_src?>", ch
->sg
.src
, ch_src_str
, sizeof(ch_src_str
));
1679 pim_inet4_dump("<ch_grp?>", ch
->sg
.grp
, ch_grp_str
, sizeof(ch_grp_str
));
1681 pim_time_uptime_begin(uptime
, sizeof(uptime
), now
, ch
->ifjoin_creation
);
1682 pim_time_timer_to_mmss(expire
, sizeof(expire
),
1683 ch
->t_ifjoin_expiry_timer
);
1684 pim_time_timer_to_mmss(prune
, sizeof(prune
),
1685 ch
->t_ifjoin_prune_pending_timer
);
1688 json_object_object_get_ex(json
, ch
->interface
->name
,
1692 json_iface
= json_object_new_object();
1693 json_object_pim_ifp_add(json_iface
, ch
->interface
);
1694 json_object_object_add(json
, ch
->interface
->name
,
1698 json_row
= json_object_new_object();
1699 json_object_string_add(json_row
, "source", ch_src_str
);
1700 json_object_string_add(json_row
, "group", ch_grp_str
);
1701 json_object_string_add(json_row
, "upTime", uptime
);
1702 json_object_string_add(json_row
, "expire", expire
);
1703 json_object_string_add(json_row
, "prune", prune
);
1704 json_object_string_add(
1705 json_row
, "channelJoinName",
1706 pim_ifchannel_ifjoin_name(ch
->ifjoin_state
, ch
->flags
));
1707 if (PIM_IF_FLAG_TEST_S_G_RPT(ch
->flags
))
1708 json_object_int_add(json_row
, "SGRpt", 1);
1710 json_object_object_get_ex(json_iface
, ch_grp_str
, &json_grp
);
1712 json_grp
= json_object_new_object();
1713 json_object_object_add(json_grp
, ch_src_str
, json_row
);
1714 json_object_object_add(json_iface
, ch_grp_str
,
1717 json_object_object_add(json_grp
, ch_src_str
, json_row
);
1719 vty_out(vty
, "%-16s %-15s %-15s %-15s %-10s %8s %-6s %5s\n",
1720 ch
->interface
->name
, inet_ntoa(ifaddr
), ch_src_str
,
1722 pim_ifchannel_ifjoin_name(ch
->ifjoin_state
, ch
->flags
),
1723 uptime
, expire
, prune
);
1727 static void pim_show_join(struct pim_instance
*pim
, struct vty
*vty
,
1728 struct prefix_sg
*sg
, bool uj
)
1730 struct pim_interface
*pim_ifp
;
1731 struct pim_ifchannel
*ch
;
1732 struct interface
*ifp
;
1734 json_object
*json
= NULL
;
1736 now
= pim_time_monotonic_sec();
1739 json
= json_object_new_object();
1742 "Interface Address Source Group State Uptime Expire Prune\n");
1744 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
1745 pim_ifp
= ifp
->info
;
1749 RB_FOREACH (ch
, pim_ifchannel_rb
, &pim_ifp
->ifchannel_rb
) {
1750 if (sg
->grp
.s_addr
!= INADDR_ANY
1751 && sg
->grp
.s_addr
!= ch
->sg
.grp
.s_addr
)
1753 if (sg
->src
.s_addr
!= INADDR_ANY
1754 && sg
->src
.s_addr
!= ch
->sg
.src
.s_addr
)
1756 pim_show_join_helper(vty
, pim_ifp
, ch
, json
, now
, uj
);
1757 } /* scan interface channels */
1761 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
1762 json
, JSON_C_TO_STRING_PRETTY
));
1763 json_object_free(json
);
1767 static void pim_show_neighbors_single(struct pim_instance
*pim
, struct vty
*vty
,
1768 const char *neighbor
, bool uj
)
1770 struct listnode
*neighnode
;
1771 struct interface
*ifp
;
1772 struct pim_interface
*pim_ifp
;
1773 struct pim_neighbor
*neigh
;
1775 int found_neighbor
= 0;
1776 int option_address_list
;
1777 int option_dr_priority
;
1778 int option_generation_id
;
1779 int option_holdtime
;
1780 int option_lan_prune_delay
;
1784 char neigh_src_str
[INET_ADDRSTRLEN
];
1786 json_object
*json
= NULL
;
1787 json_object
*json_ifp
= NULL
;
1788 json_object
*json_row
= NULL
;
1790 now
= pim_time_monotonic_sec();
1793 json
= json_object_new_object();
1795 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
1796 pim_ifp
= ifp
->info
;
1801 if (pim_ifp
->pim_sock_fd
< 0)
1804 for (ALL_LIST_ELEMENTS_RO(pim_ifp
->pim_neighbor_list
, neighnode
,
1806 pim_inet4_dump("<src?>", neigh
->source_addr
,
1807 neigh_src_str
, sizeof(neigh_src_str
));
1810 * The user can specify either the interface name or the
1812 * If this pim_ifp matches neither then skip.
1814 if (strcmp(neighbor
, "detail")
1815 && strcmp(neighbor
, ifp
->name
)
1816 && strcmp(neighbor
, neigh_src_str
))
1820 pim_time_uptime(uptime
, sizeof(uptime
),
1821 now
- neigh
->creation
);
1822 pim_time_timer_to_hhmmss(expire
, sizeof(expire
),
1823 neigh
->t_expire_timer
);
1825 option_address_list
= 0;
1826 option_dr_priority
= 0;
1827 option_generation_id
= 0;
1828 option_holdtime
= 0;
1829 option_lan_prune_delay
= 0;
1832 if (PIM_OPTION_IS_SET(neigh
->hello_options
,
1833 PIM_OPTION_MASK_ADDRESS_LIST
))
1834 option_address_list
= 1;
1836 if (PIM_OPTION_IS_SET(neigh
->hello_options
,
1837 PIM_OPTION_MASK_DR_PRIORITY
))
1838 option_dr_priority
= 1;
1840 if (PIM_OPTION_IS_SET(neigh
->hello_options
,
1841 PIM_OPTION_MASK_GENERATION_ID
))
1842 option_generation_id
= 1;
1844 if (PIM_OPTION_IS_SET(neigh
->hello_options
,
1845 PIM_OPTION_MASK_HOLDTIME
))
1846 option_holdtime
= 1;
1848 if (PIM_OPTION_IS_SET(neigh
->hello_options
,
1849 PIM_OPTION_MASK_LAN_PRUNE_DELAY
))
1850 option_lan_prune_delay
= 1;
1852 if (PIM_OPTION_IS_SET(
1853 neigh
->hello_options
,
1854 PIM_OPTION_MASK_CAN_DISABLE_JOIN_SUPPRESSION
))
1859 /* Does this ifp live in json? If not create
1861 json_object_object_get_ex(json
, ifp
->name
,
1865 json_ifp
= json_object_new_object();
1866 json_object_pim_ifp_add(json_ifp
, ifp
);
1867 json_object_object_add(json
, ifp
->name
,
1871 json_row
= json_object_new_object();
1872 json_object_string_add(json_row
, "interface",
1874 json_object_string_add(json_row
, "address",
1876 json_object_string_add(json_row
, "upTime",
1878 json_object_string_add(json_row
, "holdtime",
1880 json_object_int_add(json_row
, "drPriority",
1881 neigh
->dr_priority
);
1882 json_object_int_add(json_row
, "generationId",
1883 neigh
->generation_id
);
1885 if (option_address_list
)
1886 json_object_boolean_true_add(
1888 "helloOptionAddressList");
1890 if (option_dr_priority
)
1891 json_object_boolean_true_add(
1893 "helloOptionDrPriority");
1895 if (option_generation_id
)
1896 json_object_boolean_true_add(
1898 "helloOptionGenerationId");
1900 if (option_holdtime
)
1901 json_object_boolean_true_add(
1903 "helloOptionHoldtime");
1905 if (option_lan_prune_delay
)
1906 json_object_boolean_true_add(
1908 "helloOptionLanPruneDelay");
1911 json_object_boolean_true_add(
1912 json_row
, "helloOptionTBit");
1914 json_object_object_add(json_ifp
, neigh_src_str
,
1918 vty_out(vty
, "Interface : %s\n", ifp
->name
);
1919 vty_out(vty
, "Neighbor : %s\n", neigh_src_str
);
1927 " DR Priority : %d\n",
1928 neigh
->dr_priority
);
1930 " Generation ID : %08x\n",
1931 neigh
->generation_id
);
1933 " Override Interval (msec) : %d\n",
1934 neigh
->override_interval_msec
);
1936 " Propagation Delay (msec) : %d\n",
1937 neigh
->propagation_delay_msec
);
1939 " Hello Option - Address List : %s\n",
1940 option_address_list
? "yes" : "no");
1942 " Hello Option - DR Priority : %s\n",
1943 option_dr_priority
? "yes" : "no");
1945 " Hello Option - Generation ID : %s\n",
1946 option_generation_id
? "yes" : "no");
1948 " Hello Option - Holdtime : %s\n",
1949 option_holdtime
? "yes" : "no");
1951 " Hello Option - LAN Prune Delay : %s\n",
1952 option_lan_prune_delay
? "yes" : "no");
1954 " Hello Option - T-bit : %s\n",
1955 option_t_bit
? "yes" : "no");
1956 pim_bfd_show_info(vty
, neigh
->bfd_info
,
1964 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
1965 json
, JSON_C_TO_STRING_PRETTY
));
1966 json_object_free(json
);
1969 if (!found_neighbor
)
1971 "%% No such interface or neighbor\n");
1976 static void pim_show_state(struct pim_instance
*pim
, struct vty
*vty
,
1977 const char *src_or_group
, const char *group
, bool uj
)
1979 struct channel_oil
*c_oil
;
1980 json_object
*json
= NULL
;
1981 json_object
*json_group
= NULL
;
1982 json_object
*json_ifp_in
= NULL
;
1983 json_object
*json_ifp_out
= NULL
;
1984 json_object
*json_source
= NULL
;
1987 now
= pim_time_monotonic_sec();
1990 json
= json_object_new_object();
1993 "Codes: J -> Pim Join, I -> IGMP Report, S -> Source, * -> Inherited from (*,G), V -> VxLAN, M -> Muted");
1995 "\nActive Source Group RPT IIF OIL\n");
1998 frr_each (rb_pim_oil
, &pim
->channel_oil_head
, c_oil
) {
1999 char grp_str
[INET_ADDRSTRLEN
];
2000 char src_str
[INET_ADDRSTRLEN
];
2001 char in_ifname
[INTERFACE_NAMSIZ
+ 1];
2002 char out_ifname
[INTERFACE_NAMSIZ
+ 1];
2004 struct interface
*ifp_in
;
2009 PIM_UPSTREAM_FLAG_TEST_USE_RPT(c_oil
->up
->flags
)) ||
2010 c_oil
->oil
.mfcc_origin
.s_addr
== INADDR_ANY
)
2015 pim_inet4_dump("<group?>", c_oil
->oil
.mfcc_mcastgrp
, grp_str
,
2017 pim_inet4_dump("<source?>", c_oil
->oil
.mfcc_origin
, src_str
,
2019 ifp_in
= pim_if_find_by_vif_index(pim
, c_oil
->oil
.mfcc_parent
);
2022 strlcpy(in_ifname
, ifp_in
->name
, sizeof(in_ifname
));
2024 strlcpy(in_ifname
, "<iif?>", sizeof(in_ifname
));
2027 if (strcmp(src_or_group
, src_str
)
2028 && strcmp(src_or_group
, grp_str
))
2031 if (group
&& strcmp(group
, grp_str
))
2037 /* Find the group, create it if it doesn't exist */
2038 json_object_object_get_ex(json
, grp_str
, &json_group
);
2041 json_group
= json_object_new_object();
2042 json_object_object_add(json
, grp_str
,
2046 /* Find the source nested under the group, create it if
2047 * it doesn't exist */
2048 json_object_object_get_ex(json_group
, src_str
,
2052 json_source
= json_object_new_object();
2053 json_object_object_add(json_group
, src_str
,
2057 /* Find the inbound interface nested under the source,
2058 * create it if it doesn't exist */
2059 json_object_object_get_ex(json_source
, in_ifname
,
2063 json_ifp_in
= json_object_new_object();
2064 json_object_object_add(json_source
, in_ifname
,
2066 json_object_int_add(json_source
, "Installed",
2069 json_object_boolean_true_add(
2070 json_source
, "isRpt");
2072 json_object_boolean_false_add(
2073 json_source
, "isRpt");
2074 json_object_int_add(json_source
, "RefCount",
2075 c_oil
->oil_ref_count
);
2076 json_object_int_add(json_source
, "OilListSize",
2078 json_object_int_add(
2079 json_source
, "OilRescan",
2080 c_oil
->oil_inherited_rescan
);
2081 json_object_int_add(json_source
, "LastUsed",
2082 c_oil
->cc
.lastused
);
2083 json_object_int_add(json_source
, "PacketCount",
2085 json_object_int_add(json_source
, "ByteCount",
2087 json_object_int_add(json_source
,
2089 c_oil
->cc
.wrong_if
);
2092 vty_out(vty
, "%-6d %-15s %-15s %-3s %-16s ",
2093 c_oil
->installed
, src_str
, grp_str
,
2094 isRpt
? "y" : "n", in_ifname
);
2097 for (oif_vif_index
= 0; oif_vif_index
< MAXVIFS
;
2099 struct interface
*ifp_out
;
2100 char oif_uptime
[10];
2103 ttl
= c_oil
->oil
.mfcc_ttls
[oif_vif_index
];
2107 ifp_out
= pim_if_find_by_vif_index(pim
, oif_vif_index
);
2109 oif_uptime
, sizeof(oif_uptime
),
2110 now
- c_oil
->oif_creation
[oif_vif_index
]);
2113 strlcpy(out_ifname
, ifp_out
->name
, sizeof(out_ifname
));
2115 strlcpy(out_ifname
, "<oif?>", sizeof(out_ifname
));
2118 json_ifp_out
= json_object_new_object();
2119 json_object_string_add(json_ifp_out
, "source",
2121 json_object_string_add(json_ifp_out
, "group",
2123 json_object_string_add(json_ifp_out
,
2126 json_object_string_add(json_ifp_out
,
2127 "outboundInterface",
2129 json_object_int_add(json_ifp_out
, "installed",
2132 json_object_object_add(json_ifp_in
, out_ifname
,
2137 vty_out(vty
, "%s(%c%c%c%c%c)",
2139 (c_oil
->oif_flags
[oif_vif_index
]
2140 & PIM_OIF_FLAG_PROTO_IGMP
)
2143 (c_oil
->oif_flags
[oif_vif_index
]
2144 & PIM_OIF_FLAG_PROTO_PIM
)
2147 (c_oil
->oif_flags
[oif_vif_index
]
2148 & PIM_OIF_FLAG_PROTO_VXLAN
)
2151 (c_oil
->oif_flags
[oif_vif_index
]
2152 & PIM_OIF_FLAG_PROTO_STAR
)
2155 (c_oil
->oif_flags
[oif_vif_index
]
2156 & PIM_OIF_FLAG_MUTE
)
2160 vty_out(vty
, ", %s(%c%c%c%c%c)",
2162 (c_oil
->oif_flags
[oif_vif_index
]
2163 & PIM_OIF_FLAG_PROTO_IGMP
)
2166 (c_oil
->oif_flags
[oif_vif_index
]
2167 & PIM_OIF_FLAG_PROTO_PIM
)
2170 (c_oil
->oif_flags
[oif_vif_index
]
2171 & PIM_OIF_FLAG_PROTO_VXLAN
)
2174 (c_oil
->oif_flags
[oif_vif_index
]
2175 & PIM_OIF_FLAG_PROTO_STAR
)
2178 (c_oil
->oif_flags
[oif_vif_index
]
2179 & PIM_OIF_FLAG_MUTE
)
2191 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
2192 json
, JSON_C_TO_STRING_PRETTY
));
2193 json_object_free(json
);
2199 static void pim_show_neighbors(struct pim_instance
*pim
, struct vty
*vty
,
2202 struct listnode
*neighnode
;
2203 struct interface
*ifp
;
2204 struct pim_interface
*pim_ifp
;
2205 struct pim_neighbor
*neigh
;
2209 char neigh_src_str
[INET_ADDRSTRLEN
];
2210 json_object
*json
= NULL
;
2211 json_object
*json_ifp_rows
= NULL
;
2212 json_object
*json_row
= NULL
;
2214 now
= pim_time_monotonic_sec();
2217 json
= json_object_new_object();
2220 "Interface Neighbor Uptime Holdtime DR Pri\n");
2223 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
2224 pim_ifp
= ifp
->info
;
2229 if (pim_ifp
->pim_sock_fd
< 0)
2233 json_ifp_rows
= json_object_new_object();
2235 for (ALL_LIST_ELEMENTS_RO(pim_ifp
->pim_neighbor_list
, neighnode
,
2237 pim_inet4_dump("<src?>", neigh
->source_addr
,
2238 neigh_src_str
, sizeof(neigh_src_str
));
2239 pim_time_uptime(uptime
, sizeof(uptime
),
2240 now
- neigh
->creation
);
2241 pim_time_timer_to_hhmmss(expire
, sizeof(expire
),
2242 neigh
->t_expire_timer
);
2245 json_row
= json_object_new_object();
2246 json_object_string_add(json_row
, "interface",
2248 json_object_string_add(json_row
, "neighbor",
2250 json_object_string_add(json_row
, "upTime",
2252 json_object_string_add(json_row
, "holdTime",
2254 json_object_int_add(json_row
, "holdTimeMax",
2256 json_object_int_add(json_row
, "drPriority",
2257 neigh
->dr_priority
);
2258 json_object_object_add(json_ifp_rows
,
2259 neigh_src_str
, json_row
);
2262 vty_out(vty
, "%-16s %15s %8s %8s %6d\n",
2263 ifp
->name
, neigh_src_str
, uptime
,
2264 expire
, neigh
->dr_priority
);
2269 json_object_object_add(json
, ifp
->name
, json_ifp_rows
);
2270 json_ifp_rows
= NULL
;
2275 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
2276 json
, JSON_C_TO_STRING_PRETTY
));
2277 json_object_free(json
);
2281 static void pim_show_neighbors_secondary(struct pim_instance
*pim
,
2284 struct interface
*ifp
;
2287 "Interface Address Neighbor Secondary \n");
2289 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
2290 struct pim_interface
*pim_ifp
;
2291 struct in_addr ifaddr
;
2292 struct listnode
*neighnode
;
2293 struct pim_neighbor
*neigh
;
2295 pim_ifp
= ifp
->info
;
2300 if (pim_ifp
->pim_sock_fd
< 0)
2303 ifaddr
= pim_ifp
->primary_address
;
2305 for (ALL_LIST_ELEMENTS_RO(pim_ifp
->pim_neighbor_list
, neighnode
,
2307 char neigh_src_str
[INET_ADDRSTRLEN
];
2308 struct listnode
*prefix_node
;
2311 if (!neigh
->prefix_list
)
2314 pim_inet4_dump("<src?>", neigh
->source_addr
,
2315 neigh_src_str
, sizeof(neigh_src_str
));
2317 for (ALL_LIST_ELEMENTS_RO(neigh
->prefix_list
,
2319 char neigh_sec_str
[PREFIX2STR_BUFFER
];
2321 prefix2str(p
, neigh_sec_str
,
2322 sizeof(neigh_sec_str
));
2324 vty_out(vty
, "%-16s %-15s %-15s %-15s\n",
2325 ifp
->name
, inet_ntoa(ifaddr
),
2326 neigh_src_str
, neigh_sec_str
);
2332 static void json_object_pim_upstream_add(json_object
*json
,
2333 struct pim_upstream
*up
)
2335 if (up
->flags
& PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED
)
2336 json_object_boolean_true_add(json
, "drJoinDesired");
2338 if (up
->flags
& PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED_UPDATED
)
2339 json_object_boolean_true_add(json
, "drJoinDesiredUpdated");
2341 if (up
->flags
& PIM_UPSTREAM_FLAG_MASK_FHR
)
2342 json_object_boolean_true_add(json
, "firstHopRouter");
2344 if (up
->flags
& PIM_UPSTREAM_FLAG_MASK_SRC_IGMP
)
2345 json_object_boolean_true_add(json
, "sourceIgmp");
2347 if (up
->flags
& PIM_UPSTREAM_FLAG_MASK_SRC_PIM
)
2348 json_object_boolean_true_add(json
, "sourcePim");
2350 if (up
->flags
& PIM_UPSTREAM_FLAG_MASK_SRC_STREAM
)
2351 json_object_boolean_true_add(json
, "sourceStream");
2353 /* XXX: need to print ths flag in the plain text display as well */
2354 if (up
->flags
& PIM_UPSTREAM_FLAG_MASK_SRC_MSDP
)
2355 json_object_boolean_true_add(json
, "sourceMsdp");
2357 if (up
->flags
& PIM_UPSTREAM_FLAG_MASK_SEND_SG_RPT_PRUNE
)
2358 json_object_boolean_true_add(json
, "sendSGRptPrune");
2360 if (up
->flags
& PIM_UPSTREAM_FLAG_MASK_SRC_LHR
)
2361 json_object_boolean_true_add(json
, "lastHopRouter");
2363 if (up
->flags
& PIM_UPSTREAM_FLAG_MASK_DISABLE_KAT_EXPIRY
)
2364 json_object_boolean_true_add(json
, "disableKATExpiry");
2366 if (up
->flags
& PIM_UPSTREAM_FLAG_MASK_STATIC_IIF
)
2367 json_object_boolean_true_add(json
, "staticIncomingInterface");
2369 if (up
->flags
& PIM_UPSTREAM_FLAG_MASK_ALLOW_IIF_IN_OIL
)
2370 json_object_boolean_true_add(json
,
2371 "allowIncomingInterfaceinOil");
2373 if (up
->flags
& PIM_UPSTREAM_FLAG_MASK_NO_PIMREG_DATA
)
2374 json_object_boolean_true_add(json
, "noPimRegistrationData");
2376 if (up
->flags
& PIM_UPSTREAM_FLAG_MASK_FORCE_PIMREG
)
2377 json_object_boolean_true_add(json
, "forcePimRegistration");
2379 if (up
->flags
& PIM_UPSTREAM_FLAG_MASK_SRC_VXLAN_ORIG
)
2380 json_object_boolean_true_add(json
, "sourceVxlanOrigination");
2382 if (up
->flags
& PIM_UPSTREAM_FLAG_MASK_SRC_VXLAN_TERM
)
2383 json_object_boolean_true_add(json
, "sourceVxlanTermination");
2385 if (up
->flags
& PIM_UPSTREAM_FLAG_MASK_MLAG_VXLAN
)
2386 json_object_boolean_true_add(json
, "mlagVxlan");
2388 if (up
->flags
& PIM_UPSTREAM_FLAG_MASK_MLAG_NON_DF
)
2389 json_object_boolean_true_add(json
,
2390 "mlagNonDesignatedForwarder");
2394 pim_upstream_state2brief_str(enum pim_upstream_state join_state
,
2395 char *state_str
, size_t state_str_len
)
2397 switch (join_state
) {
2398 case PIM_UPSTREAM_NOTJOINED
:
2399 strlcpy(state_str
, "NotJ", state_str_len
);
2401 case PIM_UPSTREAM_JOINED
:
2402 strlcpy(state_str
, "J", state_str_len
);
2405 strlcpy(state_str
, "Unk", state_str_len
);
2410 static const char *pim_reg_state2brief_str(enum pim_reg_state reg_state
,
2411 char *state_str
, size_t state_str_len
)
2413 switch (reg_state
) {
2414 case PIM_REG_NOINFO
:
2415 strlcpy(state_str
, "RegNI", state_str_len
);
2418 strlcpy(state_str
, "RegJ", state_str_len
);
2420 case PIM_REG_JOIN_PENDING
:
2422 strlcpy(state_str
, "RegP", state_str_len
);
2425 strlcpy(state_str
, "Unk", state_str_len
);
2430 static void pim_show_upstream(struct pim_instance
*pim
, struct vty
*vty
,
2431 struct prefix_sg
*sg
, bool uj
)
2433 struct pim_upstream
*up
;
2435 json_object
*json
= NULL
;
2436 json_object
*json_group
= NULL
;
2437 json_object
*json_row
= NULL
;
2439 now
= pim_time_monotonic_sec();
2442 json
= json_object_new_object();
2445 "Iif Source Group State Uptime JoinTimer RSTimer KATimer RefCnt\n");
2447 frr_each (rb_pim_upstream
, &pim
->upstream_head
, up
) {
2448 char src_str
[INET_ADDRSTRLEN
];
2449 char grp_str
[INET_ADDRSTRLEN
];
2451 char join_timer
[10];
2454 char msdp_reg_timer
[10];
2455 char state_str
[PIM_REG_STATE_STR_LEN
];
2457 if (sg
->grp
.s_addr
!= INADDR_ANY
2458 && sg
->grp
.s_addr
!= up
->sg
.grp
.s_addr
)
2460 if (sg
->src
.s_addr
!= INADDR_ANY
2461 && sg
->src
.s_addr
!= up
->sg
.src
.s_addr
)
2464 pim_inet4_dump("<src?>", up
->sg
.src
, src_str
, sizeof(src_str
));
2465 pim_inet4_dump("<grp?>", up
->sg
.grp
, grp_str
, sizeof(grp_str
));
2466 pim_time_uptime(uptime
, sizeof(uptime
),
2467 now
- up
->state_transition
);
2468 pim_time_timer_to_hhmmss(join_timer
, sizeof(join_timer
),
2472 * If the upstream is not dummy and it has a J/P timer for the
2473 * neighbor display that
2475 if (!up
->t_join_timer
&& up
->rpf
.source_nexthop
.interface
) {
2476 struct pim_neighbor
*nbr
;
2478 nbr
= pim_neighbor_find(
2479 up
->rpf
.source_nexthop
.interface
,
2480 up
->rpf
.rpf_addr
.u
.prefix4
);
2482 pim_time_timer_to_hhmmss(join_timer
,
2487 pim_time_timer_to_hhmmss(rs_timer
, sizeof(rs_timer
),
2489 pim_time_timer_to_hhmmss(ka_timer
, sizeof(ka_timer
),
2491 pim_time_timer_to_hhmmss(msdp_reg_timer
, sizeof(msdp_reg_timer
),
2492 up
->t_msdp_reg_timer
);
2494 pim_upstream_state2brief_str(up
->join_state
, state_str
, sizeof(state_str
));
2495 if (up
->reg_state
!= PIM_REG_NOINFO
) {
2496 char tmp_str
[PIM_REG_STATE_STR_LEN
];
2498 sprintf(state_str
+ strlen(state_str
), ",%s",
2499 pim_reg_state2brief_str(up
->reg_state
, tmp_str
,
2504 json_object_object_get_ex(json
, grp_str
, &json_group
);
2507 json_group
= json_object_new_object();
2508 json_object_object_add(json
, grp_str
,
2512 json_row
= json_object_new_object();
2513 json_object_pim_upstream_add(json_row
, up
);
2514 json_object_string_add(
2515 json_row
, "inboundInterface",
2516 up
->rpf
.source_nexthop
.interface
2517 ? up
->rpf
.source_nexthop
.interface
->name
2521 * The RPF address we use is slightly different
2522 * based upon what we are looking up.
2523 * If we have a S, list that unless
2524 * we are the FHR, else we just put
2525 * the RP as the rpfAddress
2527 if (up
->flags
& PIM_UPSTREAM_FLAG_MASK_FHR
2528 || up
->sg
.src
.s_addr
== INADDR_ANY
) {
2529 char rpf
[PREFIX_STRLEN
];
2530 struct pim_rpf
*rpg
;
2532 rpg
= RP(pim
, up
->sg
.grp
);
2533 pim_inet4_dump("<rpf?>",
2534 rpg
->rpf_addr
.u
.prefix4
, rpf
,
2536 json_object_string_add(json_row
, "rpfAddress",
2539 json_object_string_add(json_row
, "rpfAddress",
2543 json_object_string_add(json_row
, "source", src_str
);
2544 json_object_string_add(json_row
, "group", grp_str
);
2545 json_object_string_add(json_row
, "state", state_str
);
2546 json_object_string_add(
2547 json_row
, "joinState",
2548 pim_upstream_state2str(up
->join_state
));
2549 json_object_string_add(
2550 json_row
, "regState",
2551 pim_reg_state2str(up
->reg_state
, state_str
, sizeof(state_str
)));
2552 json_object_string_add(json_row
, "upTime", uptime
);
2553 json_object_string_add(json_row
, "joinTimer",
2555 json_object_string_add(json_row
, "resetTimer",
2557 json_object_string_add(json_row
, "keepaliveTimer",
2559 json_object_string_add(json_row
, "msdpRegTimer",
2561 json_object_int_add(json_row
, "refCount",
2563 json_object_int_add(json_row
, "sptBit", up
->sptbit
);
2564 json_object_object_add(json_group
, src_str
, json_row
);
2567 "%-16s%-15s %-15s %-11s %-8s %-9s %-9s %-9s %6d\n",
2568 up
->rpf
.source_nexthop
.interface
2569 ? up
->rpf
.source_nexthop
.interface
->name
2571 src_str
, grp_str
, state_str
, uptime
, join_timer
,
2572 rs_timer
, ka_timer
, up
->ref_count
);
2577 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
2578 json
, JSON_C_TO_STRING_PRETTY
));
2579 json_object_free(json
);
2583 static void pim_show_channel_helper(struct pim_instance
*pim
,
2585 struct pim_interface
*pim_ifp
,
2586 struct pim_ifchannel
*ch
,
2587 json_object
*json
, bool uj
)
2589 struct pim_upstream
*up
= ch
->upstream
;
2590 json_object
*json_group
= NULL
;
2591 char src_str
[INET_ADDRSTRLEN
];
2592 char grp_str
[INET_ADDRSTRLEN
];
2593 json_object
*json_row
= NULL
;
2595 pim_inet4_dump("<src?>", up
->sg
.src
, src_str
, sizeof(src_str
));
2596 pim_inet4_dump("<grp?>", up
->sg
.grp
, grp_str
, sizeof(grp_str
));
2599 json_object_object_get_ex(json
, grp_str
, &json_group
);
2602 json_group
= json_object_new_object();
2603 json_object_object_add(json
, grp_str
, json_group
);
2606 json_row
= json_object_new_object();
2607 json_object_pim_upstream_add(json_row
, up
);
2608 json_object_string_add(json_row
, "interface",
2609 ch
->interface
->name
);
2610 json_object_string_add(json_row
, "source", src_str
);
2611 json_object_string_add(json_row
, "group", grp_str
);
2613 if (pim_macro_ch_lost_assert(ch
))
2614 json_object_boolean_true_add(json_row
, "lostAssert");
2616 if (pim_macro_chisin_joins(ch
))
2617 json_object_boolean_true_add(json_row
, "joins");
2619 if (pim_macro_chisin_pim_include(ch
))
2620 json_object_boolean_true_add(json_row
, "pimInclude");
2622 if (pim_upstream_evaluate_join_desired(pim
, up
))
2623 json_object_boolean_true_add(json_row
,
2624 "evaluateJoinDesired");
2626 json_object_object_add(json_group
, src_str
, json_row
);
2629 vty_out(vty
, "%-16s %-15s %-15s %-10s %-5s %-10s %-11s %-6s\n",
2630 ch
->interface
->name
, src_str
, grp_str
,
2631 pim_macro_ch_lost_assert(ch
) ? "yes" : "no",
2632 pim_macro_chisin_joins(ch
) ? "yes" : "no",
2633 pim_macro_chisin_pim_include(ch
) ? "yes" : "no",
2634 PIM_UPSTREAM_FLAG_TEST_DR_JOIN_DESIRED(up
->flags
)
2637 pim_upstream_evaluate_join_desired(pim
, up
) ? "yes"
2642 static void pim_show_channel(struct pim_instance
*pim
, struct vty
*vty
,
2645 struct pim_interface
*pim_ifp
;
2646 struct pim_ifchannel
*ch
;
2647 struct interface
*ifp
;
2649 json_object
*json
= NULL
;
2652 json
= json_object_new_object();
2655 "Interface Source Group LostAssert Joins PimInclude JoinDesired EvalJD\n");
2657 /* scan per-interface (S,G) state */
2658 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
2659 pim_ifp
= ifp
->info
;
2664 RB_FOREACH (ch
, pim_ifchannel_rb
, &pim_ifp
->ifchannel_rb
) {
2665 /* scan all interfaces */
2666 pim_show_channel_helper(pim
, vty
, pim_ifp
, ch
,
2672 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
2673 json
, JSON_C_TO_STRING_PRETTY
));
2674 json_object_free(json
);
2678 static void pim_show_join_desired_helper(struct pim_instance
*pim
,
2680 struct pim_upstream
*up
,
2681 json_object
*json
, bool uj
)
2683 json_object
*json_group
= NULL
;
2684 char src_str
[INET_ADDRSTRLEN
];
2685 char grp_str
[INET_ADDRSTRLEN
];
2686 json_object
*json_row
= NULL
;
2688 pim_inet4_dump("<src?>", up
->sg
.src
, src_str
, sizeof(src_str
));
2689 pim_inet4_dump("<grp?>", up
->sg
.grp
, grp_str
, sizeof(grp_str
));
2692 json_object_object_get_ex(json
, grp_str
, &json_group
);
2695 json_group
= json_object_new_object();
2696 json_object_object_add(json
, grp_str
, json_group
);
2699 json_row
= json_object_new_object();
2700 json_object_pim_upstream_add(json_row
, up
);
2701 json_object_string_add(json_row
, "source", src_str
);
2702 json_object_string_add(json_row
, "group", grp_str
);
2704 if (pim_upstream_evaluate_join_desired(pim
, up
))
2705 json_object_boolean_true_add(json_row
,
2706 "evaluateJoinDesired");
2708 json_object_object_add(json_group
, src_str
, json_row
);
2711 vty_out(vty
, "%-15s %-15s %-6s\n",
2713 pim_upstream_evaluate_join_desired(pim
, up
) ? "yes"
2718 static void pim_show_join_desired(struct pim_instance
*pim
, struct vty
*vty
,
2721 struct pim_upstream
*up
;
2723 json_object
*json
= NULL
;
2726 json
= json_object_new_object();
2729 "Source Group EvalJD\n");
2731 frr_each (rb_pim_upstream
, &pim
->upstream_head
, up
) {
2732 /* scan all interfaces */
2733 pim_show_join_desired_helper(pim
, vty
, up
,
2738 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
2739 json
, JSON_C_TO_STRING_PRETTY
));
2740 json_object_free(json
);
2744 static void pim_show_upstream_rpf(struct pim_instance
*pim
, struct vty
*vty
,
2747 struct pim_upstream
*up
;
2748 json_object
*json
= NULL
;
2749 json_object
*json_group
= NULL
;
2750 json_object
*json_row
= NULL
;
2753 json
= json_object_new_object();
2756 "Source Group RpfIface RibNextHop RpfAddress \n");
2758 frr_each (rb_pim_upstream
, &pim
->upstream_head
, up
) {
2759 char src_str
[INET_ADDRSTRLEN
];
2760 char grp_str
[INET_ADDRSTRLEN
];
2761 char rpf_nexthop_str
[PREFIX_STRLEN
];
2762 char rpf_addr_str
[PREFIX_STRLEN
];
2763 struct pim_rpf
*rpf
;
2764 const char *rpf_ifname
;
2768 pim_inet4_dump("<src?>", up
->sg
.src
, src_str
, sizeof(src_str
));
2769 pim_inet4_dump("<grp?>", up
->sg
.grp
, grp_str
, sizeof(grp_str
));
2770 pim_addr_dump("<nexthop?>",
2771 &rpf
->source_nexthop
.mrib_nexthop_addr
,
2772 rpf_nexthop_str
, sizeof(rpf_nexthop_str
));
2773 pim_addr_dump("<rpf?>", &rpf
->rpf_addr
, rpf_addr_str
,
2774 sizeof(rpf_addr_str
));
2776 rpf_ifname
= rpf
->source_nexthop
.interface
? rpf
->source_nexthop
.interface
->name
: "<ifname?>";
2779 json_object_object_get_ex(json
, grp_str
, &json_group
);
2782 json_group
= json_object_new_object();
2783 json_object_object_add(json
, grp_str
,
2787 json_row
= json_object_new_object();
2788 json_object_pim_upstream_add(json_row
, up
);
2789 json_object_string_add(json_row
, "source", src_str
);
2790 json_object_string_add(json_row
, "group", grp_str
);
2791 json_object_string_add(json_row
, "rpfInterface",
2793 json_object_string_add(json_row
, "ribNexthop",
2795 json_object_string_add(json_row
, "rpfAddress",
2797 json_object_object_add(json_group
, src_str
, json_row
);
2799 vty_out(vty
, "%-15s %-15s %-16s %-15s %-15s\n", src_str
,
2800 grp_str
, rpf_ifname
, rpf_nexthop_str
,
2806 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
2807 json
, JSON_C_TO_STRING_PRETTY
));
2808 json_object_free(json
);
2812 static void show_rpf_refresh_stats(struct vty
*vty
, struct pim_instance
*pim
,
2813 time_t now
, json_object
*json
)
2815 char refresh_uptime
[10];
2817 pim_time_uptime_begin(refresh_uptime
, sizeof(refresh_uptime
), now
,
2818 pim
->rpf_cache_refresh_last
);
2821 json_object_int_add(json
, "rpfCacheRefreshDelayMsecs",
2822 router
->rpf_cache_refresh_delay_msec
);
2823 json_object_int_add(
2824 json
, "rpfCacheRefreshTimer",
2825 pim_time_timer_remain_msec(pim
->rpf_cache_refresher
));
2826 json_object_int_add(json
, "rpfCacheRefreshRequests",
2827 pim
->rpf_cache_refresh_requests
);
2828 json_object_int_add(json
, "rpfCacheRefreshEvents",
2829 pim
->rpf_cache_refresh_events
);
2830 json_object_string_add(json
, "rpfCacheRefreshLast",
2832 json_object_int_add(json
, "nexthopLookups",
2833 pim
->nexthop_lookups
);
2834 json_object_int_add(json
, "nexthopLookupsAvoided",
2835 pim
->nexthop_lookups_avoided
);
2838 "RPF Cache Refresh Delay: %ld msecs\n"
2839 "RPF Cache Refresh Timer: %ld msecs\n"
2840 "RPF Cache Refresh Requests: %lld\n"
2841 "RPF Cache Refresh Events: %lld\n"
2842 "RPF Cache Refresh Last: %s\n"
2843 "Nexthop Lookups: %lld\n"
2844 "Nexthop Lookups Avoided: %lld\n",
2845 router
->rpf_cache_refresh_delay_msec
,
2846 pim_time_timer_remain_msec(pim
->rpf_cache_refresher
),
2847 (long long)pim
->rpf_cache_refresh_requests
,
2848 (long long)pim
->rpf_cache_refresh_events
,
2849 refresh_uptime
, (long long)pim
->nexthop_lookups
,
2850 (long long)pim
->nexthop_lookups_avoided
);
2854 static void show_scan_oil_stats(struct pim_instance
*pim
, struct vty
*vty
,
2857 char uptime_scan_oil
[10];
2858 char uptime_mroute_add
[10];
2859 char uptime_mroute_del
[10];
2861 pim_time_uptime_begin(uptime_scan_oil
, sizeof(uptime_scan_oil
), now
,
2862 pim
->scan_oil_last
);
2863 pim_time_uptime_begin(uptime_mroute_add
, sizeof(uptime_mroute_add
), now
,
2864 pim
->mroute_add_last
);
2865 pim_time_uptime_begin(uptime_mroute_del
, sizeof(uptime_mroute_del
), now
,
2866 pim
->mroute_del_last
);
2869 "Scan OIL - Last: %s Events: %lld\n"
2870 "MFC Add - Last: %s Events: %lld\n"
2871 "MFC Del - Last: %s Events: %lld\n",
2872 uptime_scan_oil
, (long long)pim
->scan_oil_events
,
2873 uptime_mroute_add
, (long long)pim
->mroute_add_events
,
2874 uptime_mroute_del
, (long long)pim
->mroute_del_events
);
2877 static void pim_show_rpf(struct pim_instance
*pim
, struct vty
*vty
, bool uj
)
2879 struct pim_upstream
*up
;
2880 time_t now
= pim_time_monotonic_sec();
2881 json_object
*json
= NULL
;
2882 json_object
*json_group
= NULL
;
2883 json_object
*json_row
= NULL
;
2886 json
= json_object_new_object();
2887 show_rpf_refresh_stats(vty
, pim
, now
, json
);
2889 show_rpf_refresh_stats(vty
, pim
, now
, json
);
2892 "Source Group RpfIface RpfAddress RibNextHop Metric Pref\n");
2895 frr_each (rb_pim_upstream
, &pim
->upstream_head
, up
) {
2896 char src_str
[INET_ADDRSTRLEN
];
2897 char grp_str
[INET_ADDRSTRLEN
];
2898 char rpf_addr_str
[PREFIX_STRLEN
];
2899 char rib_nexthop_str
[PREFIX_STRLEN
];
2900 const char *rpf_ifname
;
2901 struct pim_rpf
*rpf
= &up
->rpf
;
2903 pim_inet4_dump("<src?>", up
->sg
.src
, src_str
, sizeof(src_str
));
2904 pim_inet4_dump("<grp?>", up
->sg
.grp
, grp_str
, sizeof(grp_str
));
2905 pim_addr_dump("<rpf?>", &rpf
->rpf_addr
, rpf_addr_str
,
2906 sizeof(rpf_addr_str
));
2907 pim_addr_dump("<nexthop?>",
2908 &rpf
->source_nexthop
.mrib_nexthop_addr
,
2909 rib_nexthop_str
, sizeof(rib_nexthop_str
));
2911 rpf_ifname
= rpf
->source_nexthop
.interface
? rpf
->source_nexthop
.interface
->name
: "<ifname?>";
2914 json_object_object_get_ex(json
, grp_str
, &json_group
);
2917 json_group
= json_object_new_object();
2918 json_object_object_add(json
, grp_str
,
2922 json_row
= json_object_new_object();
2923 json_object_string_add(json_row
, "source", src_str
);
2924 json_object_string_add(json_row
, "group", grp_str
);
2925 json_object_string_add(json_row
, "rpfInterface",
2927 json_object_string_add(json_row
, "rpfAddress",
2929 json_object_string_add(json_row
, "ribNexthop",
2931 json_object_int_add(
2932 json_row
, "routeMetric",
2933 rpf
->source_nexthop
.mrib_route_metric
);
2934 json_object_int_add(
2935 json_row
, "routePreference",
2936 rpf
->source_nexthop
.mrib_metric_preference
);
2937 json_object_object_add(json_group
, src_str
, json_row
);
2940 vty_out(vty
, "%-15s %-15s %-16s %-15s %-15s %6d %4d\n",
2941 src_str
, grp_str
, rpf_ifname
, rpf_addr_str
,
2943 rpf
->source_nexthop
.mrib_route_metric
,
2944 rpf
->source_nexthop
.mrib_metric_preference
);
2949 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
2950 json
, JSON_C_TO_STRING_PRETTY
));
2951 json_object_free(json
);
2955 struct pnc_cache_walk_data
{
2957 struct pim_instance
*pim
;
2960 static int pim_print_pnc_cache_walkcb(struct hash_bucket
*bucket
, void *arg
)
2962 struct pim_nexthop_cache
*pnc
= bucket
->data
;
2963 struct pnc_cache_walk_data
*cwd
= arg
;
2964 struct vty
*vty
= cwd
->vty
;
2965 struct pim_instance
*pim
= cwd
->pim
;
2966 struct nexthop
*nh_node
= NULL
;
2967 ifindex_t first_ifindex
;
2968 struct interface
*ifp
= NULL
;
2970 for (nh_node
= pnc
->nexthop
; nh_node
; nh_node
= nh_node
->next
) {
2971 first_ifindex
= nh_node
->ifindex
;
2972 ifp
= if_lookup_by_index(first_ifindex
, pim
->vrf_id
);
2974 vty_out(vty
, "%-15s ", inet_ntoa(pnc
->rpf
.rpf_addr
.u
.prefix4
));
2975 vty_out(vty
, "%-16s ", ifp
? ifp
->name
: "NULL");
2976 vty_out(vty
, "%s ", inet_ntoa(nh_node
->gate
.ipv4
));
2982 static void pim_show_nexthop(struct pim_instance
*pim
, struct vty
*vty
)
2984 struct pnc_cache_walk_data cwd
;
2988 vty_out(vty
, "Number of registered addresses: %lu\n",
2989 pim
->rpf_hash
->count
);
2990 vty_out(vty
, "Address Interface Nexthop\n");
2991 vty_out(vty
, "---------------------------------------------\n");
2993 hash_walk(pim
->rpf_hash
, pim_print_pnc_cache_walkcb
, &cwd
);
2996 /* Display the bsm database details */
2997 static void pim_show_bsm_db(struct pim_instance
*pim
, struct vty
*vty
, bool uj
)
2999 struct listnode
*bsmnode
;
3002 struct bsm_info
*bsm
;
3003 json_object
*json
= NULL
;
3004 json_object
*json_group
= NULL
;
3005 json_object
*json_row
= NULL
;
3007 count
= pim
->global_scope
.bsm_list
->count
;
3010 json
= json_object_new_object();
3011 json_object_int_add(json
, "Number of the fragments", count
);
3013 vty_out(vty
, "Scope Zone: Global\n");
3014 vty_out(vty
, "Number of the fragments: %d\n", count
);
3018 for (ALL_LIST_ELEMENTS_RO(pim
->global_scope
.bsm_list
, bsmnode
, bsm
)) {
3019 char grp_str
[INET_ADDRSTRLEN
];
3020 char rp_str
[INET_ADDRSTRLEN
];
3021 char bsr_str
[INET_ADDRSTRLEN
];
3022 struct bsmmsg_grpinfo
*group
;
3023 struct bsmmsg_rpinfo
*rpaddr
;
3025 struct bsm_hdr
*hdr
;
3026 uint32_t offset
= 0;
3029 uint32_t frag_rp_cnt
= 0;
3034 /* skip pim header */
3035 buf
+= PIM_MSG_HEADER_LEN
;
3036 len
-= PIM_MSG_HEADER_LEN
;
3038 hdr
= (struct bsm_hdr
*)buf
;
3040 /* BSM starts with bsr header */
3041 buf
+= sizeof(struct bsm_hdr
);
3042 len
-= sizeof(struct bsm_hdr
);
3044 pim_inet4_dump("<BSR Address?>", hdr
->bsr_addr
.addr
, bsr_str
,
3049 json_object_string_add(json
, "BSR address", bsr_str
);
3050 json_object_int_add(json
, "BSR priority",
3052 json_object_int_add(json
, "Hashmask Length",
3054 json_object_int_add(json
, "Fragment Tag",
3055 ntohs(hdr
->frag_tag
));
3057 vty_out(vty
, "BSM Fragment : %d\n", fragment
);
3058 vty_out(vty
, "------------------\n");
3059 vty_out(vty
, "%-15s %-15s %-15s %-15s\n", "BSR-Address",
3060 "BSR-Priority", "Hashmask-len", "Fragment-Tag");
3061 vty_out(vty
, "%-15s %-15d %-15d %-15d\n", bsr_str
,
3062 hdr
->bsr_prio
, hdr
->hm_len
,
3063 ntohs(hdr
->frag_tag
));
3068 while (offset
< len
) {
3069 group
= (struct bsmmsg_grpinfo
*)buf
;
3071 if (group
->group
.family
== PIM_MSG_ADDRESS_FAMILY_IPV4
)
3072 grp
.family
= AF_INET
;
3074 grp
.prefixlen
= group
->group
.mask
;
3075 grp
.u
.prefix4
.s_addr
= group
->group
.addr
.s_addr
;
3077 prefix2str(&grp
, grp_str
, sizeof(grp_str
));
3079 buf
+= sizeof(struct bsmmsg_grpinfo
);
3080 offset
+= sizeof(struct bsmmsg_grpinfo
);
3083 json_object_object_get_ex(json
, grp_str
,
3086 json_group
= json_object_new_object();
3087 json_object_int_add(json_group
,
3090 json_object_int_add(
3091 json_group
, "Fragment Rp count",
3092 group
->frag_rp_count
);
3093 json_object_object_add(json
, grp_str
,
3097 vty_out(vty
, "Group : %s\n", grp_str
);
3098 vty_out(vty
, "-------------------\n");
3099 vty_out(vty
, "Rp Count:%d\n", group
->rp_count
);
3100 vty_out(vty
, "Fragment Rp Count : %d\n",
3101 group
->frag_rp_count
);
3104 frag_rp_cnt
= group
->frag_rp_count
;
3111 "RpAddress HoldTime Priority\n");
3113 while (frag_rp_cnt
--) {
3114 rpaddr
= (struct bsmmsg_rpinfo
*)buf
;
3116 buf
+= sizeof(struct bsmmsg_rpinfo
);
3117 offset
+= sizeof(struct bsmmsg_rpinfo
);
3119 pim_inet4_dump("<Rp addr?>",
3120 rpaddr
->rpaddr
.addr
, rp_str
,
3124 json_row
= json_object_new_object();
3125 json_object_string_add(
3126 json_row
, "Rp Address", rp_str
);
3127 json_object_int_add(
3128 json_row
, "Rp HoldTime",
3129 ntohs(rpaddr
->rp_holdtime
));
3130 json_object_int_add(json_row
,
3133 json_object_object_add(
3134 json_group
, rp_str
, json_row
);
3136 vty_out(vty
, "%-15s %-12d %d\n", rp_str
,
3137 ntohs(rpaddr
->rp_holdtime
),
3148 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
3149 json
, JSON_C_TO_STRING_PRETTY
));
3150 json_object_free(json
);
3154 /*Display the group-rp mappings */
3155 static void pim_show_group_rp_mappings_info(struct pim_instance
*pim
,
3156 struct vty
*vty
, bool uj
)
3158 struct bsgrp_node
*bsgrp
;
3159 struct listnode
*rpnode
;
3160 struct bsm_rpinfo
*bsm_rp
;
3161 struct route_node
*rn
;
3162 char bsr_str
[INET_ADDRSTRLEN
];
3163 json_object
*json
= NULL
;
3164 json_object
*json_group
= NULL
;
3165 json_object
*json_row
= NULL
;
3167 if (pim
->global_scope
.current_bsr
.s_addr
== INADDR_ANY
)
3168 strlcpy(bsr_str
, "0.0.0.0", sizeof(bsr_str
));
3171 pim_inet4_dump("<bsr?>", pim
->global_scope
.current_bsr
, bsr_str
,
3175 json
= json_object_new_object();
3176 json_object_string_add(json
, "BSR Address", bsr_str
);
3178 vty_out(vty
, "BSR Address %s\n", bsr_str
);
3181 for (rn
= route_top(pim
->global_scope
.bsrp_table
); rn
;
3182 rn
= route_next(rn
)) {
3183 bsgrp
= (struct bsgrp_node
*)rn
->info
;
3188 char grp_str
[INET_ADDRSTRLEN
];
3190 prefix2str(&bsgrp
->group
, grp_str
, sizeof(grp_str
));
3193 json_object_object_get_ex(json
, grp_str
, &json_group
);
3195 json_group
= json_object_new_object();
3196 json_object_object_add(json
, grp_str
,
3200 vty_out(vty
, "Group Address %s\n", grp_str
);
3201 vty_out(vty
, "--------------------------\n");
3202 vty_out(vty
, "%-15s %-15s %-15s %-15s\n", "Rp Address",
3203 "priority", "Holdtime", "Hash");
3205 vty_out(vty
, "(ACTIVE)\n");
3208 if (bsgrp
->bsrp_list
) {
3209 for (ALL_LIST_ELEMENTS_RO(bsgrp
->bsrp_list
, rpnode
,
3211 char rp_str
[INET_ADDRSTRLEN
];
3213 pim_inet4_dump("<Rp Address?>",
3214 bsm_rp
->rp_address
, rp_str
,
3218 json_row
= json_object_new_object();
3219 json_object_string_add(
3220 json_row
, "Rp Address", rp_str
);
3221 json_object_int_add(
3222 json_row
, "Rp HoldTime",
3223 bsm_rp
->rp_holdtime
);
3224 json_object_int_add(json_row
,
3227 json_object_int_add(json_row
,
3230 json_object_object_add(
3231 json_group
, rp_str
, json_row
);
3235 "%-15s %-15u %-15u %-15u\n",
3236 rp_str
, bsm_rp
->rp_prio
,
3237 bsm_rp
->rp_holdtime
,
3241 if (!bsgrp
->bsrp_list
->count
&& !uj
)
3242 vty_out(vty
, "Active List is empty.\n");
3246 json_object_int_add(json_group
, "Pending RP count",
3247 bsgrp
->pend_rp_cnt
);
3249 vty_out(vty
, "(PENDING)\n");
3250 vty_out(vty
, "Pending RP count :%d\n",
3251 bsgrp
->pend_rp_cnt
);
3252 if (bsgrp
->pend_rp_cnt
)
3253 vty_out(vty
, "%-15s %-15s %-15s %-15s\n",
3254 "Rp Address", "priority", "Holdtime",
3258 if (bsgrp
->partial_bsrp_list
) {
3259 for (ALL_LIST_ELEMENTS_RO(bsgrp
->partial_bsrp_list
,
3261 char rp_str
[INET_ADDRSTRLEN
];
3263 pim_inet4_dump("<Rp Addr?>", bsm_rp
->rp_address
,
3264 rp_str
, sizeof(rp_str
));
3267 json_row
= json_object_new_object();
3268 json_object_string_add(
3269 json_row
, "Rp Address", rp_str
);
3270 json_object_int_add(
3271 json_row
, "Rp HoldTime",
3272 bsm_rp
->rp_holdtime
);
3273 json_object_int_add(json_row
,
3276 json_object_int_add(json_row
,
3279 json_object_object_add(
3280 json_group
, rp_str
, json_row
);
3283 "%-15s %-15u %-15u %-15u\n",
3284 rp_str
, bsm_rp
->rp_prio
,
3285 bsm_rp
->rp_holdtime
,
3289 if (!bsgrp
->partial_bsrp_list
->count
&& !uj
)
3290 vty_out(vty
, "Partial List is empty\n");
3298 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
3299 json
, JSON_C_TO_STRING_PRETTY
));
3300 json_object_free(json
);
3304 /* pim statistics - just adding only bsm related now.
3305 * We can continue to add all pim related stats here.
3307 static void pim_show_statistics(struct pim_instance
*pim
, struct vty
*vty
,
3308 const char *ifname
, bool uj
)
3310 json_object
*json
= NULL
;
3311 struct interface
*ifp
;
3314 json
= json_object_new_object();
3315 json_object_int_add(json
, "Number of Received BSMs",
3317 json_object_int_add(json
, "Number of Forwared BSMs",
3319 json_object_int_add(json
, "Number of Dropped BSMs",
3322 vty_out(vty
, "BSM Statistics :\n");
3323 vty_out(vty
, "----------------\n");
3324 vty_out(vty
, "Number of Received BSMs : %" PRIu64
"\n",
3326 vty_out(vty
, "Number of Forwared BSMs : %" PRIu64
"\n",
3328 vty_out(vty
, "Number of Dropped BSMs : %" PRIu64
"\n",
3334 /* scan interfaces */
3335 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
3336 struct pim_interface
*pim_ifp
= ifp
->info
;
3338 if (ifname
&& strcmp(ifname
, ifp
->name
))
3345 vty_out(vty
, "Interface : %s\n", ifp
->name
);
3346 vty_out(vty
, "-------------------\n");
3348 "Number of BSMs dropped due to config miss : %u\n",
3349 pim_ifp
->pim_ifstat_bsm_cfg_miss
);
3350 vty_out(vty
, "Number of unicast BSMs dropped : %u\n",
3351 pim_ifp
->pim_ifstat_ucast_bsm_cfg_miss
);
3353 "Number of BSMs dropped due to invalid scope zone : %u\n",
3354 pim_ifp
->pim_ifstat_bsm_invalid_sz
);
3357 json_object
*json_row
= NULL
;
3359 json_row
= json_object_new_object();
3361 json_object_string_add(json_row
, "If Name", ifp
->name
);
3362 json_object_int_add(
3364 "Number of BSMs dropped due to config miss",
3365 pim_ifp
->pim_ifstat_bsm_cfg_miss
);
3366 json_object_int_add(
3367 json_row
, "Number of unicast BSMs dropped",
3368 pim_ifp
->pim_ifstat_ucast_bsm_cfg_miss
);
3369 json_object_int_add(json_row
,
3370 "Number of BSMs dropped due to invalid scope zone",
3371 pim_ifp
->pim_ifstat_bsm_invalid_sz
);
3372 json_object_object_add(json
, ifp
->name
, json_row
);
3378 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
3379 json
, JSON_C_TO_STRING_PRETTY
));
3380 json_object_free(json
);
3384 static void clear_pim_statistics(struct pim_instance
*pim
)
3386 struct interface
*ifp
;
3390 pim
->bsm_dropped
= 0;
3392 /* scan interfaces */
3393 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
3394 struct pim_interface
*pim_ifp
= ifp
->info
;
3399 pim_ifp
->pim_ifstat_bsm_cfg_miss
= 0;
3400 pim_ifp
->pim_ifstat_ucast_bsm_cfg_miss
= 0;
3401 pim_ifp
->pim_ifstat_bsm_invalid_sz
= 0;
3405 static void igmp_show_groups(struct pim_instance
*pim
, struct vty
*vty
, bool uj
)
3407 struct interface
*ifp
;
3409 json_object
*json
= NULL
;
3410 json_object
*json_iface
= NULL
;
3411 json_object
*json_row
= NULL
;
3413 now
= pim_time_monotonic_sec();
3416 json
= json_object_new_object();
3419 "Interface Address Group Mode Timer Srcs V Uptime \n");
3421 /* scan interfaces */
3422 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
3423 struct pim_interface
*pim_ifp
= ifp
->info
;
3424 struct listnode
*sock_node
;
3425 struct igmp_sock
*igmp
;
3430 /* scan igmp sockets */
3431 for (ALL_LIST_ELEMENTS_RO(pim_ifp
->igmp_socket_list
, sock_node
,
3433 char ifaddr_str
[INET_ADDRSTRLEN
];
3434 struct listnode
*grpnode
;
3435 struct igmp_group
*grp
;
3437 pim_inet4_dump("<ifaddr?>", igmp
->ifaddr
, ifaddr_str
,
3438 sizeof(ifaddr_str
));
3440 /* scan igmp groups */
3441 for (ALL_LIST_ELEMENTS_RO(igmp
->igmp_group_list
,
3443 char group_str
[INET_ADDRSTRLEN
];
3447 pim_inet4_dump("<group?>", grp
->group_addr
,
3448 group_str
, sizeof(group_str
));
3449 pim_time_timer_to_hhmmss(hhmmss
, sizeof(hhmmss
),
3450 grp
->t_group_timer
);
3451 pim_time_uptime(uptime
, sizeof(uptime
),
3452 now
- grp
->group_creation
);
3455 json_object_object_get_ex(
3456 json
, ifp
->name
, &json_iface
);
3460 json_object_new_object();
3461 json_object_pim_ifp_add(
3463 json_object_object_add(
3468 json_row
= json_object_new_object();
3469 json_object_string_add(
3470 json_row
, "source", ifaddr_str
);
3471 json_object_string_add(
3472 json_row
, "group", group_str
);
3474 if (grp
->igmp_version
== 3)
3475 json_object_string_add(
3477 grp
->group_filtermode_isexcl
3481 json_object_string_add(json_row
,
3483 json_object_int_add(
3484 json_row
, "sourcesCount",
3485 grp
->group_source_list
3487 grp
->group_source_list
)
3489 json_object_int_add(json_row
, "version",
3491 json_object_string_add(
3492 json_row
, "uptime", uptime
);
3493 json_object_object_add(json_iface
,
3499 "%-16s %-15s %-15s %4s %8s %4d %d %8s\n",
3500 ifp
->name
, ifaddr_str
,
3502 grp
->igmp_version
== 3
3503 ? (grp
->group_filtermode_isexcl
3508 grp
->group_source_list
3510 grp
->group_source_list
)
3512 grp
->igmp_version
, uptime
);
3514 } /* scan igmp groups */
3515 } /* scan igmp sockets */
3516 } /* scan interfaces */
3519 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
3520 json
, JSON_C_TO_STRING_PRETTY
));
3521 json_object_free(json
);
3525 static void igmp_show_group_retransmission(struct pim_instance
*pim
,
3528 struct interface
*ifp
;
3531 "Interface Address Group RetTimer Counter RetSrcs\n");
3533 /* scan interfaces */
3534 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
3535 struct pim_interface
*pim_ifp
= ifp
->info
;
3536 struct listnode
*sock_node
;
3537 struct igmp_sock
*igmp
;
3542 /* scan igmp sockets */
3543 for (ALL_LIST_ELEMENTS_RO(pim_ifp
->igmp_socket_list
, sock_node
,
3545 char ifaddr_str
[INET_ADDRSTRLEN
];
3546 struct listnode
*grpnode
;
3547 struct igmp_group
*grp
;
3549 pim_inet4_dump("<ifaddr?>", igmp
->ifaddr
, ifaddr_str
,
3550 sizeof(ifaddr_str
));
3552 /* scan igmp groups */
3553 for (ALL_LIST_ELEMENTS_RO(igmp
->igmp_group_list
,
3555 char group_str
[INET_ADDRSTRLEN
];
3556 char grp_retr_mmss
[10];
3557 struct listnode
*src_node
;
3558 struct igmp_source
*src
;
3559 int grp_retr_sources
= 0;
3561 pim_inet4_dump("<group?>", grp
->group_addr
,
3562 group_str
, sizeof(group_str
));
3563 pim_time_timer_to_mmss(
3564 grp_retr_mmss
, sizeof(grp_retr_mmss
),
3565 grp
->t_group_query_retransmit_timer
);
3568 /* count group sources with retransmission state
3570 for (ALL_LIST_ELEMENTS_RO(
3571 grp
->group_source_list
, src_node
,
3573 if (src
->source_query_retransmit_count
3579 vty_out(vty
, "%-16s %-15s %-15s %-8s %7d %7d\n",
3580 ifp
->name
, ifaddr_str
, group_str
,
3582 grp
->group_specific_query_retransmit_count
,
3585 } /* scan igmp groups */
3586 } /* scan igmp sockets */
3587 } /* scan interfaces */
3590 static void igmp_show_sources(struct pim_instance
*pim
, struct vty
*vty
)
3592 struct interface
*ifp
;
3595 now
= pim_time_monotonic_sec();
3598 "Interface Address Group Source Timer Fwd Uptime \n");
3600 /* scan interfaces */
3601 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
3602 struct pim_interface
*pim_ifp
= ifp
->info
;
3603 struct listnode
*sock_node
;
3604 struct igmp_sock
*igmp
;
3609 /* scan igmp sockets */
3610 for (ALL_LIST_ELEMENTS_RO(pim_ifp
->igmp_socket_list
, sock_node
,
3612 char ifaddr_str
[INET_ADDRSTRLEN
];
3613 struct listnode
*grpnode
;
3614 struct igmp_group
*grp
;
3616 pim_inet4_dump("<ifaddr?>", igmp
->ifaddr
, ifaddr_str
,
3617 sizeof(ifaddr_str
));
3619 /* scan igmp groups */
3620 for (ALL_LIST_ELEMENTS_RO(igmp
->igmp_group_list
,
3622 char group_str
[INET_ADDRSTRLEN
];
3623 struct listnode
*srcnode
;
3624 struct igmp_source
*src
;
3626 pim_inet4_dump("<group?>", grp
->group_addr
,
3627 group_str
, sizeof(group_str
));
3629 /* scan group sources */
3630 for (ALL_LIST_ELEMENTS_RO(
3631 grp
->group_source_list
, srcnode
,
3633 char source_str
[INET_ADDRSTRLEN
];
3638 "<source?>", src
->source_addr
,
3639 source_str
, sizeof(source_str
));
3641 pim_time_timer_to_mmss(
3643 src
->t_source_timer
);
3646 uptime
, sizeof(uptime
),
3647 now
- src
->source_creation
);
3650 "%-16s %-15s %-15s %-15s %5s %3s %8s\n",
3651 ifp
->name
, ifaddr_str
,
3652 group_str
, source_str
, mmss
,
3653 IGMP_SOURCE_TEST_FORWARDING(
3659 } /* scan group sources */
3660 } /* scan igmp groups */
3661 } /* scan igmp sockets */
3662 } /* scan interfaces */
3665 static void igmp_show_source_retransmission(struct pim_instance
*pim
,
3668 struct interface
*ifp
;
3671 "Interface Address Group Source Counter\n");
3673 /* scan interfaces */
3674 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
3675 struct pim_interface
*pim_ifp
= ifp
->info
;
3676 struct listnode
*sock_node
;
3677 struct igmp_sock
*igmp
;
3682 /* scan igmp sockets */
3683 for (ALL_LIST_ELEMENTS_RO(pim_ifp
->igmp_socket_list
, sock_node
,
3685 char ifaddr_str
[INET_ADDRSTRLEN
];
3686 struct listnode
*grpnode
;
3687 struct igmp_group
*grp
;
3689 pim_inet4_dump("<ifaddr?>", igmp
->ifaddr
, ifaddr_str
,
3690 sizeof(ifaddr_str
));
3692 /* scan igmp groups */
3693 for (ALL_LIST_ELEMENTS_RO(igmp
->igmp_group_list
,
3695 char group_str
[INET_ADDRSTRLEN
];
3696 struct listnode
*srcnode
;
3697 struct igmp_source
*src
;
3699 pim_inet4_dump("<group?>", grp
->group_addr
,
3700 group_str
, sizeof(group_str
));
3702 /* scan group sources */
3703 for (ALL_LIST_ELEMENTS_RO(
3704 grp
->group_source_list
, srcnode
,
3706 char source_str
[INET_ADDRSTRLEN
];
3709 "<source?>", src
->source_addr
,
3710 source_str
, sizeof(source_str
));
3713 "%-16s %-15s %-15s %-15s %7d\n",
3714 ifp
->name
, ifaddr_str
,
3715 group_str
, source_str
,
3716 src
->source_query_retransmit_count
);
3718 } /* scan group sources */
3719 } /* scan igmp groups */
3720 } /* scan igmp sockets */
3721 } /* scan interfaces */
3724 static void pim_show_bsr(struct pim_instance
*pim
,
3729 char last_bsm_seen
[10];
3732 char bsr_str
[PREFIX_STRLEN
];
3733 json_object
*json
= NULL
;
3735 vty_out(vty
, "PIMv2 Bootstrap information\n");
3737 if (pim
->global_scope
.current_bsr
.s_addr
== INADDR_ANY
) {
3738 strlcpy(bsr_str
, "0.0.0.0", sizeof(bsr_str
));
3739 pim_time_uptime(uptime
, sizeof(uptime
),
3740 pim
->global_scope
.current_bsr_first_ts
);
3741 pim_time_uptime(last_bsm_seen
, sizeof(last_bsm_seen
),
3742 pim
->global_scope
.current_bsr_last_ts
);
3746 pim_inet4_dump("<bsr?>", pim
->global_scope
.current_bsr
,
3747 bsr_str
, sizeof(bsr_str
));
3748 now
= pim_time_monotonic_sec();
3749 pim_time_uptime(uptime
, sizeof(uptime
),
3750 (now
- pim
->global_scope
.current_bsr_first_ts
));
3751 pim_time_uptime(last_bsm_seen
, sizeof(last_bsm_seen
),
3752 now
- pim
->global_scope
.current_bsr_last_ts
);
3755 switch (pim
->global_scope
.state
) {
3757 strlcpy(bsr_state
, "NO_INFO", sizeof(bsr_state
));
3760 strlcpy(bsr_state
, "ACCEPT_ANY", sizeof(bsr_state
));
3762 case ACCEPT_PREFERRED
:
3763 strlcpy(bsr_state
, "ACCEPT_PREFERRED", sizeof(bsr_state
));
3766 strlcpy(bsr_state
, "", sizeof(bsr_state
));
3770 json
= json_object_new_object();
3771 json_object_string_add(json
, "bsr", bsr_str
);
3772 json_object_int_add(json
, "priority",
3773 pim
->global_scope
.current_bsr_prio
);
3774 json_object_int_add(json
, "fragment_tag",
3775 pim
->global_scope
.bsm_frag_tag
);
3776 json_object_string_add(json
, "state", bsr_state
);
3777 json_object_string_add(json
, "upTime", uptime
);
3778 json_object_string_add(json
, "last_bsm_seen", last_bsm_seen
);
3782 vty_out(vty
, "Current preferred BSR address: %s\n", bsr_str
);
3784 "Priority Fragment-Tag State UpTime\n");
3785 vty_out(vty
, " %-12d %-12d %-13s %7s\n",
3786 pim
->global_scope
.current_bsr_prio
,
3787 pim
->global_scope
.bsm_frag_tag
,
3790 vty_out(vty
, "Last BSM seen: %s\n", last_bsm_seen
);
3794 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
3795 json
, JSON_C_TO_STRING_PRETTY
));
3796 json_object_free(json
);
3800 static void clear_igmp_interfaces(struct pim_instance
*pim
)
3802 struct interface
*ifp
;
3804 FOR_ALL_INTERFACES (pim
->vrf
, ifp
)
3805 pim_if_addr_del_all_igmp(ifp
);
3807 FOR_ALL_INTERFACES (pim
->vrf
, ifp
)
3808 pim_if_addr_add_all(ifp
);
3811 static void clear_pim_interfaces(struct pim_instance
*pim
)
3813 struct interface
*ifp
;
3815 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
3817 pim_neighbor_delete_all(ifp
, "interface cleared");
3822 static void clear_interfaces(struct pim_instance
*pim
)
3824 clear_igmp_interfaces(pim
);
3825 clear_pim_interfaces(pim
);
3828 #define PIM_GET_PIM_INTERFACE(pim_ifp, ifp) \
3829 pim_ifp = ifp->info; \
3832 "%% Enable PIM and/or IGMP on this interface first\n"); \
3833 return CMD_WARNING_CONFIG_FAILED; \
3836 DEFUN (clear_ip_interfaces
,
3837 clear_ip_interfaces_cmd
,
3838 "clear ip interfaces [vrf NAME]",
3841 "Reset interfaces\n"
3845 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
3850 clear_interfaces(vrf
->info
);
3855 DEFUN (clear_ip_igmp_interfaces
,
3856 clear_ip_igmp_interfaces_cmd
,
3857 "clear ip igmp [vrf NAME] interfaces",
3862 "Reset IGMP interfaces\n")
3865 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
3870 clear_igmp_interfaces(vrf
->info
);
3875 DEFUN (clear_ip_pim_statistics
,
3876 clear_ip_pim_statistics_cmd
,
3877 "clear ip pim statistics [vrf NAME]",
3882 "Reset PIM statistics\n")
3885 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
3890 clear_pim_statistics(vrf
->info
);
3894 static void clear_mroute(struct pim_instance
*pim
)
3896 struct pim_upstream
*up
;
3897 struct interface
*ifp
;
3899 /* scan interfaces */
3900 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
3901 struct pim_interface
*pim_ifp
= ifp
->info
;
3902 struct listnode
*sock_node
;
3903 struct igmp_sock
*igmp
;
3904 struct pim_ifchannel
*ch
;
3909 /* deleting all ifchannels */
3910 while (!RB_EMPTY(pim_ifchannel_rb
, &pim_ifp
->ifchannel_rb
)) {
3911 ch
= RB_ROOT(pim_ifchannel_rb
, &pim_ifp
->ifchannel_rb
);
3913 pim_ifchannel_delete(ch
);
3916 /* clean up all igmp groups */
3917 /* scan igmp sockets */
3918 for (ALL_LIST_ELEMENTS_RO(pim_ifp
->igmp_socket_list
, sock_node
,
3921 struct igmp_group
*grp
;
3923 if (igmp
->igmp_group_list
) {
3924 while (igmp
->igmp_group_list
->count
) {
3925 grp
= listnode_head(
3926 igmp
->igmp_group_list
);
3927 igmp_group_delete(grp
);
3934 /* clean up all upstreams*/
3935 while ((up
= rb_pim_upstream_first(&pim
->upstream_head
))) {
3936 pim_upstream_del(pim
, up
, __func__
);
3940 DEFUN (clear_ip_mroute
,
3941 clear_ip_mroute_cmd
,
3942 "clear ip mroute [vrf NAME]",
3945 "Reset multicast routes\n"
3949 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
3954 clear_mroute(vrf
->info
);
3959 DEFUN (clear_ip_pim_interfaces
,
3960 clear_ip_pim_interfaces_cmd
,
3961 "clear ip pim [vrf NAME] interfaces",
3966 "Reset PIM interfaces\n")
3969 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
3974 clear_pim_interfaces(vrf
->info
);
3979 DEFUN (clear_ip_pim_interface_traffic
,
3980 clear_ip_pim_interface_traffic_cmd
,
3981 "clear ip pim [vrf NAME] interface traffic",
3984 "PIM clear commands\n"
3986 "Reset PIM interfaces\n"
3987 "Reset Protocol Packet counters\n")
3990 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
3991 struct interface
*ifp
= NULL
;
3992 struct pim_interface
*pim_ifp
= NULL
;
3997 FOR_ALL_INTERFACES (vrf
, ifp
) {
3998 pim_ifp
= ifp
->info
;
4003 pim_ifp
->pim_ifstat_hello_recv
= 0;
4004 pim_ifp
->pim_ifstat_hello_sent
= 0;
4005 pim_ifp
->pim_ifstat_join_recv
= 0;
4006 pim_ifp
->pim_ifstat_join_send
= 0;
4007 pim_ifp
->pim_ifstat_prune_recv
= 0;
4008 pim_ifp
->pim_ifstat_prune_send
= 0;
4009 pim_ifp
->pim_ifstat_reg_recv
= 0;
4010 pim_ifp
->pim_ifstat_reg_send
= 0;
4011 pim_ifp
->pim_ifstat_reg_stop_recv
= 0;
4012 pim_ifp
->pim_ifstat_reg_stop_send
= 0;
4013 pim_ifp
->pim_ifstat_assert_recv
= 0;
4014 pim_ifp
->pim_ifstat_assert_send
= 0;
4015 pim_ifp
->pim_ifstat_bsm_rx
= 0;
4016 pim_ifp
->pim_ifstat_bsm_tx
= 0;
4022 DEFUN (clear_ip_pim_oil
,
4023 clear_ip_pim_oil_cmd
,
4024 "clear ip pim [vrf NAME] oil",
4029 "Rescan PIM OIL (output interface list)\n")
4032 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
4037 pim_scan_oil(vrf
->info
);
4042 DEFUN (show_ip_igmp_interface
,
4043 show_ip_igmp_interface_cmd
,
4044 "show ip igmp [vrf NAME] interface [detail|WORD] [json]",
4049 "IGMP interface information\n"
4055 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
4056 bool uj
= use_json(argc
, argv
);
4061 if (argv_find(argv
, argc
, "detail", &idx
)
4062 || argv_find(argv
, argc
, "WORD", &idx
))
4063 igmp_show_interfaces_single(vrf
->info
, vty
, argv
[idx
]->arg
, uj
);
4065 igmp_show_interfaces(vrf
->info
, vty
, uj
);
4070 DEFUN (show_ip_igmp_interface_vrf_all
,
4071 show_ip_igmp_interface_vrf_all_cmd
,
4072 "show ip igmp vrf all interface [detail|WORD] [json]",
4077 "IGMP interface information\n"
4083 bool uj
= use_json(argc
, argv
);
4089 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
4093 vty_out(vty
, " \"%s\": ", vrf
->name
);
4096 vty_out(vty
, "VRF: %s\n", vrf
->name
);
4097 if (argv_find(argv
, argc
, "detail", &idx
)
4098 || argv_find(argv
, argc
, "WORD", &idx
))
4099 igmp_show_interfaces_single(vrf
->info
, vty
,
4100 argv
[idx
]->arg
, uj
);
4102 igmp_show_interfaces(vrf
->info
, vty
, uj
);
4105 vty_out(vty
, "}\n");
4110 DEFUN (show_ip_igmp_join
,
4111 show_ip_igmp_join_cmd
,
4112 "show ip igmp [vrf NAME] join",
4117 "IGMP static join information\n")
4120 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
4125 igmp_show_interface_join(vrf
->info
, vty
);
4130 DEFUN (show_ip_igmp_join_vrf_all
,
4131 show_ip_igmp_join_vrf_all_cmd
,
4132 "show ip igmp vrf all join",
4137 "IGMP static join information\n")
4139 bool uj
= use_json(argc
, argv
);
4145 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
4149 vty_out(vty
, " \"%s\": ", vrf
->name
);
4152 vty_out(vty
, "VRF: %s\n", vrf
->name
);
4153 igmp_show_interface_join(vrf
->info
, vty
);
4156 vty_out(vty
, "}\n");
4161 DEFUN (show_ip_igmp_groups
,
4162 show_ip_igmp_groups_cmd
,
4163 "show ip igmp [vrf NAME] groups [json]",
4172 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
4173 bool uj
= use_json(argc
, argv
);
4178 igmp_show_groups(vrf
->info
, vty
, uj
);
4183 DEFUN (show_ip_igmp_groups_vrf_all
,
4184 show_ip_igmp_groups_vrf_all_cmd
,
4185 "show ip igmp vrf all groups [json]",
4193 bool uj
= use_json(argc
, argv
);
4199 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
4203 vty_out(vty
, " \"%s\": ", vrf
->name
);
4206 vty_out(vty
, "VRF: %s\n", vrf
->name
);
4207 igmp_show_groups(vrf
->info
, vty
, uj
);
4210 vty_out(vty
, "}\n");
4215 DEFUN (show_ip_igmp_groups_retransmissions
,
4216 show_ip_igmp_groups_retransmissions_cmd
,
4217 "show ip igmp [vrf NAME] groups retransmissions",
4223 "IGMP group retransmissions\n")
4226 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
4231 igmp_show_group_retransmission(vrf
->info
, vty
);
4236 DEFUN (show_ip_igmp_sources
,
4237 show_ip_igmp_sources_cmd
,
4238 "show ip igmp [vrf NAME] sources",
4246 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
4251 igmp_show_sources(vrf
->info
, vty
);
4256 DEFUN (show_ip_igmp_sources_retransmissions
,
4257 show_ip_igmp_sources_retransmissions_cmd
,
4258 "show ip igmp [vrf NAME] sources retransmissions",
4264 "IGMP source retransmissions\n")
4267 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
4272 igmp_show_source_retransmission(vrf
->info
, vty
);
4277 DEFUN (show_ip_igmp_statistics
,
4278 show_ip_igmp_statistics_cmd
,
4279 "show ip igmp [vrf NAME] statistics [interface WORD] [json]",
4290 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
4291 bool uj
= use_json(argc
, argv
);
4296 if (argv_find(argv
, argc
, "WORD", &idx
))
4297 igmp_show_statistics(vrf
->info
, vty
, argv
[idx
]->arg
, uj
);
4299 igmp_show_statistics(vrf
->info
, vty
, NULL
, uj
);
4304 DEFUN (show_ip_pim_mlag_summary
,
4305 show_ip_pim_mlag_summary_cmd
,
4306 "show ip pim mlag summary [json]",
4311 "status and stats\n"
4314 bool uj
= use_json(argc
, argv
);
4315 char role_buf
[MLAG_ROLE_STRSIZE
];
4316 char addr_buf
[INET_ADDRSTRLEN
];
4319 json_object
*json
= NULL
;
4320 json_object
*json_stat
= NULL
;
4322 json
= json_object_new_object();
4323 if (router
->mlag_flags
& PIM_MLAGF_LOCAL_CONN_UP
)
4324 json_object_boolean_true_add(json
, "mlagConnUp");
4325 if (router
->mlag_flags
& PIM_MLAGF_PEER_CONN_UP
)
4326 json_object_boolean_true_add(json
, "mlagPeerConnUp");
4327 if (router
->mlag_flags
& PIM_MLAGF_PEER_ZEBRA_UP
)
4328 json_object_boolean_true_add(json
, "mlagPeerZebraUp");
4329 json_object_string_add(json
, "mlagRole",
4330 mlag_role2str(router
->mlag_role
,
4331 role_buf
, sizeof(role_buf
)));
4332 inet_ntop(AF_INET
, &router
->local_vtep_ip
,
4333 addr_buf
, INET_ADDRSTRLEN
);
4334 json_object_string_add(json
, "localVtepIp", addr_buf
);
4335 inet_ntop(AF_INET
, &router
->anycast_vtep_ip
,
4336 addr_buf
, INET_ADDRSTRLEN
);
4337 json_object_string_add(json
, "anycastVtepIp", addr_buf
);
4338 json_object_string_add(json
, "peerlinkRif",
4339 router
->peerlink_rif
);
4341 json_stat
= json_object_new_object();
4342 json_object_int_add(json_stat
, "mlagConnFlaps",
4343 router
->mlag_stats
.mlagd_session_downs
);
4344 json_object_int_add(json_stat
, "mlagPeerConnFlaps",
4345 router
->mlag_stats
.peer_session_downs
);
4346 json_object_int_add(json_stat
, "mlagPeerZebraFlaps",
4347 router
->mlag_stats
.peer_zebra_downs
);
4348 json_object_int_add(json_stat
, "mrouteAddRx",
4349 router
->mlag_stats
.msg
.mroute_add_rx
);
4350 json_object_int_add(json_stat
, "mrouteAddTx",
4351 router
->mlag_stats
.msg
.mroute_add_tx
);
4352 json_object_int_add(json_stat
, "mrouteDelRx",
4353 router
->mlag_stats
.msg
.mroute_del_rx
);
4354 json_object_int_add(json_stat
, "mrouteDelTx",
4355 router
->mlag_stats
.msg
.mroute_del_tx
);
4356 json_object_int_add(json_stat
, "mlagStatusUpdates",
4357 router
->mlag_stats
.msg
.mlag_status_updates
);
4358 json_object_int_add(json_stat
, "peerZebraStatusUpdates",
4359 router
->mlag_stats
.msg
.peer_zebra_status_updates
);
4360 json_object_int_add(json_stat
, "pimStatusUpdates",
4361 router
->mlag_stats
.msg
.pim_status_updates
);
4362 json_object_int_add(json_stat
, "vxlanUpdates",
4363 router
->mlag_stats
.msg
.vxlan_updates
);
4364 json_object_object_add(json
, "connStats", json_stat
);
4366 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
4367 json
, JSON_C_TO_STRING_PRETTY
));
4368 json_object_free(json
);
4372 vty_out(vty
, "MLAG daemon connection: %s\n",
4373 (router
->mlag_flags
& PIM_MLAGF_LOCAL_CONN_UP
)
4375 vty_out(vty
, "MLAG peer state: %s\n",
4376 (router
->mlag_flags
& PIM_MLAGF_PEER_CONN_UP
)
4378 vty_out(vty
, "Zebra peer state: %s\n",
4379 (router
->mlag_flags
& PIM_MLAGF_PEER_ZEBRA_UP
)
4381 vty_out(vty
, "MLAG role: %s\n",
4382 mlag_role2str(router
->mlag_role
, role_buf
, sizeof(role_buf
)));
4383 inet_ntop(AF_INET
, &router
->local_vtep_ip
,
4384 addr_buf
, INET_ADDRSTRLEN
);
4385 vty_out(vty
, "Local VTEP IP: %s\n", addr_buf
);
4386 inet_ntop(AF_INET
, &router
->anycast_vtep_ip
,
4387 addr_buf
, INET_ADDRSTRLEN
);
4388 vty_out(vty
, "Anycast VTEP IP: %s\n", addr_buf
);
4389 vty_out(vty
, "Peerlink: %s\n", router
->peerlink_rif
);
4390 vty_out(vty
, "Session flaps: mlagd: %d mlag-peer: %d zebra-peer: %d\n",
4391 router
->mlag_stats
.mlagd_session_downs
,
4392 router
->mlag_stats
.peer_session_downs
,
4393 router
->mlag_stats
.peer_zebra_downs
);
4394 vty_out(vty
, "Message Statistics:\n");
4395 vty_out(vty
, " mroute adds: rx: %d, tx: %d\n",
4396 router
->mlag_stats
.msg
.mroute_add_rx
,
4397 router
->mlag_stats
.msg
.mroute_add_tx
);
4398 vty_out(vty
, " mroute dels: rx: %d, tx: %d\n",
4399 router
->mlag_stats
.msg
.mroute_del_rx
,
4400 router
->mlag_stats
.msg
.mroute_del_tx
);
4401 vty_out(vty
, " peer zebra status updates: %d\n",
4402 router
->mlag_stats
.msg
.peer_zebra_status_updates
);
4403 vty_out(vty
, " PIM status updates: %d\n",
4404 router
->mlag_stats
.msg
.pim_status_updates
);
4405 vty_out(vty
, " VxLAN updates: %d\n",
4406 router
->mlag_stats
.msg
.vxlan_updates
);
4411 DEFUN (show_ip_pim_assert
,
4412 show_ip_pim_assert_cmd
,
4413 "show ip pim [vrf NAME] assert",
4418 "PIM interface assert\n")
4421 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
4426 pim_show_assert(vrf
->info
, vty
);
4431 DEFUN (show_ip_pim_assert_internal
,
4432 show_ip_pim_assert_internal_cmd
,
4433 "show ip pim [vrf NAME] assert-internal",
4438 "PIM interface internal assert state\n")
4441 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
4446 pim_show_assert_internal(vrf
->info
, vty
);
4451 DEFUN (show_ip_pim_assert_metric
,
4452 show_ip_pim_assert_metric_cmd
,
4453 "show ip pim [vrf NAME] assert-metric",
4458 "PIM interface assert metric\n")
4461 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
4466 pim_show_assert_metric(vrf
->info
, vty
);
4471 DEFUN (show_ip_pim_assert_winner_metric
,
4472 show_ip_pim_assert_winner_metric_cmd
,
4473 "show ip pim [vrf NAME] assert-winner-metric",
4478 "PIM interface assert winner metric\n")
4481 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
4486 pim_show_assert_winner_metric(vrf
->info
, vty
);
4491 DEFUN (show_ip_pim_interface
,
4492 show_ip_pim_interface_cmd
,
4493 "show ip pim [mlag] [vrf NAME] interface [detail|WORD] [json]",
4499 "PIM interface information\n"
4505 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
4506 bool uj
= use_json(argc
, argv
);
4512 if (argv_find(argv
, argc
, "mlag", &idx
))
4515 if (argv_find(argv
, argc
, "WORD", &idx
)
4516 || argv_find(argv
, argc
, "detail", &idx
))
4517 pim_show_interfaces_single(vrf
->info
, vty
, argv
[idx
]->arg
, mlag
,
4520 pim_show_interfaces(vrf
->info
, vty
, mlag
, uj
);
4525 DEFUN (show_ip_pim_interface_vrf_all
,
4526 show_ip_pim_interface_vrf_all_cmd
,
4527 "show ip pim [mlag] vrf all interface [detail|WORD] [json]",
4533 "PIM interface information\n"
4539 bool uj
= use_json(argc
, argv
);
4544 if (argv_find(argv
, argc
, "mlag", &idx
))
4550 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
4554 vty_out(vty
, " \"%s\": ", vrf
->name
);
4557 vty_out(vty
, "VRF: %s\n", vrf
->name
);
4558 if (argv_find(argv
, argc
, "WORD", &idx
)
4559 || argv_find(argv
, argc
, "detail", &idx
))
4560 pim_show_interfaces_single(vrf
->info
, vty
,
4561 argv
[idx
]->arg
, mlag
, uj
);
4563 pim_show_interfaces(vrf
->info
, vty
, mlag
, uj
);
4566 vty_out(vty
, "}\n");
4571 DEFPY (show_ip_pim_join
,
4572 show_ip_pim_join_cmd
,
4573 "show ip pim [vrf NAME] join [A.B.C.D$s_or_g [A.B.C.D$g]] [json$json]",
4578 "PIM interface join information\n"
4579 "The Source or Group\n"
4583 struct prefix_sg sg
= {0};
4586 struct pim_instance
*pim
;
4588 v
= vrf_lookup_by_name(vrf
? vrf
: VRF_DEFAULT_NAME
);
4591 vty_out(vty
, "%% Vrf specified: %s does not exist\n", vrf
);
4594 pim
= pim_get_pim_instance(v
->vrf_id
);
4597 vty_out(vty
, "%% Unable to find pim instance\n");
4601 if (s_or_g
.s_addr
!= 0) {
4602 if (g
.s_addr
!= 0) {
4609 pim_show_join(pim
, vty
, &sg
, uj
);
4614 DEFUN (show_ip_pim_join_vrf_all
,
4615 show_ip_pim_join_vrf_all_cmd
,
4616 "show ip pim vrf all join [json]",
4621 "PIM interface join information\n"
4624 struct prefix_sg sg
= {0};
4625 bool uj
= use_json(argc
, argv
);
4631 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
4635 vty_out(vty
, " \"%s\": ", vrf
->name
);
4638 vty_out(vty
, "VRF: %s\n", vrf
->name
);
4639 pim_show_join(vrf
->info
, vty
, &sg
, uj
);
4642 vty_out(vty
, "}\n");
4647 static void pim_show_jp_agg_helper(struct vty
*vty
,
4648 struct interface
*ifp
,
4649 struct pim_neighbor
*neigh
,
4650 struct pim_upstream
*up
,
4653 char src_str
[INET_ADDRSTRLEN
];
4654 char grp_str
[INET_ADDRSTRLEN
];
4655 char rpf_str
[INET_ADDRSTRLEN
];
4657 pim_inet4_dump("<src?>", up
->sg
.src
, src_str
, sizeof(src_str
));
4658 pim_inet4_dump("<grp?>", up
->sg
.grp
, grp_str
, sizeof(grp_str
));
4659 /* pius->address.s_addr */
4660 pim_inet4_dump("<rpf?>", neigh
->source_addr
, rpf_str
, sizeof(rpf_str
));
4662 vty_out(vty
, "%-16s %-15s %-15s %-15s %5s\n",
4663 ifp
->name
, rpf_str
, src_str
,
4664 grp_str
, is_join
?"J":"P");
4667 static void pim_show_jp_agg_list(struct pim_instance
*pim
, struct vty
*vty
)
4669 struct interface
*ifp
;
4670 struct pim_interface
*pim_ifp
;
4671 struct listnode
*n_node
;
4672 struct pim_neighbor
*neigh
;
4673 struct listnode
*jag_node
;
4674 struct pim_jp_agg_group
*jag
;
4675 struct listnode
*js_node
;
4676 struct pim_jp_sources
*js
;
4679 "Interface RPF Nbr Source Group State\n");
4681 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
4682 pim_ifp
= ifp
->info
;
4686 for (ALL_LIST_ELEMENTS_RO(pim_ifp
->pim_neighbor_list
,
4688 for (ALL_LIST_ELEMENTS_RO(neigh
->upstream_jp_agg
,
4690 for (ALL_LIST_ELEMENTS_RO(jag
->sources
,
4692 pim_show_jp_agg_helper(vty
,
4701 DEFPY (show_ip_pim_jp_agg
,
4702 show_ip_pim_jp_agg_cmd
,
4703 "show ip pim [vrf NAME] jp-agg",
4708 "join prune aggregation list\n")
4711 struct pim_instance
*pim
;
4713 v
= vrf_lookup_by_name(vrf
? vrf
: VRF_DEFAULT_NAME
);
4716 vty_out(vty
, "%% Vrf specified: %s does not exist\n", vrf
);
4719 pim
= pim_get_pim_instance(v
->vrf_id
);
4722 vty_out(vty
, "%% Unable to find pim instance\n");
4726 pim_show_jp_agg_list(pim
, vty
);
4731 DEFUN (show_ip_pim_local_membership
,
4732 show_ip_pim_local_membership_cmd
,
4733 "show ip pim [vrf NAME] local-membership [json]",
4738 "PIM interface local-membership\n"
4742 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
4743 bool uj
= use_json(argc
, argv
);
4748 pim_show_membership(vrf
->info
, vty
, uj
);
4753 static void pim_show_mlag_up_entry_detail(struct vrf
*vrf
,
4754 struct vty
*vty
, struct pim_upstream
*up
,
4755 char *src_str
, char *grp_str
, json_object
*json
)
4758 json_object
*json_row
= NULL
;
4759 json_object
*own_list
= NULL
;
4760 json_object
*json_group
= NULL
;
4763 json_object_object_get_ex(json
, grp_str
, &json_group
);
4765 json_group
= json_object_new_object();
4766 json_object_object_add(json
, grp_str
,
4770 json_row
= json_object_new_object();
4771 json_object_string_add(json_row
, "source", src_str
);
4772 json_object_string_add(json_row
, "group", grp_str
);
4774 own_list
= json_object_new_array();
4775 if (pim_up_mlag_is_local(up
))
4776 json_object_array_add(own_list
,
4777 json_object_new_string("local"));
4778 if (up
->flags
& (PIM_UPSTREAM_FLAG_MASK_MLAG_PEER
))
4779 json_object_array_add(own_list
,
4780 json_object_new_string("peer"));
4781 if (up
->flags
& (PIM_UPSTREAM_FLAG_MASK_MLAG_INTERFACE
))
4782 json_object_array_add(
4783 own_list
, json_object_new_string("Interface"));
4784 json_object_object_add(json_row
, "owners", own_list
);
4786 json_object_int_add(json_row
, "localCost",
4787 pim_up_mlag_local_cost(up
));
4788 json_object_int_add(json_row
, "peerCost",
4789 pim_up_mlag_peer_cost(up
));
4790 if (PIM_UPSTREAM_FLAG_TEST_MLAG_NON_DF(up
->flags
))
4791 json_object_boolean_false_add(json_row
, "df");
4793 json_object_boolean_true_add(json_row
, "df");
4794 json_object_object_add(json_group
, src_str
, json_row
);
4799 if (pim_up_mlag_is_local(up
))
4800 strlcat(own_str
, "L", sizeof(own_str
));
4801 if (up
->flags
& (PIM_UPSTREAM_FLAG_MASK_MLAG_PEER
))
4802 strlcat(own_str
, "P", sizeof(own_str
));
4803 if (up
->flags
& (PIM_UPSTREAM_FLAG_MASK_MLAG_INTERFACE
))
4804 strlcat(own_str
, "I", sizeof(own_str
));
4805 /* XXX - fixup, print paragraph output */
4807 "%-15s %-15s %-6s %-11u %-10d %2s\n",
4808 src_str
, grp_str
, own_str
,
4809 pim_up_mlag_local_cost(up
),
4810 pim_up_mlag_peer_cost(up
),
4811 PIM_UPSTREAM_FLAG_TEST_MLAG_NON_DF(up
->flags
)
4816 static void pim_show_mlag_up_detail(struct vrf
*vrf
,
4817 struct vty
*vty
, const char *src_or_group
,
4818 const char *group
, bool uj
)
4820 char src_str
[INET_ADDRSTRLEN
];
4821 char grp_str
[INET_ADDRSTRLEN
];
4822 struct pim_upstream
*up
;
4823 struct pim_instance
*pim
= vrf
->info
;
4824 json_object
*json
= NULL
;
4827 json
= json_object_new_object();
4830 "Source Group Owner Local-cost Peer-cost DF\n");
4832 frr_each (rb_pim_upstream
, &pim
->upstream_head
, up
) {
4833 if (!(up
->flags
& PIM_UPSTREAM_FLAG_MASK_MLAG_PEER
)
4834 && !(up
->flags
& PIM_UPSTREAM_FLAG_MASK_MLAG_INTERFACE
)
4835 && !pim_up_mlag_is_local(up
))
4838 pim_inet4_dump("<src?>", up
->sg
.src
, src_str
, sizeof(src_str
));
4839 pim_inet4_dump("<grp?>", up
->sg
.grp
, grp_str
, sizeof(grp_str
));
4840 /* XXX: strcmps are clearly inefficient. we should do uint comps
4844 if (strcmp(src_str
, src_or_group
) ||
4845 strcmp(grp_str
, group
))
4848 if (strcmp(src_str
, src_or_group
) &&
4849 strcmp(grp_str
, src_or_group
))
4852 pim_show_mlag_up_entry_detail(vrf
, vty
, up
,
4853 src_str
, grp_str
, json
);
4857 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
4858 json
, JSON_C_TO_STRING_PRETTY
));
4859 json_object_free(json
);
4863 static void pim_show_mlag_up_vrf(struct vrf
*vrf
, struct vty
*vty
, bool uj
)
4865 json_object
*json
= NULL
;
4866 json_object
*json_row
;
4867 struct pim_upstream
*up
;
4868 char src_str
[INET_ADDRSTRLEN
];
4869 char grp_str
[INET_ADDRSTRLEN
];
4870 struct pim_instance
*pim
= vrf
->info
;
4871 json_object
*json_group
= NULL
;
4874 json
= json_object_new_object();
4877 "Source Group Owner Local-cost Peer-cost DF\n");
4880 frr_each (rb_pim_upstream
, &pim
->upstream_head
, up
) {
4881 if (!(up
->flags
& PIM_UPSTREAM_FLAG_MASK_MLAG_PEER
)
4882 && !(up
->flags
& PIM_UPSTREAM_FLAG_MASK_MLAG_INTERFACE
)
4883 && !pim_up_mlag_is_local(up
))
4885 pim_inet4_dump("<src?>", up
->sg
.src
, src_str
, sizeof(src_str
));
4886 pim_inet4_dump("<grp?>", up
->sg
.grp
, grp_str
, sizeof(grp_str
));
4888 json_object
*own_list
= NULL
;
4890 json_object_object_get_ex(json
, grp_str
, &json_group
);
4892 json_group
= json_object_new_object();
4893 json_object_object_add(json
, grp_str
,
4897 json_row
= json_object_new_object();
4898 json_object_string_add(json_row
, "vrf", vrf
->name
);
4899 json_object_string_add(json_row
, "source", src_str
);
4900 json_object_string_add(json_row
, "group", grp_str
);
4902 own_list
= json_object_new_array();
4903 if (pim_up_mlag_is_local(up
)) {
4905 json_object_array_add(own_list
,
4906 json_object_new_string("local"));
4908 if (up
->flags
& (PIM_UPSTREAM_FLAG_MASK_MLAG_PEER
)) {
4909 json_object_array_add(own_list
,
4910 json_object_new_string("peer"));
4912 json_object_object_add(json_row
, "owners", own_list
);
4914 json_object_int_add(json_row
, "localCost",
4915 pim_up_mlag_local_cost(up
));
4916 json_object_int_add(json_row
, "peerCost",
4917 pim_up_mlag_peer_cost(up
));
4918 if (PIM_UPSTREAM_FLAG_TEST_MLAG_NON_DF(up
->flags
))
4919 json_object_boolean_false_add(json_row
, "df");
4921 json_object_boolean_true_add(json_row
, "df");
4922 json_object_object_add(json_group
, src_str
, json_row
);
4927 if (pim_up_mlag_is_local(up
))
4928 strlcat(own_str
, "L", sizeof(own_str
));
4929 if (up
->flags
& (PIM_UPSTREAM_FLAG_MASK_MLAG_PEER
))
4930 strlcat(own_str
, "P", sizeof(own_str
));
4931 if (up
->flags
& (PIM_UPSTREAM_FLAG_MASK_MLAG_INTERFACE
))
4932 strlcat(own_str
, "I", sizeof(own_str
));
4934 "%-15s %-15s %-6s %-11u %-10u %2s\n",
4935 src_str
, grp_str
, own_str
,
4936 pim_up_mlag_local_cost(up
),
4937 pim_up_mlag_peer_cost(up
),
4938 PIM_UPSTREAM_FLAG_TEST_MLAG_NON_DF(up
->flags
)
4943 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
4944 json
, JSON_C_TO_STRING_PRETTY
));
4945 json_object_free(json
);
4949 static void pim_show_mlag_help_string(struct vty
*vty
, bool uj
)
4952 vty_out(vty
, "Owner codes:\n");
4954 "L: EVPN-MLAG Entry, I:PIM-MLAG Entry, "
4960 DEFUN(show_ip_pim_mlag_up
, show_ip_pim_mlag_up_cmd
,
4961 "show ip pim [vrf NAME] mlag upstream [A.B.C.D [A.B.C.D]] [json]",
4968 "Unicast or Multicast address\n"
4969 "Multicast address\n" JSON_STR
)
4971 const char *src_or_group
= NULL
;
4972 const char *group
= NULL
;
4974 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
4975 bool uj
= use_json(argc
, argv
);
4977 if (!vrf
|| !vrf
->info
) {
4978 vty_out(vty
, "%s: VRF or Info missing\n", __func__
);
4985 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
4986 src_or_group
= argv
[idx
]->arg
;
4988 group
= argv
[idx
+ 1]->arg
;
4991 pim_show_mlag_help_string(vty
, uj
);
4994 pim_show_mlag_up_detail(vrf
, vty
, src_or_group
, group
, uj
);
4996 pim_show_mlag_up_vrf(vrf
, vty
, uj
);
5002 DEFUN(show_ip_pim_mlag_up_vrf_all
, show_ip_pim_mlag_up_vrf_all_cmd
,
5003 "show ip pim vrf all mlag upstream [json]",
5004 SHOW_STR IP_STR PIM_STR VRF_CMD_HELP_STR
5006 "upstream\n" JSON_STR
)
5009 bool uj
= use_json(argc
, argv
);
5011 pim_show_mlag_help_string(vty
, uj
);
5012 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
5013 pim_show_mlag_up_vrf(vrf
, vty
, uj
);
5019 DEFUN (show_ip_pim_neighbor
,
5020 show_ip_pim_neighbor_cmd
,
5021 "show ip pim [vrf NAME] neighbor [detail|WORD] [json]",
5026 "PIM neighbor information\n"
5028 "Name of interface or neighbor\n"
5032 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
5033 bool uj
= use_json(argc
, argv
);
5038 if (argv_find(argv
, argc
, "detail", &idx
)
5039 || argv_find(argv
, argc
, "WORD", &idx
))
5040 pim_show_neighbors_single(vrf
->info
, vty
, argv
[idx
]->arg
, uj
);
5042 pim_show_neighbors(vrf
->info
, vty
, uj
);
5047 DEFUN (show_ip_pim_neighbor_vrf_all
,
5048 show_ip_pim_neighbor_vrf_all_cmd
,
5049 "show ip pim vrf all neighbor [detail|WORD] [json]",
5054 "PIM neighbor information\n"
5056 "Name of interface or neighbor\n"
5060 bool uj
= use_json(argc
, argv
);
5066 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
5070 vty_out(vty
, " \"%s\": ", vrf
->name
);
5073 vty_out(vty
, "VRF: %s\n", vrf
->name
);
5074 if (argv_find(argv
, argc
, "detail", &idx
)
5075 || argv_find(argv
, argc
, "WORD", &idx
))
5076 pim_show_neighbors_single(vrf
->info
, vty
,
5077 argv
[idx
]->arg
, uj
);
5079 pim_show_neighbors(vrf
->info
, vty
, uj
);
5082 vty_out(vty
, "}\n");
5087 DEFUN (show_ip_pim_secondary
,
5088 show_ip_pim_secondary_cmd
,
5089 "show ip pim [vrf NAME] secondary",
5094 "PIM neighbor addresses\n")
5097 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
5102 pim_show_neighbors_secondary(vrf
->info
, vty
);
5107 DEFUN (show_ip_pim_state
,
5108 show_ip_pim_state_cmd
,
5109 "show ip pim [vrf NAME] state [A.B.C.D [A.B.C.D]] [json]",
5114 "PIM state information\n"
5115 "Unicast or Multicast address\n"
5116 "Multicast address\n"
5119 const char *src_or_group
= NULL
;
5120 const char *group
= NULL
;
5122 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
5123 bool uj
= use_json(argc
, argv
);
5131 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
5132 src_or_group
= argv
[idx
]->arg
;
5134 group
= argv
[idx
+ 1]->arg
;
5137 pim_show_state(vrf
->info
, vty
, src_or_group
, group
, uj
);
5142 DEFUN (show_ip_pim_state_vrf_all
,
5143 show_ip_pim_state_vrf_all_cmd
,
5144 "show ip pim vrf all state [A.B.C.D [A.B.C.D]] [json]",
5149 "PIM state information\n"
5150 "Unicast or Multicast address\n"
5151 "Multicast address\n"
5154 const char *src_or_group
= NULL
;
5155 const char *group
= NULL
;
5157 bool uj
= use_json(argc
, argv
);
5166 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
5167 src_or_group
= argv
[idx
]->arg
;
5169 group
= argv
[idx
+ 1]->arg
;
5172 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
5176 vty_out(vty
, " \"%s\": ", vrf
->name
);
5179 vty_out(vty
, "VRF: %s\n", vrf
->name
);
5180 pim_show_state(vrf
->info
, vty
, src_or_group
, group
, uj
);
5183 vty_out(vty
, "}\n");
5188 DEFPY (show_ip_pim_upstream
,
5189 show_ip_pim_upstream_cmd
,
5190 "show ip pim [vrf NAME] upstream [A.B.C.D$s_or_g [A.B.C.D$g]] [json$json]",
5195 "PIM upstream information\n"
5196 "The Source or Group\n"
5200 struct prefix_sg sg
= {0};
5203 struct pim_instance
*pim
;
5205 v
= vrf_lookup_by_name(vrf
? vrf
: VRF_DEFAULT_NAME
);
5208 vty_out(vty
, "%% Vrf specified: %s does not exist\n", vrf
);
5211 pim
= pim_get_pim_instance(v
->vrf_id
);
5214 vty_out(vty
, "%% Unable to find pim instance\n");
5218 if (s_or_g
.s_addr
!= 0) {
5219 if (g
.s_addr
!= 0) {
5225 pim_show_upstream(pim
, vty
, &sg
, uj
);
5230 DEFUN (show_ip_pim_upstream_vrf_all
,
5231 show_ip_pim_upstream_vrf_all_cmd
,
5232 "show ip pim vrf all upstream [json]",
5237 "PIM upstream information\n"
5240 struct prefix_sg sg
= {0};
5241 bool uj
= use_json(argc
, argv
);
5247 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
5251 vty_out(vty
, " \"%s\": ", vrf
->name
);
5254 vty_out(vty
, "VRF: %s\n", vrf
->name
);
5255 pim_show_upstream(vrf
->info
, vty
, &sg
, uj
);
5261 DEFUN (show_ip_pim_channel
,
5262 show_ip_pim_channel_cmd
,
5263 "show ip pim [vrf NAME] channel [json]",
5268 "PIM downstream channel info\n"
5272 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
5273 bool uj
= use_json(argc
, argv
);
5278 pim_show_channel(vrf
->info
, vty
, uj
);
5283 DEFUN (show_ip_pim_upstream_join_desired
,
5284 show_ip_pim_upstream_join_desired_cmd
,
5285 "show ip pim [vrf NAME] upstream-join-desired [json]",
5290 "PIM upstream join-desired\n"
5294 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
5295 bool uj
= use_json(argc
, argv
);
5300 pim_show_join_desired(vrf
->info
, vty
, uj
);
5305 DEFUN (show_ip_pim_upstream_rpf
,
5306 show_ip_pim_upstream_rpf_cmd
,
5307 "show ip pim [vrf NAME] upstream-rpf [json]",
5312 "PIM upstream source rpf\n"
5316 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
5317 bool uj
= use_json(argc
, argv
);
5322 pim_show_upstream_rpf(vrf
->info
, vty
, uj
);
5327 DEFUN (show_ip_pim_rp
,
5329 "show ip pim [vrf NAME] rp-info [json]",
5334 "PIM RP information\n"
5338 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
5339 bool uj
= use_json(argc
, argv
);
5344 pim_rp_show_information(vrf
->info
, vty
, uj
);
5349 DEFUN (show_ip_pim_rp_vrf_all
,
5350 show_ip_pim_rp_vrf_all_cmd
,
5351 "show ip pim vrf all rp-info [json]",
5356 "PIM RP information\n"
5359 bool uj
= use_json(argc
, argv
);
5365 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
5369 vty_out(vty
, " \"%s\": ", vrf
->name
);
5372 vty_out(vty
, "VRF: %s\n", vrf
->name
);
5373 pim_rp_show_information(vrf
->info
, vty
, uj
);
5376 vty_out(vty
, "}\n");
5381 DEFUN (show_ip_pim_rpf
,
5382 show_ip_pim_rpf_cmd
,
5383 "show ip pim [vrf NAME] rpf [json]",
5388 "PIM cached source rpf information\n"
5392 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
5393 bool uj
= use_json(argc
, argv
);
5398 pim_show_rpf(vrf
->info
, vty
, uj
);
5403 DEFUN (show_ip_pim_rpf_vrf_all
,
5404 show_ip_pim_rpf_vrf_all_cmd
,
5405 "show ip pim vrf all rpf [json]",
5410 "PIM cached source rpf information\n"
5413 bool uj
= use_json(argc
, argv
);
5419 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
5423 vty_out(vty
, " \"%s\": ", vrf
->name
);
5426 vty_out(vty
, "VRF: %s\n", vrf
->name
);
5427 pim_show_rpf(vrf
->info
, vty
, uj
);
5430 vty_out(vty
, "}\n");
5435 DEFUN (show_ip_pim_nexthop
,
5436 show_ip_pim_nexthop_cmd
,
5437 "show ip pim [vrf NAME] nexthop",
5442 "PIM cached nexthop rpf information\n")
5445 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
5450 pim_show_nexthop(vrf
->info
, vty
);
5455 DEFUN (show_ip_pim_nexthop_lookup
,
5456 show_ip_pim_nexthop_lookup_cmd
,
5457 "show ip pim [vrf NAME] nexthop-lookup A.B.C.D A.B.C.D",
5462 "PIM cached nexthop rpf lookup\n"
5463 "Source/RP address\n"
5464 "Multicast Group address\n")
5466 struct prefix nht_p
;
5468 struct in_addr src_addr
, grp_addr
;
5469 struct in_addr vif_source
;
5470 const char *addr_str
, *addr_str1
;
5472 struct pim_nexthop nexthop
;
5473 char nexthop_addr_str
[PREFIX_STRLEN
];
5474 char grp_str
[PREFIX_STRLEN
];
5476 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
5481 argv_find(argv
, argc
, "A.B.C.D", &idx
);
5482 addr_str
= argv
[idx
]->arg
;
5483 result
= inet_pton(AF_INET
, addr_str
, &src_addr
);
5485 vty_out(vty
, "Bad unicast address %s: errno=%d: %s\n", addr_str
,
5486 errno
, safe_strerror(errno
));
5490 if (pim_is_group_224_4(src_addr
)) {
5492 "Invalid argument. Expected Valid Source Address.\n");
5496 addr_str1
= argv
[idx
+ 1]->arg
;
5497 result
= inet_pton(AF_INET
, addr_str1
, &grp_addr
);
5499 vty_out(vty
, "Bad unicast address %s: errno=%d: %s\n", addr_str
,
5500 errno
, safe_strerror(errno
));
5504 if (!pim_is_group_224_4(grp_addr
)) {
5506 "Invalid argument. Expected Valid Multicast Group Address.\n");
5510 if (!pim_rp_set_upstream_addr(vrf
->info
, &vif_source
, src_addr
,
5514 nht_p
.family
= AF_INET
;
5515 nht_p
.prefixlen
= IPV4_MAX_BITLEN
;
5516 nht_p
.u
.prefix4
= vif_source
;
5517 grp
.family
= AF_INET
;
5518 grp
.prefixlen
= IPV4_MAX_BITLEN
;
5519 grp
.u
.prefix4
= grp_addr
;
5520 memset(&nexthop
, 0, sizeof(nexthop
));
5522 result
= pim_ecmp_nexthop_lookup(vrf
->info
, &nexthop
, &nht_p
, &grp
, 0);
5526 "Nexthop Lookup failed, no usable routes returned.\n");
5530 pim_addr_dump("<grp?>", &grp
, grp_str
, sizeof(grp_str
));
5531 pim_addr_dump("<nexthop?>", &nexthop
.mrib_nexthop_addr
,
5532 nexthop_addr_str
, sizeof(nexthop_addr_str
));
5533 vty_out(vty
, "Group %s --- Nexthop %s Interface %s \n", grp_str
,
5534 nexthop_addr_str
, nexthop
.interface
->name
);
5539 DEFUN (show_ip_pim_interface_traffic
,
5540 show_ip_pim_interface_traffic_cmd
,
5541 "show ip pim [vrf NAME] interface traffic [WORD] [json]",
5546 "PIM interface information\n"
5547 "Protocol Packet counters\n"
5552 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
5553 bool uj
= use_json(argc
, argv
);
5558 if (argv_find(argv
, argc
, "WORD", &idx
))
5559 pim_show_interface_traffic_single(vrf
->info
, vty
,
5560 argv
[idx
]->arg
, uj
);
5562 pim_show_interface_traffic(vrf
->info
, vty
, uj
);
5567 DEFUN (show_ip_pim_bsm_db
,
5568 show_ip_pim_bsm_db_cmd
,
5569 "show ip pim bsm-database [vrf NAME] [json]",
5573 "PIM cached bsm packets information\n"
5578 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
5579 bool uj
= use_json(argc
, argv
);
5584 pim_show_bsm_db(vrf
->info
, vty
, uj
);
5588 DEFUN (show_ip_pim_bsrp
,
5589 show_ip_pim_bsrp_cmd
,
5590 "show ip pim bsrp-info [vrf NAME] [json]",
5594 "PIM cached group-rp mappings information\n"
5599 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
5600 bool uj
= use_json(argc
, argv
);
5605 pim_show_group_rp_mappings_info(vrf
->info
, vty
, uj
);
5610 DEFUN (show_ip_pim_statistics
,
5611 show_ip_pim_statistics_cmd
,
5612 "show ip pim [vrf NAME] statistics [interface WORD] [json]",
5623 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
5624 bool uj
= use_json(argc
, argv
);
5629 if (argv_find(argv
, argc
, "WORD", &idx
))
5630 pim_show_statistics(vrf
->info
, vty
, argv
[idx
]->arg
, uj
);
5632 pim_show_statistics(vrf
->info
, vty
, NULL
, uj
);
5637 static void show_multicast_interfaces(struct pim_instance
*pim
, struct vty
*vty
)
5639 struct interface
*ifp
;
5644 "Interface Address ifi Vif PktsIn PktsOut BytesIn BytesOut\n");
5646 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
5647 struct pim_interface
*pim_ifp
;
5648 struct in_addr ifaddr
;
5649 struct sioc_vif_req vreq
;
5651 pim_ifp
= ifp
->info
;
5656 memset(&vreq
, 0, sizeof(vreq
));
5657 vreq
.vifi
= pim_ifp
->mroute_vif_index
;
5659 if (ioctl(pim
->mroute_socket
, SIOCGETVIFCNT
, &vreq
)) {
5661 "ioctl(SIOCGETVIFCNT=%lu) failure for interface %s vif_index=%d: errno=%d: %s",
5662 (unsigned long)SIOCGETVIFCNT
, ifp
->name
,
5663 pim_ifp
->mroute_vif_index
, errno
,
5664 safe_strerror(errno
));
5667 ifaddr
= pim_ifp
->primary_address
;
5669 vty_out(vty
, "%-16s %-15s %3d %3d %7lu %7lu %10lu %10lu\n",
5670 ifp
->name
, inet_ntoa(ifaddr
), ifp
->ifindex
,
5671 pim_ifp
->mroute_vif_index
, (unsigned long)vreq
.icount
,
5672 (unsigned long)vreq
.ocount
, (unsigned long)vreq
.ibytes
,
5673 (unsigned long)vreq
.obytes
);
5677 static void pim_cmd_show_ip_multicast_helper(struct pim_instance
*pim
,
5680 struct vrf
*vrf
= pim
->vrf
;
5681 time_t now
= pim_time_monotonic_sec();
5687 vty_out(vty
, "Router MLAG Role: %s\n",
5688 mlag_role2str(router
->mlag_role
, mlag_role
, sizeof(mlag_role
)));
5689 vty_out(vty
, "Mroute socket descriptor:");
5691 vty_out(vty
, " %d(%s)\n", pim
->mroute_socket
, vrf
->name
);
5693 pim_time_uptime(uptime
, sizeof(uptime
),
5694 now
- pim
->mroute_socket_creation
);
5695 vty_out(vty
, "Mroute socket uptime: %s\n", uptime
);
5699 pim_zebra_zclient_update(vty
);
5700 pim_zlookup_show_ip_multicast(vty
);
5703 vty_out(vty
, "Maximum highest VifIndex: %d\n", PIM_MAX_USABLE_VIFS
);
5706 vty_out(vty
, "Upstream Join Timer: %d secs\n", router
->t_periodic
);
5707 vty_out(vty
, "Join/Prune Holdtime: %d secs\n", PIM_JP_HOLDTIME
);
5708 vty_out(vty
, "PIM ECMP: %s\n", pim
->ecmp_enable
? "Enable" : "Disable");
5709 vty_out(vty
, "PIM ECMP Rebalance: %s\n",
5710 pim
->ecmp_rebalance_enable
? "Enable" : "Disable");
5714 show_rpf_refresh_stats(vty
, pim
, now
, NULL
);
5718 show_scan_oil_stats(pim
, vty
, now
);
5720 show_multicast_interfaces(pim
, vty
);
5723 DEFUN (show_ip_multicast
,
5724 show_ip_multicast_cmd
,
5725 "show ip multicast [vrf NAME]",
5729 "Multicast global information\n")
5732 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
5737 pim_cmd_show_ip_multicast_helper(vrf
->info
, vty
);
5742 DEFUN (show_ip_multicast_vrf_all
,
5743 show_ip_multicast_vrf_all_cmd
,
5744 "show ip multicast vrf all",
5748 "Multicast global information\n")
5750 bool uj
= use_json(argc
, argv
);
5756 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
5760 vty_out(vty
, " \"%s\": ", vrf
->name
);
5763 vty_out(vty
, "VRF: %s\n", vrf
->name
);
5764 pim_cmd_show_ip_multicast_helper(vrf
->info
, vty
);
5767 vty_out(vty
, "}\n");
5772 static void show_mroute(struct pim_instance
*pim
, struct vty
*vty
,
5773 struct prefix_sg
*sg
, bool fill
, bool uj
)
5775 struct listnode
*node
;
5776 struct channel_oil
*c_oil
;
5777 struct static_route
*s_route
;
5779 json_object
*json
= NULL
;
5780 json_object
*json_group
= NULL
;
5781 json_object
*json_source
= NULL
;
5782 json_object
*json_oil
= NULL
;
5783 json_object
*json_ifp_out
= NULL
;
5786 char grp_str
[INET_ADDRSTRLEN
];
5787 char src_str
[INET_ADDRSTRLEN
];
5788 char in_ifname
[INTERFACE_NAMSIZ
+ 1];
5789 char out_ifname
[INTERFACE_NAMSIZ
+ 1];
5791 struct interface
*ifp_in
;
5793 char mroute_uptime
[10];
5796 json
= json_object_new_object();
5799 "Source Group Proto Input Output TTL Uptime\n");
5802 now
= pim_time_monotonic_sec();
5804 /* print list of PIM and IGMP routes */
5805 frr_each (rb_pim_oil
, &pim
->channel_oil_head
, c_oil
) {
5808 if (!c_oil
->installed
&& !uj
)
5811 if (sg
->grp
.s_addr
!= 0 &&
5812 sg
->grp
.s_addr
!= c_oil
->oil
.mfcc_mcastgrp
.s_addr
)
5814 if (sg
->src
.s_addr
!= 0 &&
5815 sg
->src
.s_addr
!= c_oil
->oil
.mfcc_origin
.s_addr
)
5818 pim_inet4_dump("<group?>", c_oil
->oil
.mfcc_mcastgrp
, grp_str
,
5820 pim_inet4_dump("<source?>", c_oil
->oil
.mfcc_origin
, src_str
,
5822 ifp_in
= pim_if_find_by_vif_index(pim
, c_oil
->oil
.mfcc_parent
);
5825 strlcpy(in_ifname
, ifp_in
->name
, sizeof(in_ifname
));
5827 strlcpy(in_ifname
, "<iif?>", sizeof(in_ifname
));
5830 pim_time_uptime(mroute_uptime
, sizeof(mroute_uptime
),
5831 now
- c_oil
->mroute_creation
);
5835 /* Find the group, create it if it doesn't exist */
5836 json_object_object_get_ex(json
, grp_str
, &json_group
);
5839 json_group
= json_object_new_object();
5840 json_object_object_add(json
, grp_str
,
5844 /* Find the source nested under the group, create it if
5845 * it doesn't exist */
5846 json_object_object_get_ex(json_group
, src_str
,
5850 json_source
= json_object_new_object();
5851 json_object_object_add(json_group
, src_str
,
5855 /* Find the inbound interface nested under the source,
5856 * create it if it doesn't exist */
5857 json_object_int_add(json_source
, "installed",
5859 json_object_int_add(json_source
, "refCount",
5860 c_oil
->oil_ref_count
);
5861 json_object_int_add(json_source
, "oilSize",
5863 json_object_int_add(json_source
, "OilInheritedRescan",
5864 c_oil
->oil_inherited_rescan
);
5865 json_object_string_add(json_source
, "iif", in_ifname
);
5866 json_object_string_add(json_source
, "upTime",
5871 for (oif_vif_index
= 0; oif_vif_index
< MAXVIFS
;
5873 struct interface
*ifp_out
;
5876 ttl
= c_oil
->oil
.mfcc_ttls
[oif_vif_index
];
5880 /* do not display muted OIFs */
5881 if (c_oil
->oif_flags
[oif_vif_index
]
5882 & PIM_OIF_FLAG_MUTE
)
5885 if (c_oil
->oil
.mfcc_parent
== oif_vif_index
&&
5886 !pim_mroute_allow_iif_in_oil(c_oil
,
5890 ifp_out
= pim_if_find_by_vif_index(pim
, oif_vif_index
);
5894 strlcpy(out_ifname
, ifp_out
->name
, sizeof(out_ifname
));
5896 strlcpy(out_ifname
, "<oif?>", sizeof(out_ifname
));
5899 json_ifp_out
= json_object_new_object();
5900 json_object_string_add(json_ifp_out
, "source",
5902 json_object_string_add(json_ifp_out
, "group",
5905 if (c_oil
->oif_flags
[oif_vif_index
]
5906 & PIM_OIF_FLAG_PROTO_PIM
)
5907 json_object_boolean_true_add(
5908 json_ifp_out
, "protocolPim");
5910 if (c_oil
->oif_flags
[oif_vif_index
]
5911 & PIM_OIF_FLAG_PROTO_IGMP
)
5912 json_object_boolean_true_add(
5913 json_ifp_out
, "protocolIgmp");
5915 if (c_oil
->oif_flags
[oif_vif_index
]
5916 & PIM_OIF_FLAG_PROTO_VXLAN
)
5917 json_object_boolean_true_add(
5918 json_ifp_out
, "protocolVxlan");
5920 if (c_oil
->oif_flags
[oif_vif_index
]
5921 & PIM_OIF_FLAG_PROTO_STAR
)
5922 json_object_boolean_true_add(
5924 "protocolInherited");
5926 json_object_string_add(json_ifp_out
,
5929 json_object_int_add(json_ifp_out
, "iVifI",
5930 c_oil
->oil
.mfcc_parent
);
5931 json_object_string_add(json_ifp_out
,
5932 "outboundInterface",
5934 json_object_int_add(json_ifp_out
, "oVifI",
5936 json_object_int_add(json_ifp_out
, "ttl", ttl
);
5937 json_object_string_add(json_ifp_out
, "upTime",
5940 json_oil
= json_object_new_object();
5941 json_object_object_add(json_source
,
5944 json_object_object_add(json_oil
, out_ifname
,
5947 if (c_oil
->oif_flags
[oif_vif_index
]
5948 & PIM_OIF_FLAG_PROTO_PIM
) {
5949 strlcpy(proto
, "PIM", sizeof(proto
));
5952 if (c_oil
->oif_flags
[oif_vif_index
]
5953 & PIM_OIF_FLAG_PROTO_IGMP
) {
5954 strlcpy(proto
, "IGMP", sizeof(proto
));
5957 if (c_oil
->oif_flags
[oif_vif_index
]
5958 & PIM_OIF_FLAG_PROTO_VXLAN
) {
5959 strlcpy(proto
, "VxLAN", sizeof(proto
));
5962 if (c_oil
->oif_flags
[oif_vif_index
]
5963 & PIM_OIF_FLAG_PROTO_STAR
) {
5964 strlcpy(proto
, "STAR", sizeof(proto
));
5968 "%-15s %-15s %-6s %-16s %-16s %-3d %8s\n",
5969 src_str
, grp_str
, proto
, in_ifname
,
5970 out_ifname
, ttl
, mroute_uptime
);
5975 in_ifname
[0] = '\0';
5976 mroute_uptime
[0] = '\0';
5982 if (!uj
&& !found_oif
) {
5983 vty_out(vty
, "%-15s %-15s %-6s %-16s %-16s %-3d %8s\n",
5984 src_str
, grp_str
, "none", in_ifname
, "none", 0,
5989 /* Print list of static routes */
5990 for (ALL_LIST_ELEMENTS_RO(pim
->static_routes
, node
, s_route
)) {
5993 if (!s_route
->c_oil
.installed
)
5996 pim_inet4_dump("<group?>", s_route
->group
, grp_str
,
5998 pim_inet4_dump("<source?>", s_route
->source
, src_str
,
6000 ifp_in
= pim_if_find_by_vif_index(pim
, s_route
->iif
);
6004 strlcpy(in_ifname
, ifp_in
->name
, sizeof(in_ifname
));
6006 strlcpy(in_ifname
, "<iif?>", sizeof(in_ifname
));
6010 /* Find the group, create it if it doesn't exist */
6011 json_object_object_get_ex(json
, grp_str
, &json_group
);
6014 json_group
= json_object_new_object();
6015 json_object_object_add(json
, grp_str
,
6019 /* Find the source nested under the group, create it if
6020 * it doesn't exist */
6021 json_object_object_get_ex(json_group
, src_str
,
6025 json_source
= json_object_new_object();
6026 json_object_object_add(json_group
, src_str
,
6030 json_object_string_add(json_source
, "iif", in_ifname
);
6033 strlcpy(proto
, "STATIC", sizeof(proto
));
6036 for (oif_vif_index
= 0; oif_vif_index
< MAXVIFS
;
6038 struct interface
*ifp_out
;
6039 char oif_uptime
[10];
6042 ttl
= s_route
->oif_ttls
[oif_vif_index
];
6046 ifp_out
= pim_if_find_by_vif_index(pim
, oif_vif_index
);
6048 oif_uptime
, sizeof(oif_uptime
),
6051 .oif_creation
[oif_vif_index
]);
6055 strlcpy(out_ifname
, ifp_out
->name
, sizeof(out_ifname
));
6057 strlcpy(out_ifname
, "<oif?>", sizeof(out_ifname
));
6060 json_ifp_out
= json_object_new_object();
6061 json_object_string_add(json_ifp_out
, "source",
6063 json_object_string_add(json_ifp_out
, "group",
6065 json_object_boolean_true_add(json_ifp_out
,
6067 json_object_string_add(json_ifp_out
,
6070 json_object_int_add(
6071 json_ifp_out
, "iVifI",
6072 s_route
->c_oil
.oil
.mfcc_parent
);
6073 json_object_string_add(json_ifp_out
,
6074 "outboundInterface",
6076 json_object_int_add(json_ifp_out
, "oVifI",
6078 json_object_int_add(json_ifp_out
, "ttl", ttl
);
6079 json_object_string_add(json_ifp_out
, "upTime",
6082 json_oil
= json_object_new_object();
6083 json_object_object_add(json_source
,
6086 json_object_object_add(json_oil
, out_ifname
,
6090 "%-15s %-15s %-6s %-16s %-16s %-3d %8s %s\n",
6091 src_str
, grp_str
, proto
, in_ifname
,
6092 out_ifname
, ttl
, oif_uptime
,
6094 if (first
&& !fill
) {
6097 in_ifname
[0] = '\0';
6103 if (!uj
&& !found_oif
) {
6105 "%-15s %-15s %-6s %-16s %-16s %-3d %8s %s\n",
6106 src_str
, grp_str
, proto
, in_ifname
, "none", 0,
6107 "--:--:--", pim
->vrf
->name
);
6112 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
6113 json
, JSON_C_TO_STRING_PRETTY
));
6114 json_object_free(json
);
6118 DEFPY (show_ip_mroute
,
6120 "show ip mroute [vrf NAME] [A.B.C.D$s_or_g [A.B.C.D$g]] [fill$fill] [json$json]",
6125 "The Source or Group\n"
6127 "Fill in Assumed data\n"
6130 struct prefix_sg sg
= {0};
6131 struct pim_instance
*pim
;
6134 v
= vrf_lookup_by_name(vrf
? vrf
: VRF_DEFAULT_NAME
);
6137 vty_out(vty
, "%% Vrf specified: %s does not exist\n", vrf
);
6140 pim
= pim_get_pim_instance(v
->vrf_id
);
6143 vty_out(vty
, "%% Unable to find pim instance\n");
6147 if (s_or_g
.s_addr
!= 0) {
6148 if (g
.s_addr
!= 0) {
6154 show_mroute(pim
, vty
, &sg
, !!fill
, !!json
);
6158 DEFUN (show_ip_mroute_vrf_all
,
6159 show_ip_mroute_vrf_all_cmd
,
6160 "show ip mroute vrf all [fill] [json]",
6165 "Fill in Assumed data\n"
6168 struct prefix_sg sg
= {0};
6169 bool uj
= use_json(argc
, argv
);
6175 if (argv_find(argv
, argc
, "fill", &idx
))
6180 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
6184 vty_out(vty
, " \"%s\": ", vrf
->name
);
6187 vty_out(vty
, "VRF: %s\n", vrf
->name
);
6188 show_mroute(vrf
->info
, vty
, &sg
, fill
, uj
);
6191 vty_out(vty
, "}\n");
6196 DEFUN (clear_ip_mroute_count
,
6197 clear_ip_mroute_count_cmd
,
6198 "clear ip mroute [vrf NAME] count",
6203 "Route and packet count data\n")
6206 struct listnode
*node
;
6207 struct channel_oil
*c_oil
;
6208 struct static_route
*sr
;
6209 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
6210 struct pim_instance
*pim
;
6216 frr_each(rb_pim_oil
, &pim
->channel_oil_head
, c_oil
) {
6217 if (!c_oil
->installed
)
6220 pim_mroute_update_counters(c_oil
);
6221 c_oil
->cc
.origpktcnt
= c_oil
->cc
.pktcnt
;
6222 c_oil
->cc
.origbytecnt
= c_oil
->cc
.bytecnt
;
6223 c_oil
->cc
.origwrong_if
= c_oil
->cc
.wrong_if
;
6226 for (ALL_LIST_ELEMENTS_RO(pim
->static_routes
, node
, sr
)) {
6227 if (!sr
->c_oil
.installed
)
6230 pim_mroute_update_counters(&sr
->c_oil
);
6232 sr
->c_oil
.cc
.origpktcnt
= sr
->c_oil
.cc
.pktcnt
;
6233 sr
->c_oil
.cc
.origbytecnt
= sr
->c_oil
.cc
.bytecnt
;
6234 sr
->c_oil
.cc
.origwrong_if
= sr
->c_oil
.cc
.wrong_if
;
6239 static void show_mroute_count(struct pim_instance
*pim
, struct vty
*vty
)
6241 struct listnode
*node
;
6242 struct channel_oil
*c_oil
;
6243 struct static_route
*sr
;
6248 "Source Group LastUsed Packets Bytes WrongIf \n");
6250 /* Print PIM and IGMP route counts */
6251 frr_each (rb_pim_oil
, &pim
->channel_oil_head
, c_oil
) {
6252 char group_str
[INET_ADDRSTRLEN
];
6253 char source_str
[INET_ADDRSTRLEN
];
6255 if (!c_oil
->installed
)
6258 pim_mroute_update_counters(c_oil
);
6260 pim_inet4_dump("<group?>", c_oil
->oil
.mfcc_mcastgrp
, group_str
,
6262 pim_inet4_dump("<source?>", c_oil
->oil
.mfcc_origin
, source_str
,
6263 sizeof(source_str
));
6265 vty_out(vty
, "%-15s %-15s %-8llu %-7ld %-10ld %-7ld\n",
6266 source_str
, group_str
, c_oil
->cc
.lastused
/ 100,
6267 c_oil
->cc
.pktcnt
- c_oil
->cc
.origpktcnt
,
6268 c_oil
->cc
.bytecnt
- c_oil
->cc
.origbytecnt
,
6269 c_oil
->cc
.wrong_if
- c_oil
->cc
.origwrong_if
);
6272 for (ALL_LIST_ELEMENTS_RO(pim
->static_routes
, node
, sr
)) {
6273 char group_str
[INET_ADDRSTRLEN
];
6274 char source_str
[INET_ADDRSTRLEN
];
6276 if (!sr
->c_oil
.installed
)
6279 pim_mroute_update_counters(&sr
->c_oil
);
6281 pim_inet4_dump("<group?>", sr
->c_oil
.oil
.mfcc_mcastgrp
,
6282 group_str
, sizeof(group_str
));
6283 pim_inet4_dump("<source?>", sr
->c_oil
.oil
.mfcc_origin
,
6284 source_str
, sizeof(source_str
));
6286 vty_out(vty
, "%-15s %-15s %-8llu %-7ld %-10ld %-7ld\n",
6287 source_str
, group_str
, sr
->c_oil
.cc
.lastused
,
6288 sr
->c_oil
.cc
.pktcnt
- sr
->c_oil
.cc
.origpktcnt
,
6289 sr
->c_oil
.cc
.bytecnt
- sr
->c_oil
.cc
.origbytecnt
,
6290 sr
->c_oil
.cc
.wrong_if
- sr
->c_oil
.cc
.origwrong_if
);
6294 DEFUN (show_ip_mroute_count
,
6295 show_ip_mroute_count_cmd
,
6296 "show ip mroute [vrf NAME] count",
6301 "Route and packet count data\n")
6304 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
6309 show_mroute_count(vrf
->info
, vty
);
6313 DEFUN (show_ip_mroute_count_vrf_all
,
6314 show_ip_mroute_count_vrf_all_cmd
,
6315 "show ip mroute vrf all count",
6320 "Route and packet count data\n")
6322 bool uj
= use_json(argc
, argv
);
6328 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
6332 vty_out(vty
, " \"%s\": ", vrf
->name
);
6335 vty_out(vty
, "VRF: %s\n", vrf
->name
);
6336 show_mroute_count(vrf
->info
, vty
);
6339 vty_out(vty
, "}\n");
6344 static void show_mroute_summary(struct pim_instance
*pim
, struct vty
*vty
)
6346 struct listnode
*node
;
6347 struct channel_oil
*c_oil
;
6348 struct static_route
*s_route
;
6349 uint32_t starg_sw_mroute_cnt
= 0;
6350 uint32_t sg_sw_mroute_cnt
= 0;
6351 uint32_t starg_hw_mroute_cnt
= 0;
6352 uint32_t sg_hw_mroute_cnt
= 0;
6354 vty_out(vty
, "Mroute Type Installed/Total\n");
6356 frr_each (rb_pim_oil
, &pim
->channel_oil_head
, c_oil
) {
6357 if (!c_oil
->installed
) {
6358 if (c_oil
->oil
.mfcc_origin
.s_addr
== INADDR_ANY
)
6359 starg_sw_mroute_cnt
++;
6363 if (c_oil
->oil
.mfcc_origin
.s_addr
== INADDR_ANY
)
6364 starg_hw_mroute_cnt
++;
6370 for (ALL_LIST_ELEMENTS_RO(pim
->static_routes
, node
, s_route
)) {
6371 if (!s_route
->c_oil
.installed
) {
6372 if (s_route
->c_oil
.oil
.mfcc_origin
.s_addr
== INADDR_ANY
)
6373 starg_sw_mroute_cnt
++;
6377 if (s_route
->c_oil
.oil
.mfcc_origin
.s_addr
== INADDR_ANY
)
6378 starg_hw_mroute_cnt
++;
6384 vty_out(vty
, "%-20s %d/%d\n", "(*, G)", starg_hw_mroute_cnt
,
6385 starg_sw_mroute_cnt
+ starg_hw_mroute_cnt
);
6386 vty_out(vty
, "%-20s %d/%d\n", "(S, G)", sg_hw_mroute_cnt
,
6387 sg_sw_mroute_cnt
+ sg_hw_mroute_cnt
);
6388 vty_out(vty
, "------\n");
6389 vty_out(vty
, "%-20s %d/%d\n", "Total",
6390 (starg_hw_mroute_cnt
+ sg_hw_mroute_cnt
),
6391 (starg_sw_mroute_cnt
+
6392 starg_hw_mroute_cnt
+
6397 DEFUN (show_ip_mroute_summary
,
6398 show_ip_mroute_summary_cmd
,
6399 "show ip mroute [vrf NAME] summary",
6404 "Summary of all mroutes\n")
6407 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
6412 show_mroute_summary(vrf
->info
, vty
);
6416 DEFUN (show_ip_mroute_summary_vrf_all
,
6417 show_ip_mroute_summary_vrf_all_cmd
,
6418 "show ip mroute vrf all summary",
6423 "Summary of all mroutes\n")
6427 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
6428 vty_out(vty
, "VRF: %s\n", vrf
->name
);
6429 show_mroute_summary(vrf
->info
, vty
);
6437 "show ip rib [vrf NAME] A.B.C.D",
6442 "Unicast address\n")
6445 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
6446 struct in_addr addr
;
6447 const char *addr_str
;
6448 struct pim_nexthop nexthop
;
6449 char nexthop_addr_str
[PREFIX_STRLEN
];
6455 memset(&nexthop
, 0, sizeof(nexthop
));
6456 argv_find(argv
, argc
, "A.B.C.D", &idx
);
6457 addr_str
= argv
[idx
]->arg
;
6458 result
= inet_pton(AF_INET
, addr_str
, &addr
);
6460 vty_out(vty
, "Bad unicast address %s: errno=%d: %s\n", addr_str
,
6461 errno
, safe_strerror(errno
));
6465 if (!pim_nexthop_lookup(vrf
->info
, &nexthop
, addr
, 0)) {
6467 "Failure querying RIB nexthop for unicast address %s\n",
6473 "Address NextHop Interface Metric Preference\n");
6475 pim_addr_dump("<nexthop?>", &nexthop
.mrib_nexthop_addr
,
6476 nexthop_addr_str
, sizeof(nexthop_addr_str
));
6478 vty_out(vty
, "%-15s %-15s %-9s %6d %10d\n", addr_str
, nexthop_addr_str
,
6479 nexthop
.interface
? nexthop
.interface
->name
: "<ifname?>",
6480 nexthop
.mrib_route_metric
, nexthop
.mrib_metric_preference
);
6485 static void show_ssmpingd(struct pim_instance
*pim
, struct vty
*vty
)
6487 struct listnode
*node
;
6488 struct ssmpingd_sock
*ss
;
6492 "Source Socket Address Port Uptime Requests\n");
6494 if (!pim
->ssmpingd_list
)
6497 now
= pim_time_monotonic_sec();
6499 for (ALL_LIST_ELEMENTS_RO(pim
->ssmpingd_list
, node
, ss
)) {
6500 char source_str
[INET_ADDRSTRLEN
];
6502 struct sockaddr_in bind_addr
;
6503 socklen_t len
= sizeof(bind_addr
);
6504 char bind_addr_str
[INET_ADDRSTRLEN
];
6506 pim_inet4_dump("<src?>", ss
->source_addr
, source_str
,
6507 sizeof(source_str
));
6509 if (pim_socket_getsockname(
6510 ss
->sock_fd
, (struct sockaddr
*)&bind_addr
, &len
)) {
6512 "%% Failure reading socket name for ssmpingd source %s on fd=%d\n",
6513 source_str
, ss
->sock_fd
);
6516 pim_inet4_dump("<addr?>", bind_addr
.sin_addr
, bind_addr_str
,
6517 sizeof(bind_addr_str
));
6518 pim_time_uptime(ss_uptime
, sizeof(ss_uptime
),
6519 now
- ss
->creation
);
6521 vty_out(vty
, "%-15s %6d %-15s %5d %8s %8lld\n", source_str
,
6522 ss
->sock_fd
, bind_addr_str
, ntohs(bind_addr
.sin_port
),
6523 ss_uptime
, (long long)ss
->requests
);
6527 DEFUN (show_ip_ssmpingd
,
6528 show_ip_ssmpingd_cmd
,
6529 "show ip ssmpingd [vrf NAME]",
6536 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
6541 show_ssmpingd(vrf
->info
, vty
);
6545 static int pim_rp_cmd_worker(struct pim_instance
*pim
, struct vty
*vty
,
6546 const char *rp
, const char *group
,
6551 result
= pim_rp_new_config(pim
, rp
, group
, plist
);
6553 if (result
== PIM_GROUP_BAD_ADDR_MASK_COMBO
) {
6554 vty_out(vty
, "%% Inconsistent address and mask: %s\n",
6556 return CMD_WARNING_CONFIG_FAILED
;
6559 if (result
== PIM_GROUP_BAD_ADDRESS
) {
6560 vty_out(vty
, "%% Bad group address specified: %s\n", group
);
6561 return CMD_WARNING_CONFIG_FAILED
;
6564 if (result
== PIM_RP_BAD_ADDRESS
) {
6565 vty_out(vty
, "%% Bad RP address specified: %s\n", rp
);
6566 return CMD_WARNING_CONFIG_FAILED
;
6569 if (result
== PIM_RP_NO_PATH
) {
6570 vty_out(vty
, "%% No Path to RP address specified: %s\n", rp
);
6574 if (result
== PIM_GROUP_OVERLAP
) {
6576 "%% Group range specified cannot exact match another\n");
6577 return CMD_WARNING_CONFIG_FAILED
;
6580 if (result
== PIM_GROUP_PFXLIST_OVERLAP
) {
6582 "%% This group is already covered by a RP prefix-list\n");
6583 return CMD_WARNING_CONFIG_FAILED
;
6586 if (result
== PIM_RP_PFXLIST_IN_USE
) {
6588 "%% The same prefix-list cannot be applied to multiple RPs\n");
6589 return CMD_WARNING_CONFIG_FAILED
;
6595 static int pim_cmd_spt_switchover(struct pim_instance
*pim
,
6596 enum pim_spt_switchover spt
,
6599 pim
->spt
.switchover
= spt
;
6601 switch (pim
->spt
.switchover
) {
6602 case PIM_SPT_IMMEDIATE
:
6603 XFREE(MTYPE_PIM_SPT_PLIST_NAME
, pim
->spt
.plist
);
6605 pim_upstream_add_lhr_star_pimreg(pim
);
6607 case PIM_SPT_INFINITY
:
6608 pim_upstream_remove_lhr_star_pimreg(pim
, plist
);
6610 XFREE(MTYPE_PIM_SPT_PLIST_NAME
, pim
->spt
.plist
);
6614 XSTRDUP(MTYPE_PIM_SPT_PLIST_NAME
, plist
);
6621 DEFUN (ip_pim_spt_switchover_infinity
,
6622 ip_pim_spt_switchover_infinity_cmd
,
6623 "ip pim spt-switchover infinity-and-beyond",
6627 "Never switch to SPT Tree\n")
6629 PIM_DECLVAR_CONTEXT(vrf
, pim
);
6630 return pim_cmd_spt_switchover(pim
, PIM_SPT_INFINITY
, NULL
);
6633 DEFUN (ip_pim_spt_switchover_infinity_plist
,
6634 ip_pim_spt_switchover_infinity_plist_cmd
,
6635 "ip pim spt-switchover infinity-and-beyond prefix-list WORD",
6639 "Never switch to SPT Tree\n"
6640 "Prefix-List to control which groups to switch\n"
6641 "Prefix-List name\n")
6643 PIM_DECLVAR_CONTEXT(vrf
, pim
);
6644 return pim_cmd_spt_switchover(pim
, PIM_SPT_INFINITY
, argv
[5]->arg
);
6647 DEFUN (no_ip_pim_spt_switchover_infinity
,
6648 no_ip_pim_spt_switchover_infinity_cmd
,
6649 "no ip pim spt-switchover infinity-and-beyond",
6654 "Never switch to SPT Tree\n")
6656 PIM_DECLVAR_CONTEXT(vrf
, pim
);
6657 return pim_cmd_spt_switchover(pim
, PIM_SPT_IMMEDIATE
, NULL
);
6660 DEFUN (no_ip_pim_spt_switchover_infinity_plist
,
6661 no_ip_pim_spt_switchover_infinity_plist_cmd
,
6662 "no ip pim spt-switchover infinity-and-beyond prefix-list WORD",
6667 "Never switch to SPT Tree\n"
6668 "Prefix-List to control which groups to switch\n"
6669 "Prefix-List name\n")
6671 PIM_DECLVAR_CONTEXT(vrf
, pim
);
6672 return pim_cmd_spt_switchover(pim
, PIM_SPT_IMMEDIATE
, NULL
);
6675 DEFUN (ip_pim_joinprune_time
,
6676 ip_pim_joinprune_time_cmd
,
6677 "ip pim join-prune-interval (60-600)",
6679 "pim multicast routing\n"
6680 "Join Prune Send Interval\n"
6683 PIM_DECLVAR_CONTEXT(vrf
, pim
);
6684 router
->t_periodic
= atoi(argv
[3]->arg
);
6688 DEFUN (no_ip_pim_joinprune_time
,
6689 no_ip_pim_joinprune_time_cmd
,
6690 "no ip pim join-prune-interval (60-600)",
6693 "pim multicast routing\n"
6694 "Join Prune Send Interval\n"
6697 PIM_DECLVAR_CONTEXT(vrf
, pim
);
6698 router
->t_periodic
= PIM_DEFAULT_T_PERIODIC
;
6702 DEFUN (ip_pim_register_suppress
,
6703 ip_pim_register_suppress_cmd
,
6704 "ip pim register-suppress-time (5-60000)",
6706 "pim multicast routing\n"
6707 "Register Suppress Timer\n"
6710 PIM_DECLVAR_CONTEXT(vrf
, pim
);
6711 router
->register_suppress_time
= atoi(argv
[3]->arg
);
6715 DEFUN (no_ip_pim_register_suppress
,
6716 no_ip_pim_register_suppress_cmd
,
6717 "no ip pim register-suppress-time (5-60000)",
6720 "pim multicast routing\n"
6721 "Register Suppress Timer\n"
6724 PIM_DECLVAR_CONTEXT(vrf
, pim
);
6725 router
->register_suppress_time
= PIM_REGISTER_SUPPRESSION_TIME_DEFAULT
;
6729 DEFUN (ip_pim_rp_keep_alive
,
6730 ip_pim_rp_keep_alive_cmd
,
6731 "ip pim rp keep-alive-timer (31-60000)",
6733 "pim multicast routing\n"
6735 "Keep alive Timer\n"
6738 PIM_DECLVAR_CONTEXT(vrf
, pim
);
6739 pim
->rp_keep_alive_time
= atoi(argv
[4]->arg
);
6743 DEFUN (no_ip_pim_rp_keep_alive
,
6744 no_ip_pim_rp_keep_alive_cmd
,
6745 "no ip pim rp keep-alive-timer (31-60000)",
6748 "pim multicast routing\n"
6750 "Keep alive Timer\n"
6753 PIM_DECLVAR_CONTEXT(vrf
, pim
);
6754 pim
->rp_keep_alive_time
= PIM_KEEPALIVE_PERIOD
;
6758 DEFUN (ip_pim_keep_alive
,
6759 ip_pim_keep_alive_cmd
,
6760 "ip pim keep-alive-timer (31-60000)",
6762 "pim multicast routing\n"
6763 "Keep alive Timer\n"
6766 PIM_DECLVAR_CONTEXT(vrf
, pim
);
6767 pim
->keep_alive_time
= atoi(argv
[3]->arg
);
6771 DEFUN (no_ip_pim_keep_alive
,
6772 no_ip_pim_keep_alive_cmd
,
6773 "no ip pim keep-alive-timer (31-60000)",
6776 "pim multicast routing\n"
6777 "Keep alive Timer\n"
6780 PIM_DECLVAR_CONTEXT(vrf
, pim
);
6781 pim
->keep_alive_time
= PIM_KEEPALIVE_PERIOD
;
6785 DEFUN (ip_pim_packets
,
6787 "ip pim packets (1-100)",
6789 "pim multicast routing\n"
6790 "packets to process at one time per fd\n"
6791 "Number of packets\n")
6793 PIM_DECLVAR_CONTEXT(vrf
, pim
);
6794 router
->packet_process
= atoi(argv
[3]->arg
);
6798 DEFUN (no_ip_pim_packets
,
6799 no_ip_pim_packets_cmd
,
6800 "no ip pim packets (1-100)",
6803 "pim multicast routing\n"
6804 "packets to process at one time per fd\n"
6805 "Number of packets\n")
6807 PIM_DECLVAR_CONTEXT(vrf
, pim
);
6808 router
->packet_process
= PIM_DEFAULT_PACKET_PROCESS
;
6812 DEFUN (ip_pim_v6_secondary
,
6813 ip_pim_v6_secondary_cmd
,
6814 "ip pim send-v6-secondary",
6816 "pim multicast routing\n"
6817 "Send v6 secondary addresses\n")
6819 PIM_DECLVAR_CONTEXT(vrf
, pim
);
6820 pim
->send_v6_secondary
= 1;
6825 DEFUN (no_ip_pim_v6_secondary
,
6826 no_ip_pim_v6_secondary_cmd
,
6827 "no ip pim send-v6-secondary",
6830 "pim multicast routing\n"
6831 "Send v6 secondary addresses\n")
6833 PIM_DECLVAR_CONTEXT(vrf
, pim
);
6834 pim
->send_v6_secondary
= 0;
6841 "ip pim rp A.B.C.D [A.B.C.D/M]",
6843 "pim multicast routing\n"
6845 "ip address of RP\n"
6846 "Group Address range to cover\n")
6848 PIM_DECLVAR_CONTEXT(vrf
, pim
);
6851 if (argc
== (idx_ipv4
+ 1))
6852 return pim_rp_cmd_worker(pim
, vty
, argv
[idx_ipv4
]->arg
, NULL
,
6855 return pim_rp_cmd_worker(pim
, vty
, argv
[idx_ipv4
]->arg
,
6856 argv
[idx_ipv4
+ 1]->arg
, NULL
);
6859 DEFUN (ip_pim_rp_prefix_list
,
6860 ip_pim_rp_prefix_list_cmd
,
6861 "ip pim rp A.B.C.D prefix-list WORD",
6863 "pim multicast routing\n"
6865 "ip address of RP\n"
6866 "group prefix-list filter\n"
6867 "Name of a prefix-list\n")
6869 PIM_DECLVAR_CONTEXT(vrf
, pim
);
6870 return pim_rp_cmd_worker(pim
, vty
, argv
[3]->arg
, NULL
, argv
[5]->arg
);
6873 static int pim_no_rp_cmd_worker(struct pim_instance
*pim
, struct vty
*vty
,
6874 const char *rp
, const char *group
,
6877 int result
= pim_rp_del_config(pim
, rp
, group
, plist
);
6879 if (result
== PIM_GROUP_BAD_ADDRESS
) {
6880 vty_out(vty
, "%% Bad group address specified: %s\n", group
);
6881 return CMD_WARNING_CONFIG_FAILED
;
6884 if (result
== PIM_RP_BAD_ADDRESS
) {
6885 vty_out(vty
, "%% Bad RP address specified: %s\n", rp
);
6886 return CMD_WARNING_CONFIG_FAILED
;
6889 if (result
== PIM_RP_NOT_FOUND
) {
6890 vty_out(vty
, "%% Unable to find specified RP\n");
6891 return CMD_WARNING_CONFIG_FAILED
;
6897 DEFUN (no_ip_pim_rp
,
6899 "no ip pim rp A.B.C.D [A.B.C.D/M]",
6902 "pim multicast routing\n"
6904 "ip address of RP\n"
6905 "Group Address range to cover\n")
6907 PIM_DECLVAR_CONTEXT(vrf
, pim
);
6908 int idx_ipv4
= 4, idx_group
= 0;
6910 if (argv_find(argv
, argc
, "A.B.C.D/M", &idx_group
))
6911 return pim_no_rp_cmd_worker(pim
, vty
, argv
[idx_ipv4
]->arg
,
6912 argv
[idx_group
]->arg
, NULL
);
6914 return pim_no_rp_cmd_worker(pim
, vty
, argv
[idx_ipv4
]->arg
, NULL
,
6918 DEFUN (no_ip_pim_rp_prefix_list
,
6919 no_ip_pim_rp_prefix_list_cmd
,
6920 "no ip pim rp A.B.C.D prefix-list WORD",
6923 "pim multicast routing\n"
6925 "ip address of RP\n"
6926 "group prefix-list filter\n"
6927 "Name of a prefix-list\n")
6929 PIM_DECLVAR_CONTEXT(vrf
, pim
);
6930 return pim_no_rp_cmd_worker(pim
, vty
, argv
[4]->arg
, NULL
, argv
[6]->arg
);
6933 static int pim_ssm_cmd_worker(struct pim_instance
*pim
, struct vty
*vty
,
6936 int result
= pim_ssm_range_set(pim
, pim
->vrf_id
, plist
);
6937 int ret
= CMD_WARNING_CONFIG_FAILED
;
6939 if (result
== PIM_SSM_ERR_NONE
)
6943 case PIM_SSM_ERR_NO_VRF
:
6944 vty_out(vty
, "%% VRF doesn't exist\n");
6946 case PIM_SSM_ERR_DUP
:
6947 vty_out(vty
, "%% duplicate config\n");
6951 vty_out(vty
, "%% ssm range config failed\n");
6957 DEFUN (ip_pim_ssm_prefix_list
,
6958 ip_pim_ssm_prefix_list_cmd
,
6959 "ip pim ssm prefix-list WORD",
6961 "pim multicast routing\n"
6962 "Source Specific Multicast\n"
6963 "group range prefix-list filter\n"
6964 "Name of a prefix-list\n")
6966 PIM_DECLVAR_CONTEXT(vrf
, pim
);
6967 return pim_ssm_cmd_worker(pim
, vty
, argv
[4]->arg
);
6970 DEFUN (no_ip_pim_ssm_prefix_list
,
6971 no_ip_pim_ssm_prefix_list_cmd
,
6972 "no ip pim ssm prefix-list",
6975 "pim multicast routing\n"
6976 "Source Specific Multicast\n"
6977 "group range prefix-list filter\n")
6979 PIM_DECLVAR_CONTEXT(vrf
, pim
);
6980 return pim_ssm_cmd_worker(pim
, vty
, NULL
);
6983 DEFUN (no_ip_pim_ssm_prefix_list_name
,
6984 no_ip_pim_ssm_prefix_list_name_cmd
,
6985 "no ip pim ssm prefix-list WORD",
6988 "pim multicast routing\n"
6989 "Source Specific Multicast\n"
6990 "group range prefix-list filter\n"
6991 "Name of a prefix-list\n")
6993 PIM_DECLVAR_CONTEXT(vrf
, pim
);
6994 struct pim_ssm
*ssm
= pim
->ssm_info
;
6996 if (ssm
->plist_name
&& !strcmp(ssm
->plist_name
, argv
[5]->arg
))
6997 return pim_ssm_cmd_worker(pim
, vty
, NULL
);
6999 vty_out(vty
, "%% pim ssm prefix-list %s doesn't exist\n", argv
[5]->arg
);
7001 return CMD_WARNING_CONFIG_FAILED
;
7004 static void ip_pim_ssm_show_group_range(struct pim_instance
*pim
,
7005 struct vty
*vty
, bool uj
)
7007 struct pim_ssm
*ssm
= pim
->ssm_info
;
7008 const char *range_str
=
7009 ssm
->plist_name
? ssm
->plist_name
: PIM_SSM_STANDARD_RANGE
;
7013 json
= json_object_new_object();
7014 json_object_string_add(json
, "ssmGroups", range_str
);
7015 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
7016 json
, JSON_C_TO_STRING_PRETTY
));
7017 json_object_free(json
);
7019 vty_out(vty
, "SSM group range : %s\n", range_str
);
7022 DEFUN (show_ip_pim_ssm_range
,
7023 show_ip_pim_ssm_range_cmd
,
7024 "show ip pim [vrf NAME] group-type [json]",
7033 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
7034 bool uj
= use_json(argc
, argv
);
7039 ip_pim_ssm_show_group_range(vrf
->info
, vty
, uj
);
7044 static void ip_pim_ssm_show_group_type(struct pim_instance
*pim
,
7045 struct vty
*vty
, bool uj
,
7048 struct in_addr group_addr
;
7049 const char *type_str
;
7052 result
= inet_pton(AF_INET
, group
, &group_addr
);
7054 type_str
= "invalid";
7056 if (pim_is_group_224_4(group_addr
))
7058 pim_is_grp_ssm(pim
, group_addr
) ? "SSM" : "ASM";
7060 type_str
= "not-multicast";
7065 json
= json_object_new_object();
7066 json_object_string_add(json
, "groupType", type_str
);
7067 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
7068 json
, JSON_C_TO_STRING_PRETTY
));
7069 json_object_free(json
);
7071 vty_out(vty
, "Group type : %s\n", type_str
);
7074 DEFUN (show_ip_pim_group_type
,
7075 show_ip_pim_group_type_cmd
,
7076 "show ip pim [vrf NAME] group-type A.B.C.D [json]",
7081 "multicast group type\n"
7086 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
7087 bool uj
= use_json(argc
, argv
);
7092 argv_find(argv
, argc
, "A.B.C.D", &idx
);
7093 ip_pim_ssm_show_group_type(vrf
->info
, vty
, uj
, argv
[idx
]->arg
);
7098 DEFUN (show_ip_pim_bsr
,
7099 show_ip_pim_bsr_cmd
,
7100 "show ip pim bsr [json]",
7104 "boot-strap router information\n"
7108 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
7109 bool uj
= use_json(argc
, argv
);
7114 pim_show_bsr(vrf
->info
, vty
, uj
);
7121 "ip ssmpingd [A.B.C.D]",
7126 PIM_DECLVAR_CONTEXT(vrf
, pim
);
7129 struct in_addr source_addr
;
7130 const char *source_str
= (argc
== 3) ? argv
[idx_ipv4
]->arg
: "0.0.0.0";
7132 result
= inet_pton(AF_INET
, source_str
, &source_addr
);
7134 vty_out(vty
, "%% Bad source address %s: errno=%d: %s\n",
7135 source_str
, errno
, safe_strerror(errno
));
7136 return CMD_WARNING_CONFIG_FAILED
;
7139 result
= pim_ssmpingd_start(pim
, source_addr
);
7141 vty_out(vty
, "%% Failure starting ssmpingd for source %s: %d\n",
7142 source_str
, result
);
7143 return CMD_WARNING_CONFIG_FAILED
;
7149 DEFUN (no_ip_ssmpingd
,
7151 "no ip ssmpingd [A.B.C.D]",
7157 PIM_DECLVAR_CONTEXT(vrf
, pim
);
7160 struct in_addr source_addr
;
7161 const char *source_str
= (argc
== 4) ? argv
[idx_ipv4
]->arg
: "0.0.0.0";
7163 result
= inet_pton(AF_INET
, source_str
, &source_addr
);
7165 vty_out(vty
, "%% Bad source address %s: errno=%d: %s\n",
7166 source_str
, errno
, safe_strerror(errno
));
7167 return CMD_WARNING_CONFIG_FAILED
;
7170 result
= pim_ssmpingd_stop(pim
, source_addr
);
7172 vty_out(vty
, "%% Failure stopping ssmpingd for source %s: %d\n",
7173 source_str
, result
);
7174 return CMD_WARNING_CONFIG_FAILED
;
7184 "pim multicast routing\n"
7185 "Enable PIM ECMP \n")
7187 PIM_DECLVAR_CONTEXT(vrf
, pim
);
7188 pim
->ecmp_enable
= true;
7193 DEFUN (no_ip_pim_ecmp
,
7198 "pim multicast routing\n"
7199 "Disable PIM ECMP \n")
7201 PIM_DECLVAR_CONTEXT(vrf
, pim
);
7202 pim
->ecmp_enable
= false;
7207 DEFUN (ip_pim_ecmp_rebalance
,
7208 ip_pim_ecmp_rebalance_cmd
,
7209 "ip pim ecmp rebalance",
7211 "pim multicast routing\n"
7212 "Enable PIM ECMP \n"
7213 "Enable PIM ECMP Rebalance\n")
7215 PIM_DECLVAR_CONTEXT(vrf
, pim
);
7216 pim
->ecmp_enable
= true;
7217 pim
->ecmp_rebalance_enable
= true;
7222 DEFUN (no_ip_pim_ecmp_rebalance
,
7223 no_ip_pim_ecmp_rebalance_cmd
,
7224 "no ip pim ecmp rebalance",
7227 "pim multicast routing\n"
7228 "Disable PIM ECMP \n"
7229 "Disable PIM ECMP Rebalance\n")
7231 PIM_DECLVAR_CONTEXT(vrf
, pim
);
7232 pim
->ecmp_rebalance_enable
= false;
7237 static int pim_cmd_igmp_start(struct vty
*vty
, struct interface
*ifp
)
7239 struct pim_interface
*pim_ifp
;
7240 uint8_t need_startup
= 0;
7242 pim_ifp
= ifp
->info
;
7245 (void)pim_if_new(ifp
, true, false, false, false);
7248 if (!PIM_IF_TEST_IGMP(pim_ifp
->options
)) {
7249 PIM_IF_DO_IGMP(pim_ifp
->options
);
7254 /* 'ip igmp' executed multiple times, with need_startup
7255 avoid multiple if add all and membership refresh */
7257 pim_if_addr_add_all(ifp
);
7258 pim_if_membership_refresh(ifp
);
7264 DEFUN (interface_ip_igmp
,
7265 interface_ip_igmp_cmd
,
7270 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7272 return pim_cmd_igmp_start(vty
, ifp
);
7275 DEFUN (interface_no_ip_igmp
,
7276 interface_no_ip_igmp_cmd
,
7282 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7283 struct pim_interface
*pim_ifp
= ifp
->info
;
7288 PIM_IF_DONT_IGMP(pim_ifp
->options
);
7290 pim_if_membership_clear(ifp
);
7292 pim_if_addr_del_all_igmp(ifp
);
7294 if (!PIM_IF_TEST_PIM(pim_ifp
->options
)) {
7301 DEFUN (interface_ip_igmp_join
,
7302 interface_ip_igmp_join_cmd
,
7303 "ip igmp join A.B.C.D [A.B.C.D]",
7306 "IGMP join multicast group\n"
7307 "Multicast group address\n"
7310 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7313 const char *group_str
;
7314 const char *source_str
;
7315 struct in_addr group_addr
;
7316 struct in_addr source_addr
;
7320 group_str
= argv
[idx_ipv4
]->arg
;
7321 result
= inet_pton(AF_INET
, group_str
, &group_addr
);
7323 vty_out(vty
, "Bad group address %s: errno=%d: %s\n", group_str
,
7324 errno
, safe_strerror(errno
));
7325 return CMD_WARNING_CONFIG_FAILED
;
7328 /* Source address */
7329 if (argc
== (idx_ipv4_2
+ 1)) {
7330 source_str
= argv
[idx_ipv4_2
]->arg
;
7331 result
= inet_pton(AF_INET
, source_str
, &source_addr
);
7333 vty_out(vty
, "Bad source address %s: errno=%d: %s\n",
7334 source_str
, errno
, safe_strerror(errno
));
7335 return CMD_WARNING_CONFIG_FAILED
;
7337 /* Reject 0.0.0.0. Reserved for any source. */
7338 if (source_addr
.s_addr
== INADDR_ANY
) {
7339 vty_out(vty
, "Bad source address %s\n", source_str
);
7340 return CMD_WARNING_CONFIG_FAILED
;
7343 source_addr
.s_addr
= INADDR_ANY
;
7346 CMD_FERR_RETURN(pim_if_igmp_join_add(ifp
, group_addr
, source_addr
),
7347 "Failure joining IGMP group: $ERR");
7352 DEFUN (interface_no_ip_igmp_join
,
7353 interface_no_ip_igmp_join_cmd
,
7354 "no ip igmp join A.B.C.D [A.B.C.D]",
7358 "IGMP join multicast group\n"
7359 "Multicast group address\n"
7362 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7365 const char *group_str
;
7366 const char *source_str
;
7367 struct in_addr group_addr
;
7368 struct in_addr source_addr
;
7372 group_str
= argv
[idx_ipv4
]->arg
;
7373 result
= inet_pton(AF_INET
, group_str
, &group_addr
);
7375 vty_out(vty
, "Bad group address %s: errno=%d: %s\n", group_str
,
7376 errno
, safe_strerror(errno
));
7377 return CMD_WARNING_CONFIG_FAILED
;
7380 /* Source address */
7381 if (argc
== (idx_ipv4_2
+ 1)) {
7382 source_str
= argv
[idx_ipv4_2
]->arg
;
7383 result
= inet_pton(AF_INET
, source_str
, &source_addr
);
7385 vty_out(vty
, "Bad source address %s: errno=%d: %s\n",
7386 source_str
, errno
, safe_strerror(errno
));
7387 return CMD_WARNING_CONFIG_FAILED
;
7389 /* Reject 0.0.0.0. Reserved for any source. */
7390 if (source_addr
.s_addr
== INADDR_ANY
) {
7391 vty_out(vty
, "Bad source address %s\n", source_str
);
7392 return CMD_WARNING_CONFIG_FAILED
;
7396 source_addr
.s_addr
= INADDR_ANY
;
7399 result
= pim_if_igmp_join_del(ifp
, group_addr
, source_addr
);
7402 "%% Failure leaving IGMP group %s source %s on interface %s: %d\n",
7403 group_str
, source_str
, ifp
->name
, result
);
7404 return CMD_WARNING_CONFIG_FAILED
;
7411 CLI reconfiguration affects the interface level (struct pim_interface).
7412 This function propagates the reconfiguration to every active socket
7415 static void igmp_sock_query_interval_reconfig(struct igmp_sock
*igmp
)
7417 struct interface
*ifp
;
7418 struct pim_interface
*pim_ifp
;
7422 /* other querier present? */
7424 if (igmp
->t_other_querier_timer
)
7427 /* this is the querier */
7429 zassert(igmp
->interface
);
7430 zassert(igmp
->interface
->info
);
7432 ifp
= igmp
->interface
;
7433 pim_ifp
= ifp
->info
;
7435 if (PIM_DEBUG_IGMP_TRACE
) {
7436 char ifaddr_str
[INET_ADDRSTRLEN
];
7437 pim_inet4_dump("<ifaddr?>", igmp
->ifaddr
, ifaddr_str
,
7438 sizeof(ifaddr_str
));
7439 zlog_debug("%s: Querier %s on %s reconfig query_interval=%d",
7440 __func__
, ifaddr_str
, ifp
->name
,
7441 pim_ifp
->igmp_default_query_interval
);
7445 igmp_startup_mode_on() will reset QQI:
7447 igmp->querier_query_interval = pim_ifp->igmp_default_query_interval;
7449 igmp_startup_mode_on(igmp
);
7452 static void igmp_sock_query_reschedule(struct igmp_sock
*igmp
)
7454 if (igmp
->mtrace_only
)
7457 if (igmp
->t_igmp_query_timer
) {
7458 /* other querier present */
7459 zassert(igmp
->t_igmp_query_timer
);
7460 zassert(!igmp
->t_other_querier_timer
);
7462 pim_igmp_general_query_off(igmp
);
7463 pim_igmp_general_query_on(igmp
);
7465 zassert(igmp
->t_igmp_query_timer
);
7466 zassert(!igmp
->t_other_querier_timer
);
7468 /* this is the querier */
7470 zassert(!igmp
->t_igmp_query_timer
);
7471 zassert(igmp
->t_other_querier_timer
);
7473 pim_igmp_other_querier_timer_off(igmp
);
7474 pim_igmp_other_querier_timer_on(igmp
);
7476 zassert(!igmp
->t_igmp_query_timer
);
7477 zassert(igmp
->t_other_querier_timer
);
7481 static void change_query_interval(struct pim_interface
*pim_ifp
,
7484 struct listnode
*sock_node
;
7485 struct igmp_sock
*igmp
;
7487 pim_ifp
->igmp_default_query_interval
= query_interval
;
7489 for (ALL_LIST_ELEMENTS_RO(pim_ifp
->igmp_socket_list
, sock_node
, igmp
)) {
7490 igmp_sock_query_interval_reconfig(igmp
);
7491 igmp_sock_query_reschedule(igmp
);
7495 static void change_query_max_response_time(struct pim_interface
*pim_ifp
,
7496 int query_max_response_time_dsec
)
7498 struct listnode
*sock_node
;
7499 struct igmp_sock
*igmp
;
7501 pim_ifp
->igmp_query_max_response_time_dsec
=
7502 query_max_response_time_dsec
;
7505 Below we modify socket/group/source timers in order to quickly
7506 reflect the change. Otherwise, those timers would eventually catch
7510 /* scan all sockets */
7511 for (ALL_LIST_ELEMENTS_RO(pim_ifp
->igmp_socket_list
, sock_node
, igmp
)) {
7512 struct listnode
*grp_node
;
7513 struct igmp_group
*grp
;
7515 /* reschedule socket general query */
7516 igmp_sock_query_reschedule(igmp
);
7518 /* scan socket groups */
7519 for (ALL_LIST_ELEMENTS_RO(igmp
->igmp_group_list
, grp_node
,
7521 struct listnode
*src_node
;
7522 struct igmp_source
*src
;
7524 /* reset group timers for groups in EXCLUDE mode */
7525 if (grp
->group_filtermode_isexcl
) {
7526 igmp_group_reset_gmi(grp
);
7529 /* scan group sources */
7530 for (ALL_LIST_ELEMENTS_RO(grp
->group_source_list
,
7533 /* reset source timers for sources with running
7535 if (src
->t_source_timer
) {
7536 igmp_source_reset_gmi(igmp
, grp
, src
);
7543 #define IGMP_QUERY_INTERVAL_MIN (1)
7544 #define IGMP_QUERY_INTERVAL_MAX (1800)
7546 DEFUN (interface_ip_igmp_query_interval
,
7547 interface_ip_igmp_query_interval_cmd
,
7548 "ip igmp query-interval (1-1800)",
7551 IFACE_IGMP_QUERY_INTERVAL_STR
7552 "Query interval in seconds\n")
7554 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7555 struct pim_interface
*pim_ifp
= ifp
->info
;
7557 int query_interval_dsec
;
7561 ret
= pim_cmd_igmp_start(vty
, ifp
);
7562 if (ret
!= CMD_SUCCESS
)
7564 pim_ifp
= ifp
->info
;
7567 query_interval
= atoi(argv
[3]->arg
);
7568 query_interval_dsec
= 10 * query_interval
;
7571 It seems we don't need to check bounds since command.c does it
7572 already, but we verify them anyway for extra safety.
7574 if (query_interval
< IGMP_QUERY_INTERVAL_MIN
) {
7576 "General query interval %d lower than minimum %d\n",
7577 query_interval
, IGMP_QUERY_INTERVAL_MIN
);
7578 return CMD_WARNING_CONFIG_FAILED
;
7580 if (query_interval
> IGMP_QUERY_INTERVAL_MAX
) {
7582 "General query interval %d higher than maximum %d\n",
7583 query_interval
, IGMP_QUERY_INTERVAL_MAX
);
7584 return CMD_WARNING_CONFIG_FAILED
;
7587 if (query_interval_dsec
<= pim_ifp
->igmp_query_max_response_time_dsec
) {
7589 "Can't set general query interval %d dsec <= query max response time %d dsec.\n",
7590 query_interval_dsec
,
7591 pim_ifp
->igmp_query_max_response_time_dsec
);
7592 return CMD_WARNING_CONFIG_FAILED
;
7595 change_query_interval(pim_ifp
, query_interval
);
7600 DEFUN (interface_no_ip_igmp_query_interval
,
7601 interface_no_ip_igmp_query_interval_cmd
,
7602 "no ip igmp query-interval",
7606 IFACE_IGMP_QUERY_INTERVAL_STR
)
7608 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7609 struct pim_interface
*pim_ifp
= ifp
->info
;
7610 int default_query_interval_dsec
;
7615 default_query_interval_dsec
= IGMP_GENERAL_QUERY_INTERVAL
* 10;
7617 if (default_query_interval_dsec
7618 <= pim_ifp
->igmp_query_max_response_time_dsec
) {
7620 "Can't set default general query interval %d dsec <= query max response time %d dsec.\n",
7621 default_query_interval_dsec
,
7622 pim_ifp
->igmp_query_max_response_time_dsec
);
7623 return CMD_WARNING_CONFIG_FAILED
;
7626 change_query_interval(pim_ifp
, IGMP_GENERAL_QUERY_INTERVAL
);
7631 DEFUN (interface_ip_igmp_version
,
7632 interface_ip_igmp_version_cmd
,
7633 "ip igmp version (2-3)",
7637 "IGMP version number\n")
7639 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7640 struct pim_interface
*pim_ifp
= ifp
->info
;
7641 int igmp_version
, old_version
= 0;
7645 ret
= pim_cmd_igmp_start(vty
, ifp
);
7646 if (ret
!= CMD_SUCCESS
)
7648 pim_ifp
= ifp
->info
;
7651 igmp_version
= atoi(argv
[3]->arg
);
7652 old_version
= pim_ifp
->igmp_version
;
7653 pim_ifp
->igmp_version
= igmp_version
;
7655 // Check if IGMP is Enabled otherwise, enable on interface
7656 if (!PIM_IF_TEST_IGMP(pim_ifp
->options
)) {
7657 PIM_IF_DO_IGMP(pim_ifp
->options
);
7658 pim_if_addr_add_all(ifp
);
7659 pim_if_membership_refresh(ifp
);
7660 old_version
= igmp_version
;
7661 // avoid refreshing membership again.
7663 /* Current and new version is different refresh existing
7664 membership. Going from 3 -> 2 or 2 -> 3. */
7665 if (old_version
!= igmp_version
)
7666 pim_if_membership_refresh(ifp
);
7671 DEFUN (interface_no_ip_igmp_version
,
7672 interface_no_ip_igmp_version_cmd
,
7673 "no ip igmp version (2-3)",
7678 "IGMP version number\n")
7680 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7681 struct pim_interface
*pim_ifp
= ifp
->info
;
7686 pim_ifp
->igmp_version
= IGMP_DEFAULT_VERSION
;
7691 #define IGMP_QUERY_MAX_RESPONSE_TIME_MIN_DSEC (10)
7692 #define IGMP_QUERY_MAX_RESPONSE_TIME_MAX_DSEC (250)
7694 DEFUN (interface_ip_igmp_query_max_response_time
,
7695 interface_ip_igmp_query_max_response_time_cmd
,
7696 "ip igmp query-max-response-time (10-250)",
7699 IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_STR
7700 "Query response value in deci-seconds\n")
7702 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7703 struct pim_interface
*pim_ifp
= ifp
->info
;
7704 int query_max_response_time
;
7708 ret
= pim_cmd_igmp_start(vty
, ifp
);
7709 if (ret
!= CMD_SUCCESS
)
7711 pim_ifp
= ifp
->info
;
7714 query_max_response_time
= atoi(argv
[3]->arg
);
7716 if (query_max_response_time
7717 >= pim_ifp
->igmp_default_query_interval
* 10) {
7719 "Can't set query max response time %d sec >= general query interval %d sec\n",
7720 query_max_response_time
,
7721 pim_ifp
->igmp_default_query_interval
);
7722 return CMD_WARNING_CONFIG_FAILED
;
7725 change_query_max_response_time(pim_ifp
, query_max_response_time
);
7730 DEFUN (interface_no_ip_igmp_query_max_response_time
,
7731 interface_no_ip_igmp_query_max_response_time_cmd
,
7732 "no ip igmp query-max-response-time (10-250)",
7736 IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_STR
7737 "Time for response in deci-seconds\n")
7739 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7740 struct pim_interface
*pim_ifp
= ifp
->info
;
7745 change_query_max_response_time(pim_ifp
,
7746 IGMP_QUERY_MAX_RESPONSE_TIME_DSEC
);
7751 #define IGMP_QUERY_MAX_RESPONSE_TIME_MIN_DSEC (10)
7752 #define IGMP_QUERY_MAX_RESPONSE_TIME_MAX_DSEC (250)
7754 DEFUN_HIDDEN (interface_ip_igmp_query_max_response_time_dsec
,
7755 interface_ip_igmp_query_max_response_time_dsec_cmd
,
7756 "ip igmp query-max-response-time-dsec (10-250)",
7759 IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC_STR
7760 "Query response value in deciseconds\n")
7762 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7763 struct pim_interface
*pim_ifp
= ifp
->info
;
7764 int query_max_response_time_dsec
;
7765 int default_query_interval_dsec
;
7769 ret
= pim_cmd_igmp_start(vty
, ifp
);
7770 if (ret
!= CMD_SUCCESS
)
7772 pim_ifp
= ifp
->info
;
7775 query_max_response_time_dsec
= atoi(argv
[4]->arg
);
7777 default_query_interval_dsec
= 10 * pim_ifp
->igmp_default_query_interval
;
7779 if (query_max_response_time_dsec
>= default_query_interval_dsec
) {
7781 "Can't set query max response time %d dsec >= general query interval %d dsec\n",
7782 query_max_response_time_dsec
,
7783 default_query_interval_dsec
);
7784 return CMD_WARNING_CONFIG_FAILED
;
7787 change_query_max_response_time(pim_ifp
, query_max_response_time_dsec
);
7792 DEFUN_HIDDEN (interface_no_ip_igmp_query_max_response_time_dsec
,
7793 interface_no_ip_igmp_query_max_response_time_dsec_cmd
,
7794 "no ip igmp query-max-response-time-dsec",
7798 IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC_STR
)
7800 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7801 struct pim_interface
*pim_ifp
= ifp
->info
;
7806 change_query_max_response_time(pim_ifp
,
7807 IGMP_QUERY_MAX_RESPONSE_TIME_DSEC
);
7812 #define IGMP_LAST_MEMBER_QUERY_COUNT_MIN (1)
7813 #define IGMP_LAST_MEMBER_QUERY_COUNT_MAX (7)
7815 DEFUN (interface_ip_igmp_last_member_query_count
,
7816 interface_ip_igmp_last_member_query_count_cmd
,
7817 "ip igmp last-member-query-count (1-7)",
7820 IFACE_IGMP_LAST_MEMBER_QUERY_COUNT_STR
7821 "Last member query count\n")
7823 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7824 struct pim_interface
*pim_ifp
= ifp
->info
;
7825 int last_member_query_count
;
7829 ret
= pim_cmd_igmp_start(vty
, ifp
);
7830 if (ret
!= CMD_SUCCESS
)
7832 pim_ifp
= ifp
->info
;
7835 last_member_query_count
= atoi(argv
[3]->arg
);
7837 pim_ifp
->igmp_last_member_query_count
= last_member_query_count
;
7842 DEFUN (interface_no_ip_igmp_last_member_query_count
,
7843 interface_no_ip_igmp_last_member_query_count_cmd
,
7844 "no ip igmp last-member-query-count",
7848 IFACE_IGMP_LAST_MEMBER_QUERY_COUNT_STR
)
7850 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7851 struct pim_interface
*pim_ifp
= ifp
->info
;
7856 pim_ifp
->igmp_last_member_query_count
=
7857 IGMP_DEFAULT_ROBUSTNESS_VARIABLE
;
7862 #define IGMP_LAST_MEMBER_QUERY_INTERVAL_MIN (1)
7863 #define IGMP_LAST_MEMBER_QUERY_INTERVAL_MAX (255)
7865 DEFUN (interface_ip_igmp_last_member_query_interval
,
7866 interface_ip_igmp_last_member_query_interval_cmd
,
7867 "ip igmp last-member-query-interval (1-255)",
7870 IFACE_IGMP_LAST_MEMBER_QUERY_INTERVAL_STR
7871 "Last member query interval in deciseconds\n")
7873 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7874 struct pim_interface
*pim_ifp
= ifp
->info
;
7875 int last_member_query_interval
;
7879 ret
= pim_cmd_igmp_start(vty
, ifp
);
7880 if (ret
!= CMD_SUCCESS
)
7882 pim_ifp
= ifp
->info
;
7885 last_member_query_interval
= atoi(argv
[3]->arg
);
7886 pim_ifp
->igmp_specific_query_max_response_time_dsec
7887 = last_member_query_interval
;
7892 DEFUN (interface_no_ip_igmp_last_member_query_interval
,
7893 interface_no_ip_igmp_last_member_query_interval_cmd
,
7894 "no ip igmp last-member-query-interval",
7898 IFACE_IGMP_LAST_MEMBER_QUERY_INTERVAL_STR
)
7900 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7901 struct pim_interface
*pim_ifp
= ifp
->info
;
7906 pim_ifp
->igmp_specific_query_max_response_time_dsec
=
7907 IGMP_SPECIFIC_QUERY_MAX_RESPONSE_TIME_DSEC
;
7912 DEFUN (interface_ip_pim_drprio
,
7913 interface_ip_pim_drprio_cmd
,
7914 "ip pim drpriority (1-4294967295)",
7917 "Set the Designated Router Election Priority\n"
7918 "Value of the new DR Priority\n")
7920 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7922 struct pim_interface
*pim_ifp
= ifp
->info
;
7923 uint32_t old_dr_prio
;
7926 vty_out(vty
, "Please enable PIM on interface, first\n");
7927 return CMD_WARNING_CONFIG_FAILED
;
7930 old_dr_prio
= pim_ifp
->pim_dr_priority
;
7932 pim_ifp
->pim_dr_priority
= strtol(argv
[idx_number
]->arg
, NULL
, 10);
7934 if (old_dr_prio
!= pim_ifp
->pim_dr_priority
) {
7935 pim_if_dr_election(ifp
);
7936 pim_hello_restart_now(ifp
);
7942 DEFUN (interface_no_ip_pim_drprio
,
7943 interface_no_ip_pim_drprio_cmd
,
7944 "no ip pim drpriority [(1-4294967295)]",
7948 "Revert the Designated Router Priority to default\n"
7949 "Old Value of the Priority\n")
7951 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7952 struct pim_interface
*pim_ifp
= ifp
->info
;
7955 vty_out(vty
, "Pim not enabled on this interface\n");
7956 return CMD_WARNING_CONFIG_FAILED
;
7959 if (pim_ifp
->pim_dr_priority
!= PIM_DEFAULT_DR_PRIORITY
) {
7960 pim_ifp
->pim_dr_priority
= PIM_DEFAULT_DR_PRIORITY
;
7961 pim_if_dr_election(ifp
);
7962 pim_hello_restart_now(ifp
);
7968 DEFPY_HIDDEN (interface_ip_igmp_query_generate
,
7969 interface_ip_igmp_query_generate_cmd
,
7970 "ip igmp generate-query-once [version (2-3)]",
7973 "Generate igmp general query once\n"
7975 "IGMP version number\n")
7977 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7978 int igmp_version
= 2;
7981 vty_out(vty
, "IGMP/PIM is not enabled on the interface %s\n",
7983 return CMD_WARNING_CONFIG_FAILED
;
7987 igmp_version
= atoi(argv
[4]->arg
);
7989 igmp_send_query_on_intf(ifp
, igmp_version
);
7994 static int pim_cmd_interface_add(struct interface
*ifp
)
7996 struct pim_interface
*pim_ifp
= ifp
->info
;
7999 pim_ifp
= pim_if_new(ifp
, false, true, false, false);
8001 PIM_IF_DO_PIM(pim_ifp
->options
);
8003 pim_if_addr_add_all(ifp
);
8004 pim_if_membership_refresh(ifp
);
8006 pim_if_create_pimreg(pim_ifp
->pim
);
8010 DEFPY_HIDDEN (pim_test_sg_keepalive
,
8011 pim_test_sg_keepalive_cmd
,
8012 "test pim [vrf NAME$name] keepalive-reset A.B.C.D$source A.B.C.D$group",
8016 "Reset the Keepalive Timer\n"
8017 "The Source we are resetting\n"
8018 "The Group we are resetting\n")
8020 struct pim_upstream
*up
;
8021 struct pim_instance
*pim
;
8022 struct prefix_sg sg
;
8028 pim
= pim_get_pim_instance(VRF_DEFAULT
);
8030 struct vrf
*vrf
= vrf_lookup_by_name(name
);
8033 vty_out(vty
, "%% Vrf specified: %s does not exist\n",
8038 pim
= pim_get_pim_instance(vrf
->vrf_id
);
8042 vty_out(vty
, "%% Unable to find pim instance\n");
8046 up
= pim_upstream_find(pim
, &sg
);
8048 vty_out(vty
, "%% Unable to find %s specified\n",
8049 pim_str_sg_dump(&sg
));
8053 vty_out(vty
, "Setting %s to current keep alive time: %d\n",
8054 pim_str_sg_dump(&sg
), pim
->keep_alive_time
);
8055 pim_upstream_keep_alive_timer_start(up
, pim
->keep_alive_time
);
8060 DEFPY (interface_ip_pim_activeactive
,
8061 interface_ip_pim_activeactive_cmd
,
8062 "[no$no] ip pim active-active",
8066 "Mark interface as Active-Active for MLAG operations, Hidden because not finished yet\n")
8068 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8069 struct pim_interface
*pim_ifp
;
8071 if (!no
&& !pim_cmd_interface_add(ifp
)) {
8072 vty_out(vty
, "Could not enable PIM SM active-active on interface\n");
8073 return CMD_WARNING_CONFIG_FAILED
;
8078 zlog_debug("%sConfiguring PIM active-active on Interface: %s",
8079 no
? "Un-":" ", ifp
->name
);
8081 pim_ifp
= ifp
->info
;
8083 pim_if_unconfigure_mlag_dualactive(pim_ifp
);
8085 pim_if_configure_mlag_dualactive(pim_ifp
);
8090 DEFUN_HIDDEN (interface_ip_pim_ssm
,
8091 interface_ip_pim_ssm_cmd
,
8097 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8099 if (!pim_cmd_interface_add(ifp
)) {
8100 vty_out(vty
, "Could not enable PIM SM on interface\n");
8101 return CMD_WARNING_CONFIG_FAILED
;
8105 "WARN: Enabled PIM SM on interface; configure PIM SSM "
8106 "range if needed\n");
8110 static int interface_ip_pim_helper(struct vty
*vty
)
8112 struct pim_interface
*pim_ifp
;
8114 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8116 if (!pim_cmd_interface_add(ifp
)) {
8117 vty_out(vty
, "Could not enable PIM SM on interface\n");
8118 return CMD_WARNING_CONFIG_FAILED
;
8121 pim_ifp
= ifp
->info
;
8123 pim_if_create_pimreg(pim_ifp
->pim
);
8128 DEFUN_HIDDEN (interface_ip_pim_sm
,
8129 interface_ip_pim_sm_cmd
,
8135 return interface_ip_pim_helper(vty
);
8138 DEFUN (interface_ip_pim
,
8139 interface_ip_pim_cmd
,
8144 return interface_ip_pim_helper(vty
);
8147 static int pim_cmd_interface_delete(struct interface
*ifp
)
8149 struct pim_interface
*pim_ifp
= ifp
->info
;
8154 PIM_IF_DONT_PIM(pim_ifp
->options
);
8156 pim_if_membership_clear(ifp
);
8159 pim_sock_delete() removes all neighbors from
8160 pim_ifp->pim_neighbor_list.
8162 pim_sock_delete(ifp
, "pim unconfigured on interface");
8164 if (!PIM_IF_TEST_IGMP(pim_ifp
->options
)) {
8165 pim_if_addr_del_all(ifp
);
8172 static int interface_no_ip_pim_helper(struct vty
*vty
)
8174 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8175 if (!pim_cmd_interface_delete(ifp
)) {
8176 vty_out(vty
, "Unable to delete interface information\n");
8177 return CMD_WARNING_CONFIG_FAILED
;
8183 DEFUN_HIDDEN (interface_no_ip_pim_ssm
,
8184 interface_no_ip_pim_ssm_cmd
,
8191 return interface_no_ip_pim_helper(vty
);
8194 DEFUN_HIDDEN (interface_no_ip_pim_sm
,
8195 interface_no_ip_pim_sm_cmd
,
8202 return interface_no_ip_pim_helper(vty
);
8205 DEFUN (interface_no_ip_pim
,
8206 interface_no_ip_pim_cmd
,
8212 return interface_no_ip_pim_helper(vty
);
8216 DEFUN(interface_ip_pim_boundary_oil
,
8217 interface_ip_pim_boundary_oil_cmd
,
8218 "ip multicast boundary oil WORD",
8220 "Generic multicast configuration options\n"
8221 "Define multicast boundary\n"
8222 "Filter OIL by group using prefix list\n"
8223 "Prefix list to filter OIL with\n")
8225 VTY_DECLVAR_CONTEXT(interface
, iif
);
8226 struct pim_interface
*pim_ifp
;
8229 argv_find(argv
, argc
, "WORD", &idx
);
8231 PIM_GET_PIM_INTERFACE(pim_ifp
, iif
);
8233 if (pim_ifp
->boundary_oil_plist
)
8234 XFREE(MTYPE_PIM_INTERFACE
, pim_ifp
->boundary_oil_plist
);
8236 pim_ifp
->boundary_oil_plist
=
8237 XSTRDUP(MTYPE_PIM_INTERFACE
, argv
[idx
]->arg
);
8239 /* Interface will be pruned from OIL on next Join */
8243 DEFUN(interface_no_ip_pim_boundary_oil
,
8244 interface_no_ip_pim_boundary_oil_cmd
,
8245 "no ip multicast boundary oil [WORD]",
8248 "Generic multicast configuration options\n"
8249 "Define multicast boundary\n"
8250 "Filter OIL by group using prefix list\n"
8251 "Prefix list to filter OIL with\n")
8253 VTY_DECLVAR_CONTEXT(interface
, iif
);
8254 struct pim_interface
*pim_ifp
;
8257 argv_find(argv
, argc
, "WORD", &idx
);
8259 PIM_GET_PIM_INTERFACE(pim_ifp
, iif
);
8261 if (pim_ifp
->boundary_oil_plist
)
8262 XFREE(MTYPE_PIM_INTERFACE
, pim_ifp
->boundary_oil_plist
);
8267 DEFUN (interface_ip_mroute
,
8268 interface_ip_mroute_cmd
,
8269 "ip mroute INTERFACE A.B.C.D [A.B.C.D]",
8271 "Add multicast route\n"
8272 "Outgoing interface name\n"
8276 VTY_DECLVAR_CONTEXT(interface
, iif
);
8277 struct pim_interface
*pim_ifp
;
8278 struct pim_instance
*pim
;
8279 int idx_interface
= 2;
8281 struct interface
*oif
;
8282 const char *oifname
;
8283 const char *grp_str
;
8284 struct in_addr grp_addr
;
8285 const char *src_str
;
8286 struct in_addr src_addr
;
8289 PIM_GET_PIM_INTERFACE(pim_ifp
, iif
);
8292 oifname
= argv
[idx_interface
]->arg
;
8293 oif
= if_lookup_by_name(oifname
, pim
->vrf_id
);
8295 vty_out(vty
, "No such interface name %s\n", oifname
);
8299 grp_str
= argv
[idx_ipv4
]->arg
;
8300 result
= inet_pton(AF_INET
, grp_str
, &grp_addr
);
8302 vty_out(vty
, "Bad group address %s: errno=%d: %s\n", grp_str
,
8303 errno
, safe_strerror(errno
));
8307 if (argc
== (idx_ipv4
+ 1)) {
8308 src_addr
.s_addr
= INADDR_ANY
;
8311 src_str
= argv
[idx_ipv4
+ 1]->arg
;
8312 result
= inet_pton(AF_INET
, src_str
, &src_addr
);
8314 vty_out(vty
, "Bad source address %s: errno=%d: %s\n", src_str
,
8315 errno
, safe_strerror(errno
));
8320 if (pim_static_add(pim
, iif
, oif
, grp_addr
, src_addr
)) {
8321 vty_out(vty
, "Failed to add static mroute\n");
8328 DEFUN (interface_no_ip_mroute
,
8329 interface_no_ip_mroute_cmd
,
8330 "no ip mroute INTERFACE A.B.C.D [A.B.C.D]",
8333 "Add multicast route\n"
8334 "Outgoing interface name\n"
8338 VTY_DECLVAR_CONTEXT(interface
, iif
);
8339 struct pim_interface
*pim_ifp
;
8340 struct pim_instance
*pim
;
8341 int idx_interface
= 3;
8343 struct interface
*oif
;
8344 const char *oifname
;
8345 const char *grp_str
;
8346 struct in_addr grp_addr
;
8347 const char *src_str
;
8348 struct in_addr src_addr
;
8351 PIM_GET_PIM_INTERFACE(pim_ifp
, iif
);
8354 oifname
= argv
[idx_interface
]->arg
;
8355 oif
= if_lookup_by_name(oifname
, pim
->vrf_id
);
8357 vty_out(vty
, "No such interface name %s\n", oifname
);
8361 grp_str
= argv
[idx_ipv4
]->arg
;
8362 result
= inet_pton(AF_INET
, grp_str
, &grp_addr
);
8364 vty_out(vty
, "Bad group address %s: errno=%d: %s\n", grp_str
,
8365 errno
, safe_strerror(errno
));
8369 if (argc
== (idx_ipv4
+ 1)) {
8370 src_addr
.s_addr
= INADDR_ANY
;
8373 src_str
= argv
[idx_ipv4
+ 1]->arg
;
8374 result
= inet_pton(AF_INET
, src_str
, &src_addr
);
8376 vty_out(vty
, "Bad source address %s: errno=%d: %s\n", src_str
,
8377 errno
, safe_strerror(errno
));
8382 if (pim_static_del(pim
, iif
, oif
, grp_addr
, src_addr
)) {
8383 vty_out(vty
, "Failed to remove static mroute\n");
8390 DEFUN (interface_ip_pim_hello
,
8391 interface_ip_pim_hello_cmd
,
8392 "ip pim hello (1-180) [(1-180)]",
8396 IFACE_PIM_HELLO_TIME_STR
8397 IFACE_PIM_HELLO_HOLD_STR
)
8399 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8402 struct pim_interface
*pim_ifp
= ifp
->info
;
8405 if (!pim_cmd_interface_add(ifp
)) {
8406 vty_out(vty
, "Could not enable PIM SM on interface\n");
8407 return CMD_WARNING_CONFIG_FAILED
;
8411 pim_ifp
= ifp
->info
;
8412 pim_ifp
->pim_hello_period
= strtol(argv
[idx_time
]->arg
, NULL
, 10);
8414 if (argc
== idx_hold
+ 1)
8415 pim_ifp
->pim_default_holdtime
=
8416 strtol(argv
[idx_hold
]->arg
, NULL
, 10);
8421 DEFUN (interface_no_ip_pim_hello
,
8422 interface_no_ip_pim_hello_cmd
,
8423 "no ip pim hello [(1-180) (1-180)]",
8428 IFACE_PIM_HELLO_TIME_STR
8429 IFACE_PIM_HELLO_HOLD_STR
)
8431 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8432 struct pim_interface
*pim_ifp
= ifp
->info
;
8435 vty_out(vty
, "Pim not enabled on this interface\n");
8436 return CMD_WARNING_CONFIG_FAILED
;
8439 pim_ifp
->pim_hello_period
= PIM_DEFAULT_HELLO_PERIOD
;
8440 pim_ifp
->pim_default_holdtime
= -1;
8451 PIM_DO_DEBUG_IGMP_EVENTS
;
8452 PIM_DO_DEBUG_IGMP_PACKETS
;
8453 PIM_DO_DEBUG_IGMP_TRACE
;
8457 DEFUN (no_debug_igmp
,
8464 PIM_DONT_DEBUG_IGMP_EVENTS
;
8465 PIM_DONT_DEBUG_IGMP_PACKETS
;
8466 PIM_DONT_DEBUG_IGMP_TRACE
;
8471 DEFUN (debug_igmp_events
,
8472 debug_igmp_events_cmd
,
8473 "debug igmp events",
8476 DEBUG_IGMP_EVENTS_STR
)
8478 PIM_DO_DEBUG_IGMP_EVENTS
;
8482 DEFUN (no_debug_igmp_events
,
8483 no_debug_igmp_events_cmd
,
8484 "no debug igmp events",
8488 DEBUG_IGMP_EVENTS_STR
)
8490 PIM_DONT_DEBUG_IGMP_EVENTS
;
8495 DEFUN (debug_igmp_packets
,
8496 debug_igmp_packets_cmd
,
8497 "debug igmp packets",
8500 DEBUG_IGMP_PACKETS_STR
)
8502 PIM_DO_DEBUG_IGMP_PACKETS
;
8506 DEFUN (no_debug_igmp_packets
,
8507 no_debug_igmp_packets_cmd
,
8508 "no debug igmp packets",
8512 DEBUG_IGMP_PACKETS_STR
)
8514 PIM_DONT_DEBUG_IGMP_PACKETS
;
8519 DEFUN (debug_igmp_trace
,
8520 debug_igmp_trace_cmd
,
8524 DEBUG_IGMP_TRACE_STR
)
8526 PIM_DO_DEBUG_IGMP_TRACE
;
8530 DEFUN (no_debug_igmp_trace
,
8531 no_debug_igmp_trace_cmd
,
8532 "no debug igmp trace",
8536 DEBUG_IGMP_TRACE_STR
)
8538 PIM_DONT_DEBUG_IGMP_TRACE
;
8543 DEFUN (debug_mroute
,
8549 PIM_DO_DEBUG_MROUTE
;
8553 DEFUN (debug_mroute_detail
,
8554 debug_mroute_detail_cmd
,
8555 "debug mroute detail",
8560 PIM_DO_DEBUG_MROUTE_DETAIL
;
8564 DEFUN (no_debug_mroute
,
8565 no_debug_mroute_cmd
,
8571 PIM_DONT_DEBUG_MROUTE
;
8575 DEFUN (no_debug_mroute_detail
,
8576 no_debug_mroute_detail_cmd
,
8577 "no debug mroute detail",
8583 PIM_DONT_DEBUG_MROUTE_DETAIL
;
8587 DEFUN (debug_pim_static
,
8588 debug_pim_static_cmd
,
8594 PIM_DO_DEBUG_STATIC
;
8598 DEFUN (no_debug_pim_static
,
8599 no_debug_pim_static_cmd
,
8600 "no debug pim static",
8606 PIM_DONT_DEBUG_STATIC
;
8617 PIM_DO_DEBUG_PIM_EVENTS
;
8618 PIM_DO_DEBUG_PIM_PACKETS
;
8619 PIM_DO_DEBUG_PIM_TRACE
;
8620 PIM_DO_DEBUG_MSDP_EVENTS
;
8621 PIM_DO_DEBUG_MSDP_PACKETS
;
8626 DEFUN (no_debug_pim
,
8633 PIM_DONT_DEBUG_PIM_EVENTS
;
8634 PIM_DONT_DEBUG_PIM_PACKETS
;
8635 PIM_DONT_DEBUG_PIM_TRACE
;
8636 PIM_DONT_DEBUG_MSDP_EVENTS
;
8637 PIM_DONT_DEBUG_MSDP_PACKETS
;
8639 PIM_DONT_DEBUG_PIM_PACKETDUMP_SEND
;
8640 PIM_DONT_DEBUG_PIM_PACKETDUMP_RECV
;
8646 DEFUN (debug_pim_nht
,
8651 "Nexthop Tracking\n")
8653 PIM_DO_DEBUG_PIM_NHT
;
8657 DEFUN (no_debug_pim_nht
,
8658 no_debug_pim_nht_cmd
,
8663 "Nexthop Tracking\n")
8665 PIM_DONT_DEBUG_PIM_NHT
;
8669 DEFUN (debug_pim_nht_rp
,
8670 debug_pim_nht_rp_cmd
,
8674 "Nexthop Tracking\n"
8675 "RP Nexthop Tracking\n")
8677 PIM_DO_DEBUG_PIM_NHT_RP
;
8681 DEFUN (no_debug_pim_nht_rp
,
8682 no_debug_pim_nht_rp_cmd
,
8683 "no debug pim nht rp",
8687 "Nexthop Tracking\n"
8688 "RP Nexthop Tracking\n")
8690 PIM_DONT_DEBUG_PIM_NHT_RP
;
8694 DEFUN (debug_pim_events
,
8695 debug_pim_events_cmd
,
8699 DEBUG_PIM_EVENTS_STR
)
8701 PIM_DO_DEBUG_PIM_EVENTS
;
8705 DEFUN (no_debug_pim_events
,
8706 no_debug_pim_events_cmd
,
8707 "no debug pim events",
8711 DEBUG_PIM_EVENTS_STR
)
8713 PIM_DONT_DEBUG_PIM_EVENTS
;
8717 DEFUN (debug_pim_packets
,
8718 debug_pim_packets_cmd
,
8719 "debug pim packets [<hello|joins|register>]",
8722 DEBUG_PIM_PACKETS_STR
8723 DEBUG_PIM_HELLO_PACKETS_STR
8724 DEBUG_PIM_J_P_PACKETS_STR
8725 DEBUG_PIM_PIM_REG_PACKETS_STR
)
8728 if (argv_find(argv
, argc
, "hello", &idx
)) {
8729 PIM_DO_DEBUG_PIM_HELLO
;
8730 vty_out(vty
, "PIM Hello debugging is on\n");
8731 } else if (argv_find(argv
, argc
, "joins", &idx
)) {
8732 PIM_DO_DEBUG_PIM_J_P
;
8733 vty_out(vty
, "PIM Join/Prune debugging is on\n");
8734 } else if (argv_find(argv
, argc
, "register", &idx
)) {
8735 PIM_DO_DEBUG_PIM_REG
;
8736 vty_out(vty
, "PIM Register debugging is on\n");
8738 PIM_DO_DEBUG_PIM_PACKETS
;
8739 vty_out(vty
, "PIM Packet debugging is on \n");
8744 DEFUN (no_debug_pim_packets
,
8745 no_debug_pim_packets_cmd
,
8746 "no debug pim packets [<hello|joins|register>]",
8750 DEBUG_PIM_PACKETS_STR
8751 DEBUG_PIM_HELLO_PACKETS_STR
8752 DEBUG_PIM_J_P_PACKETS_STR
8753 DEBUG_PIM_PIM_REG_PACKETS_STR
)
8756 if (argv_find(argv
, argc
, "hello", &idx
)) {
8757 PIM_DONT_DEBUG_PIM_HELLO
;
8758 vty_out(vty
, "PIM Hello debugging is off \n");
8759 } else if (argv_find(argv
, argc
, "joins", &idx
)) {
8760 PIM_DONT_DEBUG_PIM_J_P
;
8761 vty_out(vty
, "PIM Join/Prune debugging is off \n");
8762 } else if (argv_find(argv
, argc
, "register", &idx
)) {
8763 PIM_DONT_DEBUG_PIM_REG
;
8764 vty_out(vty
, "PIM Register debugging is off\n");
8766 PIM_DONT_DEBUG_PIM_PACKETS
;
8772 DEFUN (debug_pim_packetdump_send
,
8773 debug_pim_packetdump_send_cmd
,
8774 "debug pim packet-dump send",
8777 DEBUG_PIM_PACKETDUMP_STR
8778 DEBUG_PIM_PACKETDUMP_SEND_STR
)
8780 PIM_DO_DEBUG_PIM_PACKETDUMP_SEND
;
8784 DEFUN (no_debug_pim_packetdump_send
,
8785 no_debug_pim_packetdump_send_cmd
,
8786 "no debug pim packet-dump send",
8790 DEBUG_PIM_PACKETDUMP_STR
8791 DEBUG_PIM_PACKETDUMP_SEND_STR
)
8793 PIM_DONT_DEBUG_PIM_PACKETDUMP_SEND
;
8797 DEFUN (debug_pim_packetdump_recv
,
8798 debug_pim_packetdump_recv_cmd
,
8799 "debug pim packet-dump receive",
8802 DEBUG_PIM_PACKETDUMP_STR
8803 DEBUG_PIM_PACKETDUMP_RECV_STR
)
8805 PIM_DO_DEBUG_PIM_PACKETDUMP_RECV
;
8809 DEFUN (no_debug_pim_packetdump_recv
,
8810 no_debug_pim_packetdump_recv_cmd
,
8811 "no debug pim packet-dump receive",
8815 DEBUG_PIM_PACKETDUMP_STR
8816 DEBUG_PIM_PACKETDUMP_RECV_STR
)
8818 PIM_DONT_DEBUG_PIM_PACKETDUMP_RECV
;
8822 DEFUN (debug_pim_trace
,
8823 debug_pim_trace_cmd
,
8827 DEBUG_PIM_TRACE_STR
)
8829 PIM_DO_DEBUG_PIM_TRACE
;
8833 DEFUN (debug_pim_trace_detail
,
8834 debug_pim_trace_detail_cmd
,
8835 "debug pim trace detail",
8839 "Detailed Information\n")
8841 PIM_DO_DEBUG_PIM_TRACE_DETAIL
;
8845 DEFUN (no_debug_pim_trace
,
8846 no_debug_pim_trace_cmd
,
8847 "no debug pim trace",
8851 DEBUG_PIM_TRACE_STR
)
8853 PIM_DONT_DEBUG_PIM_TRACE
;
8857 DEFUN (no_debug_pim_trace_detail
,
8858 no_debug_pim_trace_detail_cmd
,
8859 "no debug pim trace detail",
8864 "Detailed Information\n")
8866 PIM_DONT_DEBUG_PIM_TRACE_DETAIL
;
8870 DEFUN (debug_ssmpingd
,
8876 PIM_DO_DEBUG_SSMPINGD
;
8880 DEFUN (no_debug_ssmpingd
,
8881 no_debug_ssmpingd_cmd
,
8882 "no debug ssmpingd",
8887 PIM_DONT_DEBUG_SSMPINGD
;
8891 DEFUN (debug_pim_zebra
,
8892 debug_pim_zebra_cmd
,
8896 DEBUG_PIM_ZEBRA_STR
)
8902 DEFUN (no_debug_pim_zebra
,
8903 no_debug_pim_zebra_cmd
,
8904 "no debug pim zebra",
8908 DEBUG_PIM_ZEBRA_STR
)
8910 PIM_DONT_DEBUG_ZEBRA
;
8914 DEFUN(debug_pim_mlag
, debug_pim_mlag_cmd
, "debug pim mlag",
8915 DEBUG_STR DEBUG_PIM_STR DEBUG_PIM_MLAG_STR
)
8921 DEFUN(no_debug_pim_mlag
, no_debug_pim_mlag_cmd
, "no debug pim mlag",
8922 NO_STR DEBUG_STR DEBUG_PIM_STR DEBUG_PIM_MLAG_STR
)
8924 PIM_DONT_DEBUG_MLAG
;
8928 DEFUN (debug_pim_vxlan
,
8929 debug_pim_vxlan_cmd
,
8933 DEBUG_PIM_VXLAN_STR
)
8939 DEFUN (no_debug_pim_vxlan
,
8940 no_debug_pim_vxlan_cmd
,
8941 "no debug pim vxlan",
8945 DEBUG_PIM_VXLAN_STR
)
8947 PIM_DONT_DEBUG_VXLAN
;
8957 PIM_DO_DEBUG_MSDP_EVENTS
;
8958 PIM_DO_DEBUG_MSDP_PACKETS
;
8962 DEFUN (no_debug_msdp
,
8969 PIM_DONT_DEBUG_MSDP_EVENTS
;
8970 PIM_DONT_DEBUG_MSDP_PACKETS
;
8974 DEFUN (debug_msdp_events
,
8975 debug_msdp_events_cmd
,
8976 "debug msdp events",
8979 DEBUG_MSDP_EVENTS_STR
)
8981 PIM_DO_DEBUG_MSDP_EVENTS
;
8985 DEFUN (no_debug_msdp_events
,
8986 no_debug_msdp_events_cmd
,
8987 "no debug msdp events",
8991 DEBUG_MSDP_EVENTS_STR
)
8993 PIM_DONT_DEBUG_MSDP_EVENTS
;
8997 DEFUN (debug_msdp_packets
,
8998 debug_msdp_packets_cmd
,
8999 "debug msdp packets",
9002 DEBUG_MSDP_PACKETS_STR
)
9004 PIM_DO_DEBUG_MSDP_PACKETS
;
9008 DEFUN (no_debug_msdp_packets
,
9009 no_debug_msdp_packets_cmd
,
9010 "no debug msdp packets",
9014 DEBUG_MSDP_PACKETS_STR
)
9016 PIM_DONT_DEBUG_MSDP_PACKETS
;
9020 DEFUN (debug_mtrace
,
9026 PIM_DO_DEBUG_MTRACE
;
9030 DEFUN (no_debug_mtrace
,
9031 no_debug_mtrace_cmd
,
9037 PIM_DONT_DEBUG_MTRACE
;
9052 DEFUN (no_debug_bsm
,
9065 DEFUN_NOSH (show_debugging_pim
,
9066 show_debugging_pim_cmd
,
9067 "show debugging [pim]",
9072 vty_out(vty
, "PIM debugging status\n");
9074 pim_debug_config_write(vty
);
9079 static int interface_pim_use_src_cmd_worker(struct vty
*vty
, const char *source
)
9082 struct in_addr source_addr
;
9083 int ret
= CMD_SUCCESS
;
9084 VTY_DECLVAR_CONTEXT(interface
, ifp
);
9086 result
= inet_pton(AF_INET
, source
, &source_addr
);
9088 vty_out(vty
, "%% Bad source address %s: errno=%d: %s\n", source
,
9089 errno
, safe_strerror(errno
));
9090 return CMD_WARNING_CONFIG_FAILED
;
9093 result
= pim_update_source_set(ifp
, source_addr
);
9097 case PIM_IFACE_NOT_FOUND
:
9098 ret
= CMD_WARNING_CONFIG_FAILED
;
9099 vty_out(vty
, "Pim not enabled on this interface\n");
9101 case PIM_UPDATE_SOURCE_DUP
:
9103 vty_out(vty
, "%% Source already set to %s\n", source
);
9106 ret
= CMD_WARNING_CONFIG_FAILED
;
9107 vty_out(vty
, "%% Source set failed\n");
9113 DEFUN (interface_pim_use_source
,
9114 interface_pim_use_source_cmd
,
9115 "ip pim use-source A.B.C.D",
9118 "Configure primary IP address\n"
9119 "source ip address\n")
9121 return interface_pim_use_src_cmd_worker(vty
, argv
[3]->arg
);
9124 DEFUN (interface_no_pim_use_source
,
9125 interface_no_pim_use_source_cmd
,
9126 "no ip pim use-source [A.B.C.D]",
9130 "Delete source IP address\n"
9131 "source ip address\n")
9133 return interface_pim_use_src_cmd_worker(vty
, "0.0.0.0");
9141 "Enables BFD support\n")
9143 VTY_DECLVAR_CONTEXT(interface
, ifp
);
9144 struct pim_interface
*pim_ifp
= ifp
->info
;
9145 struct bfd_info
*bfd_info
= NULL
;
9148 if (!pim_cmd_interface_add(ifp
)) {
9149 vty_out(vty
, "Could not enable PIM SM on interface\n");
9153 pim_ifp
= ifp
->info
;
9155 bfd_info
= pim_ifp
->bfd_info
;
9157 if (!bfd_info
|| !CHECK_FLAG(bfd_info
->flags
, BFD_FLAG_PARAM_CFG
))
9158 pim_bfd_if_param_set(ifp
, BFD_DEF_MIN_RX
, BFD_DEF_MIN_TX
,
9159 BFD_DEF_DETECT_MULT
, 1);
9164 DEFUN (no_ip_pim_bfd
,
9170 "Disables BFD support\n")
9172 VTY_DECLVAR_CONTEXT(interface
, ifp
);
9173 struct pim_interface
*pim_ifp
= ifp
->info
;
9176 vty_out(vty
, "Pim not enabled on this interface\n");
9180 if (pim_ifp
->bfd_info
) {
9181 pim_bfd_reg_dereg_all_nbr(ifp
, ZEBRA_BFD_DEST_DEREGISTER
);
9182 bfd_info_free(&(pim_ifp
->bfd_info
));
9193 "Enables BSM support on the interface\n")
9195 VTY_DECLVAR_CONTEXT(interface
, ifp
);
9196 struct pim_interface
*pim_ifp
= ifp
->info
;
9199 if (!pim_cmd_interface_add(ifp
)) {
9200 vty_out(vty
, "Could not enable PIM SM on interface\n");
9205 pim_ifp
= ifp
->info
;
9206 pim_ifp
->bsm_enable
= true;
9211 DEFUN (no_ip_pim_bsm
,
9217 "Disables BSM support\n")
9219 VTY_DECLVAR_CONTEXT(interface
, ifp
);
9220 struct pim_interface
*pim_ifp
= ifp
->info
;
9223 vty_out(vty
, "Pim not enabled on this interface\n");
9227 pim_ifp
->bsm_enable
= false;
9232 DEFUN (ip_pim_ucast_bsm
,
9233 ip_pim_ucast_bsm_cmd
,
9234 "ip pim unicast-bsm",
9237 "Accept/Send unicast BSM on the interface\n")
9239 VTY_DECLVAR_CONTEXT(interface
, ifp
);
9240 struct pim_interface
*pim_ifp
= ifp
->info
;
9243 if (!pim_cmd_interface_add(ifp
)) {
9244 vty_out(vty
, "Could not enable PIM SM on interface\n");
9249 pim_ifp
= ifp
->info
;
9250 pim_ifp
->ucast_bsm_accept
= true;
9255 DEFUN (no_ip_pim_ucast_bsm
,
9256 no_ip_pim_ucast_bsm_cmd
,
9257 "no ip pim unicast-bsm",
9261 "Block send/receive unicast BSM on this interface\n")
9263 VTY_DECLVAR_CONTEXT(interface
, ifp
);
9264 struct pim_interface
*pim_ifp
= ifp
->info
;
9267 vty_out(vty
, "Pim not enabled on this interface\n");
9271 pim_ifp
->ucast_bsm_accept
= false;
9279 ip_pim_bfd_param_cmd
,
9280 "ip pim bfd (2-255) (50-60000) (50-60000)",
9283 "Enables BFD support\n"
9284 "Detect Multiplier\n"
9285 "Required min receive interval\n"
9286 "Desired min transmit interval\n")
9290 ip_pim_bfd_param_cmd
,
9291 "ip pim bfd (2-255) (50-60000) (50-60000)",
9294 "Enables BFD support\n"
9295 "Detect Multiplier\n"
9296 "Required min receive interval\n"
9297 "Desired min transmit interval\n")
9298 #endif /* HAVE_BFDD */
9300 VTY_DECLVAR_CONTEXT(interface
, ifp
);
9302 int idx_number_2
= 4;
9303 int idx_number_3
= 5;
9308 struct pim_interface
*pim_ifp
= ifp
->info
;
9311 if (!pim_cmd_interface_add(ifp
)) {
9312 vty_out(vty
, "Could not enable PIM SM on interface\n");
9317 if ((ret
= bfd_validate_param(
9318 vty
, argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
,
9319 argv
[idx_number_3
]->arg
, &dm_val
, &rx_val
, &tx_val
))
9323 pim_bfd_if_param_set(ifp
, rx_val
, tx_val
, dm_val
, 0);
9329 ALIAS(no_ip_pim_bfd
, no_ip_pim_bfd_param_cmd
,
9330 "no ip pim bfd (2-255) (50-60000) (50-60000)", NO_STR IP_STR PIM_STR
9331 "Enables BFD support\n"
9332 "Detect Multiplier\n"
9333 "Required min receive interval\n"
9334 "Desired min transmit interval\n")
9335 #endif /* !HAVE_BFDD */
9337 static int ip_msdp_peer_cmd_worker(struct pim_instance
*pim
, struct vty
*vty
,
9338 const char *peer
, const char *local
)
9340 enum pim_msdp_err result
;
9341 struct in_addr peer_addr
;
9342 struct in_addr local_addr
;
9343 int ret
= CMD_SUCCESS
;
9345 result
= inet_pton(AF_INET
, peer
, &peer_addr
);
9347 vty_out(vty
, "%% Bad peer address %s: errno=%d: %s\n", peer
,
9348 errno
, safe_strerror(errno
));
9349 return CMD_WARNING_CONFIG_FAILED
;
9352 result
= inet_pton(AF_INET
, local
, &local_addr
);
9354 vty_out(vty
, "%% Bad source address %s: errno=%d: %s\n", local
,
9355 errno
, safe_strerror(errno
));
9356 return CMD_WARNING_CONFIG_FAILED
;
9359 result
= pim_msdp_peer_add(pim
, peer_addr
, local_addr
, "default",
9362 case PIM_MSDP_ERR_NONE
:
9364 case PIM_MSDP_ERR_OOM
:
9365 ret
= CMD_WARNING_CONFIG_FAILED
;
9366 vty_out(vty
, "%% Out of memory\n");
9368 case PIM_MSDP_ERR_PEER_EXISTS
:
9370 vty_out(vty
, "%% Peer exists\n");
9372 case PIM_MSDP_ERR_MAX_MESH_GROUPS
:
9373 ret
= CMD_WARNING_CONFIG_FAILED
;
9374 vty_out(vty
, "%% Only one mesh-group allowed currently\n");
9377 ret
= CMD_WARNING_CONFIG_FAILED
;
9378 vty_out(vty
, "%% peer add failed\n");
9384 DEFUN_HIDDEN (ip_msdp_peer
,
9386 "ip msdp peer A.B.C.D source A.B.C.D",
9389 "Configure MSDP peer\n"
9391 "Source address for TCP connection\n"
9392 "local ip address\n")
9394 PIM_DECLVAR_CONTEXT(vrf
, pim
);
9395 return ip_msdp_peer_cmd_worker(pim
, vty
, argv
[3]->arg
, argv
[5]->arg
);
9398 static int ip_no_msdp_peer_cmd_worker(struct pim_instance
*pim
, struct vty
*vty
,
9401 enum pim_msdp_err result
;
9402 struct in_addr peer_addr
;
9404 result
= inet_pton(AF_INET
, peer
, &peer_addr
);
9406 vty_out(vty
, "%% Bad peer address %s: errno=%d: %s\n", peer
,
9407 errno
, safe_strerror(errno
));
9408 return CMD_WARNING_CONFIG_FAILED
;
9411 result
= pim_msdp_peer_del(pim
, peer_addr
);
9413 case PIM_MSDP_ERR_NONE
:
9415 case PIM_MSDP_ERR_NO_PEER
:
9416 vty_out(vty
, "%% Peer does not exist\n");
9419 vty_out(vty
, "%% peer del failed\n");
9422 return result
? CMD_WARNING_CONFIG_FAILED
: CMD_SUCCESS
;
9425 DEFUN_HIDDEN (no_ip_msdp_peer
,
9426 no_ip_msdp_peer_cmd
,
9427 "no ip msdp peer A.B.C.D",
9431 "Delete MSDP peer\n"
9432 "peer ip address\n")
9434 PIM_DECLVAR_CONTEXT(vrf
, pim
);
9435 return ip_no_msdp_peer_cmd_worker(pim
, vty
, argv
[4]->arg
);
9438 static int ip_msdp_mesh_group_member_cmd_worker(struct pim_instance
*pim
,
9439 struct vty
*vty
, const char *mg
,
9442 enum pim_msdp_err result
;
9443 struct in_addr mbr_ip
;
9444 int ret
= CMD_SUCCESS
;
9446 result
= inet_pton(AF_INET
, mbr
, &mbr_ip
);
9448 vty_out(vty
, "%% Bad member address %s: errno=%d: %s\n", mbr
,
9449 errno
, safe_strerror(errno
));
9450 return CMD_WARNING_CONFIG_FAILED
;
9453 result
= pim_msdp_mg_mbr_add(pim
, mg
, mbr_ip
);
9455 case PIM_MSDP_ERR_NONE
:
9457 case PIM_MSDP_ERR_OOM
:
9458 ret
= CMD_WARNING_CONFIG_FAILED
;
9459 vty_out(vty
, "%% Out of memory\n");
9461 case PIM_MSDP_ERR_MG_MBR_EXISTS
:
9463 vty_out(vty
, "%% mesh-group member exists\n");
9465 case PIM_MSDP_ERR_MAX_MESH_GROUPS
:
9466 ret
= CMD_WARNING_CONFIG_FAILED
;
9467 vty_out(vty
, "%% Only one mesh-group allowed currently\n");
9470 ret
= CMD_WARNING_CONFIG_FAILED
;
9471 vty_out(vty
, "%% member add failed\n");
9477 DEFUN (ip_msdp_mesh_group_member
,
9478 ip_msdp_mesh_group_member_cmd
,
9479 "ip msdp mesh-group WORD member A.B.C.D",
9482 "Configure MSDP mesh-group\n"
9484 "mesh group member\n"
9485 "peer ip address\n")
9487 PIM_DECLVAR_CONTEXT(vrf
, pim
);
9488 return ip_msdp_mesh_group_member_cmd_worker(pim
, vty
, argv
[3]->arg
,
9492 static int ip_no_msdp_mesh_group_member_cmd_worker(struct pim_instance
*pim
,
9497 enum pim_msdp_err result
;
9498 struct in_addr mbr_ip
;
9500 result
= inet_pton(AF_INET
, mbr
, &mbr_ip
);
9502 vty_out(vty
, "%% Bad member address %s: errno=%d: %s\n", mbr
,
9503 errno
, safe_strerror(errno
));
9504 return CMD_WARNING_CONFIG_FAILED
;
9507 result
= pim_msdp_mg_mbr_del(pim
, mg
, mbr_ip
);
9509 case PIM_MSDP_ERR_NONE
:
9511 case PIM_MSDP_ERR_NO_MG
:
9512 vty_out(vty
, "%% mesh-group does not exist\n");
9514 case PIM_MSDP_ERR_NO_MG_MBR
:
9515 vty_out(vty
, "%% mesh-group member does not exist\n");
9518 vty_out(vty
, "%% mesh-group member del failed\n");
9521 return result
? CMD_WARNING_CONFIG_FAILED
: CMD_SUCCESS
;
9523 DEFUN (no_ip_msdp_mesh_group_member
,
9524 no_ip_msdp_mesh_group_member_cmd
,
9525 "no ip msdp mesh-group WORD member A.B.C.D",
9529 "Delete MSDP mesh-group member\n"
9531 "mesh group member\n"
9532 "peer ip address\n")
9534 PIM_DECLVAR_CONTEXT(vrf
, pim
);
9535 return ip_no_msdp_mesh_group_member_cmd_worker(pim
, vty
, argv
[4]->arg
,
9539 static int ip_msdp_mesh_group_source_cmd_worker(struct pim_instance
*pim
,
9540 struct vty
*vty
, const char *mg
,
9543 enum pim_msdp_err result
;
9544 struct in_addr src_ip
;
9546 result
= inet_pton(AF_INET
, src
, &src_ip
);
9548 vty_out(vty
, "%% Bad source address %s: errno=%d: %s\n", src
,
9549 errno
, safe_strerror(errno
));
9550 return CMD_WARNING_CONFIG_FAILED
;
9553 result
= pim_msdp_mg_src_add(pim
, mg
, src_ip
);
9555 case PIM_MSDP_ERR_NONE
:
9557 case PIM_MSDP_ERR_OOM
:
9558 vty_out(vty
, "%% Out of memory\n");
9560 case PIM_MSDP_ERR_MAX_MESH_GROUPS
:
9561 vty_out(vty
, "%% Only one mesh-group allowed currently\n");
9564 vty_out(vty
, "%% source add failed\n");
9567 return result
? CMD_WARNING_CONFIG_FAILED
: CMD_SUCCESS
;
9571 DEFUN (ip_msdp_mesh_group_source
,
9572 ip_msdp_mesh_group_source_cmd
,
9573 "ip msdp mesh-group WORD source A.B.C.D",
9576 "Configure MSDP mesh-group\n"
9578 "mesh group local address\n"
9579 "source ip address for the TCP connection\n")
9581 PIM_DECLVAR_CONTEXT(vrf
, pim
);
9582 return ip_msdp_mesh_group_source_cmd_worker(pim
, vty
, argv
[3]->arg
,
9586 static int ip_no_msdp_mesh_group_source_cmd_worker(struct pim_instance
*pim
,
9590 enum pim_msdp_err result
;
9592 result
= pim_msdp_mg_src_del(pim
, mg
);
9594 case PIM_MSDP_ERR_NONE
:
9596 case PIM_MSDP_ERR_NO_MG
:
9597 vty_out(vty
, "%% mesh-group does not exist\n");
9600 vty_out(vty
, "%% mesh-group source del failed\n");
9603 return result
? CMD_WARNING_CONFIG_FAILED
: CMD_SUCCESS
;
9606 static int ip_no_msdp_mesh_group_cmd_worker(struct pim_instance
*pim
,
9607 struct vty
*vty
, const char *mg
)
9609 enum pim_msdp_err result
;
9611 result
= pim_msdp_mg_del(pim
, mg
);
9613 case PIM_MSDP_ERR_NONE
:
9615 case PIM_MSDP_ERR_NO_MG
:
9616 vty_out(vty
, "%% mesh-group does not exist\n");
9619 vty_out(vty
, "%% mesh-group source del failed\n");
9622 return result
? CMD_WARNING_CONFIG_FAILED
: CMD_SUCCESS
;
9625 DEFUN (no_ip_msdp_mesh_group_source
,
9626 no_ip_msdp_mesh_group_source_cmd
,
9627 "no ip msdp mesh-group WORD source [A.B.C.D]",
9631 "Delete MSDP mesh-group source\n"
9633 "mesh group source\n"
9634 "mesh group local address\n")
9636 PIM_DECLVAR_CONTEXT(vrf
, pim
);
9638 return ip_no_msdp_mesh_group_cmd_worker(pim
, vty
, argv
[6]->arg
);
9640 return ip_no_msdp_mesh_group_source_cmd_worker(pim
, vty
,
9644 static void print_empty_json_obj(struct vty
*vty
)
9647 json
= json_object_new_object();
9648 vty_out(vty
, "%s\n",
9649 json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
));
9650 json_object_free(json
);
9653 static void ip_msdp_show_mesh_group(struct pim_instance
*pim
, struct vty
*vty
,
9656 struct listnode
*mbrnode
;
9657 struct pim_msdp_mg_mbr
*mbr
;
9658 struct pim_msdp_mg
*mg
= pim
->msdp
.mg
;
9659 char mbr_str
[INET_ADDRSTRLEN
];
9660 char src_str
[INET_ADDRSTRLEN
];
9661 char state_str
[PIM_MSDP_STATE_STRLEN
];
9662 enum pim_msdp_peer_state state
;
9663 json_object
*json
= NULL
;
9664 json_object
*json_mg_row
= NULL
;
9665 json_object
*json_members
= NULL
;
9666 json_object
*json_row
= NULL
;
9670 print_empty_json_obj(vty
);
9674 pim_inet4_dump("<source?>", mg
->src_ip
, src_str
, sizeof(src_str
));
9676 json
= json_object_new_object();
9677 /* currently there is only one mesh group but we should still
9679 * it a dict with mg-name as key */
9680 json_mg_row
= json_object_new_object();
9681 json_object_string_add(json_mg_row
, "name",
9682 mg
->mesh_group_name
);
9683 json_object_string_add(json_mg_row
, "source", src_str
);
9685 vty_out(vty
, "Mesh group : %s\n", mg
->mesh_group_name
);
9686 vty_out(vty
, " Source : %s\n", src_str
);
9687 vty_out(vty
, " Member State\n");
9690 for (ALL_LIST_ELEMENTS_RO(mg
->mbr_list
, mbrnode
, mbr
)) {
9691 pim_inet4_dump("<mbr?>", mbr
->mbr_ip
, mbr_str
, sizeof(mbr_str
));
9693 state
= mbr
->mp
->state
;
9695 state
= PIM_MSDP_DISABLED
;
9697 pim_msdp_state_dump(state
, state_str
, sizeof(state_str
));
9699 json_row
= json_object_new_object();
9700 json_object_string_add(json_row
, "member", mbr_str
);
9701 json_object_string_add(json_row
, "state", state_str
);
9702 if (!json_members
) {
9703 json_members
= json_object_new_object();
9704 json_object_object_add(json_mg_row
, "members",
9707 json_object_object_add(json_members
, mbr_str
, json_row
);
9709 vty_out(vty
, " %-15s %11s\n", mbr_str
, state_str
);
9714 json_object_object_add(json
, mg
->mesh_group_name
, json_mg_row
);
9715 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
9716 json
, JSON_C_TO_STRING_PRETTY
));
9717 json_object_free(json
);
9721 DEFUN (show_ip_msdp_mesh_group
,
9722 show_ip_msdp_mesh_group_cmd
,
9723 "show ip msdp [vrf NAME] mesh-group [json]",
9728 "MSDP mesh-group information\n"
9731 bool uj
= use_json(argc
, argv
);
9733 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
9738 ip_msdp_show_mesh_group(vrf
->info
, vty
, uj
);
9743 DEFUN (show_ip_msdp_mesh_group_vrf_all
,
9744 show_ip_msdp_mesh_group_vrf_all_cmd
,
9745 "show ip msdp vrf all mesh-group [json]",
9750 "MSDP mesh-group information\n"
9753 bool uj
= use_json(argc
, argv
);
9759 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
9763 vty_out(vty
, " \"%s\": ", vrf
->name
);
9766 vty_out(vty
, "VRF: %s\n", vrf
->name
);
9767 ip_msdp_show_mesh_group(vrf
->info
, vty
, uj
);
9770 vty_out(vty
, "}\n");
9775 static void ip_msdp_show_peers(struct pim_instance
*pim
, struct vty
*vty
,
9778 struct listnode
*mpnode
;
9779 struct pim_msdp_peer
*mp
;
9780 char peer_str
[INET_ADDRSTRLEN
];
9781 char local_str
[INET_ADDRSTRLEN
];
9782 char state_str
[PIM_MSDP_STATE_STRLEN
];
9783 char timebuf
[PIM_MSDP_UPTIME_STRLEN
];
9785 json_object
*json
= NULL
;
9786 json_object
*json_row
= NULL
;
9790 json
= json_object_new_object();
9793 "Peer Local State Uptime SaCnt\n");
9796 for (ALL_LIST_ELEMENTS_RO(pim
->msdp
.peer_list
, mpnode
, mp
)) {
9797 if (mp
->state
== PIM_MSDP_ESTABLISHED
) {
9798 now
= pim_time_monotonic_sec();
9799 pim_time_uptime(timebuf
, sizeof(timebuf
),
9802 strlcpy(timebuf
, "-", sizeof(timebuf
));
9804 pim_inet4_dump("<peer?>", mp
->peer
, peer_str
, sizeof(peer_str
));
9805 pim_inet4_dump("<local?>", mp
->local
, local_str
,
9807 pim_msdp_state_dump(mp
->state
, state_str
, sizeof(state_str
));
9809 json_row
= json_object_new_object();
9810 json_object_string_add(json_row
, "peer", peer_str
);
9811 json_object_string_add(json_row
, "local", local_str
);
9812 json_object_string_add(json_row
, "state", state_str
);
9813 json_object_string_add(json_row
, "upTime", timebuf
);
9814 json_object_int_add(json_row
, "saCount", mp
->sa_cnt
);
9815 json_object_object_add(json
, peer_str
, json_row
);
9817 vty_out(vty
, "%-15s %15s %11s %8s %6d\n", peer_str
,
9818 local_str
, state_str
, timebuf
, mp
->sa_cnt
);
9823 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
9824 json
, JSON_C_TO_STRING_PRETTY
));
9825 json_object_free(json
);
9829 static void ip_msdp_show_peers_detail(struct pim_instance
*pim
, struct vty
*vty
,
9830 const char *peer
, bool uj
)
9832 struct listnode
*mpnode
;
9833 struct pim_msdp_peer
*mp
;
9834 char peer_str
[INET_ADDRSTRLEN
];
9835 char local_str
[INET_ADDRSTRLEN
];
9836 char state_str
[PIM_MSDP_STATE_STRLEN
];
9837 char timebuf
[PIM_MSDP_UPTIME_STRLEN
];
9838 char katimer
[PIM_MSDP_TIMER_STRLEN
];
9839 char crtimer
[PIM_MSDP_TIMER_STRLEN
];
9840 char holdtimer
[PIM_MSDP_TIMER_STRLEN
];
9842 json_object
*json
= NULL
;
9843 json_object
*json_row
= NULL
;
9846 json
= json_object_new_object();
9849 for (ALL_LIST_ELEMENTS_RO(pim
->msdp
.peer_list
, mpnode
, mp
)) {
9850 pim_inet4_dump("<peer?>", mp
->peer
, peer_str
, sizeof(peer_str
));
9851 if (strcmp(peer
, "detail") && strcmp(peer
, peer_str
))
9854 if (mp
->state
== PIM_MSDP_ESTABLISHED
) {
9855 now
= pim_time_monotonic_sec();
9856 pim_time_uptime(timebuf
, sizeof(timebuf
),
9859 strlcpy(timebuf
, "-", sizeof(timebuf
));
9861 pim_inet4_dump("<local?>", mp
->local
, local_str
,
9863 pim_msdp_state_dump(mp
->state
, state_str
, sizeof(state_str
));
9864 pim_time_timer_to_hhmmss(katimer
, sizeof(katimer
),
9866 pim_time_timer_to_hhmmss(crtimer
, sizeof(crtimer
),
9868 pim_time_timer_to_hhmmss(holdtimer
, sizeof(holdtimer
),
9872 json_row
= json_object_new_object();
9873 json_object_string_add(json_row
, "peer", peer_str
);
9874 json_object_string_add(json_row
, "local", local_str
);
9875 json_object_string_add(json_row
, "meshGroupName",
9876 mp
->mesh_group_name
);
9877 json_object_string_add(json_row
, "state", state_str
);
9878 json_object_string_add(json_row
, "upTime", timebuf
);
9879 json_object_string_add(json_row
, "keepAliveTimer",
9881 json_object_string_add(json_row
, "connRetryTimer",
9883 json_object_string_add(json_row
, "holdTimer",
9885 json_object_string_add(json_row
, "lastReset",
9887 json_object_int_add(json_row
, "connAttempts",
9889 json_object_int_add(json_row
, "establishedChanges",
9891 json_object_int_add(json_row
, "saCount", mp
->sa_cnt
);
9892 json_object_int_add(json_row
, "kaSent", mp
->ka_tx_cnt
);
9893 json_object_int_add(json_row
, "kaRcvd", mp
->ka_rx_cnt
);
9894 json_object_int_add(json_row
, "saSent", mp
->sa_tx_cnt
);
9895 json_object_int_add(json_row
, "saRcvd", mp
->sa_rx_cnt
);
9896 json_object_object_add(json
, peer_str
, json_row
);
9898 vty_out(vty
, "Peer : %s\n", peer_str
);
9899 vty_out(vty
, " Local : %s\n", local_str
);
9900 vty_out(vty
, " Mesh Group : %s\n",
9901 mp
->mesh_group_name
);
9902 vty_out(vty
, " State : %s\n", state_str
);
9903 vty_out(vty
, " Uptime : %s\n", timebuf
);
9905 vty_out(vty
, " Keepalive Timer : %s\n", katimer
);
9906 vty_out(vty
, " Conn Retry Timer : %s\n", crtimer
);
9907 vty_out(vty
, " Hold Timer : %s\n", holdtimer
);
9908 vty_out(vty
, " Last Reset : %s\n",
9910 vty_out(vty
, " Conn Attempts : %d\n",
9912 vty_out(vty
, " Established Changes : %d\n",
9914 vty_out(vty
, " SA Count : %d\n",
9916 vty_out(vty
, " Statistics :\n");
9919 vty_out(vty
, " Keepalives : %10d %10d\n",
9920 mp
->ka_tx_cnt
, mp
->ka_rx_cnt
);
9921 vty_out(vty
, " SAs : %10d %10d\n",
9922 mp
->sa_tx_cnt
, mp
->sa_rx_cnt
);
9928 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
9929 json
, JSON_C_TO_STRING_PRETTY
));
9930 json_object_free(json
);
9934 DEFUN (show_ip_msdp_peer_detail
,
9935 show_ip_msdp_peer_detail_cmd
,
9936 "show ip msdp [vrf NAME] peer [detail|A.B.C.D] [json]",
9941 "MSDP peer information\n"
9946 bool uj
= use_json(argc
, argv
);
9948 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
9955 if (argv_find(argv
, argc
, "detail", &idx
))
9956 arg
= argv
[idx
]->text
;
9957 else if (argv_find(argv
, argc
, "A.B.C.D", &idx
))
9958 arg
= argv
[idx
]->arg
;
9961 ip_msdp_show_peers_detail(vrf
->info
, vty
, argv
[idx
]->arg
, uj
);
9963 ip_msdp_show_peers(vrf
->info
, vty
, uj
);
9968 DEFUN (show_ip_msdp_peer_detail_vrf_all
,
9969 show_ip_msdp_peer_detail_vrf_all_cmd
,
9970 "show ip msdp vrf all peer [detail|A.B.C.D] [json]",
9975 "MSDP peer information\n"
9981 bool uj
= use_json(argc
, argv
);
9987 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
9991 vty_out(vty
, " \"%s\": ", vrf
->name
);
9994 vty_out(vty
, "VRF: %s\n", vrf
->name
);
9995 if (argv_find(argv
, argc
, "detail", &idx
)
9996 || argv_find(argv
, argc
, "A.B.C.D", &idx
))
9997 ip_msdp_show_peers_detail(vrf
->info
, vty
,
9998 argv
[idx
]->arg
, uj
);
10000 ip_msdp_show_peers(vrf
->info
, vty
, uj
);
10003 vty_out(vty
, "}\n");
10005 return CMD_SUCCESS
;
10008 static void ip_msdp_show_sa(struct pim_instance
*pim
, struct vty
*vty
, bool uj
)
10010 struct listnode
*sanode
;
10011 struct pim_msdp_sa
*sa
;
10012 char src_str
[INET_ADDRSTRLEN
];
10013 char grp_str
[INET_ADDRSTRLEN
];
10014 char rp_str
[INET_ADDRSTRLEN
];
10015 char timebuf
[PIM_MSDP_UPTIME_STRLEN
];
10019 json_object
*json
= NULL
;
10020 json_object
*json_group
= NULL
;
10021 json_object
*json_row
= NULL
;
10024 json
= json_object_new_object();
10027 "Source Group RP Local SPT Uptime\n");
10030 for (ALL_LIST_ELEMENTS_RO(pim
->msdp
.sa_list
, sanode
, sa
)) {
10031 now
= pim_time_monotonic_sec();
10032 pim_time_uptime(timebuf
, sizeof(timebuf
), now
- sa
->uptime
);
10033 pim_inet4_dump("<src?>", sa
->sg
.src
, src_str
, sizeof(src_str
));
10034 pim_inet4_dump("<grp?>", sa
->sg
.grp
, grp_str
, sizeof(grp_str
));
10035 if (sa
->flags
& PIM_MSDP_SAF_PEER
) {
10036 pim_inet4_dump("<rp?>", sa
->rp
, rp_str
, sizeof(rp_str
));
10038 strlcpy(spt_str
, "yes", sizeof(spt_str
));
10040 strlcpy(spt_str
, "no", sizeof(spt_str
));
10043 strlcpy(rp_str
, "-", sizeof(rp_str
));
10044 strlcpy(spt_str
, "-", sizeof(spt_str
));
10046 if (sa
->flags
& PIM_MSDP_SAF_LOCAL
) {
10047 strlcpy(local_str
, "yes", sizeof(local_str
));
10049 strlcpy(local_str
, "no", sizeof(local_str
));
10052 json_object_object_get_ex(json
, grp_str
, &json_group
);
10055 json_group
= json_object_new_object();
10056 json_object_object_add(json
, grp_str
,
10060 json_row
= json_object_new_object();
10061 json_object_string_add(json_row
, "source", src_str
);
10062 json_object_string_add(json_row
, "group", grp_str
);
10063 json_object_string_add(json_row
, "rp", rp_str
);
10064 json_object_string_add(json_row
, "local", local_str
);
10065 json_object_string_add(json_row
, "sptSetup", spt_str
);
10066 json_object_string_add(json_row
, "upTime", timebuf
);
10067 json_object_object_add(json_group
, src_str
, json_row
);
10069 vty_out(vty
, "%-15s %15s %15s %5c %3c %8s\n",
10070 src_str
, grp_str
, rp_str
, local_str
[0],
10071 spt_str
[0], timebuf
);
10076 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10077 json
, JSON_C_TO_STRING_PRETTY
));
10078 json_object_free(json
);
10082 static void ip_msdp_show_sa_entry_detail(struct pim_msdp_sa
*sa
,
10083 const char *src_str
,
10084 const char *grp_str
, struct vty
*vty
,
10085 bool uj
, json_object
*json
)
10087 char rp_str
[INET_ADDRSTRLEN
];
10088 char peer_str
[INET_ADDRSTRLEN
];
10089 char timebuf
[PIM_MSDP_UPTIME_STRLEN
];
10092 char statetimer
[PIM_MSDP_TIMER_STRLEN
];
10094 json_object
*json_group
= NULL
;
10095 json_object
*json_row
= NULL
;
10097 now
= pim_time_monotonic_sec();
10098 pim_time_uptime(timebuf
, sizeof(timebuf
), now
- sa
->uptime
);
10099 if (sa
->flags
& PIM_MSDP_SAF_PEER
) {
10100 pim_inet4_dump("<rp?>", sa
->rp
, rp_str
, sizeof(rp_str
));
10101 pim_inet4_dump("<peer?>", sa
->peer
, peer_str
, sizeof(peer_str
));
10103 strlcpy(spt_str
, "yes", sizeof(spt_str
));
10105 strlcpy(spt_str
, "no", sizeof(spt_str
));
10108 strlcpy(rp_str
, "-", sizeof(rp_str
));
10109 strlcpy(peer_str
, "-", sizeof(peer_str
));
10110 strlcpy(spt_str
, "-", sizeof(spt_str
));
10112 if (sa
->flags
& PIM_MSDP_SAF_LOCAL
) {
10113 strlcpy(local_str
, "yes", sizeof(local_str
));
10115 strlcpy(local_str
, "no", sizeof(local_str
));
10117 pim_time_timer_to_hhmmss(statetimer
, sizeof(statetimer
),
10118 sa
->sa_state_timer
);
10120 json_object_object_get_ex(json
, grp_str
, &json_group
);
10123 json_group
= json_object_new_object();
10124 json_object_object_add(json
, grp_str
, json_group
);
10127 json_row
= json_object_new_object();
10128 json_object_string_add(json_row
, "source", src_str
);
10129 json_object_string_add(json_row
, "group", grp_str
);
10130 json_object_string_add(json_row
, "rp", rp_str
);
10131 json_object_string_add(json_row
, "local", local_str
);
10132 json_object_string_add(json_row
, "sptSetup", spt_str
);
10133 json_object_string_add(json_row
, "upTime", timebuf
);
10134 json_object_string_add(json_row
, "stateTimer", statetimer
);
10135 json_object_object_add(json_group
, src_str
, json_row
);
10137 vty_out(vty
, "SA : %s\n", sa
->sg_str
);
10138 vty_out(vty
, " RP : %s\n", rp_str
);
10139 vty_out(vty
, " Peer : %s\n", peer_str
);
10140 vty_out(vty
, " Local : %s\n", local_str
);
10141 vty_out(vty
, " SPT Setup : %s\n", spt_str
);
10142 vty_out(vty
, " Uptime : %s\n", timebuf
);
10143 vty_out(vty
, " State Timer : %s\n", statetimer
);
10144 vty_out(vty
, "\n");
10148 static void ip_msdp_show_sa_detail(struct pim_instance
*pim
, struct vty
*vty
,
10151 struct listnode
*sanode
;
10152 struct pim_msdp_sa
*sa
;
10153 char src_str
[INET_ADDRSTRLEN
];
10154 char grp_str
[INET_ADDRSTRLEN
];
10155 json_object
*json
= NULL
;
10158 json
= json_object_new_object();
10161 for (ALL_LIST_ELEMENTS_RO(pim
->msdp
.sa_list
, sanode
, sa
)) {
10162 pim_inet4_dump("<src?>", sa
->sg
.src
, src_str
, sizeof(src_str
));
10163 pim_inet4_dump("<grp?>", sa
->sg
.grp
, grp_str
, sizeof(grp_str
));
10164 ip_msdp_show_sa_entry_detail(sa
, src_str
, grp_str
, vty
, uj
,
10169 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10170 json
, JSON_C_TO_STRING_PRETTY
));
10171 json_object_free(json
);
10175 DEFUN (show_ip_msdp_sa_detail
,
10176 show_ip_msdp_sa_detail_cmd
,
10177 "show ip msdp [vrf NAME] sa detail [json]",
10182 "MSDP active-source information\n"
10183 "Detailed output\n"
10186 bool uj
= use_json(argc
, argv
);
10188 struct vrf
*vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
10191 return CMD_WARNING
;
10193 ip_msdp_show_sa_detail(vrf
->info
, vty
, uj
);
10195 return CMD_SUCCESS
;
10198 DEFUN (show_ip_msdp_sa_detail_vrf_all
,
10199 show_ip_msdp_sa_detail_vrf_all_cmd
,
10200 "show ip msdp vrf all sa detail [json]",
10205 "MSDP active-source information\n"
10206 "Detailed output\n"
10209 bool uj
= use_json(argc
, argv
);
10214 vty_out(vty
, "{ ");
10215 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
10218 vty_out(vty
, ", ");
10219 vty_out(vty
, " \"%s\": ", vrf
->name
);
10222 vty_out(vty
, "VRF: %s\n", vrf
->name
);
10223 ip_msdp_show_sa_detail(vrf
->info
, vty
, uj
);
10226 vty_out(vty
, "}\n");
10228 return CMD_SUCCESS
;
10231 static void ip_msdp_show_sa_addr(struct pim_instance
*pim
, struct vty
*vty
,
10232 const char *addr
, bool uj
)
10234 struct listnode
*sanode
;
10235 struct pim_msdp_sa
*sa
;
10236 char src_str
[INET_ADDRSTRLEN
];
10237 char grp_str
[INET_ADDRSTRLEN
];
10238 json_object
*json
= NULL
;
10241 json
= json_object_new_object();
10244 for (ALL_LIST_ELEMENTS_RO(pim
->msdp
.sa_list
, sanode
, sa
)) {
10245 pim_inet4_dump("<src?>", sa
->sg
.src
, src_str
, sizeof(src_str
));
10246 pim_inet4_dump("<grp?>", sa
->sg
.grp
, grp_str
, sizeof(grp_str
));
10247 if (!strcmp(addr
, src_str
) || !strcmp(addr
, grp_str
)) {
10248 ip_msdp_show_sa_entry_detail(sa
, src_str
, grp_str
, vty
,
10254 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10255 json
, JSON_C_TO_STRING_PRETTY
));
10256 json_object_free(json
);
10260 static void ip_msdp_show_sa_sg(struct pim_instance
*pim
, struct vty
*vty
,
10261 const char *src
, const char *grp
, bool uj
)
10263 struct listnode
*sanode
;
10264 struct pim_msdp_sa
*sa
;
10265 char src_str
[INET_ADDRSTRLEN
];
10266 char grp_str
[INET_ADDRSTRLEN
];
10267 json_object
*json
= NULL
;
10270 json
= json_object_new_object();
10273 for (ALL_LIST_ELEMENTS_RO(pim
->msdp
.sa_list
, sanode
, sa
)) {
10274 pim_inet4_dump("<src?>", sa
->sg
.src
, src_str
, sizeof(src_str
));
10275 pim_inet4_dump("<grp?>", sa
->sg
.grp
, grp_str
, sizeof(grp_str
));
10276 if (!strcmp(src
, src_str
) && !strcmp(grp
, grp_str
)) {
10277 ip_msdp_show_sa_entry_detail(sa
, src_str
, grp_str
, vty
,
10283 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10284 json
, JSON_C_TO_STRING_PRETTY
));
10285 json_object_free(json
);
10289 DEFUN (show_ip_msdp_sa_sg
,
10290 show_ip_msdp_sa_sg_cmd
,
10291 "show ip msdp [vrf NAME] sa [A.B.C.D [A.B.C.D]] [json]",
10296 "MSDP active-source information\n"
10297 "source or group ip\n"
10301 bool uj
= use_json(argc
, argv
);
10305 vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
10308 return CMD_WARNING
;
10310 char *src_ip
= argv_find(argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
++]->arg
10312 char *grp_ip
= idx
< argc
&& argv_find(argv
, argc
, "A.B.C.D", &idx
)
10316 if (src_ip
&& grp_ip
)
10317 ip_msdp_show_sa_sg(vrf
->info
, vty
, src_ip
, grp_ip
, uj
);
10319 ip_msdp_show_sa_addr(vrf
->info
, vty
, src_ip
, uj
);
10321 ip_msdp_show_sa(vrf
->info
, vty
, uj
);
10323 return CMD_SUCCESS
;
10326 DEFUN (show_ip_msdp_sa_sg_vrf_all
,
10327 show_ip_msdp_sa_sg_vrf_all_cmd
,
10328 "show ip msdp vrf all sa [A.B.C.D [A.B.C.D]] [json]",
10333 "MSDP active-source information\n"
10334 "source or group ip\n"
10338 bool uj
= use_json(argc
, argv
);
10343 char *src_ip
= argv_find(argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
++]->arg
10345 char *grp_ip
= idx
< argc
&& argv_find(argv
, argc
, "A.B.C.D", &idx
)
10350 vty_out(vty
, "{ ");
10351 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
10354 vty_out(vty
, ", ");
10355 vty_out(vty
, " \"%s\": ", vrf
->name
);
10358 vty_out(vty
, "VRF: %s\n", vrf
->name
);
10360 if (src_ip
&& grp_ip
)
10361 ip_msdp_show_sa_sg(vrf
->info
, vty
, src_ip
, grp_ip
, uj
);
10363 ip_msdp_show_sa_addr(vrf
->info
, vty
, src_ip
, uj
);
10365 ip_msdp_show_sa(vrf
->info
, vty
, uj
);
10368 vty_out(vty
, "}\n");
10370 return CMD_SUCCESS
;
10373 struct pim_sg_cache_walk_data
{
10376 json_object
*json_group
;
10377 struct in_addr addr
;
10381 static void pim_show_vxlan_sg_entry(struct pim_vxlan_sg
*vxlan_sg
,
10382 struct pim_sg_cache_walk_data
*cwd
)
10384 struct vty
*vty
= cwd
->vty
;
10385 json_object
*json
= cwd
->json
;
10386 char src_str
[INET_ADDRSTRLEN
];
10387 char grp_str
[INET_ADDRSTRLEN
];
10388 json_object
*json_row
;
10389 bool installed
= (vxlan_sg
->up
) ? true : false;
10390 const char *iif_name
= vxlan_sg
->iif
?vxlan_sg
->iif
->name
:"-";
10391 const char *oif_name
;
10393 if (pim_vxlan_is_orig_mroute(vxlan_sg
))
10394 oif_name
= vxlan_sg
->orig_oif
?vxlan_sg
->orig_oif
->name
:"";
10396 oif_name
= vxlan_sg
->term_oif
?vxlan_sg
->term_oif
->name
:"";
10398 if (cwd
->addr_match
&& (vxlan_sg
->sg
.src
.s_addr
!= cwd
->addr
.s_addr
) &&
10399 (vxlan_sg
->sg
.grp
.s_addr
!= cwd
->addr
.s_addr
)) {
10402 pim_inet4_dump("<src?>", vxlan_sg
->sg
.src
, src_str
, sizeof(src_str
));
10403 pim_inet4_dump("<grp?>", vxlan_sg
->sg
.grp
, grp_str
, sizeof(grp_str
));
10405 json_object_object_get_ex(json
, grp_str
, &cwd
->json_group
);
10407 if (!cwd
->json_group
) {
10408 cwd
->json_group
= json_object_new_object();
10409 json_object_object_add(json
, grp_str
,
10413 json_row
= json_object_new_object();
10414 json_object_string_add(json_row
, "source", src_str
);
10415 json_object_string_add(json_row
, "group", grp_str
);
10416 json_object_string_add(json_row
, "input", iif_name
);
10417 json_object_string_add(json_row
, "output", oif_name
);
10419 json_object_boolean_true_add(json_row
, "installed");
10421 json_object_boolean_false_add(json_row
, "installed");
10422 json_object_object_add(cwd
->json_group
, src_str
, json_row
);
10424 vty_out(vty
, "%-15s %-15s %-15s %-15s %-5s\n",
10425 src_str
, grp_str
, iif_name
, oif_name
,
10430 static void pim_show_vxlan_sg_hash_entry(struct hash_bucket
*backet
, void *arg
)
10432 pim_show_vxlan_sg_entry((struct pim_vxlan_sg
*)backet
->data
,
10433 (struct pim_sg_cache_walk_data
*)arg
);
10436 static void pim_show_vxlan_sg(struct pim_instance
*pim
,
10437 struct vty
*vty
, bool uj
)
10439 json_object
*json
= NULL
;
10440 struct pim_sg_cache_walk_data cwd
;
10443 json
= json_object_new_object();
10445 vty_out(vty
, "Codes: I -> installed\n");
10447 "Source Group Input Output Flags\n");
10450 memset(&cwd
, 0, sizeof(cwd
));
10453 hash_iterate(pim
->vxlan
.sg_hash
, pim_show_vxlan_sg_hash_entry
, &cwd
);
10456 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10457 json
, JSON_C_TO_STRING_PRETTY
));
10458 json_object_free(json
);
10462 static void pim_show_vxlan_sg_match_addr(struct pim_instance
*pim
,
10463 struct vty
*vty
, char *addr_str
, bool uj
)
10465 json_object
*json
= NULL
;
10466 struct pim_sg_cache_walk_data cwd
;
10469 memset(&cwd
, 0, sizeof(cwd
));
10470 result
= inet_pton(AF_INET
, addr_str
, &cwd
.addr
);
10472 vty_out(vty
, "Bad address %s: errno=%d: %s\n", addr_str
,
10473 errno
, safe_strerror(errno
));
10478 json
= json_object_new_object();
10480 vty_out(vty
, "Codes: I -> installed\n");
10482 "Source Group Input Output Flags\n");
10487 cwd
.addr_match
= true;
10488 hash_iterate(pim
->vxlan
.sg_hash
, pim_show_vxlan_sg_hash_entry
, &cwd
);
10491 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10492 json
, JSON_C_TO_STRING_PRETTY
));
10493 json_object_free(json
);
10497 static void pim_show_vxlan_sg_one(struct pim_instance
*pim
,
10498 struct vty
*vty
, char *src_str
, char *grp_str
, bool uj
)
10500 json_object
*json
= NULL
;
10501 struct prefix_sg sg
;
10503 struct pim_vxlan_sg
*vxlan_sg
;
10504 const char *iif_name
;
10506 const char *oif_name
;
10508 result
= inet_pton(AF_INET
, src_str
, &sg
.src
);
10510 vty_out(vty
, "Bad src address %s: errno=%d: %s\n", src_str
,
10511 errno
, safe_strerror(errno
));
10514 result
= inet_pton(AF_INET
, grp_str
, &sg
.grp
);
10516 vty_out(vty
, "Bad grp address %s: errno=%d: %s\n", grp_str
,
10517 errno
, safe_strerror(errno
));
10521 sg
.family
= AF_INET
;
10522 sg
.prefixlen
= IPV4_MAX_BITLEN
;
10524 json
= json_object_new_object();
10526 vxlan_sg
= pim_vxlan_sg_find(pim
, &sg
);
10528 installed
= (vxlan_sg
->up
) ? true : false;
10529 iif_name
= vxlan_sg
->iif
?vxlan_sg
->iif
->name
:"-";
10531 if (pim_vxlan_is_orig_mroute(vxlan_sg
))
10533 vxlan_sg
->orig_oif
?vxlan_sg
->orig_oif
->name
:"";
10536 vxlan_sg
->term_oif
?vxlan_sg
->term_oif
->name
:"";
10539 json_object_string_add(json
, "source", src_str
);
10540 json_object_string_add(json
, "group", grp_str
);
10541 json_object_string_add(json
, "input", iif_name
);
10542 json_object_string_add(json
, "output", oif_name
);
10544 json_object_boolean_true_add(json
, "installed");
10546 json_object_boolean_false_add(json
,
10549 vty_out(vty
, "SG : %s\n", vxlan_sg
->sg_str
);
10550 vty_out(vty
, " Input : %s\n", iif_name
);
10551 vty_out(vty
, " Output : %s\n", oif_name
);
10552 vty_out(vty
, " installed : %s\n",
10553 installed
?"yes":"no");
10558 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10559 json
, JSON_C_TO_STRING_PRETTY
));
10560 json_object_free(json
);
10564 DEFUN (show_ip_pim_vxlan_sg
,
10565 show_ip_pim_vxlan_sg_cmd
,
10566 "show ip pim [vrf NAME] vxlan-groups [A.B.C.D [A.B.C.D]] [json]",
10571 "VxLAN BUM groups\n"
10572 "source or group ip\n"
10576 bool uj
= use_json(argc
, argv
);
10580 vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
10583 return CMD_WARNING
;
10585 char *src_ip
= argv_find(argv
, argc
, "A.B.C.D", &idx
) ?
10586 argv
[idx
++]->arg
:NULL
;
10587 char *grp_ip
= idx
< argc
&& argv_find(argv
, argc
, "A.B.C.D", &idx
) ?
10588 argv
[idx
]->arg
:NULL
;
10590 if (src_ip
&& grp_ip
)
10591 pim_show_vxlan_sg_one(vrf
->info
, vty
, src_ip
, grp_ip
, uj
);
10593 pim_show_vxlan_sg_match_addr(vrf
->info
, vty
, src_ip
, uj
);
10595 pim_show_vxlan_sg(vrf
->info
, vty
, uj
);
10597 return CMD_SUCCESS
;
10600 static void pim_show_vxlan_sg_work(struct pim_instance
*pim
,
10601 struct vty
*vty
, bool uj
)
10603 json_object
*json
= NULL
;
10604 struct pim_sg_cache_walk_data cwd
;
10605 struct listnode
*node
;
10606 struct pim_vxlan_sg
*vxlan_sg
;
10609 json
= json_object_new_object();
10611 vty_out(vty
, "Codes: I -> installed\n");
10613 "Source Group Input Flags\n");
10616 memset(&cwd
, 0, sizeof(cwd
));
10619 for (ALL_LIST_ELEMENTS_RO(pim_vxlan_p
->work_list
, node
, vxlan_sg
))
10620 pim_show_vxlan_sg_entry(vxlan_sg
, &cwd
);
10623 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10624 json
, JSON_C_TO_STRING_PRETTY
));
10625 json_object_free(json
);
10629 DEFUN_HIDDEN (show_ip_pim_vxlan_sg_work
,
10630 show_ip_pim_vxlan_sg_work_cmd
,
10631 "show ip pim [vrf NAME] vxlan-work [json]",
10636 "VxLAN work list\n"
10639 bool uj
= use_json(argc
, argv
);
10643 vrf
= pim_cmd_lookup_vrf(vty
, argv
, argc
, &idx
);
10646 return CMD_WARNING
;
10648 pim_show_vxlan_sg_work(vrf
->info
, vty
, uj
);
10650 return CMD_SUCCESS
;
10653 DEFUN_HIDDEN (no_ip_pim_mlag
,
10654 no_ip_pim_mlag_cmd
,
10661 struct in_addr addr
;
10664 pim_vxlan_mlag_update(true/*mlag_enable*/,
10665 false/*peer_state*/, MLAG_ROLE_NONE
,
10666 NULL
/*peerlink*/, &addr
);
10668 return CMD_SUCCESS
;
10671 DEFUN_HIDDEN (ip_pim_mlag
,
10673 "ip pim mlag INTERFACE role [primary|secondary] state [up|down] addr A.B.C.D",
10677 "peerlink sub interface\n"
10679 "MLAG role primary\n"
10680 "MLAG role secondary\n"
10681 "peer session state\n"
10682 "peer session state up\n"
10683 "peer session state down\n"
10685 "unique ip address\n")
10687 struct interface
*ifp
;
10688 const char *peerlink
;
10693 struct in_addr reg_addr
;
10696 peerlink
= argv
[idx
]->arg
;
10697 ifp
= if_lookup_by_name(peerlink
, VRF_DEFAULT
);
10699 vty_out(vty
, "No such interface name %s\n", peerlink
);
10700 return CMD_WARNING
;
10704 if (!strcmp(argv
[idx
]->arg
, "primary")) {
10705 role
= MLAG_ROLE_PRIMARY
;
10706 } else if (!strcmp(argv
[idx
]->arg
, "secondary")) {
10707 role
= MLAG_ROLE_SECONDARY
;
10709 vty_out(vty
, "unknown MLAG role %s\n", argv
[idx
]->arg
);
10710 return CMD_WARNING
;
10714 if (!strcmp(argv
[idx
]->arg
, "up")) {
10716 } else if (strcmp(argv
[idx
]->arg
, "down")) {
10717 peer_state
= false;
10719 vty_out(vty
, "unknown MLAG state %s\n", argv
[idx
]->arg
);
10720 return CMD_WARNING
;
10724 result
= inet_pton(AF_INET
, argv
[idx
]->arg
, ®_addr
);
10726 vty_out(vty
, "%% Bad reg address %s: errno=%d: %s\n",
10728 errno
, safe_strerror(errno
));
10729 return CMD_WARNING_CONFIG_FAILED
;
10731 pim_vxlan_mlag_update(true, peer_state
, role
, ifp
, ®_addr
);
10733 return CMD_SUCCESS
;
10736 void pim_cmd_init(void)
10738 install_node(&interface_node
,
10739 pim_interface_config_write
); /* INTERFACE_NODE */
10742 install_node(&debug_node
, pim_debug_config_write
);
10744 install_element(ENABLE_NODE
, &pim_test_sg_keepalive_cmd
);
10746 install_element(CONFIG_NODE
, &ip_pim_rp_cmd
);
10747 install_element(VRF_NODE
, &ip_pim_rp_cmd
);
10748 install_element(CONFIG_NODE
, &no_ip_pim_rp_cmd
);
10749 install_element(VRF_NODE
, &no_ip_pim_rp_cmd
);
10750 install_element(CONFIG_NODE
, &ip_pim_rp_prefix_list_cmd
);
10751 install_element(VRF_NODE
, &ip_pim_rp_prefix_list_cmd
);
10752 install_element(CONFIG_NODE
, &no_ip_pim_rp_prefix_list_cmd
);
10753 install_element(VRF_NODE
, &no_ip_pim_rp_prefix_list_cmd
);
10754 install_element(CONFIG_NODE
, &no_ip_pim_ssm_prefix_list_cmd
);
10755 install_element(VRF_NODE
, &no_ip_pim_ssm_prefix_list_cmd
);
10756 install_element(CONFIG_NODE
, &no_ip_pim_ssm_prefix_list_name_cmd
);
10757 install_element(VRF_NODE
, &no_ip_pim_ssm_prefix_list_name_cmd
);
10758 install_element(CONFIG_NODE
, &ip_pim_ssm_prefix_list_cmd
);
10759 install_element(VRF_NODE
, &ip_pim_ssm_prefix_list_cmd
);
10760 install_element(CONFIG_NODE
, &ip_pim_register_suppress_cmd
);
10761 install_element(VRF_NODE
, &ip_pim_register_suppress_cmd
);
10762 install_element(CONFIG_NODE
, &no_ip_pim_register_suppress_cmd
);
10763 install_element(VRF_NODE
, &no_ip_pim_register_suppress_cmd
);
10764 install_element(CONFIG_NODE
, &ip_pim_spt_switchover_infinity_cmd
);
10765 install_element(VRF_NODE
, &ip_pim_spt_switchover_infinity_cmd
);
10766 install_element(CONFIG_NODE
, &ip_pim_spt_switchover_infinity_plist_cmd
);
10767 install_element(VRF_NODE
, &ip_pim_spt_switchover_infinity_plist_cmd
);
10768 install_element(CONFIG_NODE
, &no_ip_pim_spt_switchover_infinity_cmd
);
10769 install_element(VRF_NODE
, &no_ip_pim_spt_switchover_infinity_cmd
);
10770 install_element(CONFIG_NODE
,
10771 &no_ip_pim_spt_switchover_infinity_plist_cmd
);
10772 install_element(VRF_NODE
, &no_ip_pim_spt_switchover_infinity_plist_cmd
);
10773 install_element(CONFIG_NODE
, &ip_pim_joinprune_time_cmd
);
10774 install_element(VRF_NODE
, &ip_pim_joinprune_time_cmd
);
10775 install_element(CONFIG_NODE
, &no_ip_pim_joinprune_time_cmd
);
10776 install_element(VRF_NODE
, &no_ip_pim_joinprune_time_cmd
);
10777 install_element(CONFIG_NODE
, &ip_pim_keep_alive_cmd
);
10778 install_element(VRF_NODE
, &ip_pim_keep_alive_cmd
);
10779 install_element(CONFIG_NODE
, &ip_pim_rp_keep_alive_cmd
);
10780 install_element(VRF_NODE
, &ip_pim_rp_keep_alive_cmd
);
10781 install_element(CONFIG_NODE
, &no_ip_pim_keep_alive_cmd
);
10782 install_element(VRF_NODE
, &no_ip_pim_keep_alive_cmd
);
10783 install_element(CONFIG_NODE
, &no_ip_pim_rp_keep_alive_cmd
);
10784 install_element(VRF_NODE
, &no_ip_pim_rp_keep_alive_cmd
);
10785 install_element(CONFIG_NODE
, &ip_pim_packets_cmd
);
10786 install_element(VRF_NODE
, &ip_pim_packets_cmd
);
10787 install_element(CONFIG_NODE
, &no_ip_pim_packets_cmd
);
10788 install_element(VRF_NODE
, &no_ip_pim_packets_cmd
);
10789 install_element(CONFIG_NODE
, &ip_pim_v6_secondary_cmd
);
10790 install_element(VRF_NODE
, &ip_pim_v6_secondary_cmd
);
10791 install_element(CONFIG_NODE
, &no_ip_pim_v6_secondary_cmd
);
10792 install_element(VRF_NODE
, &no_ip_pim_v6_secondary_cmd
);
10793 install_element(CONFIG_NODE
, &ip_ssmpingd_cmd
);
10794 install_element(VRF_NODE
, &ip_ssmpingd_cmd
);
10795 install_element(CONFIG_NODE
, &no_ip_ssmpingd_cmd
);
10796 install_element(VRF_NODE
, &no_ip_ssmpingd_cmd
);
10797 install_element(CONFIG_NODE
, &ip_msdp_peer_cmd
);
10798 install_element(VRF_NODE
, &ip_msdp_peer_cmd
);
10799 install_element(CONFIG_NODE
, &no_ip_msdp_peer_cmd
);
10800 install_element(VRF_NODE
, &no_ip_msdp_peer_cmd
);
10801 install_element(CONFIG_NODE
, &ip_pim_ecmp_cmd
);
10802 install_element(VRF_NODE
, &ip_pim_ecmp_cmd
);
10803 install_element(CONFIG_NODE
, &no_ip_pim_ecmp_cmd
);
10804 install_element(VRF_NODE
, &no_ip_pim_ecmp_cmd
);
10805 install_element(CONFIG_NODE
, &ip_pim_ecmp_rebalance_cmd
);
10806 install_element(VRF_NODE
, &ip_pim_ecmp_rebalance_cmd
);
10807 install_element(CONFIG_NODE
, &no_ip_pim_ecmp_rebalance_cmd
);
10808 install_element(VRF_NODE
, &no_ip_pim_ecmp_rebalance_cmd
);
10809 install_element(CONFIG_NODE
, &ip_pim_mlag_cmd
);
10810 install_element(CONFIG_NODE
, &no_ip_pim_mlag_cmd
);
10812 install_element(INTERFACE_NODE
, &interface_ip_igmp_cmd
);
10813 install_element(INTERFACE_NODE
, &interface_no_ip_igmp_cmd
);
10814 install_element(INTERFACE_NODE
, &interface_ip_igmp_join_cmd
);
10815 install_element(INTERFACE_NODE
, &interface_no_ip_igmp_join_cmd
);
10816 install_element(INTERFACE_NODE
, &interface_ip_igmp_version_cmd
);
10817 install_element(INTERFACE_NODE
, &interface_no_ip_igmp_version_cmd
);
10818 install_element(INTERFACE_NODE
, &interface_ip_igmp_query_interval_cmd
);
10819 install_element(INTERFACE_NODE
,
10820 &interface_no_ip_igmp_query_interval_cmd
);
10821 install_element(INTERFACE_NODE
,
10822 &interface_ip_igmp_query_max_response_time_cmd
);
10823 install_element(INTERFACE_NODE
,
10824 &interface_no_ip_igmp_query_max_response_time_cmd
);
10825 install_element(INTERFACE_NODE
,
10826 &interface_ip_igmp_query_max_response_time_dsec_cmd
);
10827 install_element(INTERFACE_NODE
,
10828 &interface_no_ip_igmp_query_max_response_time_dsec_cmd
);
10829 install_element(INTERFACE_NODE
,
10830 &interface_ip_igmp_last_member_query_count_cmd
);
10831 install_element(INTERFACE_NODE
,
10832 &interface_no_ip_igmp_last_member_query_count_cmd
);
10833 install_element(INTERFACE_NODE
,
10834 &interface_ip_igmp_last_member_query_interval_cmd
);
10835 install_element(INTERFACE_NODE
,
10836 &interface_no_ip_igmp_last_member_query_interval_cmd
);
10837 install_element(INTERFACE_NODE
, &interface_ip_pim_activeactive_cmd
);
10838 install_element(INTERFACE_NODE
, &interface_ip_pim_ssm_cmd
);
10839 install_element(INTERFACE_NODE
, &interface_no_ip_pim_ssm_cmd
);
10840 install_element(INTERFACE_NODE
, &interface_ip_pim_sm_cmd
);
10841 install_element(INTERFACE_NODE
, &interface_no_ip_pim_sm_cmd
);
10842 install_element(INTERFACE_NODE
, &interface_ip_pim_cmd
);
10843 install_element(INTERFACE_NODE
, &interface_no_ip_pim_cmd
);
10844 install_element(INTERFACE_NODE
, &interface_ip_pim_drprio_cmd
);
10845 install_element(INTERFACE_NODE
, &interface_no_ip_pim_drprio_cmd
);
10846 install_element(INTERFACE_NODE
, &interface_ip_pim_hello_cmd
);
10847 install_element(INTERFACE_NODE
, &interface_no_ip_pim_hello_cmd
);
10848 install_element(INTERFACE_NODE
, &interface_ip_pim_boundary_oil_cmd
);
10849 install_element(INTERFACE_NODE
, &interface_no_ip_pim_boundary_oil_cmd
);
10850 install_element(INTERFACE_NODE
, &interface_ip_igmp_query_generate_cmd
);
10852 // Static mroutes NEB
10853 install_element(INTERFACE_NODE
, &interface_ip_mroute_cmd
);
10854 install_element(INTERFACE_NODE
, &interface_no_ip_mroute_cmd
);
10856 install_element(VIEW_NODE
, &show_ip_igmp_interface_cmd
);
10857 install_element(VIEW_NODE
, &show_ip_igmp_interface_vrf_all_cmd
);
10858 install_element(VIEW_NODE
, &show_ip_igmp_join_cmd
);
10859 install_element(VIEW_NODE
, &show_ip_igmp_join_vrf_all_cmd
);
10860 install_element(VIEW_NODE
, &show_ip_igmp_groups_cmd
);
10861 install_element(VIEW_NODE
, &show_ip_igmp_groups_vrf_all_cmd
);
10862 install_element(VIEW_NODE
, &show_ip_igmp_groups_retransmissions_cmd
);
10863 install_element(VIEW_NODE
, &show_ip_igmp_sources_cmd
);
10864 install_element(VIEW_NODE
, &show_ip_igmp_sources_retransmissions_cmd
);
10865 install_element(VIEW_NODE
, &show_ip_igmp_statistics_cmd
);
10866 install_element(VIEW_NODE
, &show_ip_pim_assert_cmd
);
10867 install_element(VIEW_NODE
, &show_ip_pim_assert_internal_cmd
);
10868 install_element(VIEW_NODE
, &show_ip_pim_assert_metric_cmd
);
10869 install_element(VIEW_NODE
, &show_ip_pim_assert_winner_metric_cmd
);
10870 install_element(VIEW_NODE
, &show_ip_pim_interface_traffic_cmd
);
10871 install_element(VIEW_NODE
, &show_ip_pim_interface_cmd
);
10872 install_element(VIEW_NODE
, &show_ip_pim_interface_vrf_all_cmd
);
10873 install_element(VIEW_NODE
, &show_ip_pim_join_cmd
);
10874 install_element(VIEW_NODE
, &show_ip_pim_join_vrf_all_cmd
);
10875 install_element(VIEW_NODE
, &show_ip_pim_jp_agg_cmd
);
10876 install_element(VIEW_NODE
, &show_ip_pim_local_membership_cmd
);
10877 install_element(VIEW_NODE
, &show_ip_pim_mlag_summary_cmd
);
10878 install_element(VIEW_NODE
, &show_ip_pim_mlag_up_cmd
);
10879 install_element(VIEW_NODE
, &show_ip_pim_mlag_up_vrf_all_cmd
);
10880 install_element(VIEW_NODE
, &show_ip_pim_neighbor_cmd
);
10881 install_element(VIEW_NODE
, &show_ip_pim_neighbor_vrf_all_cmd
);
10882 install_element(VIEW_NODE
, &show_ip_pim_rpf_cmd
);
10883 install_element(VIEW_NODE
, &show_ip_pim_rpf_vrf_all_cmd
);
10884 install_element(VIEW_NODE
, &show_ip_pim_secondary_cmd
);
10885 install_element(VIEW_NODE
, &show_ip_pim_state_cmd
);
10886 install_element(VIEW_NODE
, &show_ip_pim_state_vrf_all_cmd
);
10887 install_element(VIEW_NODE
, &show_ip_pim_upstream_cmd
);
10888 install_element(VIEW_NODE
, &show_ip_pim_upstream_vrf_all_cmd
);
10889 install_element(VIEW_NODE
, &show_ip_pim_channel_cmd
);
10890 install_element(VIEW_NODE
, &show_ip_pim_upstream_join_desired_cmd
);
10891 install_element(VIEW_NODE
, &show_ip_pim_upstream_rpf_cmd
);
10892 install_element(VIEW_NODE
, &show_ip_pim_rp_cmd
);
10893 install_element(VIEW_NODE
, &show_ip_pim_rp_vrf_all_cmd
);
10894 install_element(VIEW_NODE
, &show_ip_pim_bsr_cmd
);
10895 install_element(VIEW_NODE
, &show_ip_multicast_cmd
);
10896 install_element(VIEW_NODE
, &show_ip_multicast_vrf_all_cmd
);
10897 install_element(VIEW_NODE
, &show_ip_mroute_cmd
);
10898 install_element(VIEW_NODE
, &show_ip_mroute_vrf_all_cmd
);
10899 install_element(VIEW_NODE
, &show_ip_mroute_count_cmd
);
10900 install_element(VIEW_NODE
, &show_ip_mroute_count_vrf_all_cmd
);
10901 install_element(VIEW_NODE
, &show_ip_mroute_summary_cmd
);
10902 install_element(VIEW_NODE
, &show_ip_mroute_summary_vrf_all_cmd
);
10903 install_element(VIEW_NODE
, &show_ip_rib_cmd
);
10904 install_element(VIEW_NODE
, &show_ip_ssmpingd_cmd
);
10905 install_element(VIEW_NODE
, &show_debugging_pim_cmd
);
10906 install_element(VIEW_NODE
, &show_ip_pim_nexthop_cmd
);
10907 install_element(VIEW_NODE
, &show_ip_pim_nexthop_lookup_cmd
);
10908 install_element(VIEW_NODE
, &show_ip_pim_bsrp_cmd
);
10909 install_element(VIEW_NODE
, &show_ip_pim_bsm_db_cmd
);
10910 install_element(VIEW_NODE
, &show_ip_pim_statistics_cmd
);
10912 install_element(ENABLE_NODE
, &clear_ip_mroute_count_cmd
);
10913 install_element(ENABLE_NODE
, &clear_ip_interfaces_cmd
);
10914 install_element(ENABLE_NODE
, &clear_ip_igmp_interfaces_cmd
);
10915 install_element(ENABLE_NODE
, &clear_ip_mroute_cmd
);
10916 install_element(ENABLE_NODE
, &clear_ip_pim_interfaces_cmd
);
10917 install_element(ENABLE_NODE
, &clear_ip_pim_interface_traffic_cmd
);
10918 install_element(ENABLE_NODE
, &clear_ip_pim_oil_cmd
);
10919 install_element(ENABLE_NODE
, &clear_ip_pim_statistics_cmd
);
10921 install_element(ENABLE_NODE
, &debug_igmp_cmd
);
10922 install_element(ENABLE_NODE
, &no_debug_igmp_cmd
);
10923 install_element(ENABLE_NODE
, &debug_igmp_events_cmd
);
10924 install_element(ENABLE_NODE
, &no_debug_igmp_events_cmd
);
10925 install_element(ENABLE_NODE
, &debug_igmp_packets_cmd
);
10926 install_element(ENABLE_NODE
, &no_debug_igmp_packets_cmd
);
10927 install_element(ENABLE_NODE
, &debug_igmp_trace_cmd
);
10928 install_element(ENABLE_NODE
, &no_debug_igmp_trace_cmd
);
10929 install_element(ENABLE_NODE
, &debug_mroute_cmd
);
10930 install_element(ENABLE_NODE
, &debug_mroute_detail_cmd
);
10931 install_element(ENABLE_NODE
, &no_debug_mroute_cmd
);
10932 install_element(ENABLE_NODE
, &no_debug_mroute_detail_cmd
);
10933 install_element(ENABLE_NODE
, &debug_pim_static_cmd
);
10934 install_element(ENABLE_NODE
, &no_debug_pim_static_cmd
);
10935 install_element(ENABLE_NODE
, &debug_pim_cmd
);
10936 install_element(ENABLE_NODE
, &no_debug_pim_cmd
);
10937 install_element(ENABLE_NODE
, &debug_pim_nht_cmd
);
10938 install_element(ENABLE_NODE
, &no_debug_pim_nht_cmd
);
10939 install_element(ENABLE_NODE
, &debug_pim_nht_rp_cmd
);
10940 install_element(ENABLE_NODE
, &no_debug_pim_nht_rp_cmd
);
10941 install_element(ENABLE_NODE
, &debug_pim_events_cmd
);
10942 install_element(ENABLE_NODE
, &no_debug_pim_events_cmd
);
10943 install_element(ENABLE_NODE
, &debug_pim_packets_cmd
);
10944 install_element(ENABLE_NODE
, &no_debug_pim_packets_cmd
);
10945 install_element(ENABLE_NODE
, &debug_pim_packetdump_send_cmd
);
10946 install_element(ENABLE_NODE
, &no_debug_pim_packetdump_send_cmd
);
10947 install_element(ENABLE_NODE
, &debug_pim_packetdump_recv_cmd
);
10948 install_element(ENABLE_NODE
, &no_debug_pim_packetdump_recv_cmd
);
10949 install_element(ENABLE_NODE
, &debug_pim_trace_cmd
);
10950 install_element(ENABLE_NODE
, &no_debug_pim_trace_cmd
);
10951 install_element(ENABLE_NODE
, &debug_pim_trace_detail_cmd
);
10952 install_element(ENABLE_NODE
, &no_debug_pim_trace_detail_cmd
);
10953 install_element(ENABLE_NODE
, &debug_ssmpingd_cmd
);
10954 install_element(ENABLE_NODE
, &no_debug_ssmpingd_cmd
);
10955 install_element(ENABLE_NODE
, &debug_pim_zebra_cmd
);
10956 install_element(ENABLE_NODE
, &no_debug_pim_zebra_cmd
);
10957 install_element(ENABLE_NODE
, &debug_pim_mlag_cmd
);
10958 install_element(ENABLE_NODE
, &no_debug_pim_mlag_cmd
);
10959 install_element(ENABLE_NODE
, &debug_pim_vxlan_cmd
);
10960 install_element(ENABLE_NODE
, &no_debug_pim_vxlan_cmd
);
10961 install_element(ENABLE_NODE
, &debug_msdp_cmd
);
10962 install_element(ENABLE_NODE
, &no_debug_msdp_cmd
);
10963 install_element(ENABLE_NODE
, &debug_msdp_events_cmd
);
10964 install_element(ENABLE_NODE
, &no_debug_msdp_events_cmd
);
10965 install_element(ENABLE_NODE
, &debug_msdp_packets_cmd
);
10966 install_element(ENABLE_NODE
, &no_debug_msdp_packets_cmd
);
10967 install_element(ENABLE_NODE
, &debug_mtrace_cmd
);
10968 install_element(ENABLE_NODE
, &no_debug_mtrace_cmd
);
10969 install_element(ENABLE_NODE
, &debug_bsm_cmd
);
10970 install_element(ENABLE_NODE
, &no_debug_bsm_cmd
);
10972 install_element(CONFIG_NODE
, &debug_igmp_cmd
);
10973 install_element(CONFIG_NODE
, &no_debug_igmp_cmd
);
10974 install_element(CONFIG_NODE
, &debug_igmp_events_cmd
);
10975 install_element(CONFIG_NODE
, &no_debug_igmp_events_cmd
);
10976 install_element(CONFIG_NODE
, &debug_igmp_packets_cmd
);
10977 install_element(CONFIG_NODE
, &no_debug_igmp_packets_cmd
);
10978 install_element(CONFIG_NODE
, &debug_igmp_trace_cmd
);
10979 install_element(CONFIG_NODE
, &no_debug_igmp_trace_cmd
);
10980 install_element(CONFIG_NODE
, &debug_mroute_cmd
);
10981 install_element(CONFIG_NODE
, &debug_mroute_detail_cmd
);
10982 install_element(CONFIG_NODE
, &no_debug_mroute_cmd
);
10983 install_element(CONFIG_NODE
, &no_debug_mroute_detail_cmd
);
10984 install_element(CONFIG_NODE
, &debug_pim_static_cmd
);
10985 install_element(CONFIG_NODE
, &no_debug_pim_static_cmd
);
10986 install_element(CONFIG_NODE
, &debug_pim_cmd
);
10987 install_element(CONFIG_NODE
, &no_debug_pim_cmd
);
10988 install_element(CONFIG_NODE
, &debug_pim_nht_cmd
);
10989 install_element(CONFIG_NODE
, &no_debug_pim_nht_cmd
);
10990 install_element(CONFIG_NODE
, &debug_pim_nht_rp_cmd
);
10991 install_element(CONFIG_NODE
, &no_debug_pim_nht_rp_cmd
);
10992 install_element(CONFIG_NODE
, &debug_pim_events_cmd
);
10993 install_element(CONFIG_NODE
, &no_debug_pim_events_cmd
);
10994 install_element(CONFIG_NODE
, &debug_pim_packets_cmd
);
10995 install_element(CONFIG_NODE
, &no_debug_pim_packets_cmd
);
10996 install_element(CONFIG_NODE
, &debug_pim_trace_cmd
);
10997 install_element(CONFIG_NODE
, &no_debug_pim_trace_cmd
);
10998 install_element(CONFIG_NODE
, &debug_pim_trace_detail_cmd
);
10999 install_element(CONFIG_NODE
, &no_debug_pim_trace_detail_cmd
);
11000 install_element(CONFIG_NODE
, &debug_ssmpingd_cmd
);
11001 install_element(CONFIG_NODE
, &no_debug_ssmpingd_cmd
);
11002 install_element(CONFIG_NODE
, &debug_pim_zebra_cmd
);
11003 install_element(CONFIG_NODE
, &no_debug_pim_zebra_cmd
);
11004 install_element(CONFIG_NODE
, &debug_pim_mlag_cmd
);
11005 install_element(CONFIG_NODE
, &no_debug_pim_mlag_cmd
);
11006 install_element(CONFIG_NODE
, &debug_pim_vxlan_cmd
);
11007 install_element(CONFIG_NODE
, &no_debug_pim_vxlan_cmd
);
11008 install_element(CONFIG_NODE
, &debug_msdp_cmd
);
11009 install_element(CONFIG_NODE
, &no_debug_msdp_cmd
);
11010 install_element(CONFIG_NODE
, &debug_msdp_events_cmd
);
11011 install_element(CONFIG_NODE
, &no_debug_msdp_events_cmd
);
11012 install_element(CONFIG_NODE
, &debug_msdp_packets_cmd
);
11013 install_element(CONFIG_NODE
, &no_debug_msdp_packets_cmd
);
11014 install_element(CONFIG_NODE
, &debug_mtrace_cmd
);
11015 install_element(CONFIG_NODE
, &no_debug_mtrace_cmd
);
11016 install_element(CONFIG_NODE
, &debug_bsm_cmd
);
11017 install_element(CONFIG_NODE
, &no_debug_bsm_cmd
);
11019 install_element(CONFIG_NODE
, &ip_msdp_mesh_group_member_cmd
);
11020 install_element(VRF_NODE
, &ip_msdp_mesh_group_member_cmd
);
11021 install_element(CONFIG_NODE
, &no_ip_msdp_mesh_group_member_cmd
);
11022 install_element(VRF_NODE
, &no_ip_msdp_mesh_group_member_cmd
);
11023 install_element(CONFIG_NODE
, &ip_msdp_mesh_group_source_cmd
);
11024 install_element(VRF_NODE
, &ip_msdp_mesh_group_source_cmd
);
11025 install_element(CONFIG_NODE
, &no_ip_msdp_mesh_group_source_cmd
);
11026 install_element(VRF_NODE
, &no_ip_msdp_mesh_group_source_cmd
);
11027 install_element(VIEW_NODE
, &show_ip_msdp_peer_detail_cmd
);
11028 install_element(VIEW_NODE
, &show_ip_msdp_peer_detail_vrf_all_cmd
);
11029 install_element(VIEW_NODE
, &show_ip_msdp_sa_detail_cmd
);
11030 install_element(VIEW_NODE
, &show_ip_msdp_sa_detail_vrf_all_cmd
);
11031 install_element(VIEW_NODE
, &show_ip_msdp_sa_sg_cmd
);
11032 install_element(VIEW_NODE
, &show_ip_msdp_sa_sg_vrf_all_cmd
);
11033 install_element(VIEW_NODE
, &show_ip_msdp_mesh_group_cmd
);
11034 install_element(VIEW_NODE
, &show_ip_msdp_mesh_group_vrf_all_cmd
);
11035 install_element(VIEW_NODE
, &show_ip_pim_ssm_range_cmd
);
11036 install_element(VIEW_NODE
, &show_ip_pim_group_type_cmd
);
11037 install_element(VIEW_NODE
, &show_ip_pim_vxlan_sg_cmd
);
11038 install_element(VIEW_NODE
, &show_ip_pim_vxlan_sg_work_cmd
);
11039 install_element(INTERFACE_NODE
, &interface_pim_use_source_cmd
);
11040 install_element(INTERFACE_NODE
, &interface_no_pim_use_source_cmd
);
11041 /* Install BSM command */
11042 install_element(INTERFACE_NODE
, &ip_pim_bsm_cmd
);
11043 install_element(INTERFACE_NODE
, &no_ip_pim_bsm_cmd
);
11044 install_element(INTERFACE_NODE
, &ip_pim_ucast_bsm_cmd
);
11045 install_element(INTERFACE_NODE
, &no_ip_pim_ucast_bsm_cmd
);
11046 /* Install BFD command */
11047 install_element(INTERFACE_NODE
, &ip_pim_bfd_cmd
);
11048 install_element(INTERFACE_NODE
, &ip_pim_bfd_param_cmd
);
11049 install_element(INTERFACE_NODE
, &no_ip_pim_bfd_cmd
);
11051 install_element(INTERFACE_NODE
, &no_ip_pim_bfd_param_cmd
);
11052 #endif /* !HAVE_BFDD */