]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/debug_nl.c
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / zebra / debug_nl.c
index 89ef7a2076786904e9e14650859dee12214b943a..df0b5aae7bb6092eb3d36914998e9c4965fae90f 100644 (file)
@@ -1,17 +1,6 @@
+// SPDX-License-Identifier: ISC
 /*
  * Copyright (c) 2018 Rafael Zalamena
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
 #include <zebra.h>
@@ -543,6 +532,8 @@ const char *rtm_rta2str(int type)
                return "MFC_STATS";
        case RTA_NH_ID:
                return "NH_ID";
+       case RTA_EXPIRES:
+               return "EXPIRES";
        default:
                return "UNKNOWN";
        }
@@ -1070,9 +1061,11 @@ next_rta:
 
 static void nlroute_dump(struct rtmsg *rtm, size_t msglen)
 {
+       struct rta_mfc_stats *mfc_stats;
        struct rtattr *rta;
        size_t plen;
        uint32_t u32v;
+       uint64_t u64v;
 
        /* Get the first attribute and go from there. */
        rta = RTM_RTA(rtm);
@@ -1083,8 +1076,9 @@ next_rta:
 
        plen = RTA_PAYLOAD(rta);
        zlog_debug("    rta [len=%d (payload=%zu) type=(%d) %s]", rta->rta_len,
-                  plen, rta->rta_type, rtm_rta2str(rta->rta_type));
-       switch (rta->rta_type) {
+                  plen, rta->rta_type & NLA_TYPE_MASK,
+                  rtm_rta2str(rta->rta_type & NLA_TYPE_MASK));
+       switch (rta->rta_type & NLA_TYPE_MASK) {
        case RTA_IIF:
        case RTA_OIF:
        case RTA_PRIORITY:
@@ -1094,6 +1088,11 @@ next_rta:
                zlog_debug("      %u", u32v);
                break;
 
+       case RTA_EXPIRES:
+               u64v = *(uint64_t *)RTA_DATA(rta);
+               zlog_debug("      %" PRIu64, u64v);
+               break;
+
        case RTA_GATEWAY:
        case RTA_DST:
        case RTA_SRC:
@@ -1112,6 +1111,14 @@ next_rta:
                }
                break;
 
+       case RTA_MFC_STATS:
+               mfc_stats = (struct rta_mfc_stats *)RTA_DATA(rta);
+               zlog_debug("      pkts=%ju bytes=%ju wrong_if=%ju",
+                          (uintmax_t)mfc_stats->mfcs_packets,
+                          (uintmax_t)mfc_stats->mfcs_bytes,
+                          (uintmax_t)mfc_stats->mfcs_wrong_if);
+               break;
+
        default:
                /* NOTHING: unhandled. */
                break;
@@ -1518,6 +1525,24 @@ next_rta:
        goto next_rta;
 }
 
+static const char *tcm_nltype2str(int nltype)
+{
+       switch (nltype) {
+       case RTM_NEWQDISC:
+       case RTM_DELQDISC:
+               return "qdisc";
+       case RTM_NEWTCLASS:
+       case RTM_DELTCLASS:
+               return "tclass";
+       case RTM_NEWTFILTER:
+       case RTM_DELTFILTER:
+               return "tfilter";
+       default:
+               /* should never hit */
+               return "unknown";
+       }
+}
+
 static void nlncm_dump(const struct netconfmsg *ncm, size_t msglen)
 {
        const struct rtattr *rta;
@@ -1577,6 +1602,8 @@ void nl_dump(void *msg, size_t msglen)
        struct ifinfomsg *ifi;
        struct tunnel_msg *tnlm;
        struct fib_rule_hdr *frh;
+       struct tcmsg *tcm;
+
        char fbuf[128];
        char ibuf[128];
 
@@ -1712,6 +1739,21 @@ next_header:
                nlncm_dump(ncm, nlmsg->nlmsg_len - NLMSG_LENGTH(sizeof(*ncm)));
                break;
 
+       case RTM_NEWQDISC:
+       case RTM_DELQDISC:
+       case RTM_NEWTCLASS:
+       case RTM_DELTCLASS:
+       case RTM_NEWTFILTER:
+       case RTM_DELTFILTER:
+               tcm = NLMSG_DATA(nlmsg);
+               zlog_debug(
+                       " tcm [type=%s family=%s (%d) ifindex=%d handle=%04x:%04x]",
+                       tcm_nltype2str(nlmsg->nlmsg_type),
+                       af_type2str(tcm->tcm_family), tcm->tcm_family,
+                       tcm->tcm_ifindex, tcm->tcm_handle >> 16,
+                       tcm->tcm_handle & 0xffff);
+               break;
+
        default:
                break;
        }