linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftests/net: replace AF_MAX with INT_MAX in socket.c
@ 2019-09-16 15:03 Marcelo Henrique Cerri
  2019-09-16 16:09 ` shuah
  2019-09-23  8:51 ` David Miller
  0 siblings, 2 replies; 5+ messages in thread
From: Marcelo Henrique Cerri @ 2019-09-16 15:03 UTC (permalink / raw)
  To: David S. Miller, Shuah Khan; +Cc: netdev, linux-kselftest, linux-kernel

Use INT_MAX instead of AF_MAX, since libc might have a smaller value
of AF_MAX than the kernel, what causes the test to fail.

Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>
---
 tools/testing/selftests/net/socket.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/net/socket.c b/tools/testing/selftests/net/socket.c
index afca1ead677f..10e75ba90124 100644
--- a/tools/testing/selftests/net/socket.c
+++ b/tools/testing/selftests/net/socket.c
@@ -6,6 +6,7 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
+#include <limits.h>
 
 struct socket_testcase {
 	int	domain;
@@ -24,7 +25,10 @@ struct socket_testcase {
 };
 
 static struct socket_testcase tests[] = {
-	{ AF_MAX,  0,           0,           -EAFNOSUPPORT,    0 },
+	/* libc might have a smaller value of AF_MAX than the kernel
+	 * actually supports, so use INT_MAX instead.
+	 */
+	{ INT_MAX, 0,           0,           -EAFNOSUPPORT,    0  },
 	{ AF_INET, SOCK_STREAM, IPPROTO_TCP, 0,                1  },
 	{ AF_INET, SOCK_DGRAM,  IPPROTO_TCP, -EPROTONOSUPPORT, 1  },
 	{ AF_INET, SOCK_DGRAM,  IPPROTO_UDP, 0,                1  },
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] selftests/net: replace AF_MAX with INT_MAX in socket.c
  2019-09-16 15:03 [PATCH] selftests/net: replace AF_MAX with INT_MAX in socket.c Marcelo Henrique Cerri
@ 2019-09-16 16:09 ` shuah
  2019-09-17  7:12   ` Marcelo Henrique Cerri
  2019-09-23  8:51 ` David Miller
  1 sibling, 1 reply; 5+ messages in thread
From: shuah @ 2019-09-16 16:09 UTC (permalink / raw)
  To: Marcelo Henrique Cerri, David S. Miller
  Cc: netdev, linux-kselftest, linux-kernel, shuah

On 9/16/19 9:03 AM, Marcelo Henrique Cerri wrote:
> Use INT_MAX instead of AF_MAX, since libc might have a smaller value
> of AF_MAX than the kernel, what causes the test to fail.
> 
> Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>
> ---
>   tools/testing/selftests/net/socket.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/net/socket.c b/tools/testing/selftests/net/socket.c
> index afca1ead677f..10e75ba90124 100644
> --- a/tools/testing/selftests/net/socket.c
> +++ b/tools/testing/selftests/net/socket.c
> @@ -6,6 +6,7 @@
>   #include <sys/types.h>
>   #include <sys/socket.h>
>   #include <netinet/in.h>
> +#include <limits.h>
>   
>   struct socket_testcase {
>   	int	domain;
> @@ -24,7 +25,10 @@ struct socket_testcase {
>   };
>   
>   static struct socket_testcase tests[] = {
> -	{ AF_MAX,  0,           0,           -EAFNOSUPPORT,    0 },
> +	/* libc might have a smaller value of AF_MAX than the kernel
> +	 * actually supports, so use INT_MAX instead.
> +	 */
> +	{ INT_MAX, 0,           0,           -EAFNOSUPPORT,    0  },
>   	{ AF_INET, SOCK_STREAM, IPPROTO_TCP, 0,                1  },
>   	{ AF_INET, SOCK_DGRAM,  IPPROTO_TCP, -EPROTONOSUPPORT, 1  },
>   	{ AF_INET, SOCK_DGRAM,  IPPROTO_UDP, 0,                1  },
> 

What failure are you seeing? It sounds arbitrary to use INT_MAX
instead of AF_MAX. I think it is important to understand the
failure first.

Please note that AF_MAX is widely used in the kernel.

thanks,
-- Shuah

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] selftests/net: replace AF_MAX with INT_MAX in socket.c
  2019-09-16 16:09 ` shuah
@ 2019-09-17  7:12   ` Marcelo Henrique Cerri
  2019-09-17 14:09     ` shuah
  0 siblings, 1 reply; 5+ messages in thread
From: Marcelo Henrique Cerri @ 2019-09-17  7:12 UTC (permalink / raw)
  To: shuah; +Cc: David S. Miller, netdev, linux-kselftest, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2218 bytes --]

So the problem arises because the headers we have in userspace might
be older and not match what we have in the kernel. In that case, the
actual value of AF_MAX in the userspace headers might be a valid
protocol family in the new kernel.

