From patchwork Mon Feb 24 13:53:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 1243101 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=cloudflare.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=cloudflare.com header.i=@cloudflare.com header.a=rsa-sha256 header.s=google header.b=vb8eMTfQ; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 48R3SF2KtLz9sR4 for ; Tue, 25 Feb 2020 00:53:33 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727506AbgBXNxb (ORCPT ); Mon, 24 Feb 2020 08:53:31 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:39884 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727359AbgBXNxb (ORCPT ); Mon, 24 Feb 2020 08:53:31 -0500 Received: by mail-wr1-f67.google.com with SMTP id y17so1670936wrn.6 for ; Mon, 24 Feb 2020 05:53:29 -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:mime-version :content-transfer-encoding; bh=mZSTwWAn3t7JMXjmqAY0yMV0jtle3ljPKptSRmgEMBQ=; b=vb8eMTfQd/zoi8WrDi71FZ2v6JZkFmV3Sc538G8bxxFQlaRoPjFfEIRq8nXAwetMSG +VyLAfQF4LfhnF3R5Ga/v/enjri7SyAos417Jv3iLSlpBtQkmMkexZG60HP6IfIVLd4C RGcZOSDen7mpl0lwtqVhu6G0psS0JH5xjs4Do= 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:mime-version :content-transfer-encoding; bh=mZSTwWAn3t7JMXjmqAY0yMV0jtle3ljPKptSRmgEMBQ=; b=BW50xZ3SpFG0AB5L7Eky96RmDErd1Zhons2kxoBip5QutmT03B6yHCuBdA8bJcYT2J 5xVyZWsh73X7G4N+xYbI8tF+jHOOlFB/I0Ohp5wt5iYh4jJhfF0bI6Frm6zBK/q2PxCT bZ/mbSm10oiBMUOIaCkvl9Ef/2HcnHFlwp2bYvhC+MxNVv0ugtVXMcQFn/xdSpGRzQEv 9w62tjBBpzC8qUwnwu2rE9YyCZR5i/oq2eQzRASIWSlGDY8MHbi49/rPBxgV0rW8y+xK Xw0p8vXdzDKehF1ECEZBVZmBhxk6+Qs/qwbtNBstTOojlJJmViFT1QbKCM1syD/wvpSf DFow== X-Gm-Message-State: APjAAAWIkCjE8WkMJUQFs9YrJO8J4sNg+4GaS6DaMH+OpUsARP28sels LVNJwIDktzHG3Rv3n2qrA9iL5g== X-Google-Smtp-Source: APXvYqxtkoKYrvf8qfuBJvz5l/Dmdxrh1+KyJUu5NMZEsGHY4OKX+7kMzmzEiUXhBXt/6mP5aFWmmw== X-Received: by 2002:adf:fa87:: with SMTP id h7mr70545877wrr.172.1582552409148; Mon, 24 Feb 2020 05:53:29 -0800 (PST) Received: from cloudflare.com ([176.221.114.230]) by smtp.gmail.com with ESMTPSA id k16sm19139203wru.0.2020.02.24.05.53.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Feb 2020 05:53:28 -0800 (PST) From: Jakub Sitnicki To: bpf@vger.kernel.org Cc: netdev@vger.kernel.org, kernel-team@cloudflare.com, Martin Lau , Alexei Starovoitov Subject: [PATCH bpf-next 1/2] selftests/bpf: Run reuseport tests only with supported socket types Date: Mon, 24 Feb 2020 14:53:26 +0100 Message-Id: <20200224135327.121542-1-jakub@cloudflare.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org SOCKMAP and SOCKHASH map types can be used with reuseport BPF programs but don't support yet storing UDP sockets. Instead of marking UDP tests with SOCK{MAP,HASH} as skipped, don't run them at all. Skipped test might signal that the test environment is not suitable for running the test, while in reality the functionality is not implemented in the kernel yet. Before: sh# ./test_progs -t select_reuseport … #40 select_reuseport:OK Summary: 1/126 PASSED, 30 SKIPPED, 0 FAILED After: sh# ./test_progs -t select_reuseport … #40 select_reuseport:OK Summary: 1/98 PASSED, 2 SKIPPED, 0 FAILED The remaining two skipped tests are SYN cookies tests, which will be addressed in the subsequent patch. Fixes: 11318ba8cafd ("selftests/bpf: Extend SK_REUSEPORT tests to cover SOCKMAP/SOCKHASH") Reported-by: Alexei Starovoitov Signed-off-by: Jakub Sitnicki Acked-by: Martin KaFai Lau --- .../selftests/bpf/prog_tests/select_reuseport.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/select_reuseport.c b/tools/testing/selftests/bpf/prog_tests/select_reuseport.c index 68d452bb9fd9..8c41d6d63fcf 100644 --- a/tools/testing/selftests/bpf/prog_tests/select_reuseport.c +++ b/tools/testing/selftests/bpf/prog_tests/select_reuseport.c @@ -807,6 +807,12 @@ static void test_config(int sotype, sa_family_t family, bool inany) char s[MAX_TEST_NAME]; const struct test *t; + /* SOCKMAP/SOCKHASH don't support UDP yet */ + if (sotype == SOCK_DGRAM && + (inner_map_type == BPF_MAP_TYPE_SOCKMAP || + inner_map_type == BPF_MAP_TYPE_SOCKHASH)) + return; + for (t = tests; t < tests + ARRAY_SIZE(tests); t++) { snprintf(s, sizeof(s), "%s %s/%s %s %s", maptype_str(inner_map_type), @@ -816,13 +822,6 @@ static void test_config(int sotype, sa_family_t family, bool inany) if (!test__start_subtest(s)) continue; - if (sotype == SOCK_DGRAM && - inner_map_type != BPF_MAP_TYPE_REUSEPORT_SOCKARRAY) { - /* SOCKMAP/SOCKHASH don't support UDP yet */ - test__skip(); - continue; - } - setup_per_test(sotype, family, inany, t->no_inner_map); t->fn(sotype, family); cleanup_per_test(t->no_inner_map); From patchwork Mon Feb 24 13:53:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 1243103 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Original-To: incoming-bpf@patchwork.ozlabs.org Delivered-To: patchwork-incoming-bpf@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=bpf-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=cloudflare.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=cloudflare.com header.i=@cloudflare.com header.a=rsa-sha256 header.s=google header.b=OcxKrQaB; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 48R3SG1P2wz9sRR for ; Tue, 25 Feb 2020 00:53:34 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727521AbgBXNxd (ORCPT ); Mon, 24 Feb 2020 08:53:33 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:51014 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727426AbgBXNxc (ORCPT ); Mon, 24 Feb 2020 08:53:32 -0500 Received: by mail-wm1-f65.google.com with SMTP id a5so9052741wmb.0 for ; Mon, 24 Feb 2020 05:53:31 -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=vYUW0ZNGBWeZuF6KwJp8SDvklkk0aQruX2tUPqjtIgg=; b=OcxKrQaBataJHK+/J60O2wd7rJ6maecHKLZWLhQZr7J0ApjF/F40IoiVJGTDqyS7gy kO89U4c+Zk5Wwuot3Ksb6A2x3qYVZ41IqibxZT1jI9ZZUH3huXX+meb2piqST+jRAYhL adYmD+H7eQRbMwkLP8xTH7e4fHeE8qQjJy2Sc= 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=vYUW0ZNGBWeZuF6KwJp8SDvklkk0aQruX2tUPqjtIgg=; b=AGzhcoBRYPY4efeAMyjJQixsGNFx1Af6BmqQLQIjhj4bUUKRq/ZzqcfvfT4ZLatB+h pbh4hHRUcTxSkDNGPjMmBOAqBe0DiE3BKJWuPO4WXdQW6ihlWX5MJ4r6e9lU4kAS+GZx K2SHmsSGXh6vFa3oNA2mI4mfuDEd8Lrj+Q+HfoAxWUXVNDt2FwuiuuYsTjOufwaeK3jJ tQi1Gu+7AvFLTRMaYy1PJaRIVIhs4bGt7lvbZ4tITFgrsbwtWMEUIgy95WBkZ2mAQm8c w1n1GAoZ+Nj4zfD1g14MWRIImVmH8cK0iWmNLASzGn0agbY3XkG0U8y+zqDT5sVLFP0U PicQ== X-Gm-Message-State: APjAAAUv9hZ9UV8XmAcURewLVtSArFf37eqcVg5UwtUaAvPtLJ0rvmJc di2sGsofMRHJd/5VT85Y/ghUY9neN1lLWg== X-Google-Smtp-Source: APXvYqxH9LV1/+OStIpKupvzaveU+aM/4F3TrLISfj93gEotpmjZfbAMoEv5fJaahZ+H5JdTLQmzzw== X-Received: by 2002:a1c:b486:: with SMTP id d128mr22654203wmf.69.1582552410339; Mon, 24 Feb 2020 05:53:30 -0800 (PST) Received: from cloudflare.com ([176.221.114.230]) by smtp.gmail.com with ESMTPSA id t81sm18056530wmg.6.2020.02.24.05.53.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Feb 2020 05:53:30 -0800 (PST) From: Jakub Sitnicki To: bpf@vger.kernel.org Cc: netdev@vger.kernel.org, kernel-team@cloudflare.com, Martin Lau , Alexei Starovoitov Subject: [PATCH bpf-next 2/2] selftests/bpf: Run SYN cookies with reuseport BPF test only for TCP Date: Mon, 24 Feb 2020 14:53:27 +0100 Message-Id: <20200224135327.121542-2-jakub@cloudflare.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200224135327.121542-1-jakub@cloudflare.com> References: <20200224135327.121542-1-jakub@cloudflare.com> MIME-Version: 1.0 Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org Currently we run SYN cookies test for all socket types and mark the test as skipped if socket type is not compatible. This causes confusion because skipped test might indicate a problem with the testing environment. Instead, run the test only for the socket type which supports SYN cookies. Also, switch to using designated initializers when setting up tests, so that we can tweak only some test parameters, leaving the rest initialized to default values. Fixes: eecd618b4516 ("selftests/bpf: Mark SYN cookie test skipped for UDP sockets") Reported-by: Alexei Starovoitov Signed-off-by: Jakub Sitnicki Acked-by: Martin KaFai Lau --- .../selftests/bpf/prog_tests/select_reuseport.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/select_reuseport.c b/tools/testing/selftests/bpf/prog_tests/select_reuseport.c index 8c41d6d63fcf..a1dd13b34d4b 100644 --- a/tools/testing/selftests/bpf/prog_tests/select_reuseport.c +++ b/tools/testing/selftests/bpf/prog_tests/select_reuseport.c @@ -509,11 +509,6 @@ static void test_syncookie(int type, sa_family_t family) .pass_on_failure = 0, }; - if (type != SOCK_STREAM) { - test__skip(); - return; - } - /* * +1 for TCP-SYN and * +1 for the TCP-ACK (ack the syncookie) @@ -787,7 +782,7 @@ static const char *sotype_str(int sotype) } } -#define TEST_INIT(fn, ...) { fn, #fn, __VA_ARGS__ } +#define TEST_INIT(fn_, ...) { .fn = fn_, .name = #fn_, __VA_ARGS__ } static void test_config(int sotype, sa_family_t family, bool inany) { @@ -795,12 +790,15 @@ static void test_config(int sotype, sa_family_t family, bool inany) void (*fn)(int sotype, sa_family_t family); const char *name; bool no_inner_map; + int need_sotype; } tests[] = { - TEST_INIT(test_err_inner_map, true /* no_inner_map */), + TEST_INIT(test_err_inner_map, + .no_inner_map = true), TEST_INIT(test_err_skb_data), TEST_INIT(test_err_sk_select_port), TEST_INIT(test_pass), - TEST_INIT(test_syncookie), + TEST_INIT(test_syncookie, + .need_sotype = SOCK_STREAM), TEST_INIT(test_pass_on_err), TEST_INIT(test_detach_bpf), }; @@ -814,6 +812,9 @@ static void test_config(int sotype, sa_family_t family, bool inany) return; for (t = tests; t < tests + ARRAY_SIZE(tests); t++) { + if (t->need_sotype && t->need_sotype != sotype) + continue; /* test not compatible with socket type */ + snprintf(s, sizeof(s), "%s %s/%s %s %s", maptype_str(inner_map_type), family_str(family), sotype_str(sotype),