Gentoo Archives: gentoo-commits

From: "Anthony G. Basile" <blueness@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/eudev:master commit in: src/udev/
Date: Mon, 23 Aug 2021 16:03:21
Message-Id: 1629734585.841cd0ce3f6b97fbf77e12a6018a2c4a633eba89.blueness@gentoo
1 commit: 841cd0ce3f6b97fbf77e12a6018a2c4a633eba89
2 Author: Andoni Zarate <aiz <AT> arteche <DOT> es>
3 AuthorDate: Fri Apr 23 10:32:47 2021 +0000
4 Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
5 CommitDate: Mon Aug 23 16:03:05 2021 +0000
6 URL: https://gitweb.gentoo.org/proj/eudev.git/commit/?id=841cd0ce
7
8 On collision rename my name to a temporal one letting others got my name...
9
10 Signed-off-by: Anthony G. Basile <blueness <AT> gentoo.org>
11
12 src/udev/udev-event.c | 11 +++++++++++
13 1 file changed, 11 insertions(+)
14
15 diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
16 index 4120c04f2..64cc69cbc 100644
17 --- a/src/udev/udev-event.c
18 +++ b/src/udev/udev-event.c
19 @@ -826,6 +826,7 @@ static int rename_netif_dev_fromname_toname(struct udev_device *dev,const char *
20
21 #ifdef ENABLE_RULE_GENERATOR
22 int loop;
23 + struct ifreq ifr_tmp;
24
25 if (r == 0) {
26 log_info("renamed network interface %s to %s\n", ifr.ifr_name, ifr.ifr_newname);
27 @@ -835,6 +836,16 @@ static int rename_netif_dev_fromname_toname(struct udev_device *dev,const char *
28 log_debug("collision on rename of network interface %s to %s , retrying until timeout\n",
29 ifr.ifr_name, ifr.ifr_newname);
30
31 + /* there has been a collision so rename my name to a temporal name, letting other one to rename to my name, freeying its name... */
32 + memzero(&ifr_tmp, sizeof(struct ifreq));
33 + strscpy(ifr_tmp.ifr_name, IFNAMSIZ, oldname);
34 + snprintf(ifr_tmp.ifr_newname, IFNAMSIZ, "rename_%s", oldname);
35 + r = ioctl(sk, SIOCSIFNAME, &ifr_tmp);
36 + log_info("Temporarily renamed network interface %s to %s\n", ifr_tmp.ifr_name, ifr_tmp.ifr_newname);
37 +
38 + /* we have changed our name so in subsequents tries i should rename my temporal name to the wanted one */
39 + strscpy(ifr.ifr_name, IFNAMSIZ, ifr_tmp.ifr_newname);
40 +
41 r = -errno;
42 if (r != -EEXIST)
43 goto out;