]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: Add offload and trap counts to summary command for json output 7518/head
authorDonald Sharp <sharpd@nvidia.com>
Fri, 13 Nov 2020 14:51:30 +0000 (09:51 -0500)
committerDonald Sharp <sharpd@nvidia.com>
Sun, 15 Nov 2020 15:19:25 +0000 (10:19 -0500)
For the json output add offload and trap route counts for the
json output.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
zebra/zebra_vty.c

index 20f271a147c55a28a8ddafd8c053a8949577da13..ea7baa2565d9c6ec1e55b7e5bc4a96bb6d523f0a 100644 (file)
@@ -2012,6 +2012,8 @@ static void vty_show_ip_route_summary(struct vty *vty,
 #define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
        uint32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1];
        uint32_t fib_cnt[ZEBRA_ROUTE_TOTAL + 1];
+       uint32_t offload_cnt[ZEBRA_ROUTE_TOTAL + 1];
+       uint32_t trap_cnt[ZEBRA_ROUTE_TOTAL + 1];
        uint32_t i;
        uint32_t is_ibgp;
        json_object *json_route_summary = NULL;
@@ -2019,6 +2021,8 @@ static void vty_show_ip_route_summary(struct vty *vty,
 
        memset(&rib_cnt, 0, sizeof(rib_cnt));
        memset(&fib_cnt, 0, sizeof(fib_cnt));
+       memset(&offload_cnt, 0, sizeof(offload_cnt));
+       memset(&trap_cnt, 0, sizeof(trap_cnt));
 
        if (use_json) {
                json_route_summary = json_object_new_object();
@@ -2046,6 +2050,20 @@ static void vty_show_ip_route_summary(struct vty *vty,
                                else
                                        fib_cnt[re->type]++;
                        }
+
+                       if (CHECK_FLAG(re->flags, ZEBRA_FLAG_TRAPPED)) {
+                               if (is_ibgp)
+                                       trap_cnt[ZEBRA_ROUTE_IBGP]++;
+                               else
+                                       trap_cnt[re->type]++;
+                       }
+
+                       if (CHECK_FLAG(re->flags, ZEBRA_FLAG_OFFLOADED)) {
+                               if (is_ibgp)
+                                       offload_cnt[ZEBRA_ROUTE_IBGP]++;
+                               else
+                                       offload_cnt[re->type]++;
+                       }
                }
 
        if (!use_json)
@@ -2069,6 +2087,13 @@ static void vty_show_ip_route_summary(struct vty *vty,
                                        json_object_int_add(
                                                json_route_ebgp, "rib",
                                                rib_cnt[ZEBRA_ROUTE_BGP]);
+                                       json_object_int_add(
+                                               json_route_ebgp, "fibOffLoaded",
+                                               offload_cnt[ZEBRA_ROUTE_BGP]);
+                                       json_object_int_add(
+                                               json_route_ebgp, "fibTrapped",
+                                               trap_cnt[ZEBRA_ROUTE_BGP]);
+
                                        json_object_string_add(json_route_ebgp,
                                                               "type", "ebgp");
                                        json_object_array_add(json_route_routes,
@@ -2083,6 +2108,12 @@ static void vty_show_ip_route_summary(struct vty *vty,
                                        json_object_int_add(
                                                json_route_ibgp, "rib",
                                                rib_cnt[ZEBRA_ROUTE_IBGP]);
+                                       json_object_int_add(
+                                               json_route_ibgp, "fibOffLoaded",
+                                               offload_cnt[ZEBRA_ROUTE_IBGP]);
+                                       json_object_int_add(
+                                               json_route_ibgp, "fibTrapped",
+                                               trap_cnt[ZEBRA_ROUTE_IBGP]);
                                        json_object_string_add(json_route_ibgp,
                                                               "type", "ibgp");
                                        json_object_array_add(json_route_routes,
@@ -2106,6 +2137,13 @@ static void vty_show_ip_route_summary(struct vty *vty,
                                                            "fib", fib_cnt[i]);
                                        json_object_int_add(json_route_type,
                                                            "rib", rib_cnt[i]);
+
+                                       json_object_int_add(json_route_type,
+                                                           "fibOffLoaded",
+                                                           offload_cnt[i]);
+                                       json_object_int_add(json_route_type,
+                                                           "fibTrapped",
+                                                           trap_cnt[i]);
                                        json_object_string_add(
                                                json_route_type, "type",
                                                zebra_route_string(i));