From patchwork Mon Oct 25 22:33:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yucong Sun X-Patchwork-Id: 12583107 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7DD1C433FE for ; Mon, 25 Oct 2021 22:33:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CCAAD61039 for ; Mon, 25 Oct 2021 22:33:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234058AbhJYWgN (ORCPT ); Mon, 25 Oct 2021 18:36:13 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:9328 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233187AbhJYWgN (ORCPT ); Mon, 25 Oct 2021 18:36:13 -0400 Received: from pps.filterd (m0148460.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19PMGN4x017421 for ; Mon, 25 Oct 2021 15:33:50 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=gTIetxaSyuKlS96+b1d5uOAu5FQzIv1FUEI8oEa4DsE=; b=D5XSJ9KaLqRymxcnH/GknnKmfjMOW5cJidfgs/f8TMANDTpKUn+vx/dTyWvItgLHgbNk O3NkXduPmJ4qfCTzcfnBTqEf55+CdhJgAw2Xjm+vQvQeJZlER5Yc0Yu34oYlXuGYWwn1 NQ5rqnNM2TVVee3pw0gpIq2XWPKUVUAX1Y0= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com with ESMTP id 3bx4gn8dc3-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 25 Oct 2021 15:33:50 -0700 Received: from intmgw001.27.prn2.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:83::4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.14; Mon, 25 Oct 2021 15:33:48 -0700 Received: by devvm2661.vll0.facebook.com (Postfix, from userid 200310) id 3797B5DB8D3C; Mon, 25 Oct 2021 15:33:46 -0700 (PDT) From: Yucong Sun To: CC: , Yucong Sun Subject: [PATCH bpf-next 1/4] selfetests/bpf: Update vmtest.sh defaults Date: Mon, 25 Oct 2021 15:33:42 -0700 Message-ID: <20211025223345.2136168-2-fallentree@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211025223345.2136168-1-fallentree@fb.com> References: <20211025223345.2136168-1-fallentree@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-FB-Source: Intern X-Proofpoint-GUID: ppvpMYeYK3kMqTNAmsVBsmPh7v8w9APK X-Proofpoint-ORIG-GUID: ppvpMYeYK3kMqTNAmsVBsmPh7v8w9APK X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-10-25_07,2021-10-25_02,2020-04-07_01 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 mlxscore=0 lowpriorityscore=0 malwarescore=0 mlxlogscore=497 phishscore=0 adultscore=0 bulkscore=0 impostorscore=0 spamscore=0 priorityscore=1501 suspectscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2110250127 X-FB-Internal: deliver Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net From: Yucong Sun Increase memory to 4G, 8 SMP core with host cpu passthrough. This make it run faster in parallel mode and more likely to succeed. Signed-off-by: Yucong Sun --- tools/testing/selftests/bpf/vmtest.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/bpf/vmtest.sh b/tools/testing/selftests/bpf/vmtest.sh index 8889b3f55236..027198768fad 100755 --- a/tools/testing/selftests/bpf/vmtest.sh +++ b/tools/testing/selftests/bpf/vmtest.sh @@ -224,10 +224,10 @@ EOF -nodefaults \ -display none \ -serial mon:stdio \ - -cpu kvm64 \ + -cpu host \ -enable-kvm \ - -smp 4 \ - -m 2G \ + -smp 8 \ + -m 4G \ -drive file="${rootfs_img}",format=raw,index=1,media=disk,if=virtio,cache=none \ -kernel "${kernel_bzimage}" \ -append "root=/dev/vda rw console=ttyS0,115200" From patchwork Mon Oct 25 22:33:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yucong Sun X-Patchwork-Id: 12583109 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A62F6C433F5 for ; Mon, 25 Oct 2021 22:33:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8A5676105A for ; Mon, 25 Oct 2021 22:33:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233187AbhJYWgO (ORCPT ); Mon, 25 Oct 2021 18:36:14 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:7352 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233933AbhJYWgN (ORCPT ); Mon, 25 Oct 2021 18:36:13 -0400 Received: from pps.filterd (m0089730.ppops.net [127.0.0.1]) by m0089730.ppops.net (8.16.1.2/8.16.1.2) with SMTP id 19PMGMVX027756 for ; Mon, 25 Oct 2021 15:33:49 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=Bo/6+jYglVtAxnH0hh4v0nDiiIh6KvxqhBRk86Ja4n8=; b=meoCpF3l8apzJvEeYtTqhpRI5PRANIZZ+ncdhsnp4B37oKgpsOlrRB4dgPEAZT0SndLm sn827JQR8iqriZjCuUysfM0W3WH7f2RbJ+xXZV9eqp6tB5nEYOVd2aQ6NNqbUTBZcBy/ ft0J3kNwPXNPK4OkR7TqBQrjcC2lyZTbZeE= Received: from maileast.thefacebook.com ([163.114.130.16]) by m0089730.ppops.net with ESMTP id 3bx4gdrd8m-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 25 Oct 2021 15:33:49 -0700 Received: from intmgw001.27.prn2.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:82::d) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.14; Mon, 25 Oct 2021 15:33:48 -0700 Received: by devvm2661.vll0.facebook.com (Postfix, from userid 200310) id 3C5755DB8D3E; Mon, 25 Oct 2021 15:33:46 -0700 (PDT) From: Yucong Sun To: CC: , Yucong Sun Subject: [PATCH bpf-next 2/4] selftests/bpf: print subtest status line Date: Mon, 25 Oct 2021 15:33:43 -0700 Message-ID: <20211025223345.2136168-3-fallentree@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211025223345.2136168-1-fallentree@fb.com> References: <20211025223345.2136168-1-fallentree@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-FB-Source: Intern X-Proofpoint-ORIG-GUID: jQO57CmlbyWjyD6WBq98nm5vWjxAVfBN X-Proofpoint-GUID: jQO57CmlbyWjyD6WBq98nm5vWjxAVfBN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-10-25_07,2021-10-25_02,2020-04-07_01 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 bulkscore=0 malwarescore=0 impostorscore=0 spamscore=0 clxscore=1015 mlxscore=0 suspectscore=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2110250127 X-FB-Internal: deliver Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net From: Yucong Sun This patch restores behavior that prints one status line for each subtest executed. It works in both serial mode and parallel mode, and all verbosity settings. The logic around IO hijacking could use some more simplification in the future. Signed-off-by: Yucong Sun --- tools/testing/selftests/bpf/test_progs.c | 56 +++++++++++++++++++----- tools/testing/selftests/bpf/test_progs.h | 4 ++ 2 files changed, 50 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c index 1f4a48566991..ff4598126f9d 100644 --- a/tools/testing/selftests/bpf/test_progs.c +++ b/tools/testing/selftests/bpf/test_progs.c @@ -100,6 +100,18 @@ static bool should_run(struct test_selector *sel, int num, const char *name) return num < sel->num_set_len && sel->num_set[num]; } +static void dump_subtest_status(bool display) { + fflush(env.subtest_status_fd); + if (display) { + if (env.subtest_status_cnt) { + env.subtest_status_buf[env.subtest_status_cnt] = '\0'; + fputs(env.subtest_status_buf, stdout); + } + } + rewind(env.subtest_status_fd); + fflush(env.subtest_status_fd); +} + static void dump_test_log(const struct prog_test_def *test, bool failed) { if (stdout == env.stdout) @@ -112,12 +124,17 @@ static void dump_test_log(const struct prog_test_def *test, bool failed) fflush(stdout); /* exports env.log_buf & env.log_cnt */ if (env.verbosity > VERBOSE_NONE || test->force_log || failed) { - if (env.log_cnt) { - env.log_buf[env.log_cnt] = '\0'; - fprintf(env.stdout, "%s", env.log_buf); - if (env.log_buf[env.log_cnt - 1] != '\n') - fprintf(env.stdout, "\n"); - } + dump_subtest_status(false); + } else { + rewind(stdout); + dump_subtest_status(true); + fflush(stdout); + } + if (env.log_cnt) { + env.log_buf[env.log_cnt] = '\0'; + fprintf(env.stdout, "%s", env.log_buf); + if (env.log_buf[env.log_cnt - 1] != '\n') + fprintf(env.stdout, "\n"); } } @@ -183,7 +200,12 @@ void test__end_subtest(void) dump_test_log(test, sub_error_cnt); + // Print two copies here, one as part of full logs, another one will + // only be used if there is no need to show full logs. fprintf(stdout, "#%d/%d %s/%s:%s\n", + test->test_num, test->subtest_num, test->test_name, test->subtest_name, + sub_error_cnt ? "FAIL" : (test->skip_cnt ? "SKIP" : "OK")); + fprintf(env.subtest_status_fd, "#%d/%d %s/%s:%s\n", test->test_num, test->subtest_num, test->test_name, test->subtest_name, sub_error_cnt ? "FAIL" : (test->skip_cnt ? "SKIP" : "OK")); @@ -1250,6 +1272,15 @@ static int worker_main(int sock) run_one_test(test_to_run); + // discard logs if we don't need them + if (env.verbosity > VERBOSE_NONE || test->force_log || test->error_cnt) { + dump_subtest_status(false); + } else { + rewind(stdout); + dump_subtest_status(true); + fflush(stdout); + } + stdio_restore(); memset(&msg_done, 0, sizeof(msg_done)); @@ -1260,10 +1291,9 @@ static int worker_main(int sock) msg_done.test_done.sub_succ_cnt = test->sub_succ_cnt; msg_done.test_done.have_log = false; - if (env.verbosity > VERBOSE_NONE || test->force_log || test->error_cnt) { - if (env.log_cnt) - msg_done.test_done.have_log = true; - } + if (env.log_cnt) + msg_done.test_done.have_log = true; + if (send_message(sock, &msg_done) < 0) { perror("Fail to send message done"); goto out; @@ -1357,6 +1387,12 @@ int main(int argc, char **argv) env.stdout = stdout; env.stderr = stderr; + env.subtest_status_fd = open_memstream( + &env.subtest_status_buf, &env.subtest_status_cnt); + if (!env.subtest_status_fd) { + perror("Failed to setup env.subtest_status_fd"); + exit(EXIT_ERR_SETUP_INFRA); + } env.has_testmod = true; if (!env.list_test_names && load_bpf_testmod()) { diff --git a/tools/testing/selftests/bpf/test_progs.h b/tools/testing/selftests/bpf/test_progs.h index 93c1ff705533..a564215a63b1 100644 --- a/tools/testing/selftests/bpf/test_progs.h +++ b/tools/testing/selftests/bpf/test_progs.h @@ -89,6 +89,10 @@ struct test_env { pid_t *worker_pids; /* array of worker pids */ int *worker_socks; /* array of worker socks */ int *worker_current_test; /* array of current running test for each worker */ + + FILE* subtest_status_fd; /* fd for printing status line for subtests */ + char *subtest_status_buf; /* buffer for subtests status */ + size_t subtest_status_cnt; }; #define MAX_LOG_TRUNK_SIZE 8192 From patchwork Mon Oct 25 22:33:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yucong Sun X-Patchwork-Id: 12583113 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1368AC433FE for ; Mon, 25 Oct 2021 22:34:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EBD366103C for ; Mon, 25 Oct 2021 22:34:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234097AbhJYWgV (ORCPT ); Mon, 25 Oct 2021 18:36:21 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:19136 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234062AbhJYWgR (ORCPT ); Mon, 25 Oct 2021 18:36:17 -0400 Received: from pps.filterd (m0109333.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19PMGOX3032442 for ; Mon, 25 Oct 2021 15:33:55 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=jJr/4bFptm4EtxMcaSxtaJp8UT8C+DrSPhikIZhImmQ=; b=WBtf8i2xDIo6LNZp7kzpoefg9Bk3Yzj7gzQPWVw3N2lsjYJLSoSa4oUl7CcmoqFfoNWH R44j/AcU7CGHG1RQ3gmEeWqcOCIbQFNl4nu0amaR9jGpHxj1a1YFrDFSdo2ffAyVrGEw cfIc9R1IqgEy19/rIO2OF6VBsiGhofdeme0= Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com with ESMTP id 3bx4e7gef1-9 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 25 Oct 2021 15:33:54 -0700 Received: from intmgw001.37.frc1.facebook.com (2620:10d:c085:108::4) by mail.thefacebook.com (2620:10d:c085:11d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.14; Mon, 25 Oct 2021 15:33:53 -0700 Received: by devvm2661.vll0.facebook.com (Postfix, from userid 200310) id 414BB5DB8D40; Mon, 25 Oct 2021 15:33:46 -0700 (PDT) From: Yucong Sun To: CC: , Yucong Sun Subject: [PATCH bpf-next 3/4] selftests/bpf: fix attach_probe in parallel mode Date: Mon, 25 Oct 2021 15:33:44 -0700 Message-ID: <20211025223345.2136168-4-fallentree@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211025223345.2136168-1-fallentree@fb.com> References: <20211025223345.2136168-1-fallentree@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-FB-Source: Intern X-Proofpoint-GUID: qwcA43GAWgPo1EiWdMk7rMXz5sbr1KfK X-Proofpoint-ORIG-GUID: qwcA43GAWgPo1EiWdMk7rMXz5sbr1KfK X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-10-25_07,2021-10-25_02,2020-04-07_01 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 malwarescore=0 clxscore=1015 mlxscore=0 spamscore=0 lowpriorityscore=0 mlxlogscore=399 phishscore=0 impostorscore=0 suspectscore=0 priorityscore=1501 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2110250127 X-FB-Internal: deliver Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net From: Yucong Sun This patch makes attach_probe uses its own method as attach point, avoiding conflict with other tests like bpf_cookie. Signed-off-by: Yucong Sun --- tools/testing/selftests/bpf/prog_tests/attach_probe.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/attach_probe.c b/tools/testing/selftests/bpf/prog_tests/attach_probe.c index 6c511dcd1465..d0bd51eb23c8 100644 --- a/tools/testing/selftests/bpf/prog_tests/attach_probe.c +++ b/tools/testing/selftests/bpf/prog_tests/attach_probe.c @@ -5,6 +5,11 @@ /* this is how USDT semaphore is actually defined, except volatile modifier */ volatile unsigned short uprobe_ref_ctr __attribute__((unused)) __attribute((section(".probes"))); +/* attach point */ +static void method(void) { + return ; +} + void test_attach_probe(void) { DECLARE_LIBBPF_OPTS(bpf_uprobe_opts, uprobe_opts); @@ -33,7 +38,7 @@ void test_attach_probe(void) if (CHECK(base_addr < 0, "get_base_addr", "failed to find base addr: %zd", base_addr)) return; - uprobe_offset = get_uprobe_offset(&get_base_addr, base_addr); + uprobe_offset = get_uprobe_offset(&method, base_addr); ref_ctr_offset = get_rel_offset((uintptr_t)&uprobe_ref_ctr); if (!ASSERT_GE(ref_ctr_offset, 0, "ref_ctr_offset")) @@ -98,7 +103,7 @@ void test_attach_probe(void) goto cleanup; /* trigger & validate uprobe & uretprobe */ - get_base_addr(); + method(); if (CHECK(skel->bss->uprobe_res != 3, "check_uprobe_res", "wrong uprobe res: %d\n", skel->bss->uprobe_res)) From patchwork Mon Oct 25 22:33:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yucong Sun X-Patchwork-Id: 12583115 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 25E4FC433F5 for ; Mon, 25 Oct 2021 22:34:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0557D61076 for ; Mon, 25 Oct 2021 22:34:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234062AbhJYWgW (ORCPT ); Mon, 25 Oct 2021 18:36:22 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:42304 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234081AbhJYWgS (ORCPT ); Mon, 25 Oct 2021 18:36:18 -0400 Received: from pps.filterd (m0148460.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19PMGN53017421 for ; Mon, 25 Oct 2021 15:33:55 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=GmHJvVFnYPy8bDSSsfkhkG78X1TVj5lywJ8XWxYSoxA=; b=aiRVRmcIZAxWwaI5GUMXtnx4aUy6lbqwukAW63wO9C3tE8cxfOcbT74XAPJh1R0vZtr8 9aeAEhuIzW8gwh5fpheN9XJGLXanqdUK2xtjgoshqJ97+ZYwsedDATkfZHS1TwPJ7shQ qo9pXNpvSGazee6xmtypR6sA/PNbyDOFnhg= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com with ESMTP id 3bx4gn8dc3-10 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 25 Oct 2021 15:33:55 -0700 Received: from intmgw001.25.frc3.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:83::4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.14; Mon, 25 Oct 2021 15:33:52 -0700 Received: by devvm2661.vll0.facebook.com (Postfix, from userid 200310) id 468985DB8D42; Mon, 25 Oct 2021 15:33:46 -0700 (PDT) From: Yucong Sun To: CC: , Yucong Sun Subject: [PATCH bpf-next 4/4] selftests/bpf: adding a namespace reset for tc_redirect Date: Mon, 25 Oct 2021 15:33:45 -0700 Message-ID: <20211025223345.2136168-5-fallentree@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211025223345.2136168-1-fallentree@fb.com> References: <20211025223345.2136168-1-fallentree@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-FB-Source: Intern X-Proofpoint-GUID: kB11SCJ3F9LkEuIvdVj22kTAnNe2ynhK X-Proofpoint-ORIG-GUID: kB11SCJ3F9LkEuIvdVj22kTAnNe2ynhK X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-10-25_07,2021-10-25_02,2020-04-07_01 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 mlxscore=0 lowpriorityscore=0 malwarescore=0 mlxlogscore=924 phishscore=0 adultscore=0 bulkscore=0 impostorscore=0 spamscore=0 priorityscore=1501 suspectscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2110250127 X-FB-Internal: deliver Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net From: Yucong Sun This patch delete ns_src/ns_dst/ns_redir namespaces before recreating them, making the test more robust. Signed-off-by: Yucong Sun --- .../testing/selftests/bpf/prog_tests/tc_redirect.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tools/testing/selftests/bpf/prog_tests/tc_redirect.c b/tools/testing/selftests/bpf/prog_tests/tc_redirect.c index 53672634bc52..4b18b73df10b 100644 --- a/tools/testing/selftests/bpf/prog_tests/tc_redirect.c +++ b/tools/testing/selftests/bpf/prog_tests/tc_redirect.c @@ -176,6 +176,18 @@ static int netns_setup_namespaces(const char *verb) return 0; } +static void netns_setup_namespaces_nofail(const char *verb) +{ + const char * const *ns = namespaces; + char cmd[128]; + + while (*ns) { + snprintf(cmd, sizeof(cmd), "ip netns %s %s > /dev/null 2>&1", verb, *ns); + system(cmd); + ns++; + } +} + struct netns_setup_result { int ifindex_veth_src_fwd; int ifindex_veth_dst_fwd; @@ -762,6 +774,8 @@ static void test_tc_redirect_peer_l3(struct netns_setup_result *setup_result) static void *test_tc_redirect_run_tests(void *arg) { + netns_setup_namespaces_nofail("delete"); + RUN_TEST(tc_redirect_peer); RUN_TEST(tc_redirect_peer_l3); RUN_TEST(tc_redirect_neigh);