]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: Add "show evpn vni detail" command
authorNitin Soni <nsoni@cumulusnetworks.com>
Thu, 15 Nov 2018 17:33:43 +0000 (09:33 -0800)
committerNitin Soni <nsoni@cumulusnetworks.com>
Wed, 21 Nov 2018 16:13:01 +0000 (08:13 -0800)
Change helps display detailed output for all possible VNIs without
specifying VNI. It helps in troubleshooting - a single command can
be fired to capture detailed info on all VNIs.

Ticket: CM-22831
Signed-off-by: Nitin Soni <nsoni@cumulusnetworks.com>
Reviewed-by: CCR-8013
zebra/zebra_vty.c
zebra/zebra_vxlan.c
zebra/zebra_vxlan.h

index 263cb3d22c7aeded7e541624909f28775896ab6c..53853037f0d576eafb839846b7a43d617a8a90d6 100644 (file)
@@ -1782,7 +1782,7 @@ DEFUN (show_evpn_vni,
        "show evpn vni [json]",
        SHOW_STR
        "EVPN\n"
-       "VxLAN information\n"
+       "VxLAN Network Identifier\n"
        JSON_STR)
 {
        struct zebra_vrf *zvrf;
@@ -1793,6 +1793,22 @@ DEFUN (show_evpn_vni,
        return CMD_SUCCESS;
 }
 
+DEFUN (show_evpn_vni_detail, show_evpn_vni_detail_cmd,
+       "show evpn vni detail [json]",
+       SHOW_STR
+       "EVPN\n"
+       "VxLAN Network Identifier\n"
+       "Detailed Information On Each VNI\n"
+       JSON_STR)
+{
+       struct zebra_vrf *zvrf;
+       bool uj = use_json(argc, argv);
+
+       zvrf = vrf_info_lookup(VRF_DEFAULT);
+       zebra_vxlan_print_vnis_detail(vty, zvrf, uj);
+       return CMD_SUCCESS;
+}
+
 DEFUN (show_evpn_vni_vni,
        show_evpn_vni_vni_cmd,
        "show evpn vni " CMD_VNI_RANGE "[json]",
@@ -2743,6 +2759,7 @@ void zebra_vty_init(void)
 
        install_element(VIEW_NODE, &show_evpn_global_cmd);
        install_element(VIEW_NODE, &show_evpn_vni_cmd);
+       install_element(VIEW_NODE, &show_evpn_vni_detail_cmd);
        install_element(VIEW_NODE, &show_evpn_vni_vni_cmd);
        install_element(VIEW_NODE, &show_evpn_rmac_vni_mac_cmd);
        install_element(VIEW_NODE, &show_evpn_rmac_vni_cmd);
index d372d3e832b639173b20bbd4e183ff150bc382fe..ee6091a18eae5966192b6cc5e26781d8a2fe71a1 100644 (file)
@@ -1195,6 +1195,35 @@ static void zl3vni_print_hash(struct hash_backet *backet, void *ctx[])
        }
 }
 
+/* Private Structure to pass callback data for hash iterator */
+struct zvni_evpn_show {
+       struct vty *vty;
+       json_object *json;
+       struct zebra_vrf *zvrf;
+};
+
+/* print a L3 VNI hash entry in detail*/
+static void zl3vni_print_hash_detail(struct hash_backet *backet, void *data)
+{
+       struct vty *vty = NULL;
+       zebra_l3vni_t *zl3vni = NULL;
+       json_object *json = NULL;
+       bool use_json = false;
+       struct zvni_evpn_show *zes = data;
+
+       vty = zes->vty;
+       json = zes->json;
+
+       if (json)
+               use_json = true;
+
+       zl3vni = (zebra_l3vni_t *)backet->data;
+
+       zebra_vxlan_print_vni(vty, zes->zvrf, zl3vni->vni, use_json);
+       vty_out(vty, "\n");
+}
+
+
 /*
  * Print a VNI hash entry - called for display of all VNIs.
  */
@@ -1259,6 +1288,29 @@ static void zvni_print_hash(struct hash_backet *backet, void *ctxt[])
        }
 }
 
+/*
+ * Print a VNI hash entry in detail - called for display of all VNIs.
+ */
+static void zvni_print_hash_detail(struct hash_backet *backet, void *data)
+{
+       struct vty *vty;
+       zebra_vni_t *zvni;
+       json_object *json = NULL;
+       bool use_json = false;
+       struct zvni_evpn_show *zes = data;
+
+       vty = zes->vty;
+       json = zes->json;
+
+       if (json)
+               use_json = true;
+
+       zvni = (zebra_vni_t *)backet->data;
+
+       zebra_vxlan_print_vni(vty, zes->zvrf, zvni->vni, use_json);
+       vty_out(vty, "\n");
+}
+
 /*
  * Inform BGP about local MACIP.
  */
@@ -5426,6 +5478,49 @@ void zebra_vxlan_print_vnis(struct vty *vty, struct zebra_vrf *zvrf,
        }
 }
 
+/*
+ * Display VNI hash table in detail(VTY command handler).
+ */
+void zebra_vxlan_print_vnis_detail(struct vty *vty, struct zebra_vrf *zvrf,
+                                  bool use_json)
+{
+       json_object *json = NULL;
+       struct zebra_ns *zns = NULL;
+       struct zvni_evpn_show zes;
+
+       if (!is_evpn_enabled())
+               return;
+
+       zns = zebra_ns_lookup(NS_DEFAULT);
+       if (!zns)
+               return;
+
+
+       if (use_json)
+               json = json_object_new_object();
+
+       zes.vty = vty;
+       zes.json = json;
+       zes.zvrf = zvrf;
+
+       /* Display all L2-VNIs */
+       hash_iterate(zvrf->vni_table, (void (*)(struct hash_backet *,
+                                               void *))zvni_print_hash_detail,
+                    &zes);
+
+       /* Display all L3-VNIs */
+       hash_iterate(zrouter.l3vni_table,
+                    (void (*)(struct hash_backet *,
+                              void *))zl3vni_print_hash_detail,
+                    &zes);
+
+       if (use_json) {
+               vty_out(vty, "%s\n", json_object_to_json_string_ext(
+                                            json, JSON_C_TO_STRING_PRETTY));
+               json_object_free(json);
+       }
+}
+
 /*
  * Handle neighbor delete notification from the kernel (on a VLAN device
  * / L3 interface). This may result in either the neighbor getting deleted
index 1c394e9effad895bcd6643a67ab7a5e3c6e91474..0db40188e154015940bd8d597822f8d78efc3fd4 100644 (file)
@@ -117,6 +117,9 @@ extern void zebra_vxlan_print_vni(struct vty *vty, struct zebra_vrf *zvrf,
                                  vni_t vni, bool use_json);
 extern void zebra_vxlan_print_vnis(struct vty *vty, struct zebra_vrf *zvrf,
                                   bool use_json);
+extern void zebra_vxlan_print_vnis_detail(struct vty *vty,
+                                         struct zebra_vrf *zvrf,
+                                         bool use_json);
 extern void zebra_vxlan_print_rmacs_l3vni(struct vty *vty, vni_t vni,
                                          bool use_json);
 extern void zebra_vxlan_print_rmacs_all_l3vni(struct vty *vty, bool use_json);