zebra: simplify some netlink debug messages

*   Use `inet_ntop` instead of `inet_ntoa`
*   Replace function name with `__func__`
*   Inline functions

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
This commit is contained in:
Rafael Zalamena 2019-11-29 18:15:02 -03:00
parent e57a3fab68
commit 9266b31568

View File

@ -1123,6 +1123,7 @@ static void _netlink_route_build_singlepath(const struct prefix *p,
char label_buf[256];
int num_labels = 0;
struct vrf *vrf;
char addrstr[INET6_ADDRSTRLEN];
assert(nexthop);
@ -1179,11 +1180,10 @@ static void _netlink_route_build_singlepath(const struct prefix *p,
&nexthop->src.ipv4, bytelen);
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug(
" 5549: _netlink_route_build_singlepath() (%s): %pFX nexthop via %s %s if %u vrf %s(%u)",
routedesc, p, ipv4_ll_buf, label_buf,
nexthop->ifindex, VRF_LOGNAME(vrf),
nexthop->vrf_id);
zlog_debug("%s: 5549 (%s): %pFX nexthop via %s %s if %u vrf %s(%u)",
__func__, routedesc, p, ipv4_ll_buf,
label_buf, nexthop->ifindex,
VRF_LOGNAME(vrf), nexthop->vrf_id);
return;
}
@ -1204,13 +1204,15 @@ static void _netlink_route_build_singlepath(const struct prefix *p,
&nexthop->src.ipv4, bytelen);
}
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug(
"netlink_route_multipath() (%s): %pFX nexthop via %s %s if %u vrf %s(%u)",
routedesc, p, inet_ntoa(nexthop->gate.ipv4),
label_buf, nexthop->ifindex, VRF_LOGNAME(vrf),
if (IS_ZEBRA_DEBUG_KERNEL) {
inet_ntop(AF_INET, &nexthop->gate.ipv4, addrstr,
sizeof(addrstr));
zlog_debug("%s: (%s): %pFX nexthop via %s %s if %u vrf %s(%u)",
__func__, routedesc, p, addrstr, label_buf,
nexthop->ifindex, VRF_LOGNAME(vrf),
nexthop->vrf_id);
}
}
if (nexthop->type == NEXTHOP_TYPE_IPV6
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX) {
@ -1227,13 +1229,15 @@ static void _netlink_route_build_singlepath(const struct prefix *p,
&nexthop->src.ipv6, bytelen);
}
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug(
"netlink_route_multipath() (%s): %pFX nexthop via %s %s if %u vrf %s(%u)",
routedesc, p, inet6_ntoa(nexthop->gate.ipv6),
label_buf, nexthop->ifindex, VRF_LOGNAME(vrf),
if (IS_ZEBRA_DEBUG_KERNEL) {
inet_ntop(AF_INET6, &nexthop->gate.ipv6, addrstr,
sizeof(addrstr));
zlog_debug("%s: (%s): %pFX nexthop via %s %s if %u vrf %s(%u)",
__func__, routedesc, p, addrstr, label_buf,
nexthop->ifindex, VRF_LOGNAME(vrf),
nexthop->vrf_id);
}
}
/*
* We have the ifindex so we should always send it
@ -1254,9 +1258,8 @@ static void _netlink_route_build_singlepath(const struct prefix *p,
}
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug(
"netlink_route_multipath() (%s): %pFX nexthop via if %u vrf %s(%u)",
routedesc, p, nexthop->ifindex,
zlog_debug("%s: (%s): %pFX nexthop via if %u vrf %s(%u)",
__func__, routedesc, p, nexthop->ifindex,
VRF_LOGNAME(vrf), nexthop->vrf_id);
}
}
@ -1287,6 +1290,7 @@ _netlink_route_build_multipath(const struct prefix *p, const char *routedesc,
char label_buf[256];
int num_labels = 0;
struct vrf *vrf;
char addrstr[INET6_ADDRSTRLEN];
rtnh->rtnh_len = sizeof(*rtnh);
rtnh->rtnh_flags = 0;
@ -1356,8 +1360,8 @@ _netlink_route_build_multipath(const struct prefix *p, const char *routedesc,
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug(
" 5549: netlink_route_build_multipath() (%s): %pFX nexthop via %s %s if %u vrf %s(%u)",
routedesc, p, ipv4_ll_buf, label_buf,
"%s: 5549 (%s): %pFX nexthop via %s %s if %u vrf %s(%u)",
__func__, routedesc, p, ipv4_ll_buf, label_buf,
nexthop->ifindex, VRF_LOGNAME(vrf),
nexthop->vrf_id);
return;
@ -1373,13 +1377,15 @@ _netlink_route_build_multipath(const struct prefix *p, const char *routedesc,
else if (nexthop->src.ipv4.s_addr != INADDR_ANY)
*src = &nexthop->src;
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug(
"netlink_route_multipath() (%s): %pFX nexthop via %s %s if %u vrf %s(%u)",
routedesc, p, inet_ntoa(nexthop->gate.ipv4),
label_buf, nexthop->ifindex, VRF_LOGNAME(vrf),
if (IS_ZEBRA_DEBUG_KERNEL) {
inet_ntop(AF_INET, &nexthop->gate.ipv4, addrstr,
sizeof(addrstr));
zlog_debug( "%s: (%s): %pFX nexthop via %s %s if %u vrf %s(%u)",
__func__, routedesc, p, addrstr, label_buf,
nexthop->ifindex, VRF_LOGNAME(vrf),
nexthop->vrf_id);
}
}
if (nexthop->type == NEXTHOP_TYPE_IPV6
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX) {
_netlink_route_rta_add_gateway_info(rtmsg->rtm_family, AF_INET6,
@ -1391,13 +1397,15 @@ _netlink_route_build_multipath(const struct prefix *p, const char *routedesc,
else if (!IN6_IS_ADDR_UNSPECIFIED(&nexthop->src.ipv6))
*src = &nexthop->src;
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug(
"netlink_route_multipath() (%s): %pFX nexthop via %s %s if %u vrf %s(%u)",
routedesc, p, inet6_ntoa(nexthop->gate.ipv6),
label_buf, nexthop->ifindex, VRF_LOGNAME(vrf),
if (IS_ZEBRA_DEBUG_KERNEL) {
inet_ntop(AF_INET, &nexthop->gate.ipv6, addrstr,
sizeof(addrstr));
zlog_debug( "%s: (%s): %pFX nexthop via %s %s if %u vrf %s(%u)",
__func__, routedesc, p, addrstr, label_buf,
nexthop->ifindex, VRF_LOGNAME(vrf),
nexthop->vrf_id);
}
}
/*
* We have figured out the ifindex so we should always send it
@ -1415,9 +1423,8 @@ _netlink_route_build_multipath(const struct prefix *p, const char *routedesc,
*src = &nexthop->src;
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug(
"netlink_route_multipath() (%s): %pFX nexthop via if %u vrf %s(%u)",
routedesc, p, nexthop->ifindex,
zlog_debug("%s: (%s): %pFX nexthop via if %u vrf %s(%u)",
__func__, routedesc, p, nexthop->ifindex,
VRF_LOGNAME(vrf), nexthop->vrf_id);
}
@ -1457,37 +1464,6 @@ _netlink_mpls_build_multipath(const struct prefix *p, const char *routedesc,
rta, rtnh, rtmsg, src);
}
/* Log debug information for netlink_route_multipath
* if debug logging is enabled.
*
* @param cmd: Netlink command which is to be processed
* @param p: Prefix for which the change is due
* @param family: Address family which the change concerns
* @param zvrf: The vrf we are in
* @param tableid: The table we are working on
*/
static void _netlink_route_debug(int cmd, const struct prefix *p,
int family, vrf_id_t vrfid,
uint32_t tableid)
{
if (IS_ZEBRA_DEBUG_KERNEL) {
char buf[PREFIX_STRLEN];
zlog_debug(
"netlink_route_multipath(): %s %s vrf %s(%u) table_id: %u",
nl_msg_type_to_str(cmd),
prefix2str(p, buf, sizeof(buf)), vrf_id_to_name(vrfid),
vrfid, tableid);
}
}
static void _netlink_nexthop_debug(int cmd, uint32_t id)
{
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug("netlink_nexthop(): %s, id=%u",
nl_msg_type_to_str(cmd), id);
}
static void _netlink_mpls_debug(int cmd, uint32_t label, const char *routedesc)
{
if (IS_ZEBRA_DEBUG_KERNEL)
@ -1650,7 +1626,11 @@ static int netlink_route_multipath(int cmd, struct zebra_dplane_ctx *ctx,
addattr32(&req->n, datalen, RTA_TABLE, table_id);
}
_netlink_route_debug(cmd, p, family, dplane_ctx_get_vrf(ctx), table_id);
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug(
"%s: %s %pFX vrf %u(%u)", __func__,
nl_msg_type_to_str(cmd), p, dplane_ctx_get_vrf(ctx),
table_id);
/*
* If we are not updating the route and we have received
@ -1840,8 +1820,7 @@ static int netlink_route_multipath(int cmd, struct zebra_dplane_ctx *ctx,
/* If there is no useful nexthop then return. */
if (nexthop_num == 0) {
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug(
"netlink_route_multipath(): No useful nexthop.");
zlog_debug("%s: No useful nexthop.", __func__);
}
return 0;
@ -2103,7 +2082,9 @@ nexthop_done:
return -1;
}
_netlink_nexthop_debug(cmd, id);
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug("%s: %s, id=%u", __func__, nl_msg_type_to_str(cmd),
id);
return netlink_talk_info(netlink_talk_filter, &req.n,
dplane_ctx_get_ns(ctx), 0);