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 2A44C291863; Fri, 23 May 2025 13:27:47 +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=1748006870; cv=none; b=diPbG09tPVvGLtlHDHBq7z/It7VazMH/vKxOm5AIeTnhtUXvJDSpXfmaqV4uAl47QxUpvWvS5iO8IOjJThfE7Aw5geeV0bs+d9ntTusiptK8GNGbyh650mb20R+JDef2UFQMzTgKZp0cahkrvBBMahdi0BHSL/94QaXpKCtYU8M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748006870; c=relaxed/simple; bh=MzRd1/fiuSAluGEvx6qF/mPHnPkzXkm90kPUo1yDPWE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qWtOYwDcH/KFkGdPJvh3jMTAnWacFpk2B9exuD3RpUXWPFDm0/EvsrIybkHiqoJsXDYHNcVOrLtLlYEDOig7xzJyncat07w9ISDbT0aL7IZfQDHdKhrc6UXF+9ijleTDtVVosKSdfUrYRWKgzI1vOpmuywY4XdIofTsv2npRhSw= 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=X1VvwtEK; dkim=pass (2048-bit key) header.d=netfilter.org header.i=@netfilter.org header.b=moiAcrU6; 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="X1VvwtEK"; dkim=pass (2048-bit key) header.d=netfilter.org header.i=@netfilter.org header.b="moiAcrU6" Received: by mail.netfilter.org (Postfix, from userid 109) id B8CAA60762; Fri, 23 May 2025 15:27:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netfilter.org; s=2025; t=1748006866; bh=57aFevUVcInAznOruHLo81abghll3Gv0FwA2khaa0hE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X1VvwtEK+SUW2ldZR45c0sOSYfEhJUKLgtr9WdjCFn7y8U+mO6VijPzWysGCzIDUy zBVo0Rzfdfa5tVFzmWSjlHC7DUnNxwCvL/BXWeUyYA7HHMtfIFdNozdnX0xVYfx8Gc dMbMeIvIFvNl7sh1+wHeC/6c8cml8Q7E4Ft3bBnfhGzgytNjtYwVC9NCDdFe4qW5Zm Jsi+31a6JAgJYnAmFLOXz/7deMcqV5VOq/SXknO54eKlQBrOirBqdApiHJ9eVDpTjT ZgPxCGD/dI+PO5e3urRNzeY057XuLPE/sQjJcnJFB02jYe5zdpbwwq14JYF37Bknqo jk57kgKRvIhEg== X-Spam-Level: Received: from localhost.localdomain (mail-agni [217.70.190.124]) by mail.netfilter.org (Postfix) with ESMTPSA id 865DA60771; Fri, 23 May 2025 15:27:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netfilter.org; s=2025; t=1748006844; bh=57aFevUVcInAznOruHLo81abghll3Gv0FwA2khaa0hE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=moiAcrU68UGcwI/VQi6XgWx0MeNwUDmvNcIHCEh5ChiDOK8PEDazEjMIGuMwX5fSb 3UNglLKItfcNrxN5wjLOfZijkIGwjXNHk48R+jk+hY2eEREQaCF4mK4DWaS/Smj4U3 +Hcjk4xhRBVBoTOWZQubCh0dllKUngWUqGzvwqbVaNvuLhO+lU3K6J3yvlKoQNOvX4 TkwIGD/1mKxTvJ92ttdyU293Kcv0vPWY6jkwRdtSVj77UCecCqsSsn4QFGHNy8mFnT e+EfhBlOVzL0iTYErPehm1wse7+Wr/JYTdppKQHhpXw8HmAXF7mqhb3WhyOS2iPMdT VPHiCg3f6WVUw== 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: Fri, 23 May 2025 15:26:53 +0200 Message-Id: <20250523132712.458507-8-pablo@netfilter.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20250523132712.458507-1-pablo@netfilter.org> References: <20250523132712.458507-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