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

Submitted by Cyrill Gorcunov on Oct. 9, 2018, 1:49 p.m.

Details

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

Commit Message

Cyrill Gorcunov Oct. 9, 2018, 1:49 p.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 | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/libnetlink.c b/criu/libnetlink.c
index c713d907ef4d..2ce4a38262d4 100644
--- a/criu/libnetlink.c
+++ b/criu/libnetlink.c
@@ -21,10 +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)
-				return *len;
-
+				return err_cb(*len, arg);
 			return 0;
 		}
 		if (hdr->nlmsg_type == NLMSG_ERROR) {
@@ -49,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;
 }