From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 534011580B9 for ; Mon, 23 Aug 2021 16:03:21 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 8E322E086D; Mon, 23 Aug 2021 16:03:20 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 71824E086D for ; Mon, 23 Aug 2021 16:03:20 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 5A7CD335D79 for ; Mon, 23 Aug 2021 16:03:19 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id D11877B2 for ; Mon, 23 Aug 2021 16:03:17 +0000 (UTC) From: "Anthony G. Basile" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Anthony G. Basile" Message-ID: <1629734585.841cd0ce3f6b97fbf77e12a6018a2c4a633eba89.blueness@gentoo> Subject: [gentoo-commits] proj/eudev:master commit in: src/udev/ X-VCS-Repository: proj/eudev X-VCS-Files: src/udev/udev-event.c X-VCS-Directories: src/udev/ X-VCS-Committer: blueness X-VCS-Committer-Name: Anthony G. Basile X-VCS-Revision: 841cd0ce3f6b97fbf77e12a6018a2c4a633eba89 X-VCS-Branch: master Date: Mon, 23 Aug 2021 16:03:17 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 0ef1f65c-14dc-4cf9-95ba-1ebe73a14f33 X-Archives-Hash: c929e78f3a5c32efec9da5ddf7eeee9a commit: 841cd0ce3f6b97fbf77e12a6018a2c4a633eba89 Author: Andoni Zarate arteche es> AuthorDate: Fri Apr 23 10:32:47 2021 +0000 Commit: Anthony G. Basile gentoo org> CommitDate: Mon Aug 23 16:03:05 2021 +0000 URL: https://gitweb.gentoo.org/proj/eudev.git/commit/?id=841cd0ce On collision rename my name to a temporal one letting others got my name... Signed-off-by: Anthony G. Basile gentoo.org> src/udev/udev-event.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c index 4120c04f2..64cc69cbc 100644 --- a/src/udev/udev-event.c +++ b/src/udev/udev-event.c @@ -826,6 +826,7 @@ static int rename_netif_dev_fromname_toname(struct udev_device *dev,const char * #ifdef ENABLE_RULE_GENERATOR int loop; + struct ifreq ifr_tmp; if (r == 0) { log_info("renamed network interface %s to %s\n", ifr.ifr_name, ifr.ifr_newname); @@ -835,6 +836,16 @@ static int rename_netif_dev_fromname_toname(struct udev_device *dev,const char * log_debug("collision on rename of network interface %s to %s , retrying until timeout\n", ifr.ifr_name, ifr.ifr_newname); + /* there has been a collision so rename my name to a temporal name, letting other one to rename to my name, freeying its name... */ + memzero(&ifr_tmp, sizeof(struct ifreq)); + strscpy(ifr_tmp.ifr_name, IFNAMSIZ, oldname); + snprintf(ifr_tmp.ifr_newname, IFNAMSIZ, "rename_%s", oldname); + r = ioctl(sk, SIOCSIFNAME, &ifr_tmp); + log_info("Temporarily renamed network interface %s to %s\n", ifr_tmp.ifr_name, ifr_tmp.ifr_newname); + + /* we have changed our name so in subsequents tries i should rename my temporal name to the wanted one */ + strscpy(ifr.ifr_name, IFNAMSIZ, ifr_tmp.ifr_newname); + r = -errno; if (r != -EEXIST) goto out;