[CRIU] [PATCH 4/5] sockets: Be more verbose in collect_err

Cyrill Gorcunov gorcunov at gmail.com
Thu Dec 20 11:08:40 MSK 2018


So we would always know what is happening even
if module is nor compiled or supported.

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

diff --git a/criu/sockets.c b/criu/sockets.c
index 48c71940d910..6601774a9513 100644
--- a/criu/sockets.c
+++ b/criu/sockets.c
@@ -731,13 +731,20 @@ static int collect_err(int err, struct ns_id *ns, void *arg)
 	char family[32], proto[32];
 	char msg[256];
 
+	snprintf(msg, sizeof(msg),
+		 "Sockects collect procedure family %s proto %s",
+		 socket_family_name(gr->family, family, sizeof(family)),
+		 socket_proto_name(gr->protocol, proto, sizeof(proto)));
+
 	/*
 	 * If module is not compiled or unloaded,
 	 * we should simply pass error up to a caller
 	 * which then warn a user.
 	 */
-	if (err == -ENOENT)
+	if (err == -ENOENT) {
+		pr_debug("%s: %d\n", msg, err);
 		return -ENOENT;
+	}
 
 	/*
 	 * Diag modules such as unix, packet, netlink
@@ -746,23 +753,20 @@ static int collect_err(int err, struct ns_id *ns, void *arg)
 	if (err == -EINVAL) {
 		if (gr->family == AF_UNIX ||
 		    gr->family == AF_PACKET ||
-		    gr->family == AF_NETLINK)
+		    gr->family == AF_NETLINK) {
+			pr_debug("%s: %d\n", msg, err);
 			return -EINVAL;
+		}
 	}
 
 	/*
 	 * Rest is more serious, just print enough information.
 	 * In case if everything is OK -- point as well.
 	 */
-	snprintf(msg, sizeof(msg),
-		 "Sockects collect procedure family %s proto %s\n",
-		 socket_family_name(gr->family, family, sizeof(family)),
-		 socket_proto_name(gr->protocol, proto, sizeof(proto)));
-
 	if (!err)
 		pr_info("%s: OK\n", msg);
 	else
-		pr_err("%s: %s\n", msg, strerror(-err));
+		pr_err("%s: %d: %s\n", msg, err, strerror(-err));
 
 	return err;
 }
-- 
2.17.2



More information about the CRIU mailing list