forked from Mirror/frr
zebra: human readable netlink dumps
Add new compile option to enable human readable netlink dumps with `debug zebra kernel msgdump`. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
This commit is contained in:
parent
0ce5baaab1
commit
eead0bc46b
|
@ -673,6 +673,15 @@ AC_ARG_ENABLE([dev_build],
|
||||||
AC_ARG_ENABLE([lua],
|
AC_ARG_ENABLE([lua],
|
||||||
AS_HELP_STRING([--enable-lua], [Build Lua scripting]))
|
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" != "no" ; then
|
||||||
if test "$enable_time_check" = "yes" -o "$enable_time_check" = "" ; then
|
if test "$enable_time_check" = "yes" -o "$enable_time_check" = "" ; then
|
||||||
AC_DEFINE([CONSUMED_TIME_CHECK], [5000000], [Consumed Time Check])
|
AC_DEFINE([CONSUMED_TIME_CHECK], [5000000], [Consumed Time Check])
|
||||||
|
|
1246
zebra/debug_nl.c
Normal file
1246
zebra/debug_nl.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -712,7 +712,11 @@ static ssize_t netlink_send_msg(const struct nlsock *nl, void *buf,
|
||||||
|
|
||||||
if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND) {
|
if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND) {
|
||||||
zlog_debug("%s: >> netlink message dump [sent]", __func__);
|
zlog_debug("%s: >> netlink message dump [sent]", __func__);
|
||||||
|
#ifdef NETLINK_DEBUG
|
||||||
|
nl_dump(buf, buflen);
|
||||||
|
#else
|
||||||
zlog_hexdump(buf, buflen);
|
zlog_hexdump(buf, buflen);
|
||||||
|
#endif /* NETLINK_DEBUG */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status == -1) {
|
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) {
|
if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV) {
|
||||||
zlog_debug("%s: << netlink message dump [recv]", __func__);
|
zlog_debug("%s: << netlink message dump [recv]", __func__);
|
||||||
|
#ifdef NETLINK_DEBUG
|
||||||
|
nl_dump(buf, status);
|
||||||
|
#else
|
||||||
zlog_hexdump(buf, status);
|
zlog_hexdump(buf, status);
|
||||||
|
#endif /* NETLINK_DEBUG */
|
||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
|
|
|
@ -118,6 +118,29 @@ netlink_put_lsp_update_msg(struct nl_batch *bth, struct zebra_dplane_ctx *ctx);
|
||||||
extern enum netlink_msg_status
|
extern enum netlink_msg_status
|
||||||
netlink_put_pw_update_msg(struct nl_batch *bth, struct zebra_dplane_ctx *ctx);
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -220,3 +220,9 @@ zebra_dplane_fpm_nl_la_LIBADD =
|
||||||
|
|
||||||
vtysh_scan += $(top_srcdir)/zebra/dplane_fpm_nl.c
|
vtysh_scan += $(top_srcdir)/zebra/dplane_fpm_nl.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if NETLINK_DEBUG
|
||||||
|
zebra_zebra_SOURCES += \
|
||||||
|
zebra/debug_nl.c \
|
||||||
|
# end
|
||||||
|
endif
|
||||||
|
|
Loading…
Reference in a new issue