[CRIU] [PATCH 2/2] tcp_read_sysctl_limits: hide a useless error, leave a warning

Kir Kolyshkin kir at openvz.org
Wed Oct 14 15:09:57 PDT 2015


When running tests, there are a lot of errors like this:

 (00.000053) Error (sysctl.c:367): Can't open sysctl net/ipv4/tcp_rmem: No such file or directory

As Andrew explained, tests are running in a netns that lacks
this sysctl. Use CTL_FLAGS_OPTIONAL flag to hide the error message.

Since with this flag sysctl_op() will most probably return 0,
add an additional check for vect[0] == 0 to detect that the file
was not read and show an appropriate warning, i.e.
"TCP mem sysctls are not available. Using defaults."

Signed-off-by: Kir Kolyshkin <kir at openvz.org>
---
 kerndat.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kerndat.c b/kerndat.c
index 1bce836..dab56ba 100644
--- a/kerndat.c
+++ b/kerndat.c
@@ -214,7 +214,7 @@ static int tcp_read_sysctl_limits(void)
 	int ret;
 
 	struct sysctl_req req[] = {
-		{ "net/ipv4/tcp_rmem", &vect, CTL_U32A(ARRAY_SIZE(vect)) },
+		{ "net/ipv4/tcp_rmem", &vect, CTL_U32A(ARRAY_SIZE(vect)), CTL_FLAGS_OPTIONAL },
 	};
 
 	/*
@@ -222,7 +222,7 @@ static int tcp_read_sysctl_limits(void)
 	 * availabe for send/read queues on restore.
 	 */
 	ret = sysctl_op(req, ARRAY_SIZE(req), CTL_READ, 0);
-	if (ret) {
+	if (ret || vect[0] == 0) {
 		pr_warn("TCP mem sysctls are not available. Using defaults.\n");
 		goto out;
 	}
-- 
2.4.3



More information about the CRIU mailing list