That happens relatively often for us because we support different
kernel versions at the same time in a given Ubuntu series.

An alternative is to use the headers we have in the kernel tree, but I
believe that might cause other issues.

On Mon, Sep 16, 2019 at 10:09:13AM -0600, shuah wrote:
> On 9/16/19 9:03 AM, Marcelo Henrique Cerri wrote:
> > Use INT_MAX instead of AF_MAX, since libc might have a smaller value
> > of AF_MAX than the kernel, what causes the test to fail.
> > 
> > Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>
> > ---
> >   tools/testing/selftests/net/socket.c | 6 +++++-
> >   1 file changed, 5 insertions(+), 1 deletion(-)
> > 
> > diff --git a/tools/testing/selftests/net/socket.c b/tools/testing/selftests/net/socket.c
> > index afca1ead677f..10e75ba90124 100644
> > --- a/tools/testing/selftests/net/socket.c
> > +++ b/tools/testing/selftests/net/socket.c
> > @@ -6,6 +6,7 @@
> >   #include <sys/types.h>
> >   #include <sys/socket.h>
> >   #include <netinet/in.h>
> > +#include <limits.h>
> >   struct socket_testcase {
> >   	int	domain;
> > @@ -24,7 +25,10 @@ struct socket_testcase {
> >   };
> >   static struct socket_testcase tests[] = {
> > -	{ AF_MAX,  0,           0,           -EAFNOSUPPORT,    0 },
> > +	/* libc might have a smaller value of AF_MAX than the kernel
> > +	 * actually supports, so use INT_MAX instead.
> > +	 */
> > +	{ INT_MAX, 0,           0,           -EAFNOSUPPORT,    0  },
> >   	{ AF_INET, SOCK_STREAM, IPPROTO_TCP, 0,                1  },
> >   	{ AF_INET, SOCK_DGRAM,  IPPROTO_TCP, -EPROTONOSUPPORT, 1  },
> >   	{ AF_INET, SOCK_DGRAM,  IPPROTO_UDP, 0,                1  },
> > 
> 
> What failure are you seeing? It sounds arbitrary to use INT_MAX
> instead of AF_MAX. I think it is important to understand the
> failure first.
> 
> Please note that AF_MAX is widely used in the kernel.
> 
> thanks,
> -- Shuah

-- 
Regards,
Marcelo


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] selftests/net: replace AF_MAX with INT_MAX in socket.c
  2019-09-17  7:12   ` Marcelo Henrique Cerri
@ 2019-09-17 14:09     ` shuah
  0 siblings, 0 replies; 5+ messages in thread
From: shuah @ 2019-09-17 14:09 UTC (permalink / raw)
  To: Marcelo Henrique Cerri
  Cc: David S. Miller, netdev, linux-kselftest, linux-kernel, shuah

On 9/17/19 1:12 AM, Marcelo Henrique Cerri wrote:
> So the problem arises because the headers we have in userspace might
> be older and not match what we have in the kernel. In that case, the
> actual value of AF_MAX in the userspace headers might be a valid
> protocol family in the new kernel.
> 
> That happens relatively often for us because we support different
> kernel versions at the same time in a given Ubuntu series.
> 

Right. This is an evolving use-case for kselftest to make it easier to
run on distribution kernels.

> An alternative is to use the headers we have in the kernel tree, but I
> believe that might cause other issues.
> 

Kselftest is tied to the kernel in such as way that you do need to use
the kernel headers to compile.

Do you run newer tests on older kernels? Where do you build them? What
I would like to see is fixing the test to run on older kernels and not
changing the tests to suit older kernel needs.

This definitely isn't a change that is good to make. We have to come
with a better way to solve this. Could you please send me the errors
you are seeing so I can help you find a better solution.

thanks,
-- Shuah

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] selftests/net: replace AF_MAX with INT_MAX in socket.c
  2019-09-16 15:03 [PATCH] selftests/net: replace AF_MAX with INT_MAX in socket.c Marcelo Henrique Cerri
  2019-09-16 16:09 ` shuah
@ 2019-09-23  8:51 ` David Miller
  1 sibling, 0 replies; 5+ messages in thread
From: David Miller @ 2019-09-23  8:51 UTC (permalink / raw)
  To: marcelo.cerri; +Cc: shuah, netdev, linux-kselftest, linux-kernel

From: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>
Date: Mon, 16 Sep 2019 12:03:37 -0300

> Use INT_MAX instead of AF_MAX, since libc might have a smaller value
> of AF_MAX than the kernel, what causes the test to fail.
> 
> Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>

Definitely need to fix this differently.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-09-23  8:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-16 15:03 [PATCH] selftests/net: replace AF_MAX with INT_MAX in socket.c Marcelo Henrique Cerri
2019-09-16 16:09 ` shuah
2019-09-17  7:12   ` Marcelo Henrique Cerri
2019-09-17 14:09     ` shuah
2019-09-23  8:51 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).