Skip to content

Commit

Permalink
events: integrated device-ready in state transition
Browse files Browse the repository at this point in the history
  • Loading branch information
mtomaschewski committed Jul 22, 2014
1 parent c6a185e commit 68deae9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
12 changes: 3 additions & 9 deletions src/ifevent.c
Expand Up @@ -162,6 +162,7 @@ __ni_netdev_process_events(ni_netconfig_t *nc, ni_netdev_t *dev, unsigned int ol
unsigned int event_up;
unsigned int event_down;
} *edge, flag_transitions[] = {
{ NI_IFF_DEVICE_READY, NI_EVENT_DEVICE_READY, 0 },
{ NI_IFF_DEVICE_UP, NI_EVENT_DEVICE_UP, NI_EVENT_DEVICE_DOWN },
{ NI_IFF_LINK_UP, NI_EVENT_LINK_UP, NI_EVENT_LINK_DOWN },
{ NI_IFF_NETWORK_UP, NI_EVENT_NETWORK_UP, NI_EVENT_NETWORK_DOWN },
Expand All @@ -177,14 +178,6 @@ __ni_netdev_process_events(ni_netconfig_t *nc, ni_netdev_t *dev, unsigned int ol
__ni_netdev_event(nc, dev, NI_EVENT_DEVICE_CREATE);
}

/* Hmm.. do we still need this? */
if (!ni_netdev_device_is_ready(dev) &&
(ni_netdev_device_always_ready(dev) ||
!ni_server_listens_uevents())) {
dev->link.ifflags |= NI_IFF_DEVICE_READY;
__ni_netdev_event(nc, dev, NI_EVENT_DEVICE_READY);
}

/* transition up */
for (i = 0; i < flags; ++i) {
edge = &flag_transitions[i];
Expand All @@ -204,7 +197,8 @@ __ni_netdev_process_events(ni_netconfig_t *nc, ni_netdev_t *dev, unsigned int ol
if (dev->ipv6 && edge->event_down == NI_EVENT_DEVICE_DOWN)
ni_ipv6_ra_info_flush(&dev->ipv6->radv);

__ni_netdev_event(nc, dev, edge->event_down);
if (edge->event_down)
__ni_netdev_event(nc, dev, edge->event_down);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/netinfo_priv.h
Expand Up @@ -49,6 +49,7 @@ extern ni_addrconf_lease_t *__ni_netdev_address_to_lease(ni_netdev_t *, const ni
extern ni_addrconf_lease_t *__ni_netdev_route_to_lease(ni_netdev_t *, const ni_route_t *, unsigned int);
extern void __ni_netdev_track_ipv6_autoconf(ni_netdev_t *, int);
extern unsigned int __ni_netdev_translate_ifflags(unsigned int, unsigned int);
extern void __ni_netdev_process_events(ni_netconfig_t *, ni_netdev_t *, unsigned int);
extern void __ni_netdev_event(ni_netconfig_t *, ni_netdev_t *, ni_event_t);
extern int __ni_netdev_record_newroute(ni_netconfig_t *nc, ni_netdev_t *dev, ni_route_t *rp);

Expand Down
9 changes: 6 additions & 3 deletions src/uevent.c
Expand Up @@ -54,6 +54,7 @@
#include <wicked/socket.h>
#include <wicked/netinfo.h>

#include "netinfo_priv.h"
#include "socket_priv.h"
#include "uevent.h"
#include "appconfig.h"
Expand Down Expand Up @@ -651,16 +652,18 @@ __ni_uevent_ifevent_forwarder(const ni_var_array_t *vars, void *user_data)
ni_format_uint_mapped(uinfo.action, __action_map),
uinfo.ifindex,
uinfo.interface, uinfo.interface_old, uinfo.tags);
if (dev) {

if (dev && !(dev->link.ifflags & NI_IFF_DEVICE_READY)) {
unsigned int old_flags = dev->link.ifflags;

if (!ni_string_empty(uinfo.interface_old))
return;

if (!uinfo.tags || !strstr(uinfo.tags, ":systemd:"))
return;

dev->link.ifflags |= NI_IFF_DEVICE_READY;
if (ni_global.interface_event)
ni_global.interface_event(dev, NI_EVENT_DEVICE_READY);
__ni_netdev_process_events(nc, dev, old_flags);
}
}

Expand Down

0 comments on commit 68deae9

Please sign in to comment.