From patchwork Tue Jan 21 10:22:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bastien Curutchet (eBPF Foundation)" X-Patchwork-Id: 13946059 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (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 7EA061F1920; Tue, 21 Jan 2025 10:22:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737454950; cv=none; b=jqaXLsTHfsc5rETF3pzFhKADgFTcLdx847sEoW91AFuYuGbgPdfy17RmJV3BQT7+2eYPt4097cCrznfqv3Swdiu4keiLZnz+F2ak2Lz5orNiOf9fn1DPRAOuusC4tsIjNamuXHkdPI6MMFnSZjgYMYrgrW2qtVFwo7wqdmYelmY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737454950; c=relaxed/simple; bh=lPF21v0QCf4TQJl06JOjzYaiGuIDd/wbm8HXl/8BZTE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cowPKw0YRHelk0crTriujPHRtaxuxF+daDg08Luewx9FpfVQvjmLNbTpD5gI9fzOtlab1eEXw/wCVwc5itV6b67Y3whl2ZWwkpsAzsBKav+z8UI7hokvRqZEYMF2wusk42zLxcOX2SehntQYF8noS66uHJ4KaqKq9Hy1/6RGQbQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=dxRtPjQX; arc=none smtp.client-ip=217.70.183.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="dxRtPjQX" Received: by mail.gandi.net (Postfix) with ESMTPSA id 3EFA3240014; Tue, 21 Jan 2025 10:22:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1737454945; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IBT+mxeaQwIc5Sp34PwBOPaxZFkUBRct8wsZOppLvVI=; b=dxRtPjQX8XKIowG2Ys1iec6AeybDvYi/qBCUgsy1gkBAGt1ZgcT2GfcjMpHYrgbadZRd07 4ArcXyksKF5xCOsGULUl9JBIMFzZGN84zV4ECZN0433BYHtBNnZHkzbkSV6rWDmNTIcrcL r3XtClFQc8qmJ9MfBv9qQTexBxI92W3LJ6DG2KNJ+58dkvp/8FQ2Janqp6CTk5kStjjcEN f+oADVGYjF/QCPiykELmo/+HSRoGwwfgIQfevcq5509qfMlLal9P2d9gUwz4q/x/e5KSex V5hVickQw2CAr/DjmcZd74If1SUoczE/dCvo5fdiEAJC43HTs+s8zGu04wFKLw== From: "Bastien Curutchet (eBPF Foundation)" Date: Tue, 21 Jan 2025 11:22:20 +0100 Subject: [PATCH bpf-next 06/10] selftests/bpf: test_xdp_veth: Add new test cases for XDP flags Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250121-redirect-multi-v1-6-b215e35ff505@bootlin.com> References: <20250121-redirect-multi-v1-0-b215e35ff505@bootlin.com> In-Reply-To: <20250121-redirect-multi-v1-0-b215e35ff505@bootlin.com> To: Alexei Starovoitov , Daniel Borkmann , "David S. Miller" , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan Cc: Alexis Lothore , Thomas Petazzoni , netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (eBPF Foundation)" X-Mailer: b4 0.14.2 X-GND-Sasl: bastien.curutchet@bootlin.com The XDP redirection is tested without any flag provided to the xdp_attach() function. Add two subtests that check the correct behaviour with XDP_FLAGS_{DRV/SKB}_MODE flags Signed-off-by: Bastien Curutchet (eBPF Foundation) --- .../selftests/bpf/prog_tests/test_xdp_veth.c | 27 ++++++++++++++++------ 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/test_xdp_veth.c b/tools/testing/selftests/bpf/prog_tests/test_xdp_veth.c index 0aa1583b741b15f573bbb979b2047a0109070544..62a315d01e51739a7f13dddda3d5a569eab24ceb 100644 --- a/tools/testing/selftests/bpf/prog_tests/test_xdp_veth.c +++ b/tools/testing/selftests/bpf/prog_tests/test_xdp_veth.c @@ -33,6 +33,7 @@ #include "xdp_dummy.skel.h" #include "xdp_redirect_map.skel.h" #include "xdp_tx.skel.h" +#include #define VETH_PAIRS_COUNT 3 #define NS_SUFFIX_LEN 6 @@ -185,26 +186,26 @@ static int check_ping(void) } #define VETH_REDIRECT_SKEL_NB 3 -void test_xdp_veth_redirect(void) +static void xdp_veth_redirect(u32 flags) { struct prog_configuration ping_config[VETH_PAIRS_COUNT] = { { .local_name = "xdp_redirect_map_0", .remote_name = "xdp_dummy_prog", - .local_flags = 0, - .remote_flags = 0, + .local_flags = flags, + .remote_flags = flags, }, { .local_name = "xdp_redirect_map_1", .remote_name = "xdp_tx", - .local_flags = 0, - .remote_flags = 0, + .local_flags = flags, + .remote_flags = flags, }, { .local_name = "xdp_redirect_map_2", .remote_name = "xdp_dummy_prog", - .local_flags = 0, - .remote_flags = 0, + .local_flags = flags, + .remote_flags = flags, } }; struct bpf_object *bpf_objs[VETH_REDIRECT_SKEL_NB]; @@ -262,3 +263,15 @@ void test_xdp_veth_redirect(void) cleanup_network(); } + +void test_xdp_veth_redirect(void) +{ + if (test__start_subtest("0")) + xdp_veth_redirect(0); + + if (test__start_subtest("DRV_MODE")) + xdp_veth_redirect(XDP_FLAGS_DRV_MODE); + + if (test__start_subtest("SKB_MODE")) + xdp_veth_redirect(XDP_FLAGS_SKB_MODE); +}