mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-15 13:27:53 +00:00
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:
parent
e57a3fab68
commit
9266b31568
@ -1123,6 +1123,7 @@ static void _netlink_route_build_singlepath(const struct prefix *p,
|
|||||||
char label_buf[256];
|
char label_buf[256];
|
||||||
int num_labels = 0;
|
int num_labels = 0;
|
||||||
struct vrf *vrf;
|
struct vrf *vrf;
|
||||||
|
char addrstr[INET6_ADDRSTRLEN];
|
||||||
|
|
||||||
assert(nexthop);
|
assert(nexthop);
|
||||||
|
|
||||||
@ -1179,11 +1180,10 @@ static void _netlink_route_build_singlepath(const struct prefix *p,
|
|||||||
&nexthop->src.ipv4, bytelen);
|
&nexthop->src.ipv4, bytelen);
|
||||||
|
|
||||||
if (IS_ZEBRA_DEBUG_KERNEL)
|
if (IS_ZEBRA_DEBUG_KERNEL)
|
||||||
zlog_debug(
|
zlog_debug("%s: 5549 (%s): %pFX nexthop via %s %s if %u vrf %s(%u)",
|
||||||
" 5549: _netlink_route_build_singlepath() (%s): %pFX nexthop via %s %s if %u vrf %s(%u)",
|
__func__, routedesc, p, ipv4_ll_buf,
|
||||||
routedesc, p, ipv4_ll_buf, label_buf,
|
label_buf, nexthop->ifindex,
|
||||||
nexthop->ifindex, VRF_LOGNAME(vrf),
|
VRF_LOGNAME(vrf), nexthop->vrf_id);
|
||||||
nexthop->vrf_id);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1204,13 +1204,15 @@ static void _netlink_route_build_singlepath(const struct prefix *p,
|
|||||||
&nexthop->src.ipv4, bytelen);
|
&nexthop->src.ipv4, bytelen);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_ZEBRA_DEBUG_KERNEL)
|
if (IS_ZEBRA_DEBUG_KERNEL) {
|
||||||
zlog_debug(
|
inet_ntop(AF_INET, &nexthop->gate.ipv4, addrstr,
|
||||||
"netlink_route_multipath() (%s): %pFX nexthop via %s %s if %u vrf %s(%u)",
|
sizeof(addrstr));
|
||||||
routedesc, p, inet_ntoa(nexthop->gate.ipv4),
|
zlog_debug("%s: (%s): %pFX nexthop via %s %s if %u vrf %s(%u)",
|
||||||
label_buf, nexthop->ifindex, VRF_LOGNAME(vrf),
|
__func__, routedesc, p, addrstr, label_buf,
|
||||||
|
nexthop->ifindex, VRF_LOGNAME(vrf),
|
||||||
nexthop->vrf_id);
|
nexthop->vrf_id);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (nexthop->type == NEXTHOP_TYPE_IPV6
|
if (nexthop->type == NEXTHOP_TYPE_IPV6
|
||||||
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX) {
|
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX) {
|
||||||
@ -1227,13 +1229,15 @@ static void _netlink_route_build_singlepath(const struct prefix *p,
|
|||||||
&nexthop->src.ipv6, bytelen);
|
&nexthop->src.ipv6, bytelen);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_ZEBRA_DEBUG_KERNEL)
|
if (IS_ZEBRA_DEBUG_KERNEL) {
|
||||||
zlog_debug(
|
inet_ntop(AF_INET6, &nexthop->gate.ipv6, addrstr,
|
||||||
"netlink_route_multipath() (%s): %pFX nexthop via %s %s if %u vrf %s(%u)",
|
sizeof(addrstr));
|
||||||
routedesc, p, inet6_ntoa(nexthop->gate.ipv6),
|
zlog_debug("%s: (%s): %pFX nexthop via %s %s if %u vrf %s(%u)",
|
||||||
label_buf, nexthop->ifindex, VRF_LOGNAME(vrf),
|
__func__, routedesc, p, addrstr, label_buf,
|
||||||
|
nexthop->ifindex, VRF_LOGNAME(vrf),
|
||||||
nexthop->vrf_id);
|
nexthop->vrf_id);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We have the ifindex so we should always send it
|
* 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)
|
if (IS_ZEBRA_DEBUG_KERNEL)
|
||||||
zlog_debug(
|
zlog_debug("%s: (%s): %pFX nexthop via if %u vrf %s(%u)",
|
||||||
"netlink_route_multipath() (%s): %pFX nexthop via if %u vrf %s(%u)",
|
__func__, routedesc, p, nexthop->ifindex,
|
||||||
routedesc, p, nexthop->ifindex,
|
|
||||||
VRF_LOGNAME(vrf), nexthop->vrf_id);
|
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];
|
char label_buf[256];
|
||||||
int num_labels = 0;
|
int num_labels = 0;
|
||||||
struct vrf *vrf;
|
struct vrf *vrf;
|
||||||
|
char addrstr[INET6_ADDRSTRLEN];
|
||||||
|
|
||||||
rtnh->rtnh_len = sizeof(*rtnh);
|
rtnh->rtnh_len = sizeof(*rtnh);
|
||||||
rtnh->rtnh_flags = 0;
|
rtnh->rtnh_flags = 0;
|
||||||
@ -1356,8 +1360,8 @@ _netlink_route_build_multipath(const struct prefix *p, const char *routedesc,
|
|||||||
|
|
||||||
if (IS_ZEBRA_DEBUG_KERNEL)
|
if (IS_ZEBRA_DEBUG_KERNEL)
|
||||||
zlog_debug(
|
zlog_debug(
|
||||||
" 5549: netlink_route_build_multipath() (%s): %pFX nexthop via %s %s if %u vrf %s(%u)",
|
"%s: 5549 (%s): %pFX nexthop via %s %s if %u vrf %s(%u)",
|
||||||
routedesc, p, ipv4_ll_buf, label_buf,
|
__func__, routedesc, p, ipv4_ll_buf, label_buf,
|
||||||
nexthop->ifindex, VRF_LOGNAME(vrf),
|
nexthop->ifindex, VRF_LOGNAME(vrf),
|
||||||
nexthop->vrf_id);
|
nexthop->vrf_id);
|
||||||
return;
|
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)
|
else if (nexthop->src.ipv4.s_addr != INADDR_ANY)
|
||||||
*src = &nexthop->src;
|
*src = &nexthop->src;
|
||||||
|
|
||||||
if (IS_ZEBRA_DEBUG_KERNEL)
|
if (IS_ZEBRA_DEBUG_KERNEL) {
|
||||||
zlog_debug(
|
inet_ntop(AF_INET, &nexthop->gate.ipv4, addrstr,
|
||||||
"netlink_route_multipath() (%s): %pFX nexthop via %s %s if %u vrf %s(%u)",
|
sizeof(addrstr));
|
||||||
routedesc, p, inet_ntoa(nexthop->gate.ipv4),
|
zlog_debug( "%s: (%s): %pFX nexthop via %s %s if %u vrf %s(%u)",
|
||||||
label_buf, nexthop->ifindex, VRF_LOGNAME(vrf),
|
__func__, routedesc, p, addrstr, label_buf,
|
||||||
|
nexthop->ifindex, VRF_LOGNAME(vrf),
|
||||||
nexthop->vrf_id);
|
nexthop->vrf_id);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (nexthop->type == NEXTHOP_TYPE_IPV6
|
if (nexthop->type == NEXTHOP_TYPE_IPV6
|
||||||
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX) {
|
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX) {
|
||||||
_netlink_route_rta_add_gateway_info(rtmsg->rtm_family, AF_INET6,
|
_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))
|
else if (!IN6_IS_ADDR_UNSPECIFIED(&nexthop->src.ipv6))
|
||||||
*src = &nexthop->src;
|
*src = &nexthop->src;
|
||||||
|
|
||||||
if (IS_ZEBRA_DEBUG_KERNEL)
|
if (IS_ZEBRA_DEBUG_KERNEL) {
|
||||||
zlog_debug(
|
inet_ntop(AF_INET, &nexthop->gate.ipv6, addrstr,
|
||||||
"netlink_route_multipath() (%s): %pFX nexthop via %s %s if %u vrf %s(%u)",
|
sizeof(addrstr));
|
||||||
routedesc, p, inet6_ntoa(nexthop->gate.ipv6),
|
zlog_debug( "%s: (%s): %pFX nexthop via %s %s if %u vrf %s(%u)",
|
||||||
label_buf, nexthop->ifindex, VRF_LOGNAME(vrf),
|
__func__, routedesc, p, addrstr, label_buf,
|
||||||
|
nexthop->ifindex, VRF_LOGNAME(vrf),
|
||||||
nexthop->vrf_id);
|
nexthop->vrf_id);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We have figured out the ifindex so we should always send it
|
* 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;
|
*src = &nexthop->src;
|
||||||
|
|
||||||
if (IS_ZEBRA_DEBUG_KERNEL)
|
if (IS_ZEBRA_DEBUG_KERNEL)
|
||||||
zlog_debug(
|
zlog_debug("%s: (%s): %pFX nexthop via if %u vrf %s(%u)",
|
||||||
"netlink_route_multipath() (%s): %pFX nexthop via if %u vrf %s(%u)",
|
__func__, routedesc, p, nexthop->ifindex,
|
||||||
routedesc, p, nexthop->ifindex,
|
|
||||||
VRF_LOGNAME(vrf), nexthop->vrf_id);
|
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);
|
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)
|
static void _netlink_mpls_debug(int cmd, uint32_t label, const char *routedesc)
|
||||||
{
|
{
|
||||||
if (IS_ZEBRA_DEBUG_KERNEL)
|
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);
|
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
|
* 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 there is no useful nexthop then return. */
|
||||||
if (nexthop_num == 0) {
|
if (nexthop_num == 0) {
|
||||||
if (IS_ZEBRA_DEBUG_KERNEL)
|
if (IS_ZEBRA_DEBUG_KERNEL)
|
||||||
zlog_debug(
|
zlog_debug("%s: No useful nexthop.", __func__);
|
||||||
"netlink_route_multipath(): No useful nexthop.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -2103,7 +2082,9 @@ nexthop_done:
|
|||||||
return -1;
|
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,
|
return netlink_talk_info(netlink_talk_filter, &req.n,
|
||||||
dplane_ctx_get_ns(ctx), 0);
|
dplane_ctx_get_ns(ctx), 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user