]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/zebra_vty.c
Merge pull request #1847 from msablic/pim_auto_mtrace
[mirror_frr.git] / zebra / zebra_vty.c
index ccc7cb30c312d6f213251c047994ebcc28ca7171..9fe3c707bb1367f5e68daa940c12e79ecffb7869 100644 (file)
@@ -69,25 +69,20 @@ static void vty_show_ip_route_summary_prefix(struct vty *vty,
 /*
  * special macro to allow us to get the correct zebra_vrf
  */
-#define ZEBRA_DECLVAR_CONTEXT(A, B)                    \
-       struct vrf *A = VTY_GET_CONTEXT(vrf);           \
-       struct zebra_vrf *B =                           \
-               (vrf) ? vrf->info : NULL;               \
+#define ZEBRA_DECLVAR_CONTEXT(A, B)                                            \
+       struct vrf *A = VTY_GET_CONTEXT(vrf);                                  \
+       struct zebra_vrf *B = (vrf) ? vrf->info : NULL;
 
 /* VNI range as per RFC 7432 */
 #define CMD_VNI_RANGE "(1-16777215)"
 
 /* General function for static route. */
-static int zebra_static_route_leak(struct vty *vty,
-                                  struct zebra_vrf *zvrf,
-                                  struct zebra_vrf *nh_zvrf,
-                                  afi_t afi, safi_t safi,
-                                  const char *negate, const char *dest_str,
-                                  const char *mask_str, const char *src_str,
-                                  const char *gate_str, const char *ifname,
-                                  const char *flag_str, const char *tag_str,
-                                  const char *distance_str,
-                                  const char *label_str)
+static int zebra_static_route_leak(
+       struct vty *vty, struct zebra_vrf *zvrf, struct zebra_vrf *nh_zvrf,
+       afi_t afi, safi_t safi, const char *negate, const char *dest_str,
+       const char *mask_str, const char *src_str, const char *gate_str,
+       const char *ifname, const char *flag_str, const char *tag_str,
+       const char *distance_str, const char *label_str)
 {
        int ret;
        u_char distance;
@@ -180,10 +175,11 @@ static int zebra_static_route_leak(struct vty *vty,
 
        /* Null0 static route.  */
        if (ifname != NULL) {
-               if (strncasecmp(ifname, "Null0", strlen(ifname)) == 0 ||
-                   strncasecmp(ifname, "reject", strlen(ifname)) == 0 ||
-                   strncasecmp(ifname, "blackhole", strlen(ifname)) == 0) {
-                       vty_out(vty, "%% Nexthop interface cannot be Null0, reject or blackhole\n");
+               if (strncasecmp(ifname, "Null0", strlen(ifname)) == 0
+                   || strncasecmp(ifname, "reject", strlen(ifname)) == 0
+                   || strncasecmp(ifname, "blackhole", strlen(ifname)) == 0) {
+                       vty_out(vty,
+                               "%% Nexthop interface cannot be Null0, reject or blackhole\n");
                        return CMD_WARNING_CONFIG_FAILED;
                }
        }
@@ -249,12 +245,12 @@ static int zebra_static_route_leak(struct vty *vty,
 }
 
 static int zebra_static_route(struct vty *vty, afi_t afi, safi_t safi,
-                             const char *negate, const char *dest_str,
-                             const char *mask_str, const char *src_str,
-                             const char *gate_str, const char *ifname,
-                             const char *flag_str, const char *tag_str,
-                             const char *distance_str, const char *vrf_name,
-                             const char *label_str)
+                             const char *negate, const char *dest_str,
+                             const char *mask_str, const char *src_str,
+                             const char *gate_str, const char *ifname,
+                             const char *flag_str, const char *tag_str,
+                             const char *distance_str, const char *vrf_name,
+                             const char *label_str)
 {
        struct zebra_vrf *zvrf;
        struct vrf *vrf;
@@ -286,10 +282,9 @@ static int zebra_static_route(struct vty *vty, afi_t afi, safi_t safi,
                /* Mark as having FRR configuration */
                vrf_set_user_cfged(vrf);
        }
-       return zebra_static_route_leak(vty, zvrf, zvrf, afi, safi,
-                                      negate, dest_str, mask_str, src_str,
-                                      gate_str, ifname, flag_str, tag_str,
-                                      distance_str, label_str);
+       return zebra_static_route_leak(
+               vty, zvrf, zvrf, afi, safi, negate, dest_str, mask_str, src_str,
+               gate_str, ifname, flag_str, tag_str, distance_str, label_str);
 }
 
 
@@ -429,8 +424,8 @@ DEFPY(ip_route_blackhole,
       MPLS_LABEL_HELPSTR)
 {
        return zebra_static_route(vty, AFI_IP, SAFI_UNICAST, no, prefix,
-                                 mask_str, NULL, NULL, NULL, flag,
-                                 tag_str, distance_str, vrf, label);
+                                 mask_str, NULL, NULL, NULL, flag, tag_str,
+                                 distance_str, vrf, label);
 }
 
 DEFPY(ip_route_blackhole_vrf,
@@ -464,10 +459,9 @@ DEFPY(ip_route_blackhole_vrf,
         * valid.  Add an assert to make it happy
         */
        assert(prefix);
-       return zebra_static_route_leak(vty, zvrf, zvrf,
-                                      AFI_IP, SAFI_UNICAST, no, prefix,
-                                      mask_str, NULL, NULL, NULL, flag,
-                                      tag_str, distance_str, label);
+       return zebra_static_route_leak(vty, zvrf, zvrf, AFI_IP, SAFI_UNICAST,
+                                      no, prefix, mask_str, NULL, NULL, NULL,
+                                      flag, tag_str, distance_str, label);
 }
 
 DEFPY(ip_route_address_interface,
@@ -509,8 +503,7 @@ DEFPY(ip_route_address_interface,
 
        zvrf = zebra_vrf_lookup_by_name(vrf);
        if (!zvrf) {
-               vty_out(vty, "%% vrf %s is not defined\n",
-                       vrf);
+               vty_out(vty, "%% vrf %s is not defined\n", vrf);
                return CMD_WARNING_CONFIG_FAILED;
        }
 
@@ -520,15 +513,13 @@ DEFPY(ip_route_address_interface,
                nh_zvrf = zvrf;
 
        if (!nh_zvrf) {
-               vty_out(vty, "%% nexthop vrf %s is not defined\n",
-                       nexthop_vrf);
+               vty_out(vty, "%% nexthop vrf %s is not defined\n", nexthop_vrf);
                return CMD_WARNING_CONFIG_FAILED;
        }
 
-       return zebra_static_route_leak(vty, zvrf, nh_zvrf,
-                                      AFI_IP, SAFI_UNICAST, no, prefix,
-                                      mask_str, NULL, gate_str, ifname, flag,
-                                      tag_str, distance_str, label);
+       return zebra_static_route_leak(
+               vty, zvrf, nh_zvrf, AFI_IP, SAFI_UNICAST, no, prefix, mask_str,
+               NULL, gate_str, ifname, flag, tag_str, distance_str, label);
 }
 
 DEFPY(ip_route_address_interface_vrf,
@@ -573,15 +564,13 @@ DEFPY(ip_route_address_interface_vrf,
                nh_zvrf = zvrf;
 
        if (!nh_zvrf) {
-               vty_out(vty, "%% nexthop vrf %s is not defined\n",
-                       nexthop_vrf);
+               vty_out(vty, "%% nexthop vrf %s is not defined\n", nexthop_vrf);
                return CMD_WARNING_CONFIG_FAILED;
        }
 
-       return zebra_static_route_leak(vty, zvrf, nh_zvrf,
-                                      AFI_IP, SAFI_UNICAST, no, prefix,
-                                      mask_str, NULL, gate_str, ifname, flag,
-                                      tag_str, distance_str, label);
+       return zebra_static_route_leak(
+               vty, zvrf, nh_zvrf, AFI_IP, SAFI_UNICAST, no, prefix, mask_str,
+               NULL, gate_str, ifname, flag, tag_str, distance_str, label);
 }
 
 DEFPY(ip_route,
@@ -621,8 +610,7 @@ DEFPY(ip_route,
 
        zvrf = zebra_vrf_lookup_by_name(vrf);
        if (!zvrf) {
-               vty_out(vty, "%% vrf %s is not defined\n",
-                       vrf);
+               vty_out(vty, "%% vrf %s is not defined\n", vrf);
                return CMD_WARNING_CONFIG_FAILED;
        }
 
@@ -632,16 +620,14 @@ DEFPY(ip_route,
                nh_zvrf = zvrf;
 
        if (!nh_zvrf) {
-               vty_out(vty, "%% nexthop vrf %s is not defined\n",
-                       nexthop_vrf);
+               vty_out(vty, "%% nexthop vrf %s is not defined\n", nexthop_vrf);
                return CMD_WARNING_CONFIG_FAILED;
        }
 
 
-       return zebra_static_route_leak(vty, zvrf, nh_zvrf,
-                                      AFI_IP, SAFI_UNICAST, no, prefix,
-                                      mask_str, NULL, gate_str, ifname, flag,
-                                      tag_str, distance_str, label);
+       return zebra_static_route_leak(
+               vty, zvrf, nh_zvrf, AFI_IP, SAFI_UNICAST, no, prefix, mask_str,
+               NULL, gate_str, ifname, flag, tag_str, distance_str, label);
 }
 
 DEFPY(ip_route_vrf,
@@ -684,15 +670,13 @@ DEFPY(ip_route_vrf,
                nh_zvrf = zvrf;
 
        if (!nh_zvrf) {
-               vty_out(vty, "%% nexthop vrf %s is not defined\n",
-                       nexthop_vrf);
+               vty_out(vty, "%% nexthop vrf %s is not defined\n", nexthop_vrf);
                return CMD_WARNING_CONFIG_FAILED;
        }
 
-       return zebra_static_route_leak(vty, zvrf, nh_zvrf,
-                                      AFI_IP, SAFI_UNICAST, no, prefix,
-                                      mask_str, NULL, gate_str, ifname, flag,
-                                      tag_str, distance_str, label);
+       return zebra_static_route_leak(
+               vty, zvrf, nh_zvrf, AFI_IP, SAFI_UNICAST, no, prefix, mask_str,
+               NULL, gate_str, ifname, flag, tag_str, distance_str, label);
 }
 
 /* New RIB.  Detailed information for IPv4 route. */
@@ -748,24 +732,26 @@ static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn,
                vty_out(vty, "  Last update ");
 
                if (uptime < ONE_DAY_SECOND)
-                       vty_out(vty, "%02d:%02d:%02d", tm->tm_hour,
-                               tm->tm_min, tm->tm_sec);
+                       vty_out(vty, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min,
+                               tm->tm_sec);
                else if (uptime < ONE_WEEK_SECOND)
-                       vty_out(vty, "%dd%02dh%02dm", tm->tm_yday,
-                               tm->tm_hour, tm->tm_min);
+                       vty_out(vty, "%dd%02dh%02dm", tm->tm_yday, tm->tm_hour,
+                               tm->tm_min);
                else
                        vty_out(vty, "%02dw%dd%02dh", tm->tm_yday / 7,
                                tm->tm_yday - ((tm->tm_yday / 7) * 7),
                                tm->tm_hour);
                vty_out(vty, " ago\n");
 
-               for (ALL_NEXTHOPS(re->nexthop, nexthop)) {
+               for (ALL_NEXTHOPS(re->ng, nexthop)) {
                        char addrstr[32];
 
                        vty_out(vty, "  %c%s",
                                CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB)
-                                       ? CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_DUPLICATE)
-                                               ? ' ' : '*'
+                                       ? CHECK_FLAG(nexthop->flags,
+                                                    NEXTHOP_FLAG_DUPLICATE)
+                                                 ? ' '
+                                                 : '*'
                                        : ' ',
                                nexthop->rparent ? "  " : "");
 
@@ -924,11 +910,11 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
                }
 
                if (uptime < ONE_DAY_SECOND)
-                       sprintf(buf, "%02d:%02d:%02d", tm->tm_hour,
-                               tm->tm_min, tm->tm_sec);
+                       sprintf(buf, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min,
+                               tm->tm_sec);
                else if (uptime < ONE_WEEK_SECOND)
-                       sprintf(buf, "%dd%02dh%02dm", tm->tm_yday,
-                               tm->tm_hour, tm->tm_min);
+                       sprintf(buf, "%dd%02dh%02dm", tm->tm_yday, tm->tm_hour,
+                               tm->tm_min);
                else
                        sprintf(buf, "%02dw%dd%02dh", tm->tm_yday / 7,
                                tm->tm_yday - ((tm->tm_yday / 7) * 7),
@@ -936,7 +922,7 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
 
                json_object_string_add(json_route, "uptime", buf);
 
-               for (ALL_NEXTHOPS(re->nexthop, nexthop)) {
+               for (ALL_NEXTHOPS(re->ng, nexthop)) {
                        json_nexthop = json_object_new_object();
 
                        if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_DUPLICATE))
@@ -1028,8 +1014,7 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
                                struct vrf *vrf =
                                        vrf_lookup_by_id(nexthop->vrf_id);
 
-                               json_object_string_add(json_nexthop,
-                                                      "vrf",
+                               json_object_string_add(json_nexthop, "vrf",
                                                       vrf->name);
                        }
                        if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_DUPLICATE))
@@ -1103,8 +1088,8 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
        }
 
        /* Nexthop information. */
-       for (ALL_NEXTHOPS(re->nexthop, nexthop)) {
-               if (nexthop == re->nexthop) {
+       for (ALL_NEXTHOPS(re->ng, nexthop)) {
+               if (nexthop == re->ng.nexthop) {
                        /* Prefix information. */
                        len = vty_out(vty, "%c", zebra_route_char(re->type));
                        if (re->instance)
@@ -1126,8 +1111,10 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
                } else {
                        vty_out(vty, "  %c%*c",
                                CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB)
-                                       ? CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_DUPLICATE)
-                                               ? ' ' : '*'
+                                       ? CHECK_FLAG(nexthop->flags,
+                                                    NEXTHOP_FLAG_DUPLICATE)
+                                                 ? ' '
+                                                 : '*'
                                        : ' ',
                                len - 3 + (2 * nexthop_level(nexthop)), ' ');
                }
@@ -1259,8 +1246,7 @@ static void do_show_route_helper(struct vty *vty, struct zebra_vrf *zvrf,
                dest = rib_dest_from_rnode(rn);
 
                RNODE_FOREACH_RE (rn, re) {
-                       if (use_fib
-                           && re != dest->selected_fib)
+                       if (use_fib && re != dest->selected_fib)
                                continue;
 
                        if (tag && re->tag != tag)
@@ -1663,7 +1649,7 @@ DEFPY (show_route_detail,
                struct vrf *vrf;
                struct zebra_vrf *zvrf;
 
-               RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name) {
+               RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
                        if ((zvrf = vrf->info) == NULL
                            || (table = zvrf->table[afi][SAFI_UNICAST]) == NULL)
                                continue;
@@ -1737,7 +1723,7 @@ DEFPY (show_route_summary,
                struct vrf *vrf;
                struct zebra_vrf *zvrf;
 
-               RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name) {
+               RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
                        if ((zvrf = vrf->info) == NULL
                            || (table = zvrf->table[afi][SAFI_UNICAST]) == NULL)
                                continue;
@@ -1856,7 +1842,7 @@ static void vty_show_ip_route_summary_prefix(struct vty *vty,
                         * In case of ECMP, count only once.
                         */
                        cnt = 0;
-                       for (nexthop = re->nexthop; (!cnt && nexthop);
+                       for (nexthop = re->ng.nexthop; (!cnt && nexthop);
                             nexthop = nexthop->next) {
                                cnt++;
                                rib_cnt[ZEBRA_ROUTE_TOTAL]++;
@@ -1905,8 +1891,8 @@ static void vty_show_ip_route_summary_prefix(struct vty *vty,
 }
 
 /* Write static route configuration. */
-int static_config(struct vty *vty, struct zebra_vrf *zvrf,
-                 afi_t afi, safi_t safi, const char *cmd)
+int static_config(struct vty *vty, struct zebra_vrf *zvrf, afi_t afi,
+                 safi_t safi, const char *cmd)
 {
        char spacing[100];
        struct route_node *rn;
@@ -1918,8 +1904,7 @@ int static_config(struct vty *vty, struct zebra_vrf *zvrf,
        if ((stable = zvrf->stable[afi][safi]) == NULL)
                return write;
 
-       sprintf(spacing, "%s%s",
-               (zvrf->vrf->vrf_id == VRF_DEFAULT) ? "" : " ",
+       sprintf(spacing, "%s%s", (zvrf->vrf->vrf_id == VRF_DEFAULT) ? "" : " ",
                cmd);
 
        for (rn = route_top(stable); rn; rn = srcdest_route_next(rn))
@@ -1929,13 +1914,11 @@ int static_config(struct vty *vty, struct zebra_vrf *zvrf,
 
                        switch (si->type) {
                        case STATIC_IPV4_GATEWAY:
-                               vty_out(vty, " %s",
-                                       inet_ntoa(si->addr.ipv4));
+                               vty_out(vty, " %s", inet_ntoa(si->addr.ipv4));
                                break;
                        case STATIC_IPV6_GATEWAY:
                                vty_out(vty, " %s",
-                                       inet_ntop(AF_INET6,
-                                                 &si->addr.ipv6, buf,
+                                       inet_ntop(AF_INET6, &si->addr.ipv6, buf,
                                                  sizeof buf));
                                break;
                        case STATIC_IFNAME:
@@ -1956,26 +1939,22 @@ int static_config(struct vty *vty, struct zebra_vrf *zvrf,
                                break;
                        case STATIC_IPV4_GATEWAY_IFNAME:
                                vty_out(vty, " %s %s",
-                                       inet_ntop(AF_INET,
-                                                 &si->addr.ipv4, buf,
+                                       inet_ntop(AF_INET, &si->addr.ipv4, buf,
                                                  sizeof buf),
                                        si->ifname);
                                break;
                        case STATIC_IPV6_GATEWAY_IFNAME:
                                vty_out(vty, " %s %s",
-                                       inet_ntop(AF_INET6,
-                                                 &si->addr.ipv6, buf,
+                                       inet_ntop(AF_INET6, &si->addr.ipv6, buf,
                                                  sizeof buf),
                                        si->ifname);
                                break;
                        }
 
                        if (si->tag)
-                               vty_out(vty, " tag %" ROUTE_TAG_PRI,
-                                       si->tag);
+                               vty_out(vty, " tag %" ROUTE_TAG_PRI, si->tag);
 
-                       if (si->distance
-                           != ZEBRA_STATIC_DISTANCE_DEFAULT)
+                       if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT)
                                vty_out(vty, " %d", si->distance);
 
                        if (si->nh_vrf_id != si->vrf_id) {
@@ -1990,8 +1969,8 @@ int static_config(struct vty *vty, struct zebra_vrf *zvrf,
                        if (si->snh_label.num_labels)
                                vty_out(vty, " label %s",
                                        mpls_label2str(si->snh_label.num_labels,
-                                                      si->snh_label.label,
-                                                      buf, sizeof buf, 0));
+                                                      si->snh_label.label, buf,
+                                                      sizeof buf, 0));
 
                        vty_out(vty, "\n");
 
@@ -2026,8 +2005,8 @@ DEFPY(ipv6_route_blackhole,
       MPLS_LABEL_HELPSTR)
 {
        return zebra_static_route(vty, AFI_IP6, SAFI_UNICAST, no, prefix_str,
-                                 NULL, from_str, NULL, NULL, flag,
-                                 tag_str, distance_str, vrf, label);
+                                 NULL, from_str, NULL, NULL, flag, tag_str,
+                                 distance_str, vrf, label);
 }
 
 DEFPY(ipv6_route_blackhole_vrf,
@@ -2062,10 +2041,9 @@ DEFPY(ipv6_route_blackhole_vrf,
         * valid.  Add an assert to make it happy
         */
        assert(prefix);
-       return zebra_static_route_leak(vty, zvrf, zvrf,
-                                      AFI_IP6, SAFI_UNICAST, no, prefix_str,
-                                      NULL, from_str, NULL, NULL, flag,
-                                      tag_str, distance_str, label);
+       return zebra_static_route_leak(
+               vty, zvrf, zvrf, AFI_IP6, SAFI_UNICAST, no, prefix_str, NULL,
+               from_str, NULL, NULL, flag, tag_str, distance_str, label);
 }
 
 DEFPY(ipv6_route_address_interface,
@@ -2100,8 +2078,7 @@ DEFPY(ipv6_route_address_interface,
 
        zvrf = zebra_vrf_lookup_by_name(vrf);
        if (!zvrf) {
-               vty_out(vty, "%% vrf %s is not defined\n",
-                       vrf);
+               vty_out(vty, "%% vrf %s is not defined\n", vrf);
                return CMD_WARNING_CONFIG_FAILED;
        }
 
@@ -2111,15 +2088,13 @@ DEFPY(ipv6_route_address_interface,
                nh_zvrf = zvrf;
 
        if (!nh_zvrf) {
-               vty_out(vty, "%% nexthop vrf %s is not defined\n",
-                       nexthop_vrf);
+               vty_out(vty, "%% nexthop vrf %s is not defined\n", nexthop_vrf);
                return CMD_WARNING_CONFIG_FAILED;
        }
 
-       return zebra_static_route_leak(vty, zvrf, nh_zvrf,
-                                      AFI_IP6, SAFI_UNICAST, no, prefix_str,
-                                      NULL, from_str, gate_str, ifname, NULL,
-                                      tag_str, distance_str, label);
+       return zebra_static_route_leak(
+               vty, zvrf, nh_zvrf, AFI_IP6, SAFI_UNICAST, no, prefix_str, NULL,
+               from_str, gate_str, ifname, NULL, tag_str, distance_str, label);
 }
 
 DEFPY(ipv6_route_address_interface_vrf,
@@ -2157,15 +2132,13 @@ DEFPY(ipv6_route_address_interface_vrf,
                nh_zvrf = zvrf;
 
        if (!nh_zvrf) {
-               vty_out(vty, "%% nexthop vrf %s is not defined\n",
-                       nexthop_vrf);
+               vty_out(vty, "%% nexthop vrf %s is not defined\n", nexthop_vrf);
                return CMD_WARNING_CONFIG_FAILED;
        }
 
-       return zebra_static_route_leak(vty, zvrf, nh_zvrf,
-                                      AFI_IP6, SAFI_UNICAST, no, prefix_str,
-                                      NULL, from_str, gate_str, ifname, NULL,
-                                      tag_str, distance_str, label);
+       return zebra_static_route_leak(
+               vty, zvrf, nh_zvrf, AFI_IP6, SAFI_UNICAST, no, prefix_str, NULL,
+               from_str, gate_str, ifname, NULL, tag_str, distance_str, label);
 }
 
 DEFPY(ipv6_route,
@@ -2199,8 +2172,7 @@ DEFPY(ipv6_route,
 
        zvrf = zebra_vrf_lookup_by_name(vrf);
        if (!zvrf) {
-               vty_out(vty, "%% vrf %s is not defined\n",
-                       vrf);
+               vty_out(vty, "%% vrf %s is not defined\n", vrf);
                return CMD_WARNING_CONFIG_FAILED;
        }
 
@@ -2210,15 +2182,13 @@ DEFPY(ipv6_route,
                nh_zvrf = zvrf;
 
        if (!nh_zvrf) {
-               vty_out(vty, "%% nexthop vrf %s is not defined\n",
-                       nexthop_vrf);
+               vty_out(vty, "%% nexthop vrf %s is not defined\n", nexthop_vrf);
                return CMD_WARNING_CONFIG_FAILED;
        }
 
-       return zebra_static_route_leak(vty, zvrf, nh_zvrf,
-                                      AFI_IP6, SAFI_UNICAST, no, prefix_str,
-                                      NULL, from_str, gate_str, ifname, NULL,
-                                      tag_str, distance_str, label);
+       return zebra_static_route_leak(
+               vty, zvrf, nh_zvrf, AFI_IP6, SAFI_UNICAST, no, prefix_str, NULL,
+               from_str, gate_str, ifname, NULL, tag_str, distance_str, label);
 }
 
 DEFPY(ipv6_route_vrf,
@@ -2255,15 +2225,13 @@ DEFPY(ipv6_route_vrf,
                nh_zvrf = zvrf;
 
        if (!nh_zvrf) {
-               vty_out(vty, "%% nexthop vrf %s is not defined\n",
-                       nexthop_vrf);
+               vty_out(vty, "%% nexthop vrf %s is not defined\n", nexthop_vrf);
                return CMD_WARNING_CONFIG_FAILED;
        }
 
-       return zebra_static_route_leak(vty, zvrf, nh_zvrf,
-                                      AFI_IP6, SAFI_UNICAST, no, prefix_str,
-                                      NULL, from_str, gate_str, ifname, NULL,
-                                      tag_str, distance_str, label);
+       return zebra_static_route_leak(
+               vty, zvrf, nh_zvrf, AFI_IP6, SAFI_UNICAST, no, prefix_str, NULL,
+               from_str, gate_str, ifname, NULL, tag_str, distance_str, label);
 }
 
 /*
@@ -2374,8 +2342,11 @@ DEFUN (show_vrf,
                        continue;
 
                vty_out(vty, "vrf %s ", zvrf_name(zvrf));
-               if (zvrf_id(zvrf) == VRF_UNKNOWN)
+               if (zvrf_id(zvrf) == VRF_UNKNOWN || !zvrf_is_active(zvrf))
                        vty_out(vty, "inactive");
+               else if (zvrf_ns_name(zvrf))
+                       vty_out(vty, "id %u netns %s", zvrf_id(zvrf),
+                               zvrf_ns_name(zvrf));
                else
                        vty_out(vty, "id %u table %u", zvrf_id(zvrf),
                                zvrf->table_id);
@@ -2524,10 +2495,10 @@ DEFUN (show_vrf_vni,
        }
 
        if (!uj)
-               vty_out(vty, "%-37s %-10s %-20s %-20s %-5s %-18s\n",
-                       "VRF", "VNI", "VxLAN IF", "L3-SVI", "State", "Rmac");
+               vty_out(vty, "%-37s %-10s %-20s %-20s %-5s %-18s\n", "VRF",
+                       "VNI", "VxLAN IF", "L3-SVI", "State", "Rmac");
 
-       RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name) {
+       RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
                zvrf = vrf->info;
                if (!zvrf)
                        continue;
@@ -3025,10 +2996,10 @@ DEFUN_HIDDEN (zebra_workqueue_timer,
              "Work Queue\n"
              "Time in milliseconds\n")
 {
-       uint32_t timer = strtoul(argv[2]->arg, NULL, 10);
-       zebrad.ribq->spec.hold = timer;
+       uint32_t timer = strtoul(argv[2]->arg, NULL, 10);
+       zebrad.ribq->spec.hold = timer;
 
-       return CMD_SUCCESS;
+       return CMD_SUCCESS;
 }
 
 DEFUN_HIDDEN (no_zebra_workqueue_timer,
@@ -3039,9 +3010,9 @@ DEFUN_HIDDEN (no_zebra_workqueue_timer,
              "Work Queue\n"
              "Time in milliseconds\n")
 {
-       zebrad.ribq->spec.hold = ZEBRA_RIB_PROCESS_HOLD_TIME;
+       zebrad.ribq->spec.hold = ZEBRA_RIB_PROCESS_HOLD_TIME;
 
-       return CMD_SUCCESS;
+       return CMD_SUCCESS;
 }
 
 DEFUN (no_ip_zebra_import_table,
@@ -3093,8 +3064,8 @@ static int config_write_protocol(struct vty *vty)
                vty_out(vty, "zebra work-queue %u\n", zebrad.ribq->spec.hold);
 
        if (zebrad.packets_to_process != ZEBRA_ZAPI_PACKETS_TO_PROCESS)
-               vty_out(vty,
-                       "zebra zapi-packets %u\n", zebrad.packets_to_process);
+               vty_out(vty, "zebra zapi-packets %u\n",
+                       zebrad.packets_to_process);
 
        enum multicast_mode ipv4_multicast_mode = multicast_mode_ipv4_get();
 
@@ -3164,7 +3135,7 @@ DEFUN (show_zebra,
        vty_out(vty,
                "VRF                         Installs   Removals    Updates   Installs   Removals\n");
 
-       RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name) {
+       RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
                struct zebra_vrf *zvrf = vrf->info;
 
                vty_out(vty, "%-25s %10" PRIu64 " %10" PRIu64 " %10" PRIu64
@@ -3438,5 +3409,4 @@ void zebra_vty_init(void)
        install_element(CONFIG_NODE, &no_default_vrf_vni_mapping_cmd);
        install_element(VRF_NODE, &vrf_vni_mapping_cmd);
        install_element(VRF_NODE, &no_vrf_vni_mapping_cmd);
-
 }