Merge pull request #11844 from SaiGomathiN/ttable-1

pimd, pim6d: Using ttable for displaying show CLIs
This commit is contained in:
Donatas Abraitis 2022-08-26 11:48:18 +03:00 committed by GitHub
commit 5e48498795
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1827,13 +1827,14 @@ void pim_show_join(struct pim_instance *pim, struct vty *vty, pim_sgaddr *sg,
}
}
static void pim_show_jp_agg_helper(struct vty *vty, struct interface *ifp,
static void pim_show_jp_agg_helper(struct interface *ifp,
struct pim_neighbor *neigh,
struct pim_upstream *up, int is_join)
struct pim_upstream *up, int is_join,
struct ttable *tt)
{
vty_out(vty, "%-16s %-15pPAs %-15pPAs %-15pPAs %5s\n", ifp->name,
&neigh->source_addr, &up->sg.src, &up->sg.grp,
is_join ? "J" : "P");
ttable_add_row(tt, "%s|%pPAs|%pPAs|%pPAs|%s", ifp->name,
&neigh->source_addr, &up->sg.src, &up->sg.grp,
is_join ? "J" : "P");
}
int pim_show_jp_agg_list_cmd_helper(const char *vrf, struct vty *vty)
@ -1869,9 +1870,15 @@ void pim_show_jp_agg_list(struct pim_instance *pim, struct vty *vty)
struct pim_jp_agg_group *jag;
struct listnode *js_node;
struct pim_jp_sources *js;
struct ttable *tt;
char *table;
vty_out(vty,
"Interface RPF Nbr Source Group State\n");
/* Prepare table. */
tt = ttable_new(&ttable_styles[TTSTYLE_BLANK]);
ttable_add_row(tt, "Interface|RPF Nbr|Source|Group|State");
tt->style.cell.rpad = 2;
tt->style.corner = '+';
ttable_restyle(tt);
FOR_ALL_INTERFACES (pim->vrf, ifp) {
pim_ifp = ifp->info;
@ -1884,13 +1891,19 @@ void pim_show_jp_agg_list(struct pim_instance *pim, struct vty *vty)
jag_node, jag)) {
for (ALL_LIST_ELEMENTS_RO(jag->sources, js_node,
js)) {
pim_show_jp_agg_helper(vty, ifp, neigh,
pim_show_jp_agg_helper(ifp, neigh,
js->up,
js->is_join);
js->is_join, tt);
}
}
}
}
/* Dump the generated table. */
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
ttable_del(tt);
}
int pim_show_membership_cmd_helper(const char *vrf, struct vty *vty, bool uj)
@ -2025,10 +2038,10 @@ void pim_show_membership(struct pim_instance *pim, struct vty *vty, bool uj)
}
}
static void pim_show_channel_helper(struct pim_instance *pim, struct vty *vty,
static void pim_show_channel_helper(struct pim_instance *pim,
struct pim_interface *pim_ifp,
struct pim_ifchannel *ch, json_object *json,
bool uj)
bool uj, struct ttable *tt)
{
struct pim_upstream *up = ch->upstream;
json_object *json_group = NULL;
@ -2071,17 +2084,17 @@ static void pim_show_channel_helper(struct pim_instance *pim, struct vty *vty,
&up->sg.src);
} else {
vty_out(vty,
"%-16s %-15pPAs %-15pPAs %-10s %-5s %-10s %-11s %-6s\n",
ch->interface->name, &up->sg.src, &up->sg.grp,
pim_macro_ch_lost_assert(ch) ? "yes" : "no",
pim_macro_chisin_joins(ch) ? "yes" : "no",
pim_macro_chisin_pim_include(ch) ? "yes" : "no",
PIM_UPSTREAM_FLAG_TEST_DR_JOIN_DESIRED(up->flags)
? "yes"
: "no",
pim_upstream_evaluate_join_desired(pim, up) ? "yes"
: "no");
ttable_add_row(tt, "%s|%pPAs|%pPAs|%s|%s|%s|%s|%s",
ch->interface->name, &up->sg.src, &up->sg.grp,
pim_macro_ch_lost_assert(ch) ? "yes" : "no",
pim_macro_chisin_joins(ch) ? "yes" : "no",
pim_macro_chisin_pim_include(ch) ? "yes" : "no",
PIM_UPSTREAM_FLAG_TEST_DR_JOIN_DESIRED(up->flags)
? "yes"
: "no",
pim_upstream_evaluate_join_desired(pim, up)
? "yes"
: "no");
}
}
@ -2090,14 +2103,22 @@ void pim_show_channel(struct pim_instance *pim, struct vty *vty, bool uj)
struct pim_interface *pim_ifp;
struct pim_ifchannel *ch;
struct interface *ifp;
struct ttable *tt = NULL;
json_object *json = NULL;
char *table = NULL;
if (uj)
json = json_object_new_object();
else
vty_out(vty,
"Interface Source Group LostAssert Joins PimInclude JoinDesired EvalJD\n");
else {
/* Prepare table. */
tt = ttable_new(&ttable_styles[TTSTYLE_BLANK]);
ttable_add_row(
tt,
"Interface|Source|Group|LostAssert|Joins|PimInclude|JoinDesired|EvalJD");
tt->style.cell.rpad = 2;
tt->style.corner = '+';
ttable_restyle(tt);
}
/* scan per-interface (S,G) state */
FOR_ALL_INTERFACES (pim->vrf, ifp) {
@ -2105,16 +2126,21 @@ void pim_show_channel(struct pim_instance *pim, struct vty *vty, bool uj)
if (!pim_ifp)
continue;
RB_FOREACH (ch, pim_ifchannel_rb, &pim_ifp->ifchannel_rb) {
/* scan all interfaces */
pim_show_channel_helper(pim, vty, pim_ifp, ch, json,
uj);
pim_show_channel_helper(pim, pim_ifp, ch, json, uj, tt);
}
}
if (uj)
vty_json(vty, json);
else {
/* Dump the generated table. */
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
ttable_del(tt);
}
}
int pim_show_channel_cmd_helper(const char *vrf, struct vty *vty, bool uj)