summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKay Sievers <kay@vrfy.org>2014-05-15 17:25:25 -0400
committerAnthony G. Basile <blueness@gentoo.org>2014-05-15 17:25:25 -0400
commitdb992ba3a71f320faab8f90de77ef081305917bb (patch)
tree9be0abc33175d53f895eaf636ea46fdb533fa01b
parent47ef6b2c66048f898d22c8dddee581d3f55a48c8 (diff)
udev: do not skip the execution of RUN when renaming a network device fails
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
-rw-r--r--src/udev/udev-event.c31
-rw-r--r--src/udev/udev.h2
-rw-r--r--src/udev/udevadm-test.c13
-rw-r--r--src/udev/udevd.c5
-rw-r--r--test/test-udev.c5
5 files changed, 25 insertions, 31 deletions
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
index 91c34f6265..783c8cf0a7 100644
--- a/src/udev/udev-event.c
+++ b/src/udev/udev-event.c
@@ -835,13 +835,12 @@ static int rename_netif(struct udev_event *event)
return rename_netif_dev_fromname_toname(event->dev,udev_device_get_sysname(event->dev),event->name);
}
-int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules, const sigset_t *sigmask)
+void udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules, const sigset_t *sigmask)
{
struct udev_device *dev = event->dev;
- int err = 0;
if (udev_device_get_subsystem(dev) == NULL)
- return -1;
+ return;
if (streq(udev_device_get_action(dev), "remove")) {
udev_device_read_db(dev, NULL);
@@ -889,9 +888,10 @@ int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules,
* the current name IS used AND the target name != the current name
*/
+ int r;
if (udev_device_get_ifindex(dev) > 0 && streq(udev_device_get_action(dev), "add") &&
#ifdef ENABLE_RULE_GENERATOR
- (event->name == NULL && (err=udev_rules_assigning_name_to(rules,udev_device_get_sysname(dev))) > 0 ||
+ (event->name == NULL && (r=udev_rules_assigning_name_to(rules,udev_device_get_sysname(dev))) > 0 ||
event->name != NULL && !streq(event->name, udev_device_get_sysname(dev)))) {
#else
event->name != NULL && !streq(event->name, udev_device_get_sysname(dev))) {
@@ -902,8 +902,8 @@ int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules,
#ifdef ENABLE_RULE_GENERATOR
char newifname[IFNAMSIZ];
- /* err is the number of rules that assign a device with NAME= this sysname */
- if (err > 0 || (err=udev_rules_assigning_name_to(rules,udev_device_get_sysname(dev))) > 0) {
+ /* r is the number of rules that assign a device with NAME= this sysname */
+ if (r > 0 || (r=udev_rules_assigning_name_to(rules,udev_device_get_sysname(dev))) > 0) {
/* have a conflict, rename to a temp name */
char *newpos;
int ifidnum;
@@ -917,12 +917,12 @@ int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules,
/* use udev_device_get_ifindex(dev) as it is unique to every iface */
snprintf(pos,IFNAMSIZ+(newifname-pos), "%d", 128 - udev_device_get_ifindex(dev));
- /* note, err > 0, which will skip the post-rename stuff if no rename occurs */
+ /* note, r > 0, which will skip the post-rename stuff if no rename occurs */
/* if sysname isn't already the tmpname (ie there is no numeric component), do the rename */
if (!streq(newifname,udev_device_get_sysname(dev))) {
- err = rename_netif_dev_fromname_toname(dev,udev_device_get_sysname(dev),newifname);
- if (err == 0) {
+ r = rename_netif_dev_fromname_toname(dev,udev_device_get_sysname(dev),newifname);
+ if (r == 0) {
finalifname = newifname;
log_debug("renamed netif to '%s' for collision avoidance\n", newifname);
} else {
@@ -931,22 +931,22 @@ int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules,
}
/* rename it now to its final target if its not already there */
if (event->name != NULL && !streq(event->name, newifname)) {
- err = rename_netif_dev_fromname_toname(dev,newifname,event->name);
- if (err == 0)
+ r = rename_netif_dev_fromname_toname(dev,newifname,event->name);
+ if (r == 0)
finalifname = event->name;
}
} else { /* no need to rename to a tempname first, do a regular direct rename to event->name */
- err = 1; /* skip the post-rename stuff if no rename occurs */
+ r = 1; /* skip the post-rename stuff if no rename occurs */
if (!streq(event->name, udev_device_get_sysname(dev)))
- err = rename_netif(event);
+ r = rename_netif(event);
}
#else
- err = rename_netif(event);
+ r = rename_netif(event);
#endif
- if (err == 0) {
+ if (r >= 0) {
log_debug("renamed netif to '%s'", finalifname);
/* remember old name */
@@ -1009,7 +1009,6 @@ int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules,
udev_device_unref(event->dev_db);
event->dev_db = NULL;
}
- return err;
}
void udev_event_execute_run(struct udev_event *event, const sigset_t *sigmask)
diff --git a/src/udev/udev.h b/src/udev/udev.h
index 5e013d4f01..86a9ea6809 100644
--- a/src/udev/udev.h
+++ b/src/udev/udev.h
@@ -84,7 +84,7 @@ int udev_event_apply_subsys_kernel(struct udev_event *event, const char *string,
int udev_event_spawn(struct udev_event *event,
const char *cmd, char **envp, const sigset_t *sigmask,
char *result, size_t ressize);
-int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules, const sigset_t *sigset);
+void udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules, const sigset_t *sigset);
void udev_event_execute_run(struct udev_event *event, const sigset_t *sigset);
int udev_build_argv(struct udev *udev, char *cmd, int *argc, char *argv[]);
diff --git a/src/udev/udevadm-test.c b/src/udev/udevadm-test.c
index 6cd311b27d..6a2f5489fe 100644
--- a/src/udev/udevadm-test.c
+++ b/src/udev/udevadm-test.c
@@ -43,7 +43,6 @@ static int adm_test(struct udev *udev, int argc, char *argv[])
_cleanup_udev_device_unref_ struct udev_device *dev = NULL;
_cleanup_udev_event_unref_ struct udev_event *event = NULL;
sigset_t mask, sigmask_orig;
- int err;
int rc = 0, c;
static const struct option options[] = {
@@ -139,18 +138,16 @@ static int adm_test(struct udev *udev, int argc, char *argv[])
goto out;
}
- err = udev_event_execute_rules(event, rules, &sigmask_orig);
+ udev_event_execute_rules(event, rules, &sigmask_orig);
udev_list_entry_foreach(entry, udev_device_get_properties_list_entry(dev))
printf("%s=%s\n", udev_list_entry_get_name(entry), udev_list_entry_get_value(entry));
- if (err == 0) {
- udev_list_entry_foreach(entry, udev_list_get_entry(&event->run_list)) {
- char program[UTIL_PATH_SIZE];
+ udev_list_entry_foreach(entry, udev_list_get_entry(&event->run_list)) {
+ char program[UTIL_PATH_SIZE];
- udev_event_apply_format(event, udev_list_entry_get_name(entry), program, sizeof(program));
- printf("run: '%s'\n", program);
- }
+ udev_event_apply_format(event, udev_list_entry_get_name(entry), program, sizeof(program));
+ printf("run: '%s'\n", program);
}
out:
if (event != NULL && event->fd_signal >= 0)
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 0ac6ee091b..c51aa1b254 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -307,10 +307,9 @@ static void worker_new(struct event *event)
}
/* apply rules, create node, symlinks */
- err = udev_event_execute_rules(udev_event, rules, &sigmask_orig);
+ udev_event_execute_rules(udev_event, rules, &sigmask_orig);
- if (err == 0)
- udev_event_execute_run(udev_event, &sigmask_orig);
+ udev_event_execute_run(udev_event, &sigmask_orig);
/* apply/restore inotify watch */
if (err == 0 && udev_event->inotify_watch) {
diff --git a/test/test-udev.c b/test/test-udev.c
index e28cdae563..1828d54e42 100644
--- a/test/test-udev.c
+++ b/test/test-udev.c
@@ -165,9 +165,8 @@ int main(int argc, char *argv[]) {
}
}
- err = udev_event_execute_rules(event, rules, &sigmask_orig);
- if (err == 0)
- udev_event_execute_run(event, NULL);
+ udev_event_execute_rules(event, rules, &sigmask_orig);
+ udev_event_execute_run(event, NULL);
out:
if (event != NULL && event->fd_signal >= 0)
close(event->fd_signal);