Merge pull request #7162 from opensourcerouting/zebra-human-netlink

zebra: human readable netlink dumps
This commit is contained in:
Stephen Worley 2020-12-14 14:03:35 -05:00 committed by GitHub
commit 3bece1e0e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 1292 additions and 0 deletions

View File

@ -696,6 +696,15 @@ AC_ARG_ENABLE([dev_build],
AC_ARG_ENABLE([lua],
AS_HELP_STRING([--enable-lua], [Build Lua scripting]))
AC_ARG_ENABLE([netlink-debug],
AS_HELP_STRING([--disable-netlink-debug], [pretty print netlink debug messages]))
if test "$enable_netlink_debug" != "no" ; then
AC_DEFINE([NETLINK_DEBUG], [1], [Netlink extra debugging code])
fi
AM_CONDITIONAL([NETLINK_DEBUG], [test "$enable_netlink_debug" != "no"])
if test "$enable_time_check" != "no" ; then
if test "$enable_time_check" = "yes" -o "$enable_time_check" = "" ; then
AC_DEFINE([CONSUMED_TIME_CHECK], [5000000], [Consumed Time Check])

1246
zebra/debug_nl.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -712,7 +712,11 @@ static ssize_t netlink_send_msg(const struct nlsock *nl, void *buf,
if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND) {
zlog_debug("%s: >> netlink message dump [sent]", __func__);
#ifdef NETLINK_DEBUG
nl_dump(buf, buflen);
#else
zlog_hexdump(buf, buflen);
#endif /* NETLINK_DEBUG */
}
if (status == -1) {
@ -770,7 +774,11 @@ static int netlink_recv_msg(const struct nlsock *nl, struct msghdr msg,
if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV) {
zlog_debug("%s: << netlink message dump [recv]", __func__);
#ifdef NETLINK_DEBUG
nl_dump(buf, status);
#else
zlog_hexdump(buf, status);
#endif /* NETLINK_DEBUG */
}
return status;

View File

@ -121,6 +121,29 @@ netlink_put_lsp_update_msg(struct nl_batch *bth, struct zebra_dplane_ctx *ctx);
extern enum netlink_msg_status
netlink_put_pw_update_msg(struct nl_batch *bth, struct zebra_dplane_ctx *ctx);
#ifdef NETLINK_DEBUG
const char *nlmsg_type2str(uint16_t type);
const char *af_type2str(int type);
const char *ifi_type2str(int type);
const char *rta_type2str(int type);
const char *rtm_type2str(int type);
const char *rtm_protocol2str(int type);
const char *rtm_scope2str(int type);
const char *rtm_rta2str(int type);
const char *neigh_rta2str(int type);
const char *ifa_rta2str(int type);
const char *nhm_rta2str(int type);
const char *nlmsg_flags2str(uint16_t flags, char *buf, size_t buflen);
const char *if_flags2str(uint32_t flags, char *buf, size_t buflen);
const char *rtm_flags2str(uint32_t flags, char *buf, size_t buflen);
const char *neigh_state2str(uint32_t flags, char *buf, size_t buflen);
const char *neigh_flags2str(uint32_t flags, char *buf, size_t buflen);
const char *ifa_flags2str(uint32_t flags, char *buf, size_t buflen);
const char *nh_flags2str(uint32_t flags, char *buf, size_t buflen);
void nl_dump(void *msg, size_t msglen);
#endif /* NETLINK_DEBUG */
#ifdef __cplusplus
}
#endif

View File

@ -222,3 +222,9 @@ zebra_dplane_fpm_nl_la_LIBADD =
vtysh_scan += $(top_srcdir)/zebra/dplane_fpm_nl.c
endif
if NETLINK_DEBUG
zebra_zebra_SOURCES += \
zebra/debug_nl.c \
# end
endif