Skip to content

Commit 7e805fd

Browse files
Waiman-Longgregkh
authored andcommitted
selftest: memcg: skip memcg_sock test if address family not supported
[ Upstream commit 2d028f3 ] The test_memcg_sock test in memcontrol.c sets up an IPv6 socket and send data over it to consume memory and verify that memory.stat.sock and memory.current values are close. On systems where IPv6 isn't enabled or not configured to support SOCK_STREAM, the test_memcg_sock test always fails. When the socket() call fails, there is no way we can test the memory consumption and verify the above claim. I believe it is better to just skip the test in this case instead of reporting a test failure hinting that there may be something wrong with the memcg code. Link: https://lkml.kernel.org/r/20260311200526.885899-1-longman@redhat.com Fixes: 5f8f019 ("selftests: cgroup/memcontrol: add basic test for socket accounting") Signed-off-by: Waiman Long <longman@redhat.com> Acked-by: Michal Koutný <mkoutny@suse.com> Acked-by: Shakeel Butt <shakeel.butt@linux.dev> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Michal Hocko <mhocko@kernel.org> Cc: Michal Koutný <mkoutny@suse.com> Cc: Mike Rapoport <rppt@kernel.org> Cc: Muchun Song <muchun.song@linux.dev> Cc: Roman Gushchin <roman.gushchin@linux.dev> Cc: Shuah Khan <shuah@kernel.org> Cc: Tejun Heo <tj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 05a3fd5 commit 7e805fd

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

tools/testing/selftests/cgroup/test_memcontrol.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,8 +940,11 @@ static int tcp_server(const char *cgroup, void *arg)
940940
saddr.sin6_port = htons(srv_args->port);
941941

942942
sk = socket(AF_INET6, SOCK_STREAM, 0);
943-
if (sk < 0)
943+
if (sk < 0) {
944+
/* Pass back errno to the ctl_fd */
945+
write(ctl_fd, &errno, sizeof(errno));
944946
return ret;
947+
}
945948

946949
if (setsockopt(sk, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0)
947950
goto cleanup;
@@ -1071,6 +1074,12 @@ static int test_memcg_sock(const char *root)
10711074
goto cleanup;
10721075
close(args.ctl[0]);
10731076

1077+
/* Skip if address family not supported by protocol */
1078+
if (err == EAFNOSUPPORT) {
1079+
ret = KSFT_SKIP;
1080+
goto cleanup;
1081+
}
1082+
10741083
if (!err)
10751084
break;
10761085
if (err != EADDRINUSE)

0 commit comments

Comments
 (0)