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

Submitted by Cyrill Gorcunov on Sept. 27, 2018, 10:51 a.m.

Details

Message ID 20180927105137.31366-2-gorcunov@gmail.com
State New
Series "sockets: Placate logger when diag modules are missing"
Headers show

Commit Message

Cyrill Gorcunov Sept. 27, 2018, 10:51 a.m.
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@gmail.com>
---
 criu/libnetlink.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

Patch hide | download patch | download mbox

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;
 }