summaryrefslogtreecommitdiff
path: root/pimd/pim_cmd_common.c
diff options
context:
space:
mode:
authorAbhishek N R <abnr@vmware.com>2022-11-16 00:08:05 -0800
committerAbhishek N R <abnr@vmware.com>2022-11-22 22:59:30 -0800
commit774d8ad38b2fbc3f5bfc16e895ece2860250cf1f (patch)
treef25e58070766666fb711f042436a57510ee57afb /pimd/pim_cmd_common.c
parent2387dca4dcf35c7adf936c94816f5ab8f92fb550 (diff)
pimd, pim6d: Using ttable for displaying "show ip/ipv6 pim nexthop" command output
Before: R4(config)# do show ipv6 pim nexthop Number of registered addresses: 6 Address Interface Nexthop --------------------------------------------- 3700:1234:1234:1234:1234:1234:1234:1234 ens161 fe80::250:56ff:feb7:d8d5 5101::10 ens224.51 5101::10 3300::5555 ens161 fe80::250:56ff:feb7:d8d5 4400::1 ens161 fe80::250:56ff:feb7:d8d5 1020::10 ens257 1020::10 3000::1 ens192.4010 fe80::250:56ff:feb7:493b 3000::1 ens193.4015 fe80::250:56ff:feb7:b12a After: frr# show ipv6 pim nexthop Number of registered addresses: 2 Address Interface Nexthop --------------------------------------------- 105::105 lo 105::105 12::1 ens192 fe80::250:56ff:feb7:38de Issue: #11246 Signed-off-by: Abhishek N R <abnr@vmware.com>
Diffstat (limited to 'pimd/pim_cmd_common.c')
-rw-r--r--pimd/pim_cmd_common.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/pimd/pim_cmd_common.c b/pimd/pim_cmd_common.c
index b39f688cdb..a04573b302 100644
--- a/pimd/pim_cmd_common.c
+++ b/pimd/pim_cmd_common.c
@@ -2824,21 +2824,35 @@ static int pim_print_vty_pnc_cache_walkcb(struct hash_bucket *bucket, void *arg)
struct nexthop *nh_node = NULL;
ifindex_t first_ifindex;
struct interface *ifp = NULL;
+ struct ttable *tt = NULL;
+ char *table = NULL;
+
+ /* Prepare table. */
+ tt = ttable_new(&ttable_styles[TTSTYLE_BLANK]);
+ ttable_add_row(
+ tt,
+ "Address|Interface|Nexthop");
+ tt->style.cell.rpad = 2;
+ tt->style.corner = '+';
+ ttable_restyle(tt);
for (nh_node = pnc->nexthop; nh_node; nh_node = nh_node->next) {
first_ifindex = nh_node->ifindex;
ifp = if_lookup_by_index(first_ifindex, pim->vrf->vrf_id);
- vty_out(vty, "%-15pPA ", &pnc->rpf.rpf_addr);
- vty_out(vty, "%-16s ", ifp ? ifp->name : "NULL");
#if PIM_IPV == 4
- vty_out(vty, "%pI4 ", &nh_node->gate.ipv4);
+ ttable_add_row(tt, "%pPA|%s|%pI4", &pnc->rpf.rpf_addr, ifp ? ifp->name : "NULL", &nh_node->gate.ipv4);
#else
- vty_out(vty, "%pI6 ", &nh_node->gate.ipv6);
+ ttable_add_row(tt, "%pPA|%s|%pI6", &pnc->rpf.rpf_addr, ifp ? ifp->name : "NULL", &nh_node->gate.ipv6);
#endif
- vty_out(vty, "\n");
}
+ /* Dump the generated table. */
+ table = ttable_dump(tt, "\n");
+ vty_out(vty, "%s\n", table);
+ XFREE(MTYPE_TMP, table);
+ ttable_del(tt);
+
return CMD_SUCCESS;
}
@@ -2966,8 +2980,6 @@ void pim_show_nexthop(struct pim_instance *pim, struct vty *vty, bool uj)
} else {
vty_out(vty, "Number of registered addresses: %lu\n",
pim->rpf_hash->count);
- vty_out(vty, "Address Interface Nexthop\n");
- vty_out(vty, "---------------------------------------------\n");
}
if (uj) {