From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.netfilter.org (mail.netfilter.org [217.70.190.124]) (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 9CCD429A9DE; Thu, 22 May 2025 16:53:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.190.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747932792; cv=none; b=HMfhdqzLf/9BjuaPldhSlnbktpEVs8eAr6I95jxTvASioXx4bDjzzo1VElxjyDtAM3rtQtfMWQY+776uyYrIkoyNzC3+5lUNXde6AvbM0hHBI/J0CIwX3vWyjr362Bf6Oxwq0V4+f9ThI192p4qVWaZ2I4eOx0uceegpfeWcJ9A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747932792; c=relaxed/simple; bh=MzRd1/fiuSAluGEvx6qF/mPHnPkzXkm90kPUo1yDPWE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=II8DavyBkDKm93sO2Nglvvbixw0wqQiAhrcE9DqAXn6nFL5JMcxQTxrQ0yo60Be83WJw41YEUEL3rxNWQJrBC4OXR+dECpxszgIB3BapE+GFSefTW+QkdY7guJNvlExslv+IpjnxuWzREFd+UHZQCi02rVgLvypVVsX6WJOHLm8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=netfilter.org; spf=pass smtp.mailfrom=netfilter.org; dkim=pass (2048-bit key) header.d=netfilter.org header.i=@netfilter.org header.b=c9QaLc69; dkim=pass (2048-bit key) header.d=netfilter.org header.i=@netfilter.org header.b=t3vbSJex; arc=none smtp.client-ip=217.70.190.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=netfilter.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=netfilter.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=netfilter.org header.i=@netfilter.org header.b="c9QaLc69"; dkim=pass (2048-bit key) header.d=netfilter.org header.i=@netfilter.org header.b="t3vbSJex" Received: by mail.netfilter.org (Postfix, from userid 109) id 36F636071E; Thu, 22 May 2025 18:53:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netfilter.org; s=2025; t=1747932789; bh=57aFevUVcInAznOruHLo81abghll3Gv0FwA2khaa0hE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c9QaLc691oAMeYeaM6iCfOFK9sgUaUTsBA0c7DogNbwWhe2+JyqE0HJU/MjS+6TwB fcEvAasCmMcDdn3eKg/SnqPtI9o+FT79Wlp1zVXzxBJoe655RXTKtqrxdu8CsxBJrh 7fKAIlF+2sa1TrPRfHooP/R4BabXasEjmPI1r1JmsuH2lDXRcrcXowUYaozUJ/dSNi UPpvEMC2igIvZ8yixgpt5SbREMkBPqInICmtxUByBjI7D7LbsD74wOkTjsgdA/OJbC J2sD+K7/1DgiFbMRmN/iDhL+2LITYL+pMxspyH3Crzt4nhunR871jBwxxumBCGQhNA mFAZbMRPFlBqA== X-Spam-Level: Received: from localhost.localdomain (mail-agni [217.70.190.124]) by mail.netfilter.org (Postfix) with ESMTPSA id 4EFA760724; Thu, 22 May 2025 18:52:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netfilter.org; s=2025; t=1747932771; bh=57aFevUVcInAznOruHLo81abghll3Gv0FwA2khaa0hE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t3vbSJexIelOlnQ4CJKdcMtTLgI4y4qDTFF8JAKcUrU3l8bQPM4HLnoEwNFg6VkwX WWbhA3uFBQ4yefRX3b1igAGmPj8sQWairFLeS5fuiA+gE0ShzfP9VIfA4zXA4ndPkM qzO5jVJ6m/iwwWyp9he2rowo+xplVcA16ZYyU6RbYCvjQs6vZ6KXTPDGFDBwQVIi0g zcDdHfD4qfvXs43GLDTOtTKk8fXjEMlBRpKNYZZoBHyonOBIM6MmRAGet+7RdQRUHq eTKzPN6YX6ZA/DsJw9KlOtIifmD91t9r9DS/x/jpU4wsgMehhVuqhKgZSX1twndUem 9x38F4q7atstQ== From: Pablo Neira Ayuso To: netfilter-devel@vger.kernel.org Cc: davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, fw@strlen.de, horms@kernel.org Subject: [PATCH net-next 07/26] selftests: netfilter: nft_fib.sh: add type and oif tests with and without VRFs Date: Thu, 22 May 2025 18:52:19 +0200 Message-Id: <20250522165238.378456-8-pablo@netfilter.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20250522165238.378456-1-pablo@netfilter.org> References: <20250522165238.378456-1-pablo@netfilter.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Florian Westphal Replace the existing VRF test with a more comprehensive one. It tests following combinations: - fib type (returns address type, e.g. unicast) - fib oif (route output interface index - both with and without 'iif' keyword (changes result, e.g. 'fib daddr type local' will be true when the destination address is configured on the local machine, but 'fib daddr . iif type local' will only be true when the destination address is configured on the incoming interface. Add all types of addresses to test with for both ipv4 and ipv6: - local address on the incoming interface - local address on another interface - local address on another interface thats part of a vrf - address on another host The ruleset stores obtained results from 'fib' in nftables sets and then queries the sets to check that it has the expected results. Perform one pass while packets are coming in on interface NOT part of a VRF and then again when it was added and make sure fib returns the expected routes and address types for the various addresses in the setup. Signed-off-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso --- .../selftests/net/netfilter/nft_fib.sh | 392 ++++++++++++++++-- 1 file changed, 365 insertions(+), 27 deletions(-) diff --git a/tools/testing/selftests/net/netfilter/nft_fib.sh b/tools/testing/selftests/net/netfilter/nft_fib.sh index f636ad781033..9929a9ffef65 100755 --- a/tools/testing/selftests/net/netfilter/nft_fib.sh +++ b/tools/testing/selftests/net/netfilter/nft_fib.sh @@ -324,12 +324,338 @@ test_fib_vrf_dev_add_dummy() return 1 fi - ip -net "$nsrouter" link set veth0 master tvrf ip -net "$nsrouter" link set dummy0 master tvrf ip -net "$nsrouter" link set dummy0 up ip -net "$nsrouter" link set tvrf up } +load_ruleset_vrf() +{ +# Due to the many different possible combinations using named counters +# or one-rule-per-expected-result is complex. +# +# Instead, add dynamic sets for the fib modes +# (fib address type, fib output interface lookup .. ), +# and then add the obtained fib results to them. +# +# The test is successful if the sets contain the expected results +# and no unexpected extra entries existed. +ip netns exec "$nsrouter" nft -f - < /dev/null -- 2.30.2