Date: Wed, 19 Apr 2023 03:24:44 +0000 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 Message-ID: <bug-235920-7501-f75x3FUT6y@https.bugs.freebsd.org/bugzilla/> In-Reply-To: <bug-235920-7501@https.bugs.freebsd.org/bugzilla/> References: <bug-235920-7501@https.bugs.freebsd.org/bugzilla/>
next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D235920 --- Comment #4 from Zhenlei Huang <zlei@FreeBSD.org> --- (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.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-235920-7501-f75x3FUT6y>