From c312a2a929bbd273619790a9a601f685071a995a Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 29 Jun 2016 17:36:47 +0200 Subject: route/route-obj: fix debug logging in route_update() Logging with a level of "0" means to always enable the logging statement. Also, only construct the message if the logging is actually enabled. Signed-off-by: Thomas Haller --- lib/route/route_obj.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/route/route_obj.c b/lib/route/route_obj.c index 36581b3..f495ade 100644 --- a/lib/route/route_obj.c +++ b/lib/route/route_obj.c @@ -529,8 +529,7 @@ static int route_update(struct nl_object *old_obj, struct nl_object *new_obj, if (flags & OO_UPDATE_FLAGS_IS_DUMP) { struct rtnl_nexthop *old_nh; - char nbuf[256]; - char obuf[256]; + /* Kernel can return duplicates during dumps * if the dump is interrupted and kernel routing * table is going through changes during dumps. @@ -540,11 +539,18 @@ static int route_update(struct nl_object *old_obj, struct nl_object *new_obj, rtnh_list) { if (!rtnl_route_nh_compare(old_nh, new_nh, rtnl_route_nh_id_attrs(), 0)) { - nl_object_dump_buf(new_obj, nbuf, - sizeof(nbuf)); - nl_object_dump_buf(old_obj, obuf, - sizeof(obuf)); - NL_DBG(0, "%s: ignoring duplicate nexthop: ce_msgflags = (%x, %x), rt_flags = (%x, %x), rtnh_flags = (%x, %x), objs = (%s, %s)\n", __FUNCTION__, old_obj->ce_msgflags, new_obj->ce_msgflags, old_route->rt_flags, new_route->rt_flags, old_nh->rtnh_flags, new_nh->rtnh_flags, obuf, nbuf); +#ifdef NL_DEBUG + if (2 <= nl_debug) { + char nbuf[256]; + char obuf[256]; + + nl_object_dump_buf(new_obj, nbuf, + sizeof(nbuf)); + nl_object_dump_buf(old_obj, obuf, + sizeof(obuf)); + NL_DBG(2, "%s: ignoring duplicate nexthop: ce_msgflags = (%x, %x), rt_flags = (%x, %x), rtnh_flags = (%x, %x), objs = (%s, %s)\n", __FUNCTION__, old_obj->ce_msgflags, new_obj->ce_msgflags, old_route->rt_flags, new_route->rt_flags, old_nh->rtnh_flags, new_nh->rtnh_flags, obuf, nbuf); + } +#endif rtnl_route_nh_free(cloned_nh); return NLE_SUCCESS; } -- cgit v0.12