diff options
| author | Abhishek N R <abnr@vmware.com> | 2022-04-07 03:35:22 -0700 |
|---|---|---|
| committer | Abhishek N R <abnr@vmware.com> | 2022-04-26 07:02:58 -0700 |
| commit | be126d919a2aeac79f63582055f13498ae326256 (patch) | |
| tree | ae463dc94839fb1139913c41fac6c22928df979b /pimd/pim_cmd_common.c | |
| parent | d1b7dfbe0841bbfb94a72fe6ea46ae9d059b5230 (diff) | |
pimd: Moving the common functions from pim_cmd.c
Moving the functions that are used by both IPV4 and IPV6 to a
common file pim_cmd_common.c file
Signed-off-by: Abhishek N R <abnr@vmware.com>
Diffstat (limited to 'pimd/pim_cmd_common.c')
| -rw-r--r-- | pimd/pim_cmd_common.c | 146 |
1 files changed, 145 insertions, 1 deletions
diff --git a/pimd/pim_cmd_common.c b/pimd/pim_cmd_common.c index dfba369e5b..bdac2f28a4 100644 --- a/pimd/pim_cmd_common.c +++ b/pimd/pim_cmd_common.c @@ -2837,7 +2837,6 @@ int gm_process_no_last_member_query_interval_cmd(struct vty *vty) FRR_PIM_AF_XPATH_VAL); } - int pim_process_ssmpingd_cmd(struct vty *vty, enum nb_operation operation, const char *src_str) { @@ -2858,3 +2857,148 @@ int pim_process_ssmpingd_cmd(struct vty *vty, enum nb_operation operation, return nb_cli_apply_changes(vty, NULL); } + +#if PIM_IPV == 4 +static void show_scan_oil_stats(struct pim_instance *pim, struct vty *vty, + time_t now) +{ + char uptime_scan_oil[10]; + char uptime_mroute_add[10]; + char uptime_mroute_del[10]; + + pim_time_uptime_begin(uptime_scan_oil, sizeof(uptime_scan_oil), now, + pim->scan_oil_last); + pim_time_uptime_begin(uptime_mroute_add, sizeof(uptime_mroute_add), now, + pim->mroute_add_last); + pim_time_uptime_begin(uptime_mroute_del, sizeof(uptime_mroute_del), now, + pim->mroute_del_last); + + vty_out(vty, + "Scan OIL - Last: %s Events: %lld\n" + "MFC Add - Last: %s Events: %lld\n" + "MFC Del - Last: %s Events: %lld\n", + uptime_scan_oil, (long long)pim->scan_oil_events, + uptime_mroute_add, (long long)pim->mroute_add_events, + uptime_mroute_del, (long long)pim->mroute_del_events); +} + +void show_multicast_interfaces(struct pim_instance *pim, struct vty *vty, + bool uj) +{ + struct interface *ifp; + char buf[PREFIX_STRLEN]; + json_object *json = NULL; + json_object *json_row = NULL; + + vty_out(vty, "\n"); + + if (uj) + json = json_object_new_object(); + else + vty_out(vty, + "Interface Address ifi Vif PktsIn PktsOut BytesIn BytesOut\n"); + + FOR_ALL_INTERFACES (pim->vrf, ifp) { + struct pim_interface *pim_ifp; + struct in_addr ifaddr; + struct sioc_vif_req vreq; + + pim_ifp = ifp->info; + + if (!pim_ifp) + continue; + + memset(&vreq, 0, sizeof(vreq)); + vreq.vifi = pim_ifp->mroute_vif_index; + + if (ioctl(pim->mroute_socket, SIOCGETVIFCNT, &vreq)) { + zlog_warn( + "ioctl(SIOCGETVIFCNT=%lu) failure for interface %s vif_index=%d: errno=%d: %s", + (unsigned long)SIOCGETVIFCNT, ifp->name, + pim_ifp->mroute_vif_index, errno, + safe_strerror(errno)); + } + + ifaddr = pim_ifp->primary_address; + if (uj) { + json_row = json_object_new_object(); + json_object_string_add(json_row, "name", ifp->name); + json_object_string_add(json_row, "state", + if_is_up(ifp) ? "up" : "down"); + json_object_string_addf(json_row, "address", "%pI4", + &pim_ifp->primary_address); + json_object_int_add(json_row, "ifIndex", ifp->ifindex); + json_object_int_add(json_row, "vif", + pim_ifp->mroute_vif_index); + json_object_int_add(json_row, "pktsIn", + (unsigned long)vreq.icount); + json_object_int_add(json_row, "pktsOut", + (unsigned long)vreq.ocount); + json_object_int_add(json_row, "bytesIn", + (unsigned long)vreq.ibytes); + json_object_int_add(json_row, "bytesOut", + (unsigned long)vreq.obytes); + json_object_object_add(json, ifp->name, json_row); + } else { + vty_out(vty, + "%-16s %-15s %3d %3d %7lu %7lu %10lu %10lu\n", + ifp->name, + inet_ntop(AF_INET, &ifaddr, buf, sizeof(buf)), + ifp->ifindex, pim_ifp->mroute_vif_index, + (unsigned long)vreq.icount, + (unsigned long)vreq.ocount, + (unsigned long)vreq.ibytes, + (unsigned long)vreq.obytes); + } + } + + if (uj) + vty_json(vty, json); +} + +void pim_cmd_show_ip_multicast_helper(struct pim_instance *pim, + struct vty *vty) +{ + struct vrf *vrf = pim->vrf; + time_t now = pim_time_monotonic_sec(); + char uptime[10]; + char mlag_role[80]; + + pim = vrf->info; + + vty_out(vty, "Router MLAG Role: %s\n", + mlag_role2str(router->mlag_role, mlag_role, sizeof(mlag_role))); + vty_out(vty, "Mroute socket descriptor:"); + + vty_out(vty, " %d(%s)\n", pim->mroute_socket, vrf->name); + + pim_time_uptime(uptime, sizeof(uptime), + now - pim->mroute_socket_creation); + vty_out(vty, "Mroute socket uptime: %s\n", uptime); + + vty_out(vty, "\n"); + + pim_zebra_zclient_update(vty); + pim_zlookup_show_ip_multicast(vty); + + vty_out(vty, "\n"); + vty_out(vty, "Maximum highest VifIndex: %d\n", PIM_MAX_USABLE_VIFS); + + vty_out(vty, "\n"); + vty_out(vty, "Upstream Join Timer: %d secs\n", router->t_periodic); + vty_out(vty, "Join/Prune Holdtime: %d secs\n", PIM_JP_HOLDTIME); + vty_out(vty, "PIM ECMP: %s\n", pim->ecmp_enable ? "Enable" : "Disable"); + vty_out(vty, "PIM ECMP Rebalance: %s\n", + pim->ecmp_rebalance_enable ? "Enable" : "Disable"); + + vty_out(vty, "\n"); + + pim_show_rpf_refresh_stats(vty, pim, now, NULL); + + vty_out(vty, "\n"); + + show_scan_oil_stats(pim, vty, now); + + show_multicast_interfaces(pim, vty, false); +} +#endif /* PIM_IPV == 4 */ |
