[LTP] [RFC PATCH 1/2] lib: TCONF on ESOCKTNOSUPPORT and EPROTONOSUPPORT in SAFE_SOCKET()

Petr Vorel pvorel@suse.cz
Tue Feb 27 19:00:43 CET 2018


As this is clearly configuration issue.

Example of use if missing dccp module in netstress.c:
safe_net.c:117: BROK: netstress.c:654: socket(10, 6, 33) failed: ESOCKTNOSUPPORT

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 lib/safe_net.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/lib/safe_net.c b/lib/safe_net.c
index 9ea9d2b42..f8f4f44ca 100644
--- a/lib/safe_net.c
+++ b/lib/safe_net.c
@@ -111,11 +111,10 @@ int safe_socket(const char *file, const int lineno, void (cleanup_fn)(void),
 
 	rval = socket(domain, type, protocol);
 
-	if (rval < 0) {
-		tst_brkm(TBROK | TERRNO, cleanup_fn,
-			 "%s:%d: socket(%d, %d, %d) failed", file, lineno,
-			 domain, type, protocol);
-	}
+	if (rval < 0)
+		tst_brkm((errno == EPROTONOSUPPORT || errno == ESOCKTNOSUPPORT ? TCONF : TBROK)
+				 | TERRNO, cleanup_fn, "%s:%d: socket(%d, %d, %d) failed",
+				 file, lineno, domain, type, protocol);
 
 	return rval;
 }
-- 
2.16.2



More information about the ltp mailing list