]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib, zebra: Add ability to read kernel notice of TRAP/OFFLOAD 7155/head
authorDonald Sharp <sharpd@nvidia.com>
Fri, 18 Sep 2020 19:47:27 +0000 (15:47 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Tue, 22 Sep 2020 19:57:43 +0000 (15:57 -0400)
The linux kernel is getting RTM_F_TRAP and RTM_F_OFFLOAD for
kernel routes that have an underlying asic offload.  Write the
code to receive these notifications from the linux kernel and
to store that data for display about the routes.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
lib/route_types.pl
lib/zclient.h
tests/topotests/lib/topotest.py
zebra/rt_netlink.c
zebra/zebra_vty.c

index e007de4d690ef52a4f20686beeab9576da4fdb80..39af8d0d5637bb0f76ba4360ff5b1c407d2cc336 100755 (executable)
@@ -121,7 +121,10 @@ sub codelist {
        }
        $str =~ s/ $//;
        push @lines, $str . "\\n\" \\\n";
-       push @lines, "  \"       > - selected route, * - FIB route, q - queued, r - rejected, b - backup\\n\\n\"";
+       push @lines, "  \"       > - selected route, * - FIB route, q - queued, r - rejected, b - backup\\n\"";
+       push @lines, "  \"       t - trapped, o - offload failure\\n\"";
+
+
        return join("", @lines);
 }
 
index f99b3ad7432aa3cc8e617345a26d0187af864ab2..050877f27a221196d146f5eb30e13a30b6f84fac 100644 (file)
@@ -480,6 +480,20 @@ struct zapi_route {
  * route entry.  This mainly is used for backup static routes.
  */
 #define ZEBRA_FLAG_RR_USE_DISTANCE    0x40
+/*
+ * This flag tells everyone that the route was intentionally
+ * not offloaded and the route will be sent to the cpu for
+ * forwarding.  This flag makes no sense unless you are in
+ * an asic offload situation
+ */
+#define ZEBRA_FLAG_TRAPPED            0x80
+/*
+ * This flag tells everyone that the route has been
+ * successfully offloaded to an asic for forwarding.
+ * This flag makes no sense unless you are in an asic
+ * offload situation.
+ */
+#define ZEBRA_FLAG_OFFLOADED          0x100
 
        /* The older XXX_MESSAGE flags live here */
        uint32_t message;
index e34d1cf0be3605388d3f93c229957c05ba38afcf..c3f3730b2ad109c3043bde719525f62d553480bb 100644 (file)
@@ -628,7 +628,7 @@ def ip4_route_zebra(node, vrf_name=None):
     lines = output.splitlines()
     header_found = False
     while lines and (not lines[0].strip() or not header_found):
-        if "> - selected route" in lines[0]:
+        if "o - offload failure" in lines[0]:
             header_found = True
         lines = lines[1:]
     return "\n".join(lines)
@@ -654,7 +654,7 @@ def ip6_route_zebra(node, vrf_name=None):
     lines = output.splitlines()
     header_found = False
     while lines and (not lines[0].strip() or not header_found):
-        if "> - selected route" in lines[0]:
+        if "o - offload failure" in lines[0]:
             header_found = True
         lines = lines[1:]
 
index 50b1a62d86cacaa3fe028f61b5c380bed24b95f6..c4fe808071cc0db257967291c3a8b2c447ad0a7f 100644 (file)
@@ -643,6 +643,11 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
                        return 0;
        }
 
+       if (rtm->rtm_flags & RTM_F_TRAP)
+               flags |= ZEBRA_FLAG_TRAPPED;
+       if (rtm->rtm_flags & RTM_F_OFFLOAD)
+               flags |= ZEBRA_FLAG_OFFLOADED;
+
        /* Route which inserted by Zebra. */
        if (selfroute) {
                flags |= ZEBRA_FLAG_SELFROUTE;
index 3c360901b3ae519ce38c0a5a4a514e7ff56be512..28c33a70fe2f70891cabc832931092423326ec14 100644 (file)
@@ -192,6 +192,14 @@ static char re_status_output_char(const struct route_entry *re,
                                star_p = true;
                }
 
+               if (zrouter.asic_offloaded
+                   && CHECK_FLAG(re->flags, ZEBRA_FLAG_TRAPPED))
+                       return 't';
+
+               if (zrouter.asic_offloaded
+                   && !CHECK_FLAG(re->flags, ZEBRA_FLAG_OFFLOADED))
+                       return 'o';
+
                if (star_p)
                        return '*';
                else
@@ -862,6 +870,12 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
                if (CHECK_FLAG(re->status, ROUTE_ENTRY_QUEUED))
                        json_object_boolean_true_add(json_route, "queued");
 
+               if (CHECK_FLAG(re->flags, ZEBRA_FLAG_TRAPPED))
+                       json_object_boolean_true_add(json_route, "trapped");
+
+               if (CHECK_FLAG(re->flags, ZEBRA_FLAG_OFFLOADED))
+                       json_object_boolean_true_add(json_route, "offloaded");
+
                if (re->tag)
                        json_object_int_add(json_route, "tag", re->tag);