From nobody Fri Jan 9 00:44:13 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 BF56225F99B for ; Mon, 5 Jan 2026 03:45:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767584716; cv=none; b=GG+hBJWg03pfxC9Azr+ucUmEtq5rTndFd2mvRy2gAsojI2J4SBlZ1xBYHP9kcgOKCppGh+fiVofDCz1lGAXFgRp8rMVfLDEQwFuXHE24bJp414IxIQU8tcPTqqwR5kxleJCjvmObxpmVABVqDaScdRZkzFbmYjB3abSkDEvFxsw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767584716; c=relaxed/simple; bh=uRFxgVVwz4SIzsd58nKVZfi6jcW33M/juIg8syiwhW0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=u9rptKc8nMwDkWk8y4tpJzV2nLMX9QTEACaTPhRgFrZye7T9oWT49+5xd1vMPKtr9TcC/EbUwAkwI2YAtV65rQEk4A05KK9zGbwNDBd1EO4wCZbOkxvW4Tz3xi7WCnC2bU9jXWXzyOVYuqjkjPlV7bucvnXMURRBO5563FKhwvI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=EPVqpXx5; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="EPVqpXx5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1767584712; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g+m7vsuXPa0IEo+bxmHFD7Tx24Sxf6E+9tEfv8GQStw=; b=EPVqpXx5gVvtzo/3UzR9EkgQ0Tb7nqcpwxydaSXxlbUBKgRaiGTsMfnV/EPJUE7VkY7K1s CgOX+zf5XzIsQR+jlE+miGVTzlemikdxBlIiqsObJIFxTuBcw39dv7PY/JkVw8gBL578U5 emnc8joI6OM4cJAxh2qaB5AdIuF7hYE= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-662-ecJvDtlcMhuejjHxkWFmIg-1; Sun, 04 Jan 2026 22:45:07 -0500 X-MC-Unique: ecJvDtlcMhuejjHxkWFmIg-1 X-Mimecast-MFC-AGG-ID: ecJvDtlcMhuejjHxkWFmIg_1767584706 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id ED7711956050; Mon, 5 Jan 2026 03:45:05 +0000 (UTC) Received: from xudu-thinkpadx1carbongen9.nay.csb (unknown [10.66.60.72]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0F2CE1800367; Mon, 5 Jan 2026 03:45:01 +0000 (UTC) From: Xu Du To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, shuah@kernel.org Cc: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v3 3/8] selftest: tun: Refactor tun_delete to use tuntap_helpers Date: Mon, 5 Jan 2026 11:44:38 +0800 Message-ID: <832ffbf4ec570342e29c75a02457e3f4e2beb14a.1767580224.git.xudu@redhat.com> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" The previous patch introduced common tuntap helpers to simplify tuntap test code. This patch refactors the tun_delete function to use these new helpers. Signed-off-by: Xu Du --- tools/testing/selftests/net/tun.c | 39 ++----------------------------- 1 file changed, 2 insertions(+), 37 deletions(-) diff --git a/tools/testing/selftests/net/tun.c b/tools/testing/selftests/ne= t/tun.c index 128b0a5327d4..08e760fa5d15 100644 --- a/tools/testing/selftests/net/tun.c +++ b/tools/testing/selftests/net/tun.c @@ -8,14 +8,12 @@ #include #include #include -#include #include -#include -#include #include #include =20 #include "kselftest_harness.h" +#include "tuntap_helpers.h" =20 static int tun_attach(int fd, char *dev) { @@ -66,40 +64,7 @@ static int tun_alloc(char *dev) =20 static int tun_delete(char *dev) { - struct { - struct nlmsghdr nh; - struct ifinfomsg ifm; - unsigned char data[64]; - } req; - struct rtattr *rta; - int ret, rtnl; - - rtnl =3D socket(AF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE); - if (rtnl < 0) { - fprintf(stderr, "can't open rtnl: %s\n", strerror(errno)); - return 1; - } - - memset(&req, 0, sizeof(req)); - req.nh.nlmsg_len =3D NLMSG_ALIGN(NLMSG_LENGTH(sizeof(req.ifm))); - req.nh.nlmsg_flags =3D NLM_F_REQUEST; - req.nh.nlmsg_type =3D RTM_DELLINK; - - req.ifm.ifi_family =3D AF_UNSPEC; - - rta =3D (struct rtattr *)(((char *)&req) + NLMSG_ALIGN(req.nh.nlmsg_len)); - rta->rta_type =3D IFLA_IFNAME; - rta->rta_len =3D RTA_LENGTH(IFNAMSIZ); - req.nh.nlmsg_len +=3D rta->rta_len; - memcpy(RTA_DATA(rta), dev, IFNAMSIZ); - - ret =3D send(rtnl, &req, req.nh.nlmsg_len, 0); - if (ret < 0) - fprintf(stderr, "can't send: %s\n", strerror(errno)); - ret =3D (unsigned int)ret !=3D req.nh.nlmsg_len; - - close(rtnl); - return ret; + return dev_delete(dev); } =20 FIXTURE(tun) --=20 2.49.0