From patchwork Sat Oct 14 12:17:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Jian X-Patchwork-Id: 13422003 X-Patchwork-Delegate: bpf@iogearbox.net Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 397BD12B9B; Sat, 14 Oct 2023 12:04:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=none Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AD33A2; Sat, 14 Oct 2023 05:04:39 -0700 (PDT) Received: from canpemm500010.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4S724l2C6mz1kv5x; Sat, 14 Oct 2023 20:00:23 +0800 (CST) Received: from huawei.com (10.175.101.6) by canpemm500010.china.huawei.com (7.192.105.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Sat, 14 Oct 2023 20:04:23 +0800 From: Liu Jian To: , , , , , , , , , , , , , , , , CC: , , Subject: [PATCH bpf-next v6 6/7] selftests/bpf: add tests for verdict skmsg to itself Date: Sat, 14 Oct 2023 20:17:05 +0800 Message-ID: <20231014121706.967988-7-liujian56@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231014121706.967988-1-liujian56@huawei.com> References: <20231014121706.967988-1-liujian56@huawei.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.175.101.6] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To canpemm500010.china.huawei.com (7.192.105.118) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: bpf@iogearbox.net Add tests for verdict skmsg to itself in sockmap_basic.c Signed-off-by: Liu Jian --- .../selftests/bpf/prog_tests/sockmap_basic.c | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c b/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c index ade0773b6f4b..e7fb1a31bf61 100644 --- a/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c +++ b/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c @@ -476,7 +476,7 @@ static void test_sockmap_skb_verdict_fionread(bool pass_prog) test_sockmap_drop_prog__destroy(drop); } -static void test_sockmap_msg_verdict(bool is_ingress, bool is_permanent) +static void test_sockmap_msg_verdict(bool is_ingress, bool is_permanent, bool is_self) { int key, sent, recvd, recv_fd; int err, map, verdict, s, c0, c1, p0, p1; @@ -519,13 +519,23 @@ static void test_sockmap_msg_verdict(bool is_ingress, bool is_permanent) goto out_close; if (is_ingress) { - recv_fd = c1; skel->bss->skmsg_redir_flags = BPF_F_INGRESS; - skel->bss->skmsg_redir_key = 1; + if (is_self) { + skel->bss->skmsg_redir_key = 0; + recv_fd = p1; + } else { + skel->bss->skmsg_redir_key = 1; + recv_fd = c1; + } } else { - recv_fd = c0; skel->bss->skmsg_redir_flags = 0; - skel->bss->skmsg_redir_key = 2; + if (is_self) { + skel->bss->skmsg_redir_key = 0; + recv_fd = c1; + } else { + skel->bss->skmsg_redir_key = 2; + recv_fd = c0; + } } if (is_permanent) @@ -590,11 +600,15 @@ void test_sockmap_basic(void) if (test__start_subtest("sockmap skb_verdict fionread on drop")) test_sockmap_skb_verdict_fionread(false); if (test__start_subtest("sockmap msg_verdict")) - test_sockmap_msg_verdict(false, false); + test_sockmap_msg_verdict(false, false, false); if (test__start_subtest("sockmap msg_verdict ingress")) - test_sockmap_msg_verdict(true, false); + test_sockmap_msg_verdict(true, false, false); if (test__start_subtest("sockmap msg_verdict permanent")) - test_sockmap_msg_verdict(false, true); + test_sockmap_msg_verdict(false, true, false); if (test__start_subtest("sockmap msg_verdict ingress permanent")) - test_sockmap_msg_verdict(true, true); + test_sockmap_msg_verdict(true, true, false); + if (test__start_subtest("sockmap msg_verdict permanent self")) + test_sockmap_msg_verdict(false, true, true); + if (test__start_subtest("sockmap msg_verdict ingress permanent self")) + test_sockmap_msg_verdict(true, true, true); }