]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: Add encap and group type decoding to nexthop dump
authorDonald Sharp <sharpd@nvidia.com>
Fri, 13 May 2022 14:25:13 +0000 (10:25 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Fri, 13 May 2022 14:37:30 +0000 (10:37 -0400)
Add the ability to give data about the nexthop group type
and encap type so that it is human readable.

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

index b7d12bf53789232964dbe95d4c9692ba71b58108..98b3a9ed504f3ad7181d553a7875433e0416bc13 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/rtnetlink.h>
 #include <net/if_arp.h>
 #include <linux/fib_rules.h>
+#include <linux/lwtunnel.h>
 
 #include <stdio.h>
 #include <stdint.h>
@@ -1234,6 +1235,42 @@ next_rta:
        goto next_rta;
 }
 
+static const char *lwt_type2str(uint16_t type)
+{
+       switch (type) {
+       case LWTUNNEL_ENCAP_NONE:
+               return "NONE";
+       case LWTUNNEL_ENCAP_MPLS:
+               return "MPLS";
+       case LWTUNNEL_ENCAP_IP:
+               return "IPv4";
+       case LWTUNNEL_ENCAP_ILA:
+               return "ILA";
+       case LWTUNNEL_ENCAP_IP6:
+               return "IPv6";
+       case LWTUNNEL_ENCAP_SEG6:
+               return "SEG6";
+       case LWTUNNEL_ENCAP_BPF:
+               return "BPF";
+       case LWTUNNEL_ENCAP_SEG6_LOCAL:
+               return "SEG6_LOCAL";
+       default:
+               return "UNKNOWN";
+       }
+}
+
+static const char *nhg_type2str(uint16_t type)
+{
+       switch (type) {
+       case NEXTHOP_GRP_TYPE_MPATH:
+               return "MULTIPATH";
+       case NEXTHOP_GRP_TYPE_RES:
+               return "RESILIENT MULTIPATH";
+       default:
+               return "UNKNOWN";
+       }
+}
+
 static void nlnh_dump(struct nhmsg *nhm, size_t msglen)
 {
        struct rtattr *rta;
@@ -1275,9 +1312,12 @@ next_rta:
                                   nhgrp[i].weight);
                break;
        case NHA_ENCAP_TYPE:
+               u16v = *(uint16_t *)RTA_DATA(rta);
+               zlog_debug("      %s", lwt_type2str(u16v));
+               break;
        case NHA_GROUP_TYPE:
                u16v = *(uint16_t *)RTA_DATA(rta);
-               zlog_debug("      %d", u16v);
+               zlog_debug("      %s", nhg_type2str(u16v));
                break;
        case NHA_BLACKHOLE:
                /* NOTHING */