[bionic:linux] UBUNTU: SAUCE: selftests: net: replace AF_MAX with INT_MAX in socket.c
diff mbox series

Message ID 20190916132145.26170-1-marcelo.cerri@canonical.com
State New
Headers show
Series
  • [bionic:linux] UBUNTU: SAUCE: selftests: net: replace AF_MAX with INT_MAX in socket.c
Related show

Commit Message

Marcelo Henrique Cerri Sept. 16, 2019, 1:21 p.m. UTC
BugLink: https://bugs.launchpad.net/bugs/1842023

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>
---

Usually this issue will only occur with backport kernels (such as hwe)
since the glibc headers need to be older than the kernel for this test
to fail. Apply the fix to the generic kernel though so we can ensure
that all derivatives actually include it.

---
 tools/testing/selftests/net/socket.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Thadeu Lima de Souza Cascardo Sept. 16, 2019, 1:50 p.m. UTC | #1
On Mon, Sep 16, 2019 at 10:21:45AM -0300, Marcelo Henrique Cerri wrote:
> BugLink: https://bugs.launchpad.net/bugs/1842023
> 
> 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>

Why not send this upstream?

> ---
> 
> Usually this issue will only occur with backport kernels (such as hwe)
> since the glibc headers need to be older than the kernel for this test
> to fail. Apply the fix to the generic kernel though so we can ensure
> that all derivatives actually include it.
> 
> ---
>  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
> 
> 
> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team
Marcelo Henrique Cerri Sept. 16, 2019, 2:17 p.m. UTC | #2
I can try. But I would like to include that to bionic in the meantime
anyway since we are already carrying it in Disco.

On Mon, Sep 16, 2019 at 10:50:55AM -0300, Thadeu Lima de Souza Cascardo wrote:
> On Mon, Sep 16, 2019 at 10:21:45AM -0300, Marcelo Henrique Cerri wrote:
> > BugLink: https://bugs.launchpad.net/bugs/1842023
> > 
> > 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>
> 
> Why not send this upstream?
> 
> > ---
> > 
> > Usually this issue will only occur with backport kernels (such as hwe)
> > since the glibc headers need to be older than the kernel for this test
> > to fail. Apply the fix to the generic kernel though so we can ensure
> > that all derivatives actually include it.
> > 
> > ---
> >  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
> > 
> > 
> > -- 
> > kernel-team mailing list
> > kernel-team@lists.ubuntu.com
> > https://lists.ubuntu.com/mailman/listinfo/kernel-team
Thadeu Lima de Souza Cascardo Sept. 16, 2019, 2:20 p.m. UTC | #3
I would still like to see this submitted upstream, so we stop carrying this
delta forever.

Acked-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Marcelo Henrique Cerri Sept. 16, 2019, 3:05 p.m. UTC | #4
https://lkml.org/lkml/2019/9/16/470

On Mon, Sep 16, 2019 at 11:17:35AM -0300, Marcelo Henrique Cerri wrote:
> I can try. But I would like to include that to bionic in the meantime
> anyway since we are already carrying it in Disco.
> 
> On Mon, Sep 16, 2019 at 10:50:55AM -0300, Thadeu Lima de Souza Cascardo wrote:
> > On Mon, Sep 16, 2019 at 10:21:45AM -0300, Marcelo Henrique Cerri wrote:
> > > BugLink: https://bugs.launchpad.net/bugs/1842023
> > > 
> > > 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>
> > 
> > Why not send this upstream?
> > 
> > > ---
> > > 
> > > Usually this issue will only occur with backport kernels (such as hwe)
> > > since the glibc headers need to be older than the kernel for this test
> > > to fail. Apply the fix to the generic kernel though so we can ensure
> > > that all derivatives actually include it.
> > > 
> > > ---
> > >  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
> > > 
> > > 
> > > -- 
> > > kernel-team mailing list
> > > kernel-team@lists.ubuntu.com
> > > https://lists.ubuntu.com/mailman/listinfo/kernel-team
> 
> -- 
> Regards,
> Marcelo
>
Stefan Bader Sept. 25, 2019, 8:55 a.m. UTC | #5
On 16.09.19 15:21, Marcelo Henrique Cerri wrote:
> BugLink: https://bugs.launchpad.net/bugs/1842023
> 
> 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>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
> ---
> 
> Usually this issue will only occur with backport kernels (such as hwe)
> since the glibc headers need to be older than the kernel for this test
> to fail. Apply the fix to the generic kernel though so we can ensure
> that all derivatives actually include it.

Is this relevant for Eoan/devel? If not you should mark the main tasks (not the
nomination tasks) invalid.

-Stefan
> 
> ---
>  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  },
>
Kleber Souza Sept. 27, 2019, 12:50 p.m. UTC | #6
On 16.09.19 15:21, Marcelo Henrique Cerri wrote:
> BugLink: https://bugs.launchpad.net/bugs/1842023
> 
> 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>
> ---
> 
> Usually this issue will only occur with backport kernels (such as hwe)
> since the glibc headers need to be older than the kernel for this test
> to fail. Apply the fix to the generic kernel though so we can ensure
> that all derivatives actually include it.
> 
> ---
>  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  },
> 

Applied to bionic/master-next branch.

Upstream folks don't seem to like this approach. It would be nice to keep an
eye on it and backport the fix to our kernels once something is accepted
upstream.

Thanks,
Kleber

Patch
diff mbox series

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  },