From nobody Wed Apr 19 03:24:44 2023 X-Original-To: net@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Q1R3y48hrz44s6D for ; Wed, 19 Apr 2023 03:24:46 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Q1R3y1flkz4NBJ for ; Wed, 19 Apr 2023 03:24:46 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681874686; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZVBLtJU8ZPTcQrBNkvuJmfdIyXo1772ZVkzSK9WgNFk=; b=dd2cOcmKZgKw/2NRxbxXKI2g2CLM2fP78hKgrXVAqh/Q9ujn5bKNgnL7BZ4NfBV8s4o8ZZ 7p8u3WGHNm7VkT4O9DajMOSSdWRdLs/5+NBvmlYyGiGif0idc6JE/8uiDrENo8TuIZZ6Hq r4y4IfbapVVjgeOBPU+Dtp3Wkrgps3SEfehzRAWu6P67YiYDEDNq5xmZWgEjG+ACrifbH4 foicWHztISW8JxWj1uQ2LhsT0QIOQfI83i14i9PyBz8Zc8N8CqGeoDRQzQzmh4+dSMoR+y 1J2p/AY5ayMA9pGHohllSpvW1q+CkJQpA6ZSqmrzK/pP2Ul0uoqA7CgG963UKQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1681874686; a=rsa-sha256; cv=none; b=ADzb79AKpwLzYCn4kvzPU855T6GWC9JW4NG7zHj4LXmIxTj+ZXBYAI6Af4W0NF7aJgdosm x6wB7UlE/WWfFytqUyur7nJ8YMWyFuDmJqq25sO1jGQJV8EuD/toc5wCa37a+yrTh8s14y 8AK57unlsKYiPoh0Q4y3+IbYazQ4OaG29qQMPnEwD6goxqe3KgYtHyHz9pOkeIodEfSTl4 bK9u/AqJ6NnbhgTKbnKacU/WmNnS9uSbVGmrnU3Ss66blY3kaUM/tVEkNwyz7B9QHunr7z g1jObyoWCVKmWcHSxSzbQ6j7FCEYC2ZL4b0pIlMoveKZBXEdD8yoNzgzBfYMVg== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Q1R3y0Vn0zdmf for ; Wed, 19 Apr 2023 03:24:46 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 33J3OjX2064165 for ; Wed, 19 Apr 2023 03:24:45 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 33J3Oj07064164 for net@FreeBSD.org; Wed, 19 Apr 2023 03:24:45 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: net@FreeBSD.org Subject: [Bug 235920] ifconfig: unable to create another interface after renaming the previous one with the same name Date: Wed, 19 Apr 2023 03:24:44 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Many People X-Bugzilla-Who: zlei@FreeBSD.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: net@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Networking and TCP/IP with FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-net List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-net@freebsd.org MIME-Version: 1.0 X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D235920 --- Comment #4 from Zhenlei Huang --- (In reply to Oleg Ginzburg from comment #0) If `ifconfig create` with an unit number, then cloner will check whether the number is available or not ( via alloc_unr_specific() ). ``` static int tun_clone_create(struct if_clone *ifc, char *name, size_t len, struct ifc_data *ifd, struct ifnet **ifpp) { struct tuntap_driver *drv; struct cdev *dev; int err, i, tunflags, unit; tunflags =3D 0; /* The name here tells us exactly what we're creating */ err =3D tuntap_name2info(name, &unit, &tunflags); if (err !=3D 0) return (err); drv =3D tuntap_driver_from_flags(tunflags); if (drv =3D=3D NULL) return (ENXIO); if (unit !=3D -1) { /* If this unit number is still available that's okay. */ if (alloc_unr_specific(drv->unrhdr, unit) =3D=3D -1) return (EEXIST); } else { unit =3D alloc_unr(drv->unrhdr); } snprintf(name, IFNAMSIZ, "%s%d", drv->cdevsw.d_name, unit); /* find any existing device, or allocate new unit number */ dev =3D NULL; i =3D clone_create(&drv->clones, &drv->cdevsw, &unit, &dev, 0); /* No preexisting struct cdev *, create one */ if (i !=3D 0) i =3D tun_create_device(drv, unit, NULL, &dev, name); if (i =3D=3D 0) { tuncreate(dev); struct tuntap_softc *tp =3D dev->si_drv1; *ifpp =3D tp->tun_ifp; } return (i); } ``` When an interface is renamed, its unit number is not `freed` and thus lead = this problem. Other interfaces such as if_bridge are also affected. ``` # ifconfig bridge0 create name br0 # ifconfig bridge0 create ifconfig: interface bridge0 already exists ``` --=20 You are receiving this mail because: You are the assignee for the bug.=