[v2,2/3] lib: TCONF on "not supported" errnos in SAFE_SOCKET()

Message ID 20180313150111.16501-2-pvorel@suse.cz
State Accepted, archived
Delegated to: Petr Vorel
Headers show
Series
  • Untitled series #33483
Related show

Commit Message

Petr Vorel March 13, 2018, 3:01 p.m.
*NOSUPPORT errnos likely mean there is configuration issue rather than
test failure.

e.g. missing dccp module in netstress.c which was so far set as TBROK:
safe_net.c:117: BROK: netstress.c:654: socket(10, 6, 33) failed: ESOCKTNOSUPPORT

Signed-off-by: Petr Vorel <pvorel@suse.cz>
Acked-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
 lib/safe_net.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

Comments

Sun Lianwen March 14, 2018, 12:42 a.m. | #1
Hi
    I am sorry I forget to report my debug info on RHEL7.5Beta about 
this question.
I write a testcase on RHEL7.5Beta. the test case is below.

#include <netinet/in.h>
#include <sys/socket.h>
#include <stdio.h>

int main (int argc, const char * argv[])
{
     //create a dccp socket
     int server_socket = socket(AF_INET6, SOCK_DCCP, IPPROTO_DCCP);
     if (server_socket == -1) {
         perror("socket error");
         return 1;
     }
    printf("test is ok \n");
}

And the  RHEL7.5Beta will report "Socket type not supported"  when run 
my testcase  on RHEL7.5Beta .
and the RHEL7.4GA will report "Permission denied " when run my testcase 
on RHEL7.4GA
it's ok when run my testcase on RHEL7.3GA.

That's all.

Thanks
Lianwen Sun

On 03/13/2018 11:01 PM, Petr Vorel wrote:
> *NOSUPPORT errnos likely mean there is configuration issue rather than
> test failure.
>
> e.g. missing dccp module in netstress.c which was so far set as TBROK:
> safe_net.c:117: BROK: netstress.c:654: socket(10, 6, 33) failed: ESOCKTNOSUPPORT
>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> Acked-by: Alexey Kodanev <alexey.kodanev@oracle.com>
> ---
>   lib/safe_net.c | 16 ++++++++++++++--
>   1 file changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/lib/safe_net.c b/lib/safe_net.c
> index 9ea9d2b42..9ed52dcd1 100644
> --- a/lib/safe_net.c
> +++ b/lib/safe_net.c
> @@ -107,12 +107,24 @@ int tst_getsockport(const char *file, const int lineno, int sockfd)
>   int safe_socket(const char *file, const int lineno, void (cleanup_fn)(void),
>   		int domain, int type, int protocol)
>   {
> -	int rval;
> +	int rval, ttype;
>   
>   	rval = socket(domain, type, protocol);
>   
>   	if (rval < 0) {
> -		tst_brkm(TBROK | TERRNO, cleanup_fn,
> +		switch (errno) {
> +		case EPROTONOSUPPORT:
> +		case ESOCKTNOSUPPORT:
> +		case EOPNOTSUPP:
> +		case EPFNOSUPPORT:
> +		case EAFNOSUPPORT:
> +			ttype = TCONF;
> +			break;
> +		default:
> +			ttype = TBROK;
> +		}
> +
> +		tst_brkm(ttype | TERRNO, cleanup_fn,
>   			 "%s:%d: socket(%d, %d, %d) failed", file, lineno,
>   			 domain, type, protocol);
>   	}
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#C0C0C0">
    <p>Hi<br>
         I am sorry I forget to report my debug info on RHEL7.5Beta
      about this question.<br>
      I write a testcase on RHEL7.5Beta. the test case is below.<br>
      <br>
      #include &lt;netinet/in.h&gt;<br>
      #include &lt;sys/socket.h&gt;<br>
      #include &lt;stdio.h&gt;<br>
      <br>
      int main (int argc, const char * argv[])<br>
      {<br>
          //create a dccp socket <br>
          int server_socket = socket(AF_INET6, SOCK_DCCP, IPPROTO_DCCP);<br>
          if (server_socket == -1) {<br>
              perror("socket error");<br>
              return 1;<br>
          }<br>
         printf("test is ok \n");<br>
      }<br>
      <br>
      And the  RHEL7.5Beta will report "Socket type not supported"  when
      run my testcase  on RHEL7.5Beta .<br>
      and the RHEL7.4GA will report "Permission denied " when run my
      testcase on RHEL7.4GA<br>
      it's ok when run my testcase on RHEL7.3GA.<br>
      <br>
      That's all.<br>
      <br>
      Thanks<br>
      Lianwen Sun<br>
      <br>
    </p>
    <div class="moz-cite-prefix">On 03/13/2018 11:01 PM, Petr Vorel
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:20180313150111.16501-2-pvorel@suse.cz">
      <pre wrap="">*NOSUPPORT errnos likely mean there is configuration issue rather than
test failure.

e.g. missing dccp module in netstress.c which was so far set as TBROK:
safe_net.c:117: BROK: netstress.c:654: socket(10, 6, 33) failed: ESOCKTNOSUPPORT

Signed-off-by: Petr Vorel <a class="moz-txt-link-rfc2396E" href="mailto:pvorel@suse.cz">&lt;pvorel@suse.cz&gt;</a>
Acked-by: Alexey Kodanev <a class="moz-txt-link-rfc2396E" href="mailto:alexey.kodanev@oracle.com">&lt;alexey.kodanev@oracle.com&gt;</a>
---
 lib/safe_net.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/lib/safe_net.c b/lib/safe_net.c
index 9ea9d2b42..9ed52dcd1 100644
--- a/lib/safe_net.c
+++ b/lib/safe_net.c
@@ -107,12 +107,24 @@ int tst_getsockport(const char *file, const int lineno, int sockfd)
 int safe_socket(const char *file, const int lineno, void (cleanup_fn)(void),
 		int domain, int type, int protocol)
 {
-	int rval;
+	int rval, ttype;
 
 	rval = socket(domain, type, protocol);
 
 	if (rval &lt; 0) {
-		tst_brkm(TBROK | TERRNO, cleanup_fn,
+		switch (errno) {
+		case EPROTONOSUPPORT:
+		case ESOCKTNOSUPPORT:
+		case EOPNOTSUPP:
+		case EPFNOSUPPORT:
+		case EAFNOSUPPORT:
+			ttype = TCONF;
+			break;
+		default:
+			ttype = TBROK;
+		}
+
+		tst_brkm(ttype | TERRNO, cleanup_fn,
 			 "%s:%d: socket(%d, %d, %d) failed", file, lineno,
 			 domain, type, protocol);
 	}
</pre>
    </blockquote>
    <br>
  </body>
</html>
Petr Vorel March 14, 2018, 12:09 p.m. | #2
Hi Lianwen,

> Hi
>    I am sorry I forget to report my debug info on RHEL7.5Beta about this
> question.
> I write a testcase on RHEL7.5Beta. the test case is below.

> #include <netinet/in.h>
> #include <sys/socket.h>
> #include <stdio.h>

> int main (int argc, const char * argv[])
> {
>     //create a dccp socket
>     int server_socket = socket(AF_INET6, SOCK_DCCP, IPPROTO_DCCP);
>     if (server_socket == -1) {
>         perror("socket error");
>         return 1;
>     }
>    printf("test is ok \n");
> }

> And the  RHEL7.5Beta will report "Socket type not supported"  when run my
> testcase  on RHEL7.5Beta .
This is ESOCKTNOSUPPORT.

> and the RHEL7.4GA will report "Permission denied " when run my testcase on
> RHEL7.4GA
Not sure why it does not report ESOCKTNOSUPPORT, but I've seen some of these.

> it's ok when run my testcase on RHEL7.3GA.

> That's all.

> Thanks
> Lianwen Sun

Thanks for testing!


Kind regards,
Petr

Patch

diff --git a/lib/safe_net.c b/lib/safe_net.c
index 9ea9d2b42..9ed52dcd1 100644
--- a/lib/safe_net.c
+++ b/lib/safe_net.c
@@ -107,12 +107,24 @@  int tst_getsockport(const char *file, const int lineno, int sockfd)
 int safe_socket(const char *file, const int lineno, void (cleanup_fn)(void),
 		int domain, int type, int protocol)
 {
-	int rval;
+	int rval, ttype;
 
 	rval = socket(domain, type, protocol);
 
 	if (rval < 0) {
-		tst_brkm(TBROK | TERRNO, cleanup_fn,
+		switch (errno) {
+		case EPROTONOSUPPORT:
+		case ESOCKTNOSUPPORT:
+		case EOPNOTSUPP:
+		case EPFNOSUPPORT:
+		case EAFNOSUPPORT:
+			ttype = TCONF;
+			break;
+		default:
+			ttype = TBROK;
+		}
+
+		tst_brkm(ttype | TERRNO, cleanup_fn,
 			 "%s:%d: socket(%d, %d, %d) failed", file, lineno,
 			 domain, type, protocol);
 	}