Skip to content

Commit

Permalink
Merge pull request FRRouting#12899 from patrasar/pimv6_mld_interface_cmd
Browse files Browse the repository at this point in the history
pim6d: Fix display issue in "show ipv6 mld interface" command
  • Loading branch information
ton31337 authored Feb 27, 2023
2 parents 6fc45a9 + cbb1e51 commit 6e6bde1
Showing 1 changed file with 36 additions and 21 deletions.
57 changes: 36 additions & 21 deletions pimd/pim6_mld.c
Original file line number Diff line number Diff line change
Expand Up @@ -2380,24 +2380,18 @@ static void gm_show_if_one_detail(struct vty *vty, struct interface *ifp)
}

static void gm_show_if_one(struct vty *vty, struct interface *ifp,
json_object *js_if)
json_object *js_if, struct ttable *tt)
{
struct pim_interface *pim_ifp = (struct pim_interface *)ifp->info;
struct gm_if *gm_ifp = pim_ifp->mld;
bool querier;

if (!gm_ifp) {
if (js_if)
json_object_string_add(js_if, "state", "down");
else
vty_out(vty, "%-16s %5s\n", ifp->name, "down");
return;
}

querier = IPV6_ADDR_SAME(&gm_ifp->querier, &pim_ifp->ll_lowest);

if (js_if) {
json_object_string_add(js_if, "name", ifp->name);
json_object_string_addf(js_if, "address", "%pPA",
&pim_ifp->primary_address);
json_object_string_add(js_if, "state", "up");
json_object_string_addf(js_if, "version", "%d",
gm_ifp->cur_version);
Expand All @@ -2424,25 +2418,39 @@ static void gm_show_if_one(struct vty *vty, struct interface *ifp,
json_object_int_add(js_if, "timerLastMemberQueryIntervalMsec",
gm_ifp->cur_query_intv_trig);
} else {
vty_out(vty, "%-16s %-5s %d %-25pPA %-5s %11pTH %pTVMs\n",
ifp->name, "up", gm_ifp->cur_version, &gm_ifp->querier,
querier ? "query" : "other",
querier ? gm_ifp->t_query : gm_ifp->t_other_querier,
&gm_ifp->started);
ttable_add_row(tt, "%s|%s|%pPAs|%d|%s|%pPAs|%pTH|%pTVMs",
ifp->name, "up", &pim_ifp->primary_address,
gm_ifp->cur_version, querier ? "local" : "other",
&gm_ifp->querier, gm_ifp->t_query,
&gm_ifp->started);
}
}

static void gm_show_if_vrf(struct vty *vty, struct vrf *vrf, const char *ifname,
bool detail, json_object *js)
{
struct interface *ifp;
json_object *js_vrf;
json_object *js_vrf = NULL;
struct pim_interface *pim_ifp;
struct ttable *tt = NULL;
char *table = NULL;

if (js) {
js_vrf = json_object_new_object();
json_object_object_add(js, vrf->name, js_vrf);
}

if (!js && !detail) {
/* Prepare table. */
tt = ttable_new(&ttable_styles[TTSTYLE_BLANK]);
ttable_add_row(
tt,
"Interface|State|Address|V|Querier|QuerierIp|Query Timer|Uptime");
tt->style.cell.rpad = 2;
tt->style.corner = '+';
ttable_restyle(tt);
}

FOR_ALL_INTERFACES (vrf, ifp) {
json_object *js_if = NULL;

Expand All @@ -2453,24 +2461,31 @@ static void gm_show_if_vrf(struct vty *vty, struct vrf *vrf, const char *ifname,
continue;
}

if (!ifp->info)
pim_ifp = ifp->info;

if (!pim_ifp || !pim_ifp->mld)
continue;

if (js) {
js_if = json_object_new_object();
json_object_object_add(js_vrf, ifp->name, js_if);
}

gm_show_if_one(vty, ifp, js_if);
gm_show_if_one(vty, ifp, js_if, tt);
}

/* Dump the generated table. */
if (!js && !detail) {
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
ttable_del(tt);
}
}

static void gm_show_if(struct vty *vty, struct vrf *vrf, const char *ifname,
bool detail, json_object *js)
{
if (!js && !detail)
vty_out(vty, "%-16s %-5s V %-25s %-18s %s\n", "Interface",
"State", "Querier", "Timer", "Uptime");

if (vrf)
gm_show_if_vrf(vty, vrf, ifname, detail, js);
else
Expand Down

0 comments on commit 6e6bde1

Please sign in to comment.