From nobody Fri Sep 20 22:14:59 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 213097F8; Mon, 8 Apr 2024 01:36:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712540210; cv=none; b=dKg/bwNo7OemazU/cHMAYG3uQDYbp5H8GxYx1H5Z6VkEHRKl2Wdo7aV6zZnBDEjmFl72ke3fIQCXF/e/8oNMU78VKs1ThQ06JZYpcO3xwpBg30nW+tLTTRpDRF2E+76ZvoTOqoi0G9JzcvCoonPySDHCga5DTr/q1oq+39D5/Lc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712540210; c=relaxed/simple; bh=knQEsTcpSgk/3Cc+TDk8z2dvFHCQMXuY0MUvtDfCQFM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XYnLlEov5k5dm/2Omx3QnbAQ0Kt7K3E/hGCFb83DH4buwvy7pOvojItpQZ5D0JSZy6eKX2IMCbuPOFcTTKmMkV+BMAF6w4g1QP/bHCXzJm+Kd62Iprp7DMoum7dFiHmNBdDG4ZthPXEmugFfIDZ6LQHCw08tGrovS0uasBQtko0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AjfeU0Z7; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AjfeU0Z7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1A760C433B1; Mon, 8 Apr 2024 01:36:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712540209; bh=knQEsTcpSgk/3Cc+TDk8z2dvFHCQMXuY0MUvtDfCQFM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AjfeU0Z7VuvNB8H/6RTPXObLTeQjbapggW1bsdLECbot2KTu6OYX1pcTj0yF+hOFS 30ohM5EDP2xf5csHemUyNGuQ53j+D9Aq+FjOZSiKxc+veC8k7QppW+fMLh4qWq/PsD dD0QTv4FxGdqTxzep5jRdmtce8UDjwtoPuI7TCigSmKqnjmqI7+YrsZATfZSXKu4XO JS8rWKeYiTLSpOxe/vREakdmYBLe5Hs5we7Dd+y1g53ttnYZOY3fRNesiph59iv9ee n/UC0UoFeGcmHuJrqXJ8qei7zw8cqffe2iT21peVSmhG1bn629nZtuAzqsQmk7+mCt /GhvxWGuFwnJA== From: Geliang Tang To: Andrii Nakryiko , Eduard Zingerman , Mykola Lysenko , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan , Jakub Sitnicki Cc: Geliang Tang , bpf@vger.kernel.org, mptcp@lists.linux.dev Subject: [PATCH bpf-next v3 1/2] selftests/bpf: Add F_SETFL for fcntl in test_sockmap Date: Mon, 8 Apr 2024 09:36:29 +0800 Message-Id: <2f9f84be1366ca68b1123dd2f3fd06034e1bd3a4.1712539403.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang Incorrect arguments are passed to fcntl() in test_sockmap.c when invoking it to set file status flags. If O_NONBLOCK is used as 2nd argument and passed into fcntl, -EINVAL will be returned (See do_fcntl() in fs/fcntl.c). The correct approach is to use F_SETFL as 2nd argument, and O_NONBLOCK as 3rd one. In nonblock mode, if EWOULDBLOCK is received, continue receiving, otherwise some subtests of test_sockmap will fail. Fixes: 16962b2404ac ("bpf: sockmap, add selftests") Signed-off-by: Geliang Tang Acked-by: Yonghong Song --- tools/testing/selftests/bpf/test_sockmap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/test_sockmap.c b/tools/testing/sel= ftests/bpf/test_sockmap.c index 024a0faafb3b..4f32a5eb3864 100644 --- a/tools/testing/selftests/bpf/test_sockmap.c +++ b/tools/testing/selftests/bpf/test_sockmap.c @@ -603,7 +603,7 @@ static int msg_loop(int fd, int iov_count, int iov_leng= th, int cnt, struct timeval timeout; fd_set w; =20 - fcntl(fd, fd_flags); + fcntl(fd, F_SETFL, fd_flags); /* Account for pop bytes noting each iteration of apply will * call msg_pop_data helper so we need to account for this * by calculating the number of apply iterations. Note user @@ -678,6 +678,9 @@ static int msg_loop(int fd, int iov_count, int iov_leng= th, int cnt, perror("recv failed()"); goto out_errno; } + fd_flags =3D fcntl(fd, F_GETFL); + if (fd_flags & O_NONBLOCK) + continue; } =20 s->bytes_recvd +=3D recv; --=20 2.40.1 From nobody Fri Sep 20 22:14:59 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB03B15A8; Mon, 8 Apr 2024 01:36:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712540217; cv=none; b=MkkposOXG/pcyIoL0DFBHzmvO11fnttt26ITtWSl2/yaJvqm1c3j7yF9u0qUHOTc8DOLqJPigCcc9733YaiaYi/2S0juzbM8f4brOUcHLxR75vf4EaHPAK77vG6Zs3P1rwVhJP0alose7BLA5yepASvsItkBNxbBCoTLyBscq0g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712540217; c=relaxed/simple; bh=RVZ4fWIaP6IkTFxSplanoo7QUKrtDeQ9Xtuch5dmv78=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SVdru5L70BO8+7IOw6WlfALMm0bnC79y+GdYzDI595nqY9rVQmADrC4d1ZURdWhXfi2rqPMa5H9j5GL04zDtla27lLGILfVXmRDwOGhcJ7KCR2WYR8ReiPM/48f9gJ43KD8Cv7Z6na70/SAGLZrhaAuchKqfmIY6QqX/mtaAWxE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=R4lLhY0u; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="R4lLhY0u" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B379C433C7; Mon, 8 Apr 2024 01:36:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712540216; bh=RVZ4fWIaP6IkTFxSplanoo7QUKrtDeQ9Xtuch5dmv78=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R4lLhY0umj7k0Umxz5i4vPnUyLYD/Y3k7PFrB80+2vYSnBkgc+ARayCO8eA9W85kD 3MrZkUQkJ1OvSrYczAqFmpndz4kwVlzvscQOpsvdp2mcY9xRuxhX9i1YzmT2Fw9eAi t4LF4meLOONUSF2WehB8dGa4G8Gu0hoK5byA0fPfCR8fMQiCnB4j43heVAuJxiTBU/ cGwdjQJnMaFKEsxWKBYJB7VCsXbxPYgTT1JFbWnCag39tCRy/PNBv4lzR2vPvJgm95 6jbmR3CDD7zXqKPSyCU5neBK+JJHmTm2nszKMoS7qGmHmMXpkC8ZiiEaXeRDx1Yc9G QJHvH5RvxxG3g== From: Geliang Tang To: Andrii Nakryiko , Eduard Zingerman , Mykola Lysenko , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan , Jakub Sitnicki Cc: Geliang Tang , bpf@vger.kernel.org, mptcp@lists.linux.dev Subject: [PATCH bpf-next v3 2/2] selftests/bpf: Fix umount cgroup2 error in test_sockmap Date: Mon, 8 Apr 2024 09:36:30 +0800 Message-Id: <5dcde0bcff8d37a5ffe61dbd51848385ddaf2951.1712539403.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang This patch fixes the following "umount cgroup2" error in test_sockmap.c: (cgroup_helpers.c:353: errno: Device or resource busy) umount cgroup2 Cgroup fd cg_fd should be closed before cleanup_cgroup_environment(). Fixes: 13a5f3ffd202 ("bpf: Selftests, sockmap test prog run without setting= cgroup") Signed-off-by: Geliang Tang Acked-by: Yonghong Song --- tools/testing/selftests/bpf/test_sockmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/test_sockmap.c b/tools/testing/sel= ftests/bpf/test_sockmap.c index 4f32a5eb3864..520b7d0dadda 100644 --- a/tools/testing/selftests/bpf/test_sockmap.c +++ b/tools/testing/selftests/bpf/test_sockmap.c @@ -2107,9 +2107,9 @@ int main(int argc, char **argv) free(options.whitelist); if (options.blacklist) free(options.blacklist); + close(cg_fd); if (cg_created) cleanup_cgroup_environment(); - close(cg_fd); return err; } =20 --=20 2.40.1