summaryrefslogtreecommitdiff
path: root/udev
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2010-10-13 13:03:27 +0200
committerKay Sievers <kay.sievers@vrfy.org>2010-10-13 13:08:29 +0200
commitfc416258f346cd20cf822705bd0a50de82569a63 (patch)
tree4cf45dedef8daf9f1d2e762c5b099abfc04c3420 /udev
parent457c67e7c1bc971c64e56dd11aaf697d2f9a1c76 (diff)
udevd: do not wrongly delay events for devices with swapped names
Renaming network devices might delay events for the other device, which has the same devpath in the meantime as the original event. Causing a delay until the timout of the event is reached. Look at the ifindex/devnum of the devices to check if they are really the same devices.
Diffstat (limited to 'udev')
-rw-r--r--udev/udevd.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/udev/udevd.c b/udev/udevd.c
index 2efab5b39d..21dde824ee 100644
--- a/udev/udevd.c
+++ b/udev/udevd.c
@@ -123,6 +123,7 @@ struct event {
const char *devpath_old;
dev_t devnum;
bool is_block;
+ int ifindex;
};
static struct event *node_to_event(struct udev_list_node *node)
@@ -419,6 +420,7 @@ static int event_queue_insert(struct udev_device *dev)
event->devpath_old = udev_device_get_devpath_old(dev);
event->devnum = udev_device_get_devnum(dev);
event->is_block = (strcmp("block", udev_device_get_subsystem(dev)) == 0);
+ event->ifindex = udev_device_get_ifindex(dev);
udev_queue_export_device_queued(udev_queue_export, dev);
info(event->udev, "seq %llu queued, '%s' '%s'\n", udev_device_get_seqnum(dev),
@@ -486,6 +488,10 @@ static bool is_devpath_busy(struct event *event)
if (major(event->devnum) != 0 && event->devnum == loop_event->devnum && event->is_block == loop_event->is_block)
return true;
+ /* check network device ifindex */
+ if (event->ifindex != 0 && event->ifindex == loop_event->ifindex)
+ return true;
+
/* check our old name */
if (event->devpath_old != NULL && strcmp(loop_event->devpath, event->devpath_old) == 0) {
event->delaying_seqnum = loop_event->seqnum;
@@ -501,6 +507,11 @@ static bool is_devpath_busy(struct event *event)
/* identical device event found */
if (loop_event->devpath_len == event->devpath_len) {
+ /* devices names might have changed/swapped in the meantime */
+ if (major(event->devnum) != 0 && (event->devnum != loop_event->devnum || event->is_block != loop_event->is_block))
+ continue;
+ if (event->ifindex != 0 && event->ifindex != loop_event->ifindex)
+ continue;
event->delaying_seqnum = loop_event->seqnum;
return true;
}