Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1705525pxb; Wed, 9 Feb 2022 02:42:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJwQ6d9i5RAN0HKjlPy8r/u51OOiIRKOBJBOEMsUOHUnZUe6RBUGDLA+0Cfpdw8CWpgWei23 X-Received: by 2002:a63:1466:: with SMTP id 38mr1380041pgu.141.1644403324462; Wed, 09 Feb 2022 02:42:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644403324; cv=none; d=google.com; s=arc-20160816; b=GCoerch4ymuGxyxRBH/ck2oikSiHc7cljtT5Eu10Gfq8yH8uHP2dbqvX9MEoy15bR+ yQPdss2sGHvF/O00Mw4MSHYk10P2HBI6QdSNIDuXaSbhHWbr8LjmtsM7+CtKjZTkZwro a0VCskoUGU1wsjNa4+C7gCzM0MfRhCUXYseEVmpyQYDLwKFN0josP5vyjP/dvjRxqfYU QUUT9Bs6puNm9LJTKorGQaFZd+DMubqWeDUvy6PujiVt5pVJZp/yqIcy2qgPhzZDWq/h +APsdL1VOa+KSaVmdKdQDpQQIt84GW1C3bDCLcDht2mKBQOCHGz8pBhRNhgaG1Yo4QP1 mhXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ej0vwsnnN+K4JjFDcQmrFPIjEPW4mf5zqdzpG02NH/E=; b=xeyxR3AGuqoQQGbzV4AFGj8gv2ljxkBLdl6kUUe3UQ7tQK3Mf4iiKdxnhkYwVGTEMb TmFWLesuv6DFfeMltt7SELYXxQzMlXZIxkPh9dcMbuE+TtoVlj1uw4SHkFTYOPhpOqcQ iG5cmFKEHSHvzD1gJOJlquWjlNlrcJCHznGfWVl9KIi78UhkKd0goq4QXARdi8gnmNUy GkuR8b1MvjvxuYzISvgw4LDHxtdiIKd9ceSqwqOq7GovqVumhspz+4ykkfMskHb4RlUv C7127mv0oMAWmnWM2GIoqIk7oQv5v1tkPrMK2npxOZuUZ6OMcvXXY5rr5sNc7koZ6541 YM4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lC37KSiN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id d127si15120895pgc.215.2022.02.09.02.42.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 02:42:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lC37KSiN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 329BDE056C15; Wed, 9 Feb 2022 01:24:52 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391540AbiBGMCK (ORCPT + 99 others); Mon, 7 Feb 2022 07:02:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386798AbiBGLhL (ORCPT ); Mon, 7 Feb 2022 06:37:11 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75A8DC043181; Mon, 7 Feb 2022 03:37:10 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0D9456091A; Mon, 7 Feb 2022 11:37:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C98CAC004E1; Mon, 7 Feb 2022 11:37:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233829; bh=MLFw33SBS/pqg+VfKau4wYtPr8pye3UBHws0wWK4l+Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lC37KSiNZZ3Eo+zA76rTPrLD+9L9jfE7GAphPivjiMbi0gBfsvPWBrl/Ll/j2quHv Hn1MK3w8ADdClI3uaRCmZv/smT4ynw+nYK48YzRjYGPCSb7+yAlDrvPqubBK2VC4iG jsXkqiHxoVZpXrVHUhocajoD7suAZZOpUbJ6K5UA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Florian Westphal , Stefano Brivio , Pablo Neira Ayuso Subject: [PATCH 5.16 125/126] selftests: nft_concat_range: add test for reload with no element add/del Date: Mon, 7 Feb 2022 12:07:36 +0100 Message-Id: <20220207103808.361008101@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Florian Westphal commit eda0cf1202acf1ef47f93d8f92d4839213431424 upstream. Add a specific test for the reload issue fixed with commit 23c54263efd7cb ("netfilter: nft_set_pipapo: allocate pcpu scratch maps on clone"). Add to set, then flush set content + restore without other add/remove in the transaction. On kernels before the fix, this test case fails: net,mac with reload [FAIL] Signed-off-by: Florian Westphal Reviewed-by: Stefano Brivio Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman --- tools/testing/selftests/netfilter/nft_concat_range.sh | 72 +++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) --- a/tools/testing/selftests/netfilter/nft_concat_range.sh +++ b/tools/testing/selftests/netfilter/nft_concat_range.sh @@ -27,7 +27,7 @@ TYPES="net_port port_net net6_port port_ net6_port_net6_port net_port_mac_proto_net" # Reported bugs, also described by TYPE_ variables below -BUGS="flush_remove_add" +BUGS="flush_remove_add reload" # List of possible paths to pktgen script from kernel tree for performance tests PKTGEN_SCRIPT_PATHS=" @@ -354,6 +354,23 @@ TYPE_flush_remove_add=" display Add two elements, flush, re-add " +TYPE_reload=" +display net,mac with reload +type_spec ipv4_addr . ether_addr +chain_spec ip daddr . ether saddr +dst addr4 +src mac +start 1 +count 1 +src_delta 2000 +tools sendip nc bash +proto udp + +race_repeat 0 + +perf_duration 0 +" + # Set template for all tests, types and rules are filled in depending on test set_template=' flush ruleset @@ -1473,6 +1490,59 @@ test_bug_flush_remove_add() { nft flush ruleset } +# - add ranged element, check that packets match it +# - reload the set, check packets still match +test_bug_reload() { + setup veth send_"${proto}" set || return ${KSELFTEST_SKIP} + rstart=${start} + + range_size=1 + for i in $(seq "${start}" $((start + count))); do + end=$((start + range_size)) + + # Avoid negative or zero-sized port ranges + if [ $((end / 65534)) -gt $((start / 65534)) ]; then + start=${end} + end=$((end + 1)) + fi + srcstart=$((start + src_delta)) + srcend=$((end + src_delta)) + + add "$(format)" || return 1 + range_size=$((range_size + 1)) + start=$((end + range_size)) + done + + # check kernel does allocate pcpu sctrach map + # for reload with no elemet add/delete + ( echo flush set inet filter test ; + nft list set inet filter test ) | nft -f - + + start=${rstart} + range_size=1 + + for i in $(seq "${start}" $((start + count))); do + end=$((start + range_size)) + + # Avoid negative or zero-sized port ranges + if [ $((end / 65534)) -gt $((start / 65534)) ]; then + start=${end} + end=$((end + 1)) + fi + srcstart=$((start + src_delta)) + srcend=$((end + src_delta)) + + for j in $(seq ${start} $((range_size / 2 + 1)) ${end}); do + send_match "${j}" $((j + src_delta)) || return 1 + done + + range_size=$((range_size + 1)) + start=$((end + range_size)) + done + + nft flush ruleset +} + test_reported_issues() { eval test_bug_"${subtest}" }