summaryrefslogtreecommitdiff
path: root/src/udev/udev-event.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-09-09 11:15:37 +0200
committerTom Gundersen <teg@jklm.no>2014-09-09 15:30:10 +0200
commit4c83d994566718043e61e568cc214bdc4587f869 (patch)
tree19d720648aee971cc588171d887e1bd4dff889db /src/udev/udev-event.c
parentb081b27e1433cdc7ac72b25ae8b4db887d79187f (diff)
udev: event - keep one rtnl per worker, rather than per event
Creating the rtnl context is cheap, but freeing it may not be, due to synchronous close(). Also drop some excessive logging. We now log about the changing ifname exactly once.
Diffstat (limited to 'src/udev/udev-event.c')
-rw-r--r--src/udev/udev-event.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
index 18b92ca428..1bbf41e757 100644
--- a/src/udev/udev-event.c
+++ b/src/udev/udev-event.c
@@ -53,6 +53,7 @@ struct udev_event *udev_event_new(struct udev_device *dev) {
void udev_event_unref(struct udev_event *event) {
if (event == NULL)
return;
+ sd_rtnl_unref(event->rtnl);
udev_list_cleanup(&event->run_list);
udev_list_cleanup(&event->seclabel_list);
free(event->program_result);
@@ -746,30 +747,24 @@ out:
static int rename_netif(struct udev_event *event) {
struct udev_device *dev = event->dev;
- _cleanup_rtnl_unref_ sd_rtnl *rtnl = NULL;
char name[IFNAMSIZ];
const char *oldname;
int r;
oldname = udev_device_get_sysname(dev);
- log_debug("changing net interface name from '%s' to '%s'",
- oldname, event->name);
-
strscpy(name, IFNAMSIZ, event->name);
- r = sd_rtnl_open(&rtnl, 0);
- if (r < 0)
+ r = rtnl_set_link_name(&event->rtnl, udev_device_get_ifindex(dev), name);
+ if (r < 0) {
+ log_error("error changing net interface name '%s' to '%s': %s",
+ oldname, name, strerror(-r));
return r;
+ }
- r = rtnl_set_link_name(rtnl, udev_device_get_ifindex(dev), name);
- if (r < 0)
- log_error("error changing net interface name %s to %s: %s",
- oldname, name, strerror(-r));
- else
- print_kmsg("renamed network interface %s to %s\n", oldname, name);
+ print_kmsg("renamed network interface '%s' to '%s'\n", oldname, name);
- return r;
+ return 0;
}
void udev_event_execute_rules(struct udev_event *event,
@@ -832,8 +827,6 @@ void udev_event_execute_rules(struct udev_event *event,
r = rename_netif(event);
if (r >= 0) {
- log_debug("renamed netif to '%s'", event->name);
-
/* remember old name */
udev_device_add_property(dev, "INTERFACE_OLD", udev_device_get_sysname(dev));