]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: Print out netlink message type instead of number
authorDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 14 Sep 2018 21:48:51 +0000 (17:48 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 14 Sep 2018 21:48:51 +0000 (17:48 -0400)
When we are displaying data about a netlink message
in debugs or errors, print out the message type
as a string instead of a number.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
zebra/if_netlink.c
zebra/kernel_netlink.c
zebra/rt_netlink.c

index 7942069fb4664f5c2dda930af0503a0de6a86ae2..47a101e619b84055c193934d7570879b219de141 100644 (file)
@@ -901,8 +901,8 @@ int netlink_interface_addr(struct nlmsghdr *h, ns_id_t ns_id, int startup)
        if (ifa->ifa_family != AF_INET && ifa->ifa_family != AF_INET6) {
                flog_warn(
                        EC_ZEBRA_UNKNOWN_FAMILY,
-                       "Invalid address family: %u received from kernel interface addr change: %u",
-                       ifa->ifa_family, h->nlmsg_type);
+                       "Invalid address family: %u received from kernel interface addr change: %s",
+                       ifa->ifa_family, nl_msg_type_to_str(h->nlmsg_type));
                return 0;
        }
 
@@ -1006,8 +1006,9 @@ int netlink_interface_addr(struct nlmsghdr *h, ns_id_t ns_id, int startup)
        if (ifa->ifa_family == AF_INET) {
                if (ifa->ifa_prefixlen > IPV4_MAX_BITLEN) {
                        zlog_err(
-                               "Invalid prefix length: %u received from kernel interface addr change: %u",
-                               ifa->ifa_prefixlen, h->nlmsg_type);
+                               "Invalid prefix length: %u received from kernel interface addr change: %s",
+                               ifa->ifa_prefixlen,
+                               nl_msg_type_to_str(h->nlmsg_type));
                        return -1;
                }
                if (h->nlmsg_type == RTM_NEWADDR)
@@ -1022,8 +1023,9 @@ int netlink_interface_addr(struct nlmsghdr *h, ns_id_t ns_id, int startup)
        if (ifa->ifa_family == AF_INET6) {
                if (ifa->ifa_prefixlen > IPV6_MAX_BITLEN) {
                        zlog_err(
-                               "Invalid prefix length: %u received from kernel interface addr change: %u",
-                               ifa->ifa_prefixlen, h->nlmsg_type);
+                               "Invalid prefix length: %u received from kernel interface addr change: %s",
+                               ifa->ifa_prefixlen,
+                               nl_msg_type_to_str(h->nlmsg_type));
                        return -1;
                }
                if (h->nlmsg_type == RTM_NEWADDR) {
@@ -1073,8 +1075,8 @@ int netlink_link_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
        /* assume if not default zns, then new VRF */
        if (!(h->nlmsg_type == RTM_NEWLINK || h->nlmsg_type == RTM_DELLINK)) {
                /* If this is not link add/delete message so print warning. */
-               zlog_debug("netlink_link_change: wrong kernel message %d",
-                          h->nlmsg_type);
+               zlog_debug("netlink_link_change: wrong kernel message %s",
+                          nl_msg_type_to_str(h->nlmsg_type));
                return 0;
        }
 
@@ -1082,8 +1084,8 @@ int netlink_link_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
              || ifi->ifi_family == AF_INET6)) {
                flog_warn(
                        EC_ZEBRA_UNKNOWN_FAMILY,
-                       "Invalid address family: %u received from kernel link change: %u",
-                       ifi->ifi_family, h->nlmsg_type);
+                       "Invalid address family: %u received from kernel link change: %s",
+                       ifi->ifi_family, nl_msg_type_to_str(h->nlmsg_type));
                return 0;
        }
 
index 1b713cc8cd62b81a2bc3a06483239b8a5f6cc25b..d35230d7bd416fc034bc8d6a590c74d67c015b26 100644 (file)
@@ -641,8 +641,9 @@ static void netlink_parse_extended_ack(struct nlmsghdr *h)
                         * but noticing it for later.
                         */
                        err_nlh = &err->msg;
-                       zlog_debug("%s: Received %d extended Ack",
-                                  __PRETTY_FUNCTION__, err_nlh->nlmsg_type);
+                       zlog_debug("%s: Received %s extended Ack",
+                                  __PRETTY_FUNCTION__,
+                                  nl_msg_type_to_str(err_nlh->nlmsg_type));
                }
        }
 
index 7d4c68cc01e55155d518827250945374ebc16cad..20b88bb6d802620637b3a11318af52b0da7dec78 100644 (file)
@@ -828,15 +828,16 @@ int netlink_route_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
 
        if (!(h->nlmsg_type == RTM_NEWROUTE || h->nlmsg_type == RTM_DELROUTE)) {
                /* If this is not route add/delete message print warning. */
-               zlog_debug("Kernel message: %d NS %u\n", h->nlmsg_type, ns_id);
+               zlog_debug("Kernel message: %s NS %u\n",
+                          nl_msg_type_to_str(h->nlmsg_type), ns_id);
                return 0;
        }
 
        if (!(rtm->rtm_family == AF_INET || rtm->rtm_family == AF_INET6)) {
                flog_warn(
                        EC_ZEBRA_UNKNOWN_FAMILY,
-                       "Invalid address family: %u received from kernel route change: %u",
-                       rtm->rtm_family, h->nlmsg_type);
+                       "Invalid address family: %u received from kernel route change: %s",
+                       rtm->rtm_family, nl_msg_type_to_str(h->nlmsg_type));
                return 0;
        }
 
@@ -2487,8 +2488,8 @@ int netlink_neigh_change(struct nlmsghdr *h, ns_id_t ns_id)
        else {
                flog_warn(
                        EC_ZEBRA_UNKNOWN_FAMILY,
-                       "Invalid address family: %u received from kernel neighbor change: %u",
-                       ndm->ndm_family, h->nlmsg_type);
+                       "Invalid address family: %u received from kernel neighbor change: %s",
+                       ndm->ndm_family, nl_msg_type_to_str(h->nlmsg_type));
                return 0;
        }