From patchwork Thu Mar 13 10:48:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Curutchet X-Patchwork-Id: 14014710 X-Patchwork-Delegate: bpf@iogearbox.net Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (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 7874D266B41; Thu, 13 Mar 2025 10:48:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741862899; cv=none; b=DWB+9FgAoGlteKcKrGR/rOi4CGrJlY4Dys+uAq5hCEfiaPbHefe1v8NLyzpiwNkTpF8H4Gv2QyAjev5+S/KI72IcUIjIV0WkL3kPHOVUud/K6qnTdyKR0kwWiF2CnK0SsJ1R5Q9YHTFTEQhXVCrpcgtjMZdchxyQX7nFd7QGd3w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741862899; c=relaxed/simple; bh=rdlBQ/9cR69+PuOmroy/ajzlNeMG3kAPngtSW7aanS8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=d/Jt0Ik70qaGfTcFMyrIvX5eCXfgkaoh8UThlpE5gJvo3ccWOMXPslsS/TbhvbhGurJDrXVRidN9G3XCE56lmlx0oJ7iA3Mx8LwP/awCZ0eciwxJdxiHi/FBkwCjiE+dP819ZGZd02ZoKF+bgaF7thfXcMs3NiB2kfWDzXxYLUU= 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=PhzzVpJ/; arc=none smtp.client-ip=217.70.183.200 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="PhzzVpJ/" Received: by mail.gandi.net (Postfix) with ESMTPSA id EEF344419D; Thu, 13 Mar 2025 10:48:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1741862890; 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=op67NNxbforWlSNJbclp0mBeqaWx1V4Ywj9DWeO0Ca0=; b=PhzzVpJ/0rA/jVC4dXcxF0mI0m+rN4gpMy+CvSQe6O2AmgUb3aNf8WPYPO2okrIEJPO6aI JzMVCrzIOfxfPWKgXpCxcSIpnDoitpVmHFu2KomKpmGMl7HzETwPHmHzIapLR0L2KGFIQJ sVFpu8W7dIbeNggv1L1fjL+dVGhSfFiAKKYSIOHKR7N+B2AJ/Dlk6XV3OLTHHVPSpYke1H yYqRIv+PNnWOMtYHaAbFHTtxT+u4AkoiwcJNbLobDzOknkutLiXF9rKBL5Coyf4OImy1lj Ex1eJU8kxRbQrJ4C1XkSZhjWiwl0wetifS2DmJg1JYnug3bji/83gd0fFWssOA== From: "Bastien Curutchet (eBPF Foundation)" Date: Thu, 13 Mar 2025 11:48:02 +0100 Subject: [PATCH 04/13] selftests/bpf: test_xsk: Add return value to init_iface() Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250313-xsk-v1-4-7374729a93b9@bootlin.com> References: <20250313-xsk-v1-0-7374729a93b9@bootlin.com> In-Reply-To: <20250313-xsk-v1-0-7374729a93b9@bootlin.com> To: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan , "David S. Miller" , Jakub Kicinski , Jesper Dangaard Brouer Cc: Thomas Petazzoni , Alexis Lothore , 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-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdduvdejjeehucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomhepfdeurghsthhivghnucevuhhruhhttghhvghtucdlvgeurffhucfhohhunhgurghtihhonhdmfdcuoegsrghsthhivghnrdgtuhhruhhttghhvghtsegsohhothhlihhnrdgtohhmqeenucggtffrrghtthgvrhhnpeegfeduhfeutddtieffteffleejffekveeviedutdegjeelfedtjeegtdejtddthfenucfkphepvdgrtddumegtsgduleemkedvheefmeguuddttdemfhelvgdumeeftgejudemjeeitdgtmedutggsrgenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpedvrgdtudemtggsudelmeekvdehfeemugdutddtmehflegvudemfegtjedumeejiedttgemudgtsggrpdhhvghlohepfhgvughorhgrrdhhohhmvgdpmhgrihhlfhhrohhmpegsrghsthhivghnrdgtuhhruhhttghhvghtsegsohhothhlihhnrdgtohhmpdhnsggprhgtphhtthhopedvkedprhgtphhtthhopegvugguhiiikeejsehgmhgrihhlrdgtohhmpdhrtghpthhtoheprghlvgigihhsrdhlohhthhhorhgvsegsohhothhlihhnrdgtohhmpdhrtghpt hhtohepshhhuhgrhheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepmhihkhholhgrlhesfhgsrdgtohhmpdhrtghpthhtohephihonhhghhhonhhgrdhsohhngheslhhinhhugidruggvvhdprhgtphhtthhopehmrghgnhhushdrkhgrrhhlshhsohhnsehinhhtvghlrdgtohhmpdhrtghpthhtohepmhgrrhhtihhnrdhlrghusehlihhnuhigrdguvghvpdhrtghpthhtohepsggrshhtihgvnhdrtghurhhuthgthhgvthessghoohhtlhhinhdrtghomh X-GND-Sasl: bastien.curutchet@bootlin.com X-Patchwork-Delegate: bpf@iogearbox.net init_iface() doesn't have any return value while it can fail. In case of failure it calls exit_on_error() which will terminate the test immediately. Add a return value to init_iface() so errors can be handled more smoothly. Signed-off-by: Bastien Curutchet (eBPF Foundation) --- tools/testing/selftests/bpf/xskxceiver.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c index 8b74a0f79c2e594b4db495acabd02a01a5b1b95f..01a0ddbf1cf52760a4a4d168da2fec1859e6b4b8 100644 --- a/tools/testing/selftests/bpf/xskxceiver.c +++ b/tools/testing/selftests/bpf/xskxceiver.c @@ -2380,7 +2380,7 @@ static bool hugepages_present(void) return true; } -static void init_iface(struct ifobject *ifobj, thread_func_t func_ptr) +static int init_iface(struct ifobject *ifobj, thread_func_t func_ptr) { LIBBPF_OPTS(bpf_xdp_query_opts, query_opts); int err; @@ -2390,7 +2390,7 @@ static void init_iface(struct ifobject *ifobj, thread_func_t func_ptr) err = xsk_load_xdp_programs(ifobj); if (err) { print_msg("Error loading XDP program\n"); - exit_with_error(err); + return err; } if (hugepages_present()) @@ -2399,7 +2399,7 @@ static void init_iface(struct ifobject *ifobj, thread_func_t func_ptr) err = bpf_xdp_query(ifobj->ifindex, XDP_FLAGS_DRV_MODE, &query_opts); if (err) { print_msg("Error querying XDP capabilities\n"); - exit_with_error(-err); + return err; } if (query_opts.feature_flags & NETDEV_XDP_ACT_RX_SG) ifobj->multi_buff_supp = true; @@ -2411,6 +2411,8 @@ static void init_iface(struct ifobject *ifobj, thread_func_t func_ptr) ifobj->xdp_zc_max_segs = 0; } } + + return 0; } static int testapp_send_receive(struct test_spec *test) @@ -2719,8 +2721,11 @@ int main(int argc, char **argv) ifobj_tx->set_ring.default_rx = ifobj_tx->ring.rx_pending; } - init_iface(ifobj_rx, worker_testapp_validate_rx); - init_iface(ifobj_tx, worker_testapp_validate_tx); + if (init_iface(ifobj_rx, worker_testapp_validate_rx) || + init_iface(ifobj_tx, worker_testapp_validate_tx)) { + print_msg("Error : can't initialize interfaces\n"); + ksft_exit_xfail(); + } test_spec_init(&test, ifobj_tx, ifobj_rx, 0, &tests[0]); tx_pkt_stream_default = pkt_stream_generate(DEFAULT_PKT_CNT, MIN_PKT_SIZE);