From patchwork Thu Jan 23 16:59:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenz Bauer X-Patchwork-Id: 208892 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11972C33CB6 for ; Thu, 23 Jan 2020 16:59:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DC6BD21D7E for ; Thu, 23 Jan 2020 16:59:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=cloudflare.com header.i=@cloudflare.com header.b="ZBYiAK31" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729751AbgAWQ7o (ORCPT ); Thu, 23 Jan 2020 11:59:44 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:45597 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729727AbgAWQ7n (ORCPT ); Thu, 23 Jan 2020 11:59:43 -0500 Received: by mail-wr1-f65.google.com with SMTP id j42so3864631wrj.12 for ; Thu, 23 Jan 2020 08:59:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=U8uUo0eaJeKJ0jdbXMjf43VAJdQstWVWgqdI6CSzlSg=; b=ZBYiAK31WOO0xPmTOkUDOEZRtghl3RzdtoEptjudCjV2kUxmHW05di8KVWAHgyu0/k 1c8+KarUAPRv3AsK6adDHyUV2PPufffkYjy3iJkmEWZXLA2oquozbnezzeKzB9fVTCNp p0mcdJ74lP9u+fQLEDxTO47ildJS+I5mltKtE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=U8uUo0eaJeKJ0jdbXMjf43VAJdQstWVWgqdI6CSzlSg=; b=mCTm3YRmyGl3W9IOx/ZrismkWx/c325btwFwtWTbKBPuds7DaIvCnTaIj2eFweB5qE hQQRF1LyAVQW6lgqn9oCJYRplPCsdNeCkpU/kmU3ieHPtg7nPem8jeBZ/Ad7AF6xuyOu Ydv6i6wXA6LcKqEIk0VyJ2bOjj8+8xlLQ/UWYnKihafwF0qzUaDP3I0MNopVyaVRXy7H iy22X6MxSbjPZuaK5lZCb83ZUzCYDa+24tKsnbZvii5/34yQE6huPl+/YTzeeOtKCs2B fQkz1y4OItPEFUSg2yQ6HCr4UleWsK2wYpeien5CiOxkq2T5XYE6x3jS+5uEhQtoXz1E kRng== X-Gm-Message-State: APjAAAUUJg2CWEKsPLOcBZ6BOQNMdnOa46uX7mpQp8kXn2hJ+Y0tWndJ FnXhp7picNm5k1gzTcsdbQriWwyuL1VetQ== X-Google-Smtp-Source: APXvYqztXSSZ2nYGIIOXGCU19AzvGz7ltbdVZS6Ad/z/XL7I6uqOCN+zAkxKcPOoy0Q+UnAyTkUoDA== X-Received: by 2002:a5d:6652:: with SMTP id f18mr19175902wrw.246.1579798781846; Thu, 23 Jan 2020 08:59:41 -0800 (PST) Received: from localhost.localdomain ([2a06:98c0:1000:8250:d0a9:6cca:1210:a574]) by smtp.gmail.com with ESMTPSA id u1sm3217698wmc.5.2020.01.23.08.59.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2020 08:59:40 -0800 (PST) From: Lorenz Bauer To: Shuah Khan , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko Cc: Lorenz Bauer , linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf 1/4] selftests: bpf: use a temporary file in test_sockmap Date: Thu, 23 Jan 2020 16:59:30 +0000 Message-Id: <20200123165934.9584-2-lmb@cloudflare.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200123165934.9584-1-lmb@cloudflare.com> References: <20200123165934.9584-1-lmb@cloudflare.com> MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Use a proper temporary file for sendpage tests. This means that running the tests doesn't clutter the working directory, and allows running the test on read-only filesystems. Signed-off-by: Lorenz Bauer --- tools/testing/selftests/bpf/test_sockmap.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/bpf/test_sockmap.c b/tools/testing/selftests/bpf/test_sockmap.c index 4a851513c842..779e11da979c 100644 --- a/tools/testing/selftests/bpf/test_sockmap.c +++ b/tools/testing/selftests/bpf/test_sockmap.c @@ -331,7 +331,7 @@ static int msg_loop_sendpage(int fd, int iov_length, int cnt, FILE *file; int i, fp; - file = fopen(".sendpage_tst.tmp", "w+"); + file = tmpfile(); if (!file) { perror("create file for sendpage"); return 1; @@ -340,13 +340,8 @@ static int msg_loop_sendpage(int fd, int iov_length, int cnt, fwrite(&k, sizeof(char), 1, file); fflush(file); fseek(file, 0, SEEK_SET); - fclose(file); - fp = open(".sendpage_tst.tmp", O_RDONLY); - if (fp < 0) { - perror("reopen file for sendpage"); - return 1; - } + fp = fileno(file); clock_gettime(CLOCK_MONOTONIC, &s->start); for (i = 0; i < cnt; i++) { @@ -354,11 +349,11 @@ static int msg_loop_sendpage(int fd, int iov_length, int cnt, if (!drop && sent < 0) { perror("send loop error"); - close(fp); + fclose(file); return sent; } else if (drop && sent >= 0) { printf("sendpage loop error expected: %i\n", sent); - close(fp); + fclose(file); return -EIO; } @@ -366,7 +361,7 @@ static int msg_loop_sendpage(int fd, int iov_length, int cnt, s->bytes_sent += sent; } clock_gettime(CLOCK_MONOTONIC, &s->end); - close(fp); + fclose(file); return 0; } From patchwork Fri Jan 24 11:27:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenz Bauer X-Patchwork-Id: 208881 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 480DCC2D0DB for ; Fri, 24 Jan 2020 11:38:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1E39020708 for ; Fri, 24 Jan 2020 11:38:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=cloudflare.com header.i=@cloudflare.com header.b="wyPpvX1o" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731637AbgAXLiP (ORCPT ); Fri, 24 Jan 2020 06:38:15 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:36478 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389526AbgAXL34 (ORCPT ); Fri, 24 Jan 2020 06:29:56 -0500 Received: by mail-wr1-f67.google.com with SMTP id z3so1565643wru.3 for ; Fri, 24 Jan 2020 03:29:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=23V7V0bQTVhkXPFpZHbr/dpA6QXlskc4s7MHHF/kg3o=; b=wyPpvX1on05Qgb1oTJUYHbUJNqNJVywXnK+eYc/CEFlZ+FYyxqBTorCIgNRAatuedc 1WogFxqm4Rx0i8D0wQaMEkYW3ZxpGbv9QkI8SDAT6ozhh49OB2EEr2X39omSbAaz9zvK y9U+UJQby0rEgCppiEyU3ntbK9vAInHyG7GO4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=23V7V0bQTVhkXPFpZHbr/dpA6QXlskc4s7MHHF/kg3o=; b=amws2UlKOJkcytTc4n/fSRb0nev+5ZlKHz+GEFH+pVWa4FknV+qhnPp2HkFe5R8lt2 gMqCcBSbWAfZhryiHcV/5SYg/YeBbpWlHLgBcn/2LzUy+hC4viy3ehNBtjVIShNiBww1 5g3Da9269A+HbY2DoJfkCWF/SpwhrGri7FeM7LOSI0IjMTKuzuaZqqrh4EaFWO2rqE43 +c0cxmISY4Mv8N2A0sQDCwa82/W256rciHbfPFLDMCumGhg/c2uAhyN6JlKQ9tPIUewf X3F9kYUL827yMuDpc0SGMUvAhuKl0lANF4FX5flUV3qIadWkMfhOS0IKANqpeLze5NEC 0uUA== X-Gm-Message-State: APjAAAW0/WfSM0jIX+13WwcNCqS8k0r+pMHLo4xnVCS6fUsRcGLbWcKA hs5aAl8M2iyt/BKEaNTNbsTkdg== X-Google-Smtp-Source: APXvYqxR4PnKJm5OXMmu+YwHZ8oajyip6nFIy5+fZ9y6nFyYA1+taQrddJKco673nEo5N8RV5VfLpA== X-Received: by 2002:adf:9144:: with SMTP id j62mr3863056wrj.168.1579865394173; Fri, 24 Jan 2020 03:29:54 -0800 (PST) Received: from antares.lan (3.a.c.b.c.e.9.a.8.e.c.d.e.4.1.6.f.f.6.2.a.5.a.7.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:7a5a:26ff:614e:dce8:a9ec:bca3]) by smtp.gmail.com with ESMTPSA id n189sm6808688wme.33.2020.01.24.03.29.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jan 2020 03:29:53 -0800 (PST) From: Lorenz Bauer To: Shuah Khan , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko Cc: Lorenz Bauer , linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf-next v2 2/4] selftests: bpf: ignore FIN packets for reuseport tests Date: Fri, 24 Jan 2020 11:27:52 +0000 Message-Id: <20200124112754.19664-3-lmb@cloudflare.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200124112754.19664-1-lmb@cloudflare.com> References: <20200123165934.9584-1-lmb@cloudflare.com> <20200124112754.19664-1-lmb@cloudflare.com> MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org The reuseport tests currently suffer from a race condition: FIN packets count towards DROP_ERR_SKB_DATA, since they don't contain a valid struct cmd. Tests will spuriously fail depending on whether check_results is called before or after the FIN is processed. Exit the BPF program early if FIN is set. Signed-off-by: Lorenz Bauer Fixes: 91134d849a0e ("bpf: Test BPF_PROG_TYPE_SK_REUSEPORT") --- .../selftests/bpf/progs/test_select_reuseport_kern.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/testing/selftests/bpf/progs/test_select_reuseport_kern.c b/tools/testing/selftests/bpf/progs/test_select_reuseport_kern.c index d69a1f2bbbfd..26e77dcc7e91 100644 --- a/tools/testing/selftests/bpf/progs/test_select_reuseport_kern.c +++ b/tools/testing/selftests/bpf/progs/test_select_reuseport_kern.c @@ -113,6 +113,12 @@ int _select_by_skb_data(struct sk_reuseport_md *reuse_md) data_check.skb_ports[0] = th->source; data_check.skb_ports[1] = th->dest; + if (th->fin) + /* The connection is being torn down at the end of a + * test. It can't contain a cmd, so return early. + */ + return SK_PASS; + if ((th->doff << 2) + sizeof(*cmd) > data_check.len) GOTO_DONE(DROP_ERR_SKB_DATA); if (bpf_skb_load_bytes(reuse_md, th->doff << 2, &cmd_copy, From patchwork Fri Jan 24 11:27:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenz Bauer X-Patchwork-Id: 208882 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2618C32771 for ; Fri, 24 Jan 2020 11:38:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8946120708 for ; Fri, 24 Jan 2020 11:38:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=cloudflare.com header.i=@cloudflare.com header.b="iljVGTV1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391978AbgAXLiI (ORCPT ); Fri, 24 Jan 2020 06:38:08 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:54379 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391846AbgAXL35 (ORCPT ); Fri, 24 Jan 2020 06:29:57 -0500 Received: by mail-wm1-f68.google.com with SMTP id g1so1281341wmh.4 for ; Fri, 24 Jan 2020 03:29:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=smQgb7OTV4+v464Eh5cc5iALcZWmuJ7KE4TsJ4XSwN0=; b=iljVGTV1W2UYOROZJjXL2BxExKTYltjH3RaXZgCT13fFOm+Nx1p1W/EGg/MHPiN123 Y/fZoxx0KKrnFOrhiFtN23VntLi2zzgiJv8qGtINNs6LfVaD6TObjxAWKjjZjHKldcjL 6oghRAaotdWG00W3x+PMzNjFhFogTKlxzTHpw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=smQgb7OTV4+v464Eh5cc5iALcZWmuJ7KE4TsJ4XSwN0=; b=f6m6FUCceNEoZcZaLBEbO5fLkvmOjFvcp8JLXegwDF3usNhw3uoKPH48aI8w31HVGA JydMzv61S9OPi8BkN+r5wc8bXkpDalJ2u+zGIFUNiJU31CxnQZcUu/kV5OdTtOTjM//b ShvwCQ/8h2WIw8/HQO+7fEhB0lxkwBjIS2eqmi5GjRpCzRuL4pd2Xm7dm58TikbN8mDw CNvYCXoVUWjLvaU4w9/rb2XpyZFGPoiyynC+TnwoiAABjH49KNEBLpFokImZwEUNiRV+ Hl50qAUScXASAVz6snIHTwJr0Y+2EulWGPEFcm7hGmB/31YQh08vXNJ3ZmN1Rzz0g0B8 m9mg== X-Gm-Message-State: APjAAAXgaCxj6qrU+xfinRfJsBKxkh59Xb+57PiQK8nflxE+wv7s3uC+ 6hhA/i2zodw0b6f+RKffDL0Fzw== X-Google-Smtp-Source: APXvYqzBfQGrlE8ATwQ4rMxw2LQnHJD+IP5+yBioiZsrDvhY5hZKhMjpzp6Bd8H8znTSi5coAdlQTg== X-Received: by 2002:a7b:cb91:: with SMTP id m17mr2777626wmi.146.1579865395785; Fri, 24 Jan 2020 03:29:55 -0800 (PST) Received: from antares.lan (3.a.c.b.c.e.9.a.8.e.c.d.e.4.1.6.f.f.6.2.a.5.a.7.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:7a5a:26ff:614e:dce8:a9ec:bca3]) by smtp.gmail.com with ESMTPSA id n189sm6808688wme.33.2020.01.24.03.29.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jan 2020 03:29:55 -0800 (PST) From: Lorenz Bauer To: Shuah Khan , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko Cc: Lorenz Bauer , linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf-next v2 3/4] selftests: bpf: make reuseport test output more legible Date: Fri, 24 Jan 2020 11:27:53 +0000 Message-Id: <20200124112754.19664-4-lmb@cloudflare.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200124112754.19664-1-lmb@cloudflare.com> References: <20200123165934.9584-1-lmb@cloudflare.com> <20200124112754.19664-1-lmb@cloudflare.com> MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Include the name of the mismatching result in human readable format when reporting an error. The new output looks like the following: unexpected result result: [1, 0, 0, 0, 0, 0] expected: [0, 0, 0, 0, 0, 0] mismatch on DROP_ERR_INNER_MAP (bpf_prog_linum:153) check_results:FAIL:382 Signed-off-by: Lorenz Bauer --- .../bpf/prog_tests/select_reuseport.c | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/select_reuseport.c b/tools/testing/selftests/bpf/prog_tests/select_reuseport.c index 2c37ae7dc214..e7e56929751c 100644 --- a/tools/testing/selftests/bpf/prog_tests/select_reuseport.c +++ b/tools/testing/selftests/bpf/prog_tests/select_reuseport.c @@ -316,6 +316,26 @@ static void check_data(int type, sa_family_t family, const struct cmd *cmd, expected.len, result.len, get_linum()); } +static const char *result_to_str(enum result res) +{ + switch (res) { + case DROP_ERR_INNER_MAP: + return "DROP_ERR_INNER_MAP"; + case DROP_ERR_SKB_DATA: + return "DROP_ERR_SKB_DATA"; + case DROP_ERR_SK_SELECT_REUSEPORT: + return "DROP_ERR_SK_SELECT_REUSEPORT"; + case DROP_MISC: + return "DROP_MISC"; + case PASS: + return "PASS"; + case PASS_ERR_SK_SELECT_REUSEPORT: + return "PASS_ERR_SK_SELECT_REUSEPORT"; + default: + return "UNKNOWN"; + } +} + static void check_results(void) { __u32 results[NR_RESULTS]; @@ -351,10 +371,10 @@ static void check_results(void) printf(", %u", expected_results[i]); printf("]\n"); - RET_IF(expected_results[broken] != results[broken], - "unexpected result", - "expected_results[%u] != results[%u] bpf_prog_linum:%ld\n", - broken, broken, get_linum()); + printf("mismatch on %s (bpf_prog_linum:%ld)\n", result_to_str(broken), + get_linum()); + + CHECK_FAIL(true); } static int send_data(int type, sa_family_t family, void *data, size_t len, From patchwork Thu Jan 23 16:59:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenz Bauer X-Patchwork-Id: 208891 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B506EC2D0DB for ; Thu, 23 Jan 2020 16:59:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8CBF424687 for ; Thu, 23 Jan 2020 16:59:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=cloudflare.com header.i=@cloudflare.com header.b="rmcV1F+u" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729838AbgAWQ7y (ORCPT ); Thu, 23 Jan 2020 11:59:54 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:41350 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729774AbgAWQ7t (ORCPT ); Thu, 23 Jan 2020 11:59:49 -0500 Received: by mail-wr1-f65.google.com with SMTP id c9so3897925wrw.8 for ; Thu, 23 Jan 2020 08:59:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lzJSOoo0RY3SkOVg99jXaD0hCIShOjvh87S5WEoUKHA=; b=rmcV1F+uEgQl1C9Bw8jxZiHVIX5+T5T3sxYSgR7I6GG/JUWe0M8tWN2DUqqzWdoYgX N2B0KivXpJcrI72myxxmd5mlC6uuOjeJuGV48CFZb+1C4xJ7slk65KxrEZJDZHcr+vJB gTkFp0ARrz5plhGXPSwjmnDPxsDwOS9CKDuE8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lzJSOoo0RY3SkOVg99jXaD0hCIShOjvh87S5WEoUKHA=; b=AM7LW5YZRoVePNJz/aZp9eG/sE0GVH41TLo4OMW6LU0TDT+w7iwzCFxHBGXgqLSovo uk01sPq6fhc/4egtekSmo89eeWtPSlGToY3LKIkwqgyhmQiSOEM3p1soJJOU13H4irkj c4l5OHs6YJ7DZ5Tw/NzeEW4xxylThAZLYXPkf1RVhRkvkuXhELVhg7E26AUHNVbRXEIu jHZ0AltQUnFk5s/kX+j6n/DDnMjki8qJ68lNkv4QRuqtnAn4EnkDJFh1c4tMRWP9hi7c 6OSUN3ZlXcFDvifKdmV/ot09VGnGW2Gkm/awPvQ29rtYWxLfJC0UAOAkhFSgb6PmI9lc oWkw== X-Gm-Message-State: APjAAAXaRCRERg95mIbsAeo8ILUj2fVqsMjrDjqumDXT/LWPBjdX68Fy THIS16o2IuomLrFJ8xuQ2rQm1vuzBGIZUA== X-Google-Smtp-Source: APXvYqznD+zC0q/A4MhGzomvxakH4li9R6cnks1twXRbQNsnspUm7dxAarVtPVqc3Z3Kl1zIo2bzig== X-Received: by 2002:adf:fc03:: with SMTP id i3mr18956626wrr.306.1579798787004; Thu, 23 Jan 2020 08:59:47 -0800 (PST) Received: from localhost.localdomain ([2a06:98c0:1000:8250:d0a9:6cca:1210:a574]) by smtp.gmail.com with ESMTPSA id u1sm3217698wmc.5.2020.01.23.08.59.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2020 08:59:46 -0800 (PST) From: Lorenz Bauer To: Shuah Khan , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko Cc: Lorenz Bauer , linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf 4/4] selftests: bpf: reset global state between reuseport test runs Date: Thu, 23 Jan 2020 16:59:33 +0000 Message-Id: <20200123165934.9584-5-lmb@cloudflare.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200123165934.9584-1-lmb@cloudflare.com> References: <20200123165934.9584-1-lmb@cloudflare.com> MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Currently, there is a lot of false positives if a single reuseport test fails. This is because expected_results and the result map are not cleared. Zero both after individual test runs, which fixes the mentioned false positives. Signed-off-by: Lorenz Bauer --- .../selftests/bpf/prog_tests/select_reuseport.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/prog_tests/select_reuseport.c b/tools/testing/selftests/bpf/prog_tests/select_reuseport.c index 09a536af139a..0bab8b1ca1c3 100644 --- a/tools/testing/selftests/bpf/prog_tests/select_reuseport.c +++ b/tools/testing/selftests/bpf/prog_tests/select_reuseport.c @@ -699,7 +699,19 @@ static void setup_per_test(int type, sa_family_t family, bool inany, static void cleanup_per_test(bool no_inner_map) { - int i, err; + int i, err, zero = 0; + + memset(expected_results, 0, sizeof(expected_results)); + + for (i = 0; i < NR_RESULTS; i++) { + err = bpf_map_update_elem(result_map, &i, &zero, BPF_ANY); + RET_IF(err, "reset elem in result_map", + "i:%u err:%d errno:%d\n", i, err, errno); + } + + err = bpf_map_update_elem(linum_map, &zero, &zero, BPF_ANY); + RET_IF(err, "reset line number in linum_map", "err:%d errno:%d\n", + err, errno); for (i = 0; i < REUSEPORT_ARRAY_SIZE; i++) close(sk_fds[i]);