From cd333cf968cef441abdea460eceab73f4cfefafd Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Mon, 3 Jun 2019 10:39:23 -0400 Subject: [PATCH] pimd: Add `clear ip mroute [vrf NAME] count` command to pim When debugging a large number of mroutes and data is changing fast it is sometimes hard to know what has actually changed. Add a `clear ip mroute count` command that resets the last data points gathered and allows you to see what has changed since the last clear. Output: donna.cumulusnetworks.com# show ip mroute count Source Group LastUsed Packets Bytes WrongIf * 224.0.1.60 272 0 0 0 10.50.11.11 239.255.255.250 2 1 203 1 10.50.11.13 239.255.255.250 66 1 203 1 10.50.11.100 239.255.255.250 68 1 203 1 10.50.11.114 239.255.255.250 62 2 406 1 10.50.11.129 239.255.255.250 10 1 199 1 10.50.11.143 239.255.255.250 44 1 203 1 10.50.11.144 239.255.255.250 44 1 203 1 10.50.11.156 239.255.255.250 66 1 203 1 10.50.11.235 239.255.255.250 149 0 0 0 10.50.11.246 239.255.255.250 54 5 965 1 donna.cumulusnetworks.com# clear ip mroute count donna.cumulusnetworks.com# show ip mroute count Source Group LastUsed Packets Bytes WrongIf * 224.0.1.60 279 0 0 0 10.50.11.11 239.255.255.250 9 0 0 0 10.50.11.13 239.255.255.250 73 0 0 0 10.50.11.100 239.255.255.250 76 0 0 0 10.50.11.114 239.255.255.250 69 0 0 0 10.50.11.129 239.255.255.250 17 0 0 0 10.50.11.143 239.255.255.250 51 0 0 0 10.50.11.144 239.255.255.250 51 0 0 0 10.50.11.156 239.255.255.250 73 0 0 0 10.50.11.235 239.255.255.250 156 0 0 0 10.50.11.246 239.255.255.250 61 0 0 0 donna.cumulusnetworks.com# show ip mroute count Source Group LastUsed Packets Bytes WrongIf * 224.0.1.60 300 0 0 0 10.50.11.11 239.255.255.250 30 0 0 0 10.50.11.13 239.255.255.250 94 0 0 0 10.50.11.100 239.255.255.250 96 0 0 0 10.50.11.114 239.255.255.250 90 0 0 0 10.50.11.119 239.255.255.250 7 1 203 1 10.50.11.127 239.255.255.250 3 2 406 1 10.50.11.129 239.255.255.250 38 0 0 0 10.50.11.143 239.255.255.250 72 0 0 0 10.50.11.144 239.255.255.250 72 0 0 0 10.50.11.156 239.255.255.250 94 0 0 0 10.50.11.197 239.255.255.250 2 1 200 1 10.50.11.235 239.255.255.250 177 0 0 0 10.50.11.246 239.255.255.250 82 0 0 0 Signed-off-by: Donald Sharp --- pimd/pim_cmd.c | 68 ++++++++++++++++++++++++++++++++++++++++++-------- pimd/pim_oil.h | 3 +++ 2 files changed, 60 insertions(+), 11 deletions(-) diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index 2b97dd3822..82b0d54c30 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -5658,11 +5658,54 @@ DEFUN (show_ip_mroute_vrf_all, return CMD_SUCCESS; } +DEFUN (clear_ip_mroute_count, + clear_ip_mroute_count_cmd, + "clear ip mroute [vrf NAME] count", + CLEAR_STR + IP_STR + MROUTE_STR + VRF_CMD_HELP_STR + "Route and packet count data\n") +{ + int idx = 2; + struct listnode *node; + struct channel_oil *c_oil; + struct static_route *sr; + struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx); + struct pim_instance *pim; + + if (!vrf) + return CMD_WARNING; + + pim = vrf->info; + for (ALL_LIST_ELEMENTS_RO(pim->channel_oil_list, node, c_oil)) { + if (!c_oil->installed) + continue; + + pim_mroute_update_counters(c_oil); + c_oil->cc.origpktcnt = c_oil->cc.pktcnt; + c_oil->cc.origbytecnt = c_oil->cc.bytecnt; + c_oil->cc.origwrong_if = c_oil->cc.wrong_if; + } + + for (ALL_LIST_ELEMENTS_RO(pim->static_routes, node, sr)) { + if (!sr->c_oil.installed) + continue; + + pim_mroute_update_counters(&sr->c_oil); + + sr->c_oil.cc.origpktcnt = sr->c_oil.cc.pktcnt; + sr->c_oil.cc.origbytecnt = sr->c_oil.cc.bytecnt; + sr->c_oil.cc.origwrong_if = sr->c_oil.cc.wrong_if; + } + return CMD_SUCCESS; +} + static void show_mroute_count(struct pim_instance *pim, struct vty *vty) { struct listnode *node; struct channel_oil *c_oil; - struct static_route *s_route; + struct static_route *sr; vty_out(vty, "\n"); @@ -5686,28 +5729,30 @@ static void show_mroute_count(struct pim_instance *pim, struct vty *vty) vty_out(vty, "%-15s %-15s %-8llu %-7ld %-10ld %-7ld\n", source_str, group_str, c_oil->cc.lastused / 100, - c_oil->cc.pktcnt, c_oil->cc.bytecnt, - c_oil->cc.wrong_if); + c_oil->cc.pktcnt - c_oil->cc.origpktcnt, + c_oil->cc.bytecnt - c_oil->cc.origbytecnt, + c_oil->cc.wrong_if - c_oil->cc.origwrong_if); } - for (ALL_LIST_ELEMENTS_RO(pim->static_routes, node, s_route)) { + for (ALL_LIST_ELEMENTS_RO(pim->static_routes, node, sr)) { char group_str[INET_ADDRSTRLEN]; char source_str[INET_ADDRSTRLEN]; - if (!s_route->c_oil.installed) + if (!sr->c_oil.installed) continue; - pim_mroute_update_counters(&s_route->c_oil); + pim_mroute_update_counters(&sr->c_oil); - pim_inet4_dump("", s_route->c_oil.oil.mfcc_mcastgrp, + pim_inet4_dump("", sr->c_oil.oil.mfcc_mcastgrp, group_str, sizeof(group_str)); - pim_inet4_dump("", s_route->c_oil.oil.mfcc_origin, + pim_inet4_dump("", sr->c_oil.oil.mfcc_origin, source_str, sizeof(source_str)); vty_out(vty, "%-15s %-15s %-8llu %-7ld %-10ld %-7ld\n", - source_str, group_str, s_route->c_oil.cc.lastused, - s_route->c_oil.cc.pktcnt, s_route->c_oil.cc.bytecnt, - s_route->c_oil.cc.wrong_if); + source_str, group_str, sr->c_oil.cc.lastused, + sr->c_oil.cc.pktcnt - sr->c_oil.cc.origpktcnt, + sr->c_oil.cc.bytecnt - sr->c_oil.cc.origbytecnt, + sr->c_oil.cc.wrong_if - sr->c_oil.cc.origwrong_if); } } @@ -10351,6 +10396,7 @@ void pim_cmd_init(void) install_element(VIEW_NODE, &show_ip_pim_bsm_db_cmd); install_element(VIEW_NODE, &show_ip_pim_statistics_cmd); + install_element(ENABLE_NODE, &clear_ip_mroute_count_cmd); install_element(ENABLE_NODE, &clear_ip_interfaces_cmd); install_element(ENABLE_NODE, &clear_ip_igmp_interfaces_cmd); install_element(ENABLE_NODE, &clear_ip_mroute_cmd); diff --git a/pimd/pim_oil.h b/pimd/pim_oil.h index c5106d01cb..57930e3418 100644 --- a/pimd/pim_oil.h +++ b/pimd/pim_oil.h @@ -53,10 +53,13 @@ struct channel_counts { unsigned long long lastused; + unsigned long origpktcnt; unsigned long pktcnt; unsigned long oldpktcnt; + unsigned long origbytecnt; unsigned long bytecnt; unsigned long oldbytecnt; + unsigned long origwrong_if; unsigned long wrong_if; unsigned long oldwrong_if; };