[CRIU] [PATCH 1/2] net: libnetlink -- Call error handler instead of unconditional error message

Cyrill Gorcunov gorcunov at gmail.com
Thu Sep 27 13:51:36 MSK 2018


To be able to zap error messages when needed. Without error
handler we will continue printing error. This will placate
diag modules probing since they are not mandatory features.

Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
---
 criu/libnetlink.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/criu/libnetlink.c b/criu/libnetlink.c
index 986a05bca9aa..2ce4a38262d4 100644
--- a/criu/libnetlink.c
+++ b/criu/libnetlink.c
@@ -21,13 +21,8 @@ static int nlmsg_receive(char *buf, int len,
 			continue;
 		if (hdr->nlmsg_type == NLMSG_DONE) {
 			int *len = (int *)NLMSG_DATA(hdr);
-
-			if (*len < 0) {
-				pr_err("ERROR %d reported by netlink (%s)\n",
-					*len, strerror(-*len));
-				return *len;
-			}
-
+			if (*len < 0)
+				return err_cb(*len, arg);
 			return 0;
 		}
 		if (hdr->nlmsg_type == NLMSG_ERROR) {
@@ -52,7 +47,8 @@ static int nlmsg_receive(char *buf, int len,
 
 static int rtnl_return_err(int err, void *arg)
 {
-	pr_warn("ERROR %d reported by netlink\n", err);
+	errno = -err;
+	pr_perror("ERROR %d reported by netlink", err);
 	return err;
 }
 
-- 
2.17.1



More information about the CRIU mailing list