summaryrefslogtreecommitdiff
path: root/libudev
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 /libudev
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 'libudev')
-rw-r--r--libudev/libudev-device.c16
-rw-r--r--libudev/libudev-private.h2
2 files changed, 18 insertions, 0 deletions
diff --git a/libudev/libudev-device.c b/libudev/libudev-device.c
index 5811490a34..e5f8cc3e46 100644
--- a/libudev/libudev-device.c
+++ b/libudev/libudev-device.c
@@ -67,6 +67,7 @@ struct udev_device {
int devlink_priority;
int refcount;
dev_t devnum;
+ int ifindex;
int watch_handle;
int maj, min;
bool parent_set;
@@ -187,6 +188,8 @@ void udev_device_add_property_from_string_parse(struct udev_device *udev_device,
udev_device_set_seqnum(udev_device, strtoull(&property[7], NULL, 10));
} else if (strncmp(property, "TIMEOUT=", 8) == 0) {
udev_device_set_timeout(udev_device, strtoull(&property[8], NULL, 10));
+ } else if (strncmp(property, "IFINDEX=", 8) == 0) {
+ udev_device_set_ifindex(udev_device, strtoull(&property[8], NULL, 10));
} else {
udev_device_add_property_from_string(udev_device, property);
}
@@ -358,6 +361,8 @@ int udev_device_read_uevent_file(struct udev_device *udev_device)
maj = strtoull(&line[6], NULL, 10);
else if (strncmp(line, "MINOR=", 6) == 0)
min = strtoull(&line[6], NULL, 10);
+ else if (strncmp(line, "IFINDEX=", 8) == 0)
+ udev_device_set_ifindex(udev_device, strtoull(&line[8], NULL, 10));
else if (strncmp(line, "DEVNAME=", 8) == 0)
udev_device_set_knodename(udev_device, &line[8]);
@@ -1536,3 +1541,14 @@ int udev_device_set_watch_handle(struct udev_device *udev_device, int handle)
udev_device->watch_handle = handle;
return 0;
}
+
+int udev_device_get_ifindex(struct udev_device *udev_device)
+{
+ return udev_device->ifindex;
+}
+
+int udev_device_set_ifindex(struct udev_device *udev_device, int ifindex)
+{
+ udev_device->ifindex = ifindex;
+ return 0;
+}
diff --git a/libudev/libudev-private.h b/libudev/libudev-private.h
index 7ed4afc42c..c9ed46211c 100644
--- a/libudev/libudev-private.h
+++ b/libudev/libudev-private.h
@@ -99,6 +99,8 @@ int udev_device_get_devlink_priority(struct udev_device *udev_device);
int udev_device_set_devlink_priority(struct udev_device *udev_device, int prio);
int udev_device_get_watch_handle(struct udev_device *udev_device);
int udev_device_set_watch_handle(struct udev_device *udev_device, int handle);
+int udev_device_get_ifindex(struct udev_device *udev_device);
+int udev_device_set_ifindex(struct udev_device *udev_device, int ifindex);
void udev_device_set_info_loaded(struct udev_device *device);
/* libudev-device-private.c */