From patchwork Thu May 23 06:49:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13671312 X-Patchwork-Delegate: bpf@iogearbox.net 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 CA01FEC5; Thu, 23 May 2024 06:50:27 +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=1716447027; cv=none; b=UoSX9bYtZDOv34bU2RTnt/5FDYgPtTQ7PQtj9JFHbcebFvCRnHdImv8h7Z8fAwYkrDJrL0IU4tOEJNHXC/aDyV5dSAXUrNmOOtliRVC9u8THYj52q0crvSGcdnjBkysKsE36BrW4fo8RziCGfPaVXkH/WVVimDcQFka2+Hn5+6M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716447027; c=relaxed/simple; bh=jzxUYLvnv6hkKSXo/p1R8ovUX+pIaKQO539KVGwiG20=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YJB/PUHdx1ahuXv+9XvpEqkY5x5WR182yduu3UN5wN9ohUE1qx6+CCE4s475Nlc9N6sMt8NXPIhUcZ0pKYszJ/+ixMSALFuuk0UlQbPscmzgRf5+QGN84qM9c2behVeGjoQq1yoTxaQ20gQIDq4yLOHS9Rc5ZajwBwsAl/rlWLQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eby2GAoI; 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="eby2GAoI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 62A0FC2BD10; Thu, 23 May 2024 06:50:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716447027; bh=jzxUYLvnv6hkKSXo/p1R8ovUX+pIaKQO539KVGwiG20=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eby2GAoIUIjb8+GelMPK80DThcXma/TaB4tdAg9Dpz9a+WQTRkAcbgDP7JRq/3XSM 9n0t59bQ7UOMVEtXr9596kjARqSzS9f0sKa4gZZxoXQs2pv6IjdSztgxu2lXaqUl0+ 8elsjNjnh5H0IFne3CAlB+/tVA5h1ytfwYaqGyZtrOTW58f9YiaMjKW6lrB2SgoizY 6u7U1G4IhLJoexVXqZWXpasiaYDyKQsPW3vW+vis2DpMa6/puBwpecS/0jP7qez3g3 KvqraSfxxqatgmTSmAkqSs+9cxE/rUBp0sycnL5zUDE/6f5VlKz7tmrV5DMdX83v2c 6wZpRG1NZZyXA== 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, linux-kselftest@vger.kernel.org Subject: [PATCH bpf-next 1/8] selftests/bpf: Fix tx_prog_fd values in test_sockmap Date: Thu, 23 May 2024 14:49:57 +0800 Message-ID: <08b20ffc544324d40939efeae93800772a91a58e.1716446893.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net From: Geliang Tang The values of tx_prog_fd in run_options() should not be 0, so set it as -1 in else branch, and test it using "if (tx_prog_fd > 0)" condition, not "if (tx_prog_fd)" or "if (tx_prog_fd >= 0)". Signed-off-by: Geliang Tang Acked-by: John Fastabend --- tools/testing/selftests/bpf/test_sockmap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/bpf/test_sockmap.c b/tools/testing/selftests/bpf/test_sockmap.c index 4499b3cfc3a6..fde0dd741e69 100644 --- a/tools/testing/selftests/bpf/test_sockmap.c +++ b/tools/testing/selftests/bpf/test_sockmap.c @@ -1027,9 +1027,9 @@ static int run_options(struct sockmap_options *options, int cg_fd, int test) else if (txmsg_drop) tx_prog_fd = prog_fd[8]; else - tx_prog_fd = 0; + tx_prog_fd = -1; - if (tx_prog_fd) { + if (tx_prog_fd > 0) { int redir_fd, i = 0; err = bpf_prog_attach(tx_prog_fd, @@ -1285,7 +1285,7 @@ static int run_options(struct sockmap_options *options, int cg_fd, int test) bpf_prog_detach2(prog_fd[0], map_fd[8], BPF_SK_SKB_STREAM_PARSER); bpf_prog_detach2(prog_fd[2], map_fd[8], BPF_SK_SKB_STREAM_VERDICT); - if (tx_prog_fd >= 0) + if (tx_prog_fd > 0) bpf_prog_detach2(tx_prog_fd, map_fd[1], BPF_SK_MSG_VERDICT); for (i = 0; i < 8; i++) { From patchwork Thu May 23 06:49:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13671313 X-Patchwork-Delegate: bpf@iogearbox.net 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 7955D13C838; Thu, 23 May 2024 06:50:33 +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=1716447033; cv=none; b=NEjOZNtTHB37z+JwTIqa2TuMlwSZRQq0r4br+fsHr66T8ysekJRv8JBnE5eNmwxrhEF6tLl1nlXKmD51wJbFOQ1ai0/Wvxb9ymx9vOvx4JWgU08NzMBS3eQI7N85EdO4PAhOY6YUlDUQRZwxz6MLes8qpVwCqG+BYqD8tUsNRZY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716447033; c=relaxed/simple; bh=42iO5udp2Ibn41SCzR7Waf2A6G0d38SJCLI0k7E2p9c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qwqwGHAmxdjqrJ2SvsYD4WDLzYcVmqXsTum0F4lEHFi0FEbpHj5vfoIqruYdIHH0CMou5hMYjBdtezUAwLe6tUEGnFTIRbvPTZQhOpKKDiWUikhXFXw6YmOVpNM1YIKtUMAoemLiCcM6lS5FLyVTlNDZ7IlOdimVt2TLgpJ4uIk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rfC1r6kG; 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="rfC1r6kG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D083C2BD10; Thu, 23 May 2024 06:50:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716447033; bh=42iO5udp2Ibn41SCzR7Waf2A6G0d38SJCLI0k7E2p9c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rfC1r6kGtHRqIpoIVkdw8w355iSN31tdhJ5/4cnHIakh2Y/fIHVpFgS/efrk9SOD1 EiC7x21WWKCZmW8n+bL8eOyEXvWF09I8U41Kh0HCsJ4AIBx9wDejfLglz87lSDm6Iv 646TusHdPuc/eK0e95q7Y+I1eRdwmeAdZiiW8KhXNLAeC+uXD+FyjKe8Kf+IedBimM yFs3A6hLTM6QVPZTrY07ozqJcM3VSEQk67DaD1zk1TzVkSR+Ey+bgtYZtfXefOZxiv se1wC688HbQFx0NCZCDqe3UQw4Y3uaqNkwKCuiI81xnJqpPTl6mNQcIrnAC0h4SAp7 8b3yB/7aR+tTg== 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, linux-kselftest@vger.kernel.org Subject: [PATCH bpf-next 2/8] selftests/bpf: Drop duplicate definition of i in test_sockmap Date: Thu, 23 May 2024 14:49:58 +0800 Message-ID: <8d690682330a59361562bca75d6903253d16f312.1716446893.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net From: Geliang Tang There's already a definition of i in run_options() at the beginning, no need to define a new one in "if (tx_prog_fd > 0)" block. Signed-off-by: Geliang Tang Acked-by: John Fastabend --- tools/testing/selftests/bpf/test_sockmap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/test_sockmap.c b/tools/testing/selftests/bpf/test_sockmap.c index fde0dd741e69..e7dbf49a2ca6 100644 --- a/tools/testing/selftests/bpf/test_sockmap.c +++ b/tools/testing/selftests/bpf/test_sockmap.c @@ -1030,7 +1030,7 @@ static int run_options(struct sockmap_options *options, int cg_fd, int test) tx_prog_fd = -1; if (tx_prog_fd > 0) { - int redir_fd, i = 0; + int redir_fd; err = bpf_prog_attach(tx_prog_fd, map_fd[1], BPF_SK_MSG_VERDICT, 0); @@ -1041,6 +1041,7 @@ static int run_options(struct sockmap_options *options, int cg_fd, int test) goto out; } + i = 0; err = bpf_map_update_elem(map_fd[1], &i, &c1, BPF_ANY); if (err) { fprintf(stderr, From patchwork Thu May 23 06:49:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13671314 X-Patchwork-Delegate: bpf@iogearbox.net 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 E5D2D13C8E1; Thu, 23 May 2024 06:50:39 +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=1716447040; cv=none; b=fxRI/gsOrGIvqqFyMFUI635tFl6eR6QXgj1tCgGZmeQIH6sLRI8VCmGAUQVRlN0b+nPy7RoJEDcN3H/e734DbQp1rvDK6JRCT2aNyfwBvnZSyycYOcqNdk5NznlVfQHeql3d3FDjqrxG+RXyBi8VnXiVqv9QwuQRGZMz44KN++Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716447040; c=relaxed/simple; bh=j+Yzr44J3a/y0uMOBUQ0oSYXFSurJrqVJ6d0Uotfark=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ew09LSNDHRg5/frDkDu+x+8p36RB0ilJ1Dp+xM8qIB8Skg13N3NYtPtgURtgM8IaCQsSG6jv0vWWIpv9+RBRNI8zZUL37MmAUkqO3exbrZkV1lN1Wgx+Xhn3+gJ7/xoqdt8AkYfA9EDP/vqpmxpimPA5rCJmcdWeGFbvawf3CU4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cLXTYBmC; 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="cLXTYBmC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 00E51C32782; Thu, 23 May 2024 06:50:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716447039; bh=j+Yzr44J3a/y0uMOBUQ0oSYXFSurJrqVJ6d0Uotfark=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cLXTYBmC9qdkVCPDH1Vxcmic2fuUaIF/DZWKMYZr7aHHhSBKr9qGWR60dBMtlZ4xt TF2U3FNb6KpusCJtKrJUpkQ58ql8eAxdqqUG14fYYR81zVG+kqO1P0EPVQVgeAl5Z8 gdTLeL/qIfLIzQbomqeG5xlO01f2TT3Di9yJKEiw0BviUzrC2rSl5rvZQWsi8KGynh w/Ve6EBVeUqY3WaFgU2Nj9gwn8W26GeVDQHtMlxMEOCsyedWzKdf7A2htnjWAhyjg1 mv7UmLRaDBFQ2Tb2crXn76NG2B/W+CXtjTW2pSap5XKFMJmb5lR5k/ZmJCz1gFDYUM 9HFIUCplfMVMw== 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, linux-kselftest@vger.kernel.org Subject: [PATCH bpf-next 3/8] selftests/bpf: Use bpf_link attachments in test_sockmap Date: Thu, 23 May 2024 14:49:59 +0800 Message-ID: <32cf8376a810e2e9c719f8e4cfb97132ed2d1f9c.1716446893.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net From: Geliang Tang Switch attachments to bpf_link using bpf_program__attach_sockmap() instead of bpf_prog_attach(). This patch adds a new array progs[] to replace prog_fd[] array, set in populate_progs() for each program in bpf object. And another new array links[] to save the attached bpf_link. It is initalized as NULL in populate_progs, set as the return valuses of bpf_program__attach_sockmap(), and detached by bpf_link__detach(). Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/test_sockmap.c | 59 ++++++++++++---------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/tools/testing/selftests/bpf/test_sockmap.c b/tools/testing/selftests/bpf/test_sockmap.c index e7dbf49a2ca6..d7581bbbc473 100644 --- a/tools/testing/selftests/bpf/test_sockmap.c +++ b/tools/testing/selftests/bpf/test_sockmap.c @@ -64,6 +64,8 @@ int failed; int map_fd[9]; struct bpf_map *maps[9]; int prog_fd[9]; +struct bpf_program *progs[9]; +struct bpf_link *links[9]; int txmsg_pass; int txmsg_redir; @@ -960,43 +962,39 @@ static int run_options(struct sockmap_options *options, int cg_fd, int test) /* Attach programs to sockmap */ if (!txmsg_omit_skb_parser) { - err = bpf_prog_attach(prog_fd[0], map_fd[0], - BPF_SK_SKB_STREAM_PARSER, 0); - if (err) { + links[0] = bpf_program__attach_sockmap(progs[0], map_fd[0]); + if (!links[0]) { fprintf(stderr, - "ERROR: bpf_prog_attach (sockmap %i->%i): %d (%s)\n", - prog_fd[0], map_fd[0], err, strerror(errno)); - return err; + "ERROR: bpf_program__attach_sockmap (sockmap %i->%i): (%s)\n", + bpf_program__fd(progs[0]), map_fd[0], strerror(errno)); + return -1; } } - err = bpf_prog_attach(prog_fd[1], map_fd[0], - BPF_SK_SKB_STREAM_VERDICT, 0); - if (err) { - fprintf(stderr, "ERROR: bpf_prog_attach (sockmap): %d (%s)\n", - err, strerror(errno)); - return err; + links[1] = bpf_program__attach_sockmap(progs[1], map_fd[0]); + if (!links[1]) { + fprintf(stderr, "ERROR: bpf_program__attach_sockmap (sockmap): (%s)\n", + strerror(errno)); + return -1; } /* Attach programs to TLS sockmap */ if (txmsg_ktls_skb) { if (!txmsg_omit_skb_parser) { - err = bpf_prog_attach(prog_fd[0], map_fd[8], - BPF_SK_SKB_STREAM_PARSER, 0); - if (err) { + links[2] = bpf_program__attach_sockmap(progs[0], map_fd[8]); + if (!links[2]) { fprintf(stderr, - "ERROR: bpf_prog_attach (TLS sockmap %i->%i): %d (%s)\n", - prog_fd[0], map_fd[8], err, strerror(errno)); - return err; + "ERROR: bpf_program__attach_sockmap (TLS sockmap %i->%i): (%s)\n", + bpf_program__fd(progs[0]), map_fd[8], strerror(errno)); + return -1; } } - err = bpf_prog_attach(prog_fd[2], map_fd[8], - BPF_SK_SKB_STREAM_VERDICT, 0); - if (err) { - fprintf(stderr, "ERROR: bpf_prog_attach (TLS sockmap): %d (%s)\n", - err, strerror(errno)); - return err; + links[3] = bpf_program__attach_sockmap(progs[2], map_fd[8]); + if (!links[3]) { + fprintf(stderr, "ERROR: bpf_program__attach_sockmap (TLS sockmap): (%s)\n", + strerror(errno)); + return -1; } } @@ -1281,10 +1279,11 @@ static int run_options(struct sockmap_options *options, int cg_fd, int test) out: /* Detatch and zero all the maps */ bpf_prog_detach2(prog_fd[3], cg_fd, BPF_CGROUP_SOCK_OPS); - bpf_prog_detach2(prog_fd[0], map_fd[0], BPF_SK_SKB_STREAM_PARSER); - bpf_prog_detach2(prog_fd[1], map_fd[0], BPF_SK_SKB_STREAM_VERDICT); - bpf_prog_detach2(prog_fd[0], map_fd[8], BPF_SK_SKB_STREAM_PARSER); - bpf_prog_detach2(prog_fd[2], map_fd[8], BPF_SK_SKB_STREAM_VERDICT); + + for (i = 0; i < ARRAY_SIZE(links); i++) { + if (links[i]) + bpf_link__detach(links[i]); + } if (tx_prog_fd > 0) bpf_prog_detach2(tx_prog_fd, map_fd[1], BPF_SK_MSG_VERDICT); @@ -1836,6 +1835,7 @@ static int populate_progs(char *bpf_file) i = bpf_object__load(obj); i = 0; bpf_object__for_each_program(prog, obj) { + progs[i] = prog; prog_fd[i] = bpf_program__fd(prog); i++; } @@ -1850,6 +1850,9 @@ static int populate_progs(char *bpf_file) } } + for (i = 0; i < ARRAY_SIZE(links); i++) + links[i] = NULL; + return 0; } From patchwork Thu May 23 06:50:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13671315 X-Patchwork-Delegate: bpf@iogearbox.net 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 8913213C838; Thu, 23 May 2024 06:50:45 +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=1716447045; cv=none; b=Owni4GA15IZtKqjjljdIAWFCjma4/pZ7C3wy4Yo+nIASuEZs7jZcxwX8DTx2ZPbpAMD2aWVbJJTlVA8RUbLfrBi948zfz5EwF5Q5K6T9+Ixs29uF8iGMqJzjmjY3EFiT4XvA3Xv7F4cGOkZc3Pu2C+KrVtHpchy05VwtoRxdOkg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716447045; c=relaxed/simple; bh=EsgKr2+15JU23386C02AiaPX82NABHkp3oBufrNJeLE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q7lvGqR0NqcSsCFWAwQrylhZ/EXdHSN2XSZFcx/XO011yMKgmbFQ6iMS7KmYzIAKkeDEBNpMgge5v3aNIpHZHcoC97TU/nbBnM48YZIRq0ONDiJ9aYoT3680MwFQKZseem0927Xu6p/lcryslloFuvLzCx/0mMtU0H2ghMBU0mA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aOB1RTw6; 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="aOB1RTw6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 220D3C2BD10; Thu, 23 May 2024 06:50:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716447045; bh=EsgKr2+15JU23386C02AiaPX82NABHkp3oBufrNJeLE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aOB1RTw63RqL0BbGW60bu5BO0B7L9tVOMackeER5+2CY4tKejCceupNgyj32hn5cp niqoR3j5B8bz6FZQZKAXhhL/hUQ3mzn2s0E0TyapXxvnWEi/VHDwmB8YBABkkiUnA6 uuZHlkb4qBTRJZwN0zy0b0XNxnldrLFR9uxM4emOKjvsHCgTszWrdLwQSXIjN8f5P8 fOr7c0if/bF3y/+xikF+CLjEwG5ix2Se2NN8fAXozza/T6bODy+STmFULgPV0iOhXh so4kE+4kXOV/OEMNRos+nitdmA9nYDCmc8Iba9j3lYTxlfb0EbpviMJrs6Au/xxp33 jqm3NiY5Au5Bw== 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, linux-kselftest@vger.kernel.org Subject: [PATCH bpf-next 4/8] selftests/bpf: Replace tx_prog_fd with tx_prog in test_sockmap Date: Thu, 23 May 2024 14:50:00 +0800 Message-ID: <23b37f932c547dd1ebfe154bbc0b0e957be21ee6.1716446893.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net From: Geliang Tang bpf_program__attach_sockmap() needs to take a parameter of type bpf_program instead of an fd, so tx_prog_fd becomes useless. This patch uses a pointer tx_prog to point to an item in progs[] array. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/test_sockmap.c | 30 ++++++++++------------ 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/tools/testing/selftests/bpf/test_sockmap.c b/tools/testing/selftests/bpf/test_sockmap.c index d7581bbbc473..8e32d157bac0 100644 --- a/tools/testing/selftests/bpf/test_sockmap.c +++ b/tools/testing/selftests/bpf/test_sockmap.c @@ -954,7 +954,8 @@ enum { static int run_options(struct sockmap_options *options, int cg_fd, int test) { - int i, key, next_key, err, tx_prog_fd = -1, zero = 0; + int i, key, next_key, err, zero = 0; + struct bpf_program *tx_prog; /* If base test skip BPF setup */ if (test == BASE || test == BASE_SENDPAGE) @@ -1015,27 +1016,27 @@ static int run_options(struct sockmap_options *options, int cg_fd, int test) /* Attach txmsg program to sockmap */ if (txmsg_pass) - tx_prog_fd = prog_fd[4]; + tx_prog = progs[4]; else if (txmsg_redir) - tx_prog_fd = prog_fd[5]; + tx_prog = progs[5]; else if (txmsg_apply) - tx_prog_fd = prog_fd[6]; + tx_prog = progs[6]; else if (txmsg_cork) - tx_prog_fd = prog_fd[7]; + tx_prog = progs[7]; else if (txmsg_drop) - tx_prog_fd = prog_fd[8]; + tx_prog = progs[8]; else - tx_prog_fd = -1; + tx_prog = NULL; - if (tx_prog_fd > 0) { + if (tx_prog) { int redir_fd; - err = bpf_prog_attach(tx_prog_fd, - map_fd[1], BPF_SK_MSG_VERDICT, 0); - if (err) { + links[4] = bpf_program__attach_sockmap(tx_prog, map_fd[1]); + if (!links[4]) { fprintf(stderr, - "ERROR: bpf_prog_attach (txmsg): %d (%s)\n", - err, strerror(errno)); + "ERROR: bpf_program__attach_sockmap (txmsg): (%s)\n", + strerror(errno)); + err = -1; goto out; } @@ -1285,9 +1286,6 @@ static int run_options(struct sockmap_options *options, int cg_fd, int test) bpf_link__detach(links[i]); } - if (tx_prog_fd > 0) - bpf_prog_detach2(tx_prog_fd, map_fd[1], BPF_SK_MSG_VERDICT); - for (i = 0; i < 8; i++) { key = next_key = 0; bpf_map_update_elem(map_fd[i], &key, &zero, BPF_ANY); From patchwork Thu May 23 06:50:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13671316 X-Patchwork-Delegate: bpf@iogearbox.net 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 046C613C838; Thu, 23 May 2024 06:50:51 +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=1716447052; cv=none; b=JywuqU5Hi98U6M+ertTyhDAAbpez5UGGlFLydfdrsG7i7Wvp0Q6BKtrO4ZpCSppOzWVbvofQ9JoW/Tbf1cJKWyFn/y5ewGj1nPBrV73HyEiEYRs3b84SsMjUyzIOzOsasl8QhhdGWruYfvGDHzoISy8FTYtm0INl2an4Sh7D7TE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716447052; c=relaxed/simple; bh=XxU76wSm2VGBTgKDwcx/rB1boeVCdpt1MRZ/fiiWAOA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Vhdnp7ctVBKMPeVI5u4Bk937Hgo+BSfCUnCyTLoUHR6lSFVCm1jnJhXlQ2Q1hgc84QoAw590z0uJnOfuX5XTcBNgGPw7Kph0bqMOcEOG+x+5u6RwY5o82u7ua9t2PDofLo9jRmQ/2ZhCV8DiMF03mj0S1/rlah6hcoSdK7fAy64= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cGq8GO5I; 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="cGq8GO5I" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ED88BC2BD10; Thu, 23 May 2024 06:50:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716447051; bh=XxU76wSm2VGBTgKDwcx/rB1boeVCdpt1MRZ/fiiWAOA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cGq8GO5I7w/oERSiKjS6JbZ834/uTytnA8GchwA9/Gc4vyJWOyDxkEzZdrEFotFvp iJnFrqVrsnx31KWz3d1FFQ1i6UVJD+6HvGWeVtL64us5uoYwpC80+p0iKGAm6eMBYq kNUKLQzJfm9yLcqSJnNmXpX32oVE6deed0Nx8/JRJ7liz+qEV4xZWrvW4LoBXst9E/ IYbtF7kz4FIozfCxJgOS1e4hBD1LJR63k1axZEr+nxnLjvunPsxF0q83rjMKhvrprM OHCeVrqSbBitM9E8zVjUkq6I78ZNASFpbasgbCjI78DuVWFR+VKaEJAunqAA9NmpO1 jlZg+iGV/yXCw== 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, linux-kselftest@vger.kernel.org Subject: [PATCH bpf-next 5/8] selftests/bpf: Drop prog_fd array in test_sockmap Date: Thu, 23 May 2024 14:50:01 +0800 Message-ID: <9a6335e4d8dbab23c0d8906074457ceddd61e74b.1716446893.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net From: Geliang Tang The program fds can be got by using bpf_program__fd(progs[]), then prog_fd becomes useless. This patch drops it. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/test_sockmap.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/bpf/test_sockmap.c b/tools/testing/selftests/bpf/test_sockmap.c index 8e32d157bac0..e83ca0005721 100644 --- a/tools/testing/selftests/bpf/test_sockmap.c +++ b/tools/testing/selftests/bpf/test_sockmap.c @@ -63,7 +63,6 @@ int passed; int failed; int map_fd[9]; struct bpf_map *maps[9]; -int prog_fd[9]; struct bpf_program *progs[9]; struct bpf_link *links[9]; @@ -1000,7 +999,7 @@ static int run_options(struct sockmap_options *options, int cg_fd, int test) } /* Attach to cgroups */ - err = bpf_prog_attach(prog_fd[3], cg_fd, BPF_CGROUP_SOCK_OPS, 0); + err = bpf_prog_attach(bpf_program__fd(progs[3]), cg_fd, BPF_CGROUP_SOCK_OPS, 0); if (err) { fprintf(stderr, "ERROR: bpf_prog_attach (groups): %d (%s)\n", err, strerror(errno)); @@ -1279,7 +1278,7 @@ static int run_options(struct sockmap_options *options, int cg_fd, int test) fprintf(stderr, "unknown test\n"); out: /* Detatch and zero all the maps */ - bpf_prog_detach2(prog_fd[3], cg_fd, BPF_CGROUP_SOCK_OPS); + bpf_prog_detach2(bpf_program__fd(progs[3]), cg_fd, BPF_CGROUP_SOCK_OPS); for (i = 0; i < ARRAY_SIZE(links); i++) { if (links[i]) @@ -1834,7 +1833,6 @@ static int populate_progs(char *bpf_file) i = 0; bpf_object__for_each_program(prog, obj) { progs[i] = prog; - prog_fd[i] = bpf_program__fd(prog); i++; } From patchwork Thu May 23 06:50:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13671317 X-Patchwork-Delegate: bpf@iogearbox.net 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 26DF013C8F2; Thu, 23 May 2024 06:50:57 +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=1716447058; cv=none; b=Oqse2sHhVocI1tJI0JXg8Z/1nbPSC2Mf/B/sSrOELFHPqZAmH3yV/FbIlGhiQcVUamVFOYMaFF5Cu2JXMM75o+qTiS/n2eW6d0Kw02WbiwEsCKDJO4X5o/pFdB4FRUtW7U6H25VndI8D6A4sRJzf9A546jXAPuEvjEXFM3Zz8s0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716447058; c=relaxed/simple; bh=icBCMYv8O7EZO08xGmk+z3plQf8DdXeJ7xlVNI+eUg8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gItQKgnynlp8Pc5VQu6zCG/GE+aIUqPlEqI75RP+PTXTjHLMaLe7PkAQwiKOk2cAmzGtItrbKzmy9kKT486clcjwK52ERgzr8pijTH5UT3X5CmjdYWINUgpPaVL/5TGthwmMmOo9T4BM7fmivkF/QhmNXNmya4e5V9znHIIZy6w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=N5JTXCuk; 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="N5JTXCuk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20EBBC3277B; Thu, 23 May 2024 06:50:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716447057; bh=icBCMYv8O7EZO08xGmk+z3plQf8DdXeJ7xlVNI+eUg8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N5JTXCukGzZwBFu63kpWcjZa9lIhGnvdH6ee7TC/8LFPVu3JMRcm4UpWoJnKgyMK4 yftbDFVUcHAyDeREJwQM5CfdJmE07k9Glf+oqJ2Ckes9uKb22SFI/1ubktHfZQaGwY HvSe+jCYWSMzbVdCVgiU85dmUDLWYX9LgaUEex7LaBd4hHOLqGvRSW4bCLDiXGPxo4 s3/SHicJCh/VpyqIO2bi+4QkH1kaXXLKHo+y4SEhZoogljXlhNVmBysbjNNIa/QM8i YIbQvwtPSFi1bE54RNEQg58G87r3plgjNJ+Srtu6wUwJ1CYgfwc2+6d4q4fcJoNBnj Lfiinq436IS8Q== 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, linux-kselftest@vger.kernel.org Subject: [PATCH bpf-next 6/8] selftests/bpf: Fix size of map_fd in test_sockmap Date: Thu, 23 May 2024 14:50:02 +0800 Message-ID: <0972529ee01ebf8a8fd2b310bdec90831c94be77.1716446893.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net From: Geliang Tang The array size of map_fd[] is 9, not 8. This patch changes it as a more general form: ARRAY_SIZE(map_fd). Signed-off-by: Geliang Tang Acked-by: John Fastabend --- 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 e83ca0005721..3654babfac59 100644 --- a/tools/testing/selftests/bpf/test_sockmap.c +++ b/tools/testing/selftests/bpf/test_sockmap.c @@ -1285,7 +1285,7 @@ static int run_options(struct sockmap_options *options, int cg_fd, int test) bpf_link__detach(links[i]); } - for (i = 0; i < 8; i++) { + for (i = 0; i < ARRAY_SIZE(map_fd); i++) { key = next_key = 0; bpf_map_update_elem(map_fd[i], &key, &zero, BPF_ANY); while (bpf_map_get_next_key(map_fd[i], &key, &next_key) == 0) { From patchwork Thu May 23 06:50:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13671318 X-Patchwork-Delegate: bpf@iogearbox.net 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 50B2413C8F2; Thu, 23 May 2024 06:51:03 +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=1716447063; cv=none; b=D5X4JS2ubqI3jk/MmRlOFSMJNLWPw+ChM11MWEmaUAwHRB/52Eb1+1BeRNSOWstVMNxvQXiYjo809UtP1Q474TDwOLG9zTbi2y+ltHshsMK5vw0X5eU+IUTnvzZas4J01eQA4Dtcqr0L5vV35o50g4/9CerRVSR4IeYt5Y9kn0g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716447063; c=relaxed/simple; bh=0LAI2gSq/78VUmPVnhaSZfCl2xOHD0Zb0z7FrKUwl4s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VN7T3WwuxTZdjgrsaghRg+qJE0CxGljOFHzYkDrixPeYyBC7F/aqAYEzWw0KqFx4yIXAKDf+ffS3yoM1zgjEzN0yxaszWuVYM7Ek/E4HpZcp5ZB6RatL8TI+/AJLsmvXfQQozNOeTVdntE4JRjC1rPGRPbKS5QBRhWZtm7JIJJQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HblURiMY; 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="HblURiMY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41950C32782; Thu, 23 May 2024 06:50:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716447063; bh=0LAI2gSq/78VUmPVnhaSZfCl2xOHD0Zb0z7FrKUwl4s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HblURiMYwX88M9GZxVJ+LeazU0EFypTaWEIovopa7SuowVhSo0Ak44JVvQ9FbQxic RHKVRCmubgmJQsPCpIybr7ytKeURTIRcW82Lq0WH2h2oSdTlcP6SkV4ZCppfrxN8I9 6tJpziAXMy11ynj6nxQI7vL3qqj8x7NaPT9F2AyODbbChWqGkPOxjgxIr8zKOJSlv0 UqsgZNIdYmMHH7esMeHR3IjiYgyphxOyPA3XVV8t3vquIIoQH/OHLWeB1MscSIuXmG kH4uUhNMQHoHiJPEnXHCENIieLnwdkp3NG9YGfbF/f497auG6KOQgFVwn0pUQDUWfb gJ2PpXXckWP1w== 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, linux-kselftest@vger.kernel.org Subject: [PATCH bpf-next 7/8] selftests/bpf: Check length of recv in test_sockmap Date: Thu, 23 May 2024 14:50:03 +0800 Message-ID: <5172563f7c7b2a2e953cef02e89fc34664a7b190.1716446893.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net From: Geliang Tang The value of recv in msg_loop may be negative, like EWOULDBLOCK, so it's necessary to check if it is positive before accumulating it to bytes_recvd. Fixes: 16962b2404ac ("bpf: sockmap, add selftests") Signed-off-by: Geliang Tang Acked-by: John Fastabend --- tools/testing/selftests/bpf/test_sockmap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/test_sockmap.c b/tools/testing/selftests/bpf/test_sockmap.c index 3654babfac59..4c7cb206b31d 100644 --- a/tools/testing/selftests/bpf/test_sockmap.c +++ b/tools/testing/selftests/bpf/test_sockmap.c @@ -681,7 +681,8 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt, } } - s->bytes_recvd += recv; + if (recv > 0) + s->bytes_recvd += recv; if (opt->check_recved_len && s->bytes_recvd > total_bytes) { errno = EMSGSIZE; From patchwork Thu May 23 06:50:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13671319 X-Patchwork-Delegate: bpf@iogearbox.net 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 539F813C8F8; Thu, 23 May 2024 06:51:09 +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=1716447069; cv=none; b=U1fOPt6J+GV8SZ9fTO2g0ZyV1XBgtBP0n6FkpTL1kLBRhZc6H3n0k7U+h/QqBP5jYxrJHkErBmiSHOA93yLrrrDXmHJebH3vxzH4R30QDVn9qXX8WHwuqEjwtvsm0JMwVepHt9WaSXhIFTCy0bbqjqPjbQo6QhKOFaR6eJXp1Sk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716447069; c=relaxed/simple; bh=5wDxYXK13L3RuBy8KDQkEjCCur0RuR4zEdgfgA9ZV3k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KPNV/O4qx8p1frbcKf3WZw5HcIE6/lVbS0hLF9rgMWwCrvWHdNugbhGh6S0mczd21gdIhuYXPa4oFyTdwariQLlQLxylGlXf77cwBfDs4uWRLljrKnYOWeGCpOlg1ArW62Z1Id5Zh4dqJG/soon0M9WeQCKqp/g5dmFbpWPVEMs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EOBX6h3a; 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="EOBX6h3a" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F962C32782; Thu, 23 May 2024 06:51:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716447069; bh=5wDxYXK13L3RuBy8KDQkEjCCur0RuR4zEdgfgA9ZV3k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EOBX6h3alzW886v/NBWBo/WBdLR1K0pDyyI+lMNvqQ9OaNyjmmm6CGl+VxUWf8c2d jQ+FEQ0GONgss55K4lhVIM9Pq9lAWbKwU+Nw1ig51o9DVRdCmvhAtbhQqU428JZYPS DSk+q/smJOzU/l73KEa88GauGOjqMwhKhsYz5+COTBB9UVANPGGWNMzuz6alHmlaWU 1A+F7GrKvTFuiSTljYjZLy8m7RXkF3XJycoECfmvKKXpIURLEIRd7aDfxNprIz+BGA 3nXsbG4YRPMghg6/dASBjDtj5Iu/bekiTUIImml9m/teLJKfjGnaGQC4d/STYxOwR5 phCK31J3EbfBw== 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, linux-kselftest@vger.kernel.org Subject: [PATCH bpf-next 8/8] selftests/bpf: Drop duplicate bpf_map_lookup_elem in test_sockmap Date: Thu, 23 May 2024 14:50:04 +0800 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net From: Geliang Tang bpf_map_lookup_elem is invoked in bpf_prog3() already, no need to invoke it again. This patch drops it. Signed-off-by: Geliang Tang Acked-by: John Fastabend --- tools/testing/selftests/bpf/progs/test_sockmap_kern.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/tools/testing/selftests/bpf/progs/test_sockmap_kern.h b/tools/testing/selftests/bpf/progs/test_sockmap_kern.h index 99d2ea9fb658..2399958991e7 100644 --- a/tools/testing/selftests/bpf/progs/test_sockmap_kern.h +++ b/tools/testing/selftests/bpf/progs/test_sockmap_kern.h @@ -177,9 +177,6 @@ int bpf_prog3(struct __sk_buff *skb) return bpf_sk_redirect_hash(skb, &tls_sock_map, &ret, flags); #endif } - f = bpf_map_lookup_elem(&sock_skb_opts, &one); - if (f && *f) - ret = SK_DROP; err = bpf_skb_adjust_room(skb, 4, 0, 0); if (err) return SK_DROP;