summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-06-29 15:36:47 (GMT)
committerThomas Haller <thaller@redhat.com>2016-07-08 10:02:07 (GMT)
commitc312a2a929bbd273619790a9a601f685071a995a (patch)
tree0fcc6375a89412b7154f4c126e1eb6f8a2ba8e42
parentd7b54b17b6a1be62aa99d34e24d0476b7f5039ba (diff)
downloadlibnl-c312a2a929bbd273619790a9a601f685071a995a.zip
libnl-c312a2a929bbd273619790a9a601f685071a995a.tar.gz
libnl-c312a2a929bbd273619790a9a601f685071a995a.tar.bz2
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 <thaller@redhat.com>
-rw-r--r--lib/route/route_obj.c20
1 files 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;
}