From fe4db62c3dbc7a2ab1b27ae879bf0a76dcfe5b4d Mon Sep 17 00:00:00 2001 From: Sarita Patra Date: Fri, 24 Feb 2023 07:01:22 -0800 Subject: [PATCH 1/3] pim6d: Don't display MLD disabled or down interfaces in "show ipv6 mld interface" cmd We should not display down interfaces or MLD disabled interfaces in "show ipv6 mld interface" command. Before fix: ========== frr# show ipv6 mld interface Interface State V Querier Timer Uptime ens192 up 2 fe80::250:56ff:feb7:d04 query 00:00:25.432 00:00:07.038 ens224 up 1 fe80::250:56ff:feb7:a7e3 query 00:00:24.219 00:00:07.031 pim6reg down After fix: ========= frr# show ipv6 mld interface Interface State V Querier Timer Uptime ens192 up 2 fe80::250:56ff:feb7:d04 query 00:00:25.432 00:00:07.038 ens224 up 1 fe80::250:56ff:feb7:a7e3 query 00:00:24.219 00:00:07.031 Issue: #11241 Signed-off-by: Sarita Patra --- pimd/pim6_mld.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/pimd/pim6_mld.c b/pimd/pim6_mld.c index 75d809882145..f76b4ec591a7 100644 --- a/pimd/pim6_mld.c +++ b/pimd/pim6_mld.c @@ -2386,14 +2386,6 @@ static void gm_show_if_one(struct vty *vty, struct interface *ifp, 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) { @@ -2437,6 +2429,7 @@ static void gm_show_if_vrf(struct vty *vty, struct vrf *vrf, const char *ifname, { struct interface *ifp; json_object *js_vrf; + struct pim_interface *pim_ifp; if (js) { js_vrf = json_object_new_object(); @@ -2453,8 +2446,11 @@ 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); From 3ab119a4bb79c46c8cce99c8a6ee860c43e378dd Mon Sep 17 00:00:00 2001 From: Sarita Patra Date: Fri, 24 Feb 2023 07:11:57 -0800 Subject: [PATCH 2/3] pim6d: Display primary address in "show ipv6 mld interface json" cmd Signed-off-by: Sarita Patra --- pimd/pim6_mld.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pimd/pim6_mld.c b/pimd/pim6_mld.c index f76b4ec591a7..eb897e660d2c 100644 --- a/pimd/pim6_mld.c +++ b/pimd/pim6_mld.c @@ -2390,6 +2390,8 @@ static void gm_show_if_one(struct vty *vty, struct interface *ifp, 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); From cbb1e51311ca710540d752c9d6c7689f8fc65dc4 Mon Sep 17 00:00:00 2001 From: Sarita Patra Date: Fri, 24 Feb 2023 07:13:30 -0800 Subject: [PATCH 3/3] pim6d: Fix missing parameters in "show ipv6 mld interface" command Before fix: ========== frr# show ipv6 mld interface Interface State V Querier Timer Uptime ens224 up 1 fe80::250:56ff:feb7:a7e3 query 00:00:24.219 00:00:07.031 After fix: ========= frr(config-if)# do show ipv6 mld interface Interface State Address V Querier QuerierIp Query Timer Uptime ens224 up fe80::250:56ff:feb7:a7e3 1 local fe80::250:56ff:feb7:a7e3 00:01:22.263 00:08:00.237 Issue: #11241 Signed-off-by: Sarita Patra --- pimd/pim6_mld.c | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/pimd/pim6_mld.c b/pimd/pim6_mld.c index eb897e660d2c..fcece56c6faf 100644 --- a/pimd/pim6_mld.c +++ b/pimd/pim6_mld.c @@ -2380,7 +2380,7 @@ 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; @@ -2418,11 +2418,11 @@ 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); } } @@ -2430,14 +2430,27 @@ 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; @@ -2448,7 +2461,7 @@ static void gm_show_if_vrf(struct vty *vty, struct vrf *vrf, const char *ifname, continue; } - pim_ifp = ifp ->info; + pim_ifp = ifp->info; if (!pim_ifp || !pim_ifp->mld) continue; @@ -2458,17 +2471,21 @@ static void gm_show_if_vrf(struct vty *vty, struct vrf *vrf, const char *ifname, 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