From patchwork Tue Jan 21 13:01:28 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: 13946268 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.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 A047C1F3FD6; Tue, 21 Jan 2025 13:01:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737464497; cv=none; b=A0Y4O6MQArTTVJ2E18Lyl2SP+g5fIvDv2vrrJyn3xz2TsgXf1G+GQWzUl3DUMfJ9e3uMzWHfVc16AV9619I0mRDR47/tW7PLmEXIFvhYO3aYxOriQ00NVWBCn3AbKpXpfFc4KBKKCBfaHqcf/NDLkhKprv58haIXpup76ZvxFxM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737464497; c=relaxed/simple; bh=lPF21v0QCf4TQJl06JOjzYaiGuIDd/wbm8HXl/8BZTE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NaozkUg6VG/unEVRyW6iopy23Is3+cnEURUUUweujzTVRh7rqa2DC8qAJOtZvdNobuqZzJMa56Ghiqd2b+irocnp8FGNLhkEYmR19Xv/7O5q8C1JtsccbttJ0RIp61pJkXhZRTfj4OrFqaRAfcfVjApeZvGy5fx0z77cnHid2VI= 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=GnJryEm1; arc=none smtp.client-ip=217.70.183.201 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="GnJryEm1" Received: by mail.gandi.net (Postfix) with ESMTPSA id 0C4291BF209; Tue, 21 Jan 2025 13:01:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1737464493; 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=GnJryEm1swSzhCeF2lZE/Nint/jNaOEF08H6cafsE54pS/vEy5BU6u1qNoWBhuoKoFbs1w EAfap+4w7FmznxUyHXKjQm9cDVTHaS84m88sfoZ0RDOfM+1AWPS6uRNeNsG+u6l3BEJMIQ an0gtRCANth5m9/xz/YanCJDD8KrTwVen1wxZyZ+5ctuNpeeXyd3HTnIAtW4d22c4WW4IJ GexB6A2Y6ZC595YSRbhTHBNRqMgBOb4D6v7P5xDqIFkeCMQ4UQrR4wK01EC60L9bStb5Gy RA1UaoI1fHXHwrSnd/BMmbxEmkpC/fVrP1OFAvQ7j47Rlgfn3JCS3QOSWldGLA== From: "Bastien Curutchet (eBPF Foundation)" Date: Tue, 21 Jan 2025 14:01:28 +0100 Subject: [PATCH bpf-next v2 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-v2-6-fc9cacabc6b2@bootlin.com> References: <20250121-redirect-multi-v2-0-fc9cacabc6b2@bootlin.com> In-Reply-To: <20250121-redirect-multi-v2-0-fc9cacabc6b2@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); +}