From nobody Fri Oct 3 07:40:40 2025 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (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 E14D32F9C23; Thu, 4 Sep 2025 10:11:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756980688; cv=none; b=FZbk7UZ73ozX6STUg4aooNVaueoEpgF8VBO59ghaInr+cCHwju9JvLjGemk4M8AyE5TAXwNYgTYTkOiq8Qv727XBvCWx0ulEnTg5qdDKn/7wvId3ZZInqK8/wo0ZfVonJ8Rn68jMCXOWKoVflUnflOG6K8Td1ZrhPenCJ5cLggM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756980688; c=relaxed/simple; bh=IEPHuqnbRSKAeGCFI2Kg+8RLi1TPHm2Vo+JJUOCvWMA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ks0iwQ5UzF+KOwI0BRIscFHXDCHCxz4iQ2zm/F90jzDpQ90Lo8sRYZQ1Hx7RJQG4XZmsDRNg+AH9v0nqEJlWPt2s+sAxisgfSYQVpA5RSz8vVS5lA9aiOq6F+rn12C1bzYC8uStbDZDwDe6AdLx/T4Z/TzQNsLnAgOK1tD9a6lg= 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=Zl4qeXTI; arc=none smtp.client-ip=185.246.84.56 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="Zl4qeXTI" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 829AF1A0D64; Thu, 4 Sep 2025 10:11:25 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 54459606BB; Thu, 4 Sep 2025 10:11:25 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 72EC51C22DE29; Thu, 4 Sep 2025 12:11:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1756980683; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=j7rcPwwGDfvSooU7OQI5sxso3YC/QBKzLUx9piCbBMY=; b=Zl4qeXTIVH0xK+BUmfmyBWgs0Uq5kqhEbrBFLXzQSm1LC1Rw1YrMJidbrmo0I0T7hEfW1d FjkRtDrm+sWgVbhEQN4TBMMYFU8LoEHOKtkuPXThw0ESW8ldqQJBSCGyb5SK+y/sjsYLE+ +GKlMjLs2RbGY4QN7OjZ3hOWRrkHHeBEllEvejubccX50FB5g2NN/LW+IVovEGXhkpJKmE I2UZDJhUUmsH96IYj8ZVX9RsK7MR7fkn5iQ4CFW2TS/HcCmtLjnC+0VUvi395r4FEmdPLS F3ollufy9mdgksJ43tbMIrNvMcZVNGvHHfzh1Qp4uqLV60Uewx9lIa9xstTX9w== From: "Bastien Curutchet (eBPF Foundation)" Date: Thu, 04 Sep 2025 12:10:19 +0200 Subject: [PATCH bpf-next v3 04/14] selftests/bpf: test_xsk: Wrap test clean-up in functions Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250904-xsk-v3-4-ce382e331485@bootlin.com> References: <20250904-xsk-v3-0-ce382e331485@bootlin.com> In-Reply-To: <20250904-xsk-v3-0-ce382e331485@bootlin.com> To: =?utf-8?q?Bj=C3=B6rn_T=C3=B6pel?= , 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-Last-TLS-Session-Version: TLSv1.3 The clean-up done at the end of a test in __testapp_validate_traffic() isn't wrapped in a function. It isn't convenient if we want to use it somewhere else in the code. Wrap the clean-up in two new functions : the first deletes the sockets, the second releases the umem. Signed-off-by: Bastien Curutchet (eBPF Foundation) --- tools/testing/selftests/bpf/test_xsk.c | 36 ++++++++++++++++++++++--------= ---- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/tools/testing/selftests/bpf/test_xsk.c b/tools/testing/selftes= ts/bpf/test_xsk.c index e4059c7d0a289449a6b73669fa87f7440b7f55c0..f70a05d570681e36d3e592a6845= 637402d1bb58f 100644 --- a/tools/testing/selftests/bpf/test_xsk.c +++ b/tools/testing/selftests/bpf/test_xsk.c @@ -1689,6 +1689,27 @@ static void xsk_attach_xdp_progs(struct test_spec *t= est, struct ifobject *ifobj_ xsk_reattach_xdp(ifobj_tx, test->xdp_prog_tx, test->xskmap_tx, test->mod= e); } =20 +static void clean_sockets(struct test_spec *test, struct ifobject *ifobj) +{ + u32 i; + + if (!ifobj || !test) + return; + + for (i =3D 0; i < test->nb_sockets; i++) + xsk_socket__delete(ifobj->xsk_arr[i].xsk); +} + +static void clean_umem(struct test_spec *test, struct ifobject *ifobj1, st= ruct ifobject *ifobj2) +{ + if (!ifobj1) + return; + + testapp_clean_xsk_umem(ifobj1); + if (ifobj2 && !ifobj2->shared_umem) + testapp_clean_xsk_umem(ifobj2); +} + static int __testapp_validate_traffic(struct test_spec *test, struct ifobj= ect *ifobj1, struct ifobject *ifobj2) { @@ -1744,18 +1765,9 @@ static int __testapp_validate_traffic(struct test_sp= ec *test, struct ifobject *i pthread_join(t0, NULL); =20 if (test->total_steps =3D=3D test->current_step || test->fail) { - u32 i; - - if (ifobj2) - for (i =3D 0; i < test->nb_sockets; i++) - xsk_socket__delete(ifobj2->xsk_arr[i].xsk); - - for (i =3D 0; i < test->nb_sockets; i++) - xsk_socket__delete(ifobj1->xsk_arr[i].xsk); - - testapp_clean_xsk_umem(ifobj1); - if (ifobj2 && !ifobj2->shared_umem) - testapp_clean_xsk_umem(ifobj2); + clean_sockets(test, ifobj1); + clean_sockets(test, ifobj2); + clean_umem(test, ifobj1, ifobj2); } =20 return !!test->fail; --=20 2.50.1