#include "path-util.h"
#include "networkd.h"
#include "libudev-private.h"
+#include "udev-util.h"
int manager_new(Manager **ret) {
_cleanup_manager_free_ Manager *m = NULL;
if (r < 0)
return r;
+ sd_event_set_watchdog(m->event, true);
+
r = sd_rtnl_open(RTMGRP_LINK | RTMGRP_IPV4_IFADDR, &m->rtnl);
if (r < 0)
return r;
static int manager_dispatch_link_udev(sd_event_source *source, int fd, uint32_t revents, void *userdata) {
Manager *m = userdata;
struct udev_monitor *monitor = m->udev_monitor;
- struct udev_device *device;
- int r;
+ _cleanup_udev_device_unref_ struct udev_device *device = NULL;
device = udev_monitor_receive_device(monitor);
if (!device)
return -ENOMEM;
- r = manager_process_link(m, device);
- if (r < 0)
- return r;
-
- udev_device_unref(device);
-
+ manager_process_link(m, device);
return 0;
}
static int manager_rtnl_process_link(sd_rtnl *rtnl, sd_rtnl_message *message, void *userdata) {
Manager *m = userdata;
Link *link;
- unsigned flags;
int r, ifindex;
r = sd_rtnl_message_link_get_ifindex(message, &ifindex);
if (!link)
return 0;
- r = sd_rtnl_message_link_get_flags(message, &flags);
- if (r < 0)
- return 0;
-
- r = link_update_flags(link, flags);
+ r = link_update(link, message);
if (r < 0)
return 0;