From patchwork Tue Jun 11 02:27:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13692753 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 110D4BA4B; Tue, 11 Jun 2024 02:27:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718072870; cv=none; b=XEsetVp4v6Qtk2ybbhVZ33HxEKnFWKh3h5htBWEqmsAg5jS2F0032KTVf/HHSo87ae27KYBMUj3/6z/Y1TJRU2fAxBhKFbTImFVStOJ39weXqL75Jw9wnNS9uDsiOTYsetXVVu2CnVzv83GlCmACG4SSmg7FsVEKrPp+mHlLog4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718072870; c=relaxed/simple; bh=2N7cLTt3HayJgqi/3bNdeO+1xYh+bh+nh3jwFc5kyz8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HL9FeUMTd913YHCceD62H0sncMU0+1bufNcy0LZ5ZO3qagiVy0aSHmCH9+iFBXPv9d3pOfJ3Fr2ZsDfVNJSGxDvCv25ZpYw2tCsQsI+57wEO2j352M033kI/HLWH/kGVXzBDfpUU/QZKvhePfYSxOS/9HZMG7mdjH/LdUq72PEI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SkowLrCu; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SkowLrCu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 481BEC2BBFC; Tue, 11 Jun 2024 02:27:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718072869; bh=2N7cLTt3HayJgqi/3bNdeO+1xYh+bh+nh3jwFc5kyz8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SkowLrCucwT6AHkKRzdjB+yWZb9BYH5xQ0wT/G52yMQs3THSE4bKuNrAIONz70vo4 fQ1CNGxeqeiyKRIgp7xkPEDWLsvo0Y6GVZi8jz0eU5wb8ZGyWjlafnSf4A1e70w3Vc SXWIQPT3sPT/TbBLe9vCERqL6yKrbBt9GT54ZbQJyXFxV+xY6T1lCoNpbAsoY46nqq 4usAIX/LEAch1mK/6fHDRka+gZCSoPej29y3Zv/X2p0TRAv6PSxXik5nNDP8lOhhyF RG2GTPPYR90s2XjM4AStpBBDIsR+VFyLqtfawm2w1+MwZQ+Ct9qFQu3+IQ1lDxswGv Br/oUv0RfttXg== From: Geliang Tang To: Andrii Nakryiko , Eduard Zingerman , Mykola Lysenko , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan Cc: Geliang Tang , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH bpf-next v2 1/2] selftests/bpf: Enable INET_XFRM_TUNNEL in config Date: Tue, 11 Jun 2024 10:27:27 +0800 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang The kconfigs CONFIG_INET_XFRM_TUNNEL and CONFIG_INET6_XFRM_TUNNEL are needed by test_tunnel tests. This patch enables them together with the dependent kconfigs CONFIG_INET_IPCOMP and CONFIG_INET6_IPCOMP. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/config | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/testing/selftests/bpf/config b/tools/testing/selftests/bpf/config index 2fb16da78dce..de358b51a05a 100644 --- a/tools/testing/selftests/bpf/config +++ b/tools/testing/selftests/bpf/config @@ -96,3 +96,7 @@ CONFIG_XDP_SOCKETS=y CONFIG_XFRM_INTERFACE=y CONFIG_TCP_CONG_DCTCP=y CONFIG_TCP_CONG_BBR=y +CONFIG_INET_IPCOMP=y +CONFIG_INET_XFRM_TUNNEL=y +CONFIG_INET6_IPCOMP=y +CONFIG_INET6_XFRM_TUNNEL=y From patchwork Tue Jun 11 02:27:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13692754 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 9D5748C04; Tue, 11 Jun 2024 02:27:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718072877; cv=none; b=tA3w1FturxqwAXetQLZf+ZN7UzI57GrYMzKVWA2qs1xUhmKz0U6dCHQqMB8BogloYOAnGJhQhuIoghOCZBr3AHK6PS0qbEeVTdGPyHkeeWXpQZAxwXSjo4sRUlE8DeDAuI7sgOw9YI3eScifePpfe3rctgSPuQskB6MmlR8isYc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718072877; c=relaxed/simple; bh=soo8O23hvdU9RFLYaLJElksgq2fkfTRKU7M9abjFpM8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qG9nDA0g6aScH4JzTz1+KwFSaos3levQInszDKA2JO7Vqepl47g3EFKCrpAcCrUPhxFZob4egRkdh75d0Jb/BKsvajm4piVofMBpk52nHxiO84wmCc4+wkcy7xR75iEg7KaSWXS7oWmFxUQGss98arhRFH5B4EBxnJ8ONI3kaRQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=U5XvMSB6; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="U5XvMSB6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA175C2BBFC; Tue, 11 Jun 2024 02:27:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718072877; bh=soo8O23hvdU9RFLYaLJElksgq2fkfTRKU7M9abjFpM8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U5XvMSB654yYtH2oIG8Dj+aLokfPKpehgjlyrDNLUbQkekdYVFrjMIGcdJBmIhGNT 1ovX8mSheMvJfnlue84JruMedDlUeJsyEmW37eTJJqaqW43e500uJDGrvbYl/jWX8i q3hIYH+02Tc7nbvu7gL+1QmwbcZvZ8Anm6Yvl0PELG+PEtRD0rb4879RMEjEe3Nj63 0dDbI4GFU/gn2jE9sRQtrw5D10cz059KCsxICIE4n1x09y2quMbISL6xp66Y6tMqSt 1u8M24vc4j2js7b5Lz+DmR/p9SV0ZrOfpiqB4yiafLHlhvYhPOP81eNz+86I12UOBt jWMhi8m8wR4PQ== From: Geliang Tang To: Andrii Nakryiko , Eduard Zingerman , Mykola Lysenko , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan Cc: Geliang Tang , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH bpf-next v2 2/2] selftests/bpf: Close netns in error paths in test_tunnel Date: Tue, 11 Jun 2024 10:27:28 +0800 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang netns created by open_netns() should be closed in error paths in test_vxlan_tunnel(), test_ip6vxlan_tunnel() and test_ipip_tunnel(). Signed-off-by: Geliang Tang --- .../selftests/bpf/prog_tests/test_tunnel.c | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/test_tunnel.c b/tools/testing/selftests/bpf/prog_tests/test_tunnel.c index cec746e77cd3..f19e8177bcec 100644 --- a/tools/testing/selftests/bpf/prog_tests/test_tunnel.c +++ b/tools/testing/selftests/bpf/prog_tests/test_tunnel.c @@ -448,14 +448,20 @@ static void test_vxlan_tunnel(void) if (!ASSERT_OK_PTR(nstoken, "setns src")) goto done; ifindex = if_nametoindex(VXLAN_TUNL_DEV0); - if (!ASSERT_NEQ(ifindex, 0, "vxlan00 ifindex")) + if (!ASSERT_NEQ(ifindex, 0, "vxlan00 ifindex")) { + close_netns(nstoken); goto done; + } tc_hook.ifindex = ifindex; set_dst_prog_fd = bpf_program__fd(skel->progs.vxlan_set_tunnel_dst); - if (!ASSERT_GE(set_dst_prog_fd, 0, "bpf_program__fd")) + if (!ASSERT_GE(set_dst_prog_fd, 0, "bpf_program__fd")) { + close_netns(nstoken); goto done; - if (attach_tc_prog(&tc_hook, -1, set_dst_prog_fd)) + } + if (attach_tc_prog(&tc_hook, -1, set_dst_prog_fd)) { + close_netns(nstoken); goto done; + } close_netns(nstoken); /* use veth1 ip 2 as tunnel source ip */ @@ -521,14 +527,20 @@ static void test_ip6vxlan_tunnel(void) if (!ASSERT_OK_PTR(nstoken, "setns src")) goto done; ifindex = if_nametoindex(IP6VXLAN_TUNL_DEV0); - if (!ASSERT_NEQ(ifindex, 0, "ip6vxlan00 ifindex")) + if (!ASSERT_NEQ(ifindex, 0, "ip6vxlan00 ifindex")) { + close_netns(nstoken); goto done; + } tc_hook.ifindex = ifindex; set_dst_prog_fd = bpf_program__fd(skel->progs.ip6vxlan_set_tunnel_dst); - if (!ASSERT_GE(set_dst_prog_fd, 0, "bpf_program__fd")) + if (!ASSERT_GE(set_dst_prog_fd, 0, "bpf_program__fd")) { + close_netns(nstoken); goto done; - if (attach_tc_prog(&tc_hook, -1, set_dst_prog_fd)) + } + if (attach_tc_prog(&tc_hook, -1, set_dst_prog_fd)) { + close_netns(nstoken); goto done; + } close_netns(nstoken); /* use veth1 ip 2 as tunnel source ip */ @@ -615,8 +627,7 @@ static void test_ipip_tunnel(enum ipip_encap encap) if (!ASSERT_OK_PTR(nstoken, "setns")) goto done; err = test_ping(AF_INET, IP4_ADDR_TUNL_DEV1); - if (!ASSERT_OK(err, "test_ping")) - goto done; + ASSERT_OK(err, "test_ping"); close_netns(nstoken); done: