From patchwork Wed Apr 3 08:32:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13615363 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 9C7E26EB44; Wed, 3 Apr 2024 08:32:24 +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=1712133144; cv=none; b=Izbx9OdlWJ5wk7bYUARMemK6sdc/kLwv57wnp66JXeibaoh+VBZBr5zz/9Va0OG7XYsxw/C8WFPs0U2rkRcMagiwLK+NwhPUtJ4QD6I/te+h/GC6l0Jcz9W/GrC2oivNqF1Cqs6XC4zjVUzeeVL4nWlAA1vtUR01fm46lNoDUnU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712133144; c=relaxed/simple; bh=a1QM+YXnVizSAScGqWou87zl63DEaL9XVdmkRA97npY=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=hLk/WHV614uCdEiUJcNKD3tISjl8oidqg2LWqUd8HkLS37zhYKBiUbV9pquS41QknSt6+8rNm9+MR+b2ipRrepcJSsdiwc62chDT7tS00MGRDbLv36Ir+2TolOxIpUgfbpt/plt8fccEO+vG1nVbC8ZZpUaimTH0BKcWhmN6BBw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TwS9iZg4; 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="TwS9iZg4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 01FBDC433F1; Wed, 3 Apr 2024 08:32:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712133144; bh=a1QM+YXnVizSAScGqWou87zl63DEaL9XVdmkRA97npY=; h=From:To:Cc:Subject:Date:From; b=TwS9iZg4x/uWYNwypdvrH21teIYr8PkqQX64NYDPE5SXIc2FPibbW50XEcddxbGZj zJ5EMdIaeEzCHHcnZs5RdUpyLup0MLVL3j84/5JpOau6WsS8vUip5WECS2HtNfHnCn xIvGc9FB9OMjYrYeUxEOf9AaVTKyXIt7xh/BjwigkOXTPvW4hOF+YmJrTSjUBWEqXz Tf8jJSlEjFgKLMxs13JycR77lpJYV3wvdy2/yf6lM18M9415S/su48scHAyv7a6hGH 8Sm3RCSyIwGuKfnfgASGfrQJVr2X1aNfInYehadfaPZ+S6epyPAfuf9Tg7xi3zw/3E uOweYUwAYy2+Q== 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 Cc: Geliang Tang , bpf@vger.kernel.org, mptcp@lists.linux.dev, linux-kselftest@vger.kernel.org Subject: [PATCH bpf-next] selftests/bpf: Add F_SETFL for fcntl Date: Wed, 3 Apr 2024 16:32:16 +0800 Message-Id: X-Mailer: git-send-email 2.40.1 Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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. Fixes: 16962b2404ac ("bpf: sockmap, add selftests") Signed-off-by: Geliang Tang --- 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/selftests/bpf/test_sockmap.c index 024a0faafb3b..34d6a1e6f664 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_length, int cnt, struct timeval timeout; fd_set w; - 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