APPLIED/cmnt: [bionic:linux][PATCH] UBUNTU: SAUCE: selftests: net: replace AF_MAX with INT_MAX in socket.c

Kleber Souza kleber.souza at canonical.com
Fri Sep 27 12:50:17 UTC 2019


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



More information about the kernel-team mailing list