core: merge branch 'bg/update-dev-state-file-rh1593282'
https://github.com/NetworkManager/NetworkManager/pull/178 https://bugzilla.redhat.com/show_bug.cgi?id=1593282
This commit is contained in:
@@ -59,7 +59,6 @@
|
||||
#endif
|
||||
|
||||
#define NM_DEFAULT_PID_FILE NMRUNDIR "/NetworkManager.pid"
|
||||
#define NM_DEFAULT_SYSTEM_STATE_FILE NMSTATEDIR "/NetworkManager.state"
|
||||
|
||||
#define CONFIG_ATOMIC_SECTION_PREFIXES ((char **) NULL)
|
||||
|
||||
@@ -444,7 +443,7 @@ done:
|
||||
* state here. We don't bother updating the state as devices
|
||||
* change during regular operation. If NM is killed with SIGKILL,
|
||||
* it misses to update the state. */
|
||||
nm_manager_write_device_state (manager);
|
||||
nm_manager_write_device_state_all (manager);
|
||||
|
||||
nm_manager_stop (manager);
|
||||
|
||||
|
@@ -1459,20 +1459,23 @@ manager_device_state_changed (NMDevice *device,
|
||||
&& new_state > NM_DEVICE_STATE_UNMANAGED)
|
||||
retry_connections_for_parent_device (self, device);
|
||||
|
||||
switch (new_state) {
|
||||
case NM_DEVICE_STATE_UNMANAGED:
|
||||
case NM_DEVICE_STATE_UNAVAILABLE:
|
||||
case NM_DEVICE_STATE_DISCONNECTED:
|
||||
case NM_DEVICE_STATE_PREPARE:
|
||||
case NM_DEVICE_STATE_FAILED:
|
||||
if (NM_IN_SET (new_state,
|
||||
NM_DEVICE_STATE_UNMANAGED,
|
||||
NM_DEVICE_STATE_UNAVAILABLE,
|
||||
NM_DEVICE_STATE_DISCONNECTED,
|
||||
NM_DEVICE_STATE_PREPARE,
|
||||
NM_DEVICE_STATE_FAILED))
|
||||
_notify (self, PROP_ACTIVE_CONNECTIONS);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if ( new_state == NM_DEVICE_STATE_UNAVAILABLE
|
||||
|| new_state == NM_DEVICE_STATE_DISCONNECTED)
|
||||
if (NM_IN_SET (new_state,
|
||||
NM_DEVICE_STATE_UNMANAGED,
|
||||
NM_DEVICE_STATE_DISCONNECTED,
|
||||
NM_DEVICE_STATE_ACTIVATED))
|
||||
nm_manager_write_device_state (self, device);
|
||||
|
||||
if (NM_IN_SET (new_state,
|
||||
NM_DEVICE_STATE_UNAVAILABLE,
|
||||
NM_DEVICE_STATE_DISCONNECTED))
|
||||
nm_settings_device_added (priv->settings, device);
|
||||
}
|
||||
|
||||
@@ -5934,17 +5937,10 @@ start_factory (NMDeviceFactory *factory, gpointer user_data)
|
||||
nm_device_factory_start (factory);
|
||||
}
|
||||
|
||||
void
|
||||
nm_manager_write_device_state (NMManager *self)
|
||||
gboolean
|
||||
nm_manager_write_device_state (NMManager *self, NMDevice *device)
|
||||
{
|
||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
||||
NMDevice *device;
|
||||
gs_unref_hashtable GHashTable *seen_ifindexes = NULL;
|
||||
int nm_owned;
|
||||
|
||||
seen_ifindexes = g_hash_table_new (nm_direct_hash, NULL);
|
||||
|
||||
c_list_for_each_entry (device, &priv->devices_lst_head, devices_lst) {
|
||||
int ifindex;
|
||||
gboolean managed;
|
||||
NMConfigDeviceStateManagedType managed_type;
|
||||
@@ -5954,17 +5950,18 @@ nm_manager_write_device_state (NMManager *self)
|
||||
gboolean perm_hw_addr_is_fake;
|
||||
guint32 route_metric_default_aspired;
|
||||
guint32 route_metric_default_effective;
|
||||
int nm_owned;
|
||||
|
||||
ifindex = nm_device_get_ip_ifindex (device);
|
||||
if (ifindex <= 0)
|
||||
continue;
|
||||
return FALSE;
|
||||
if (ifindex == 1) {
|
||||
/* ignore loopback */
|
||||
continue;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!nm_platform_link_get (priv->platform, ifindex))
|
||||
continue;
|
||||
return FALSE;
|
||||
|
||||
managed = nm_device_get_managed (device, FALSE);
|
||||
if (managed) {
|
||||
@@ -5986,14 +5983,29 @@ nm_manager_write_device_state (NMManager *self)
|
||||
route_metric_default_effective = _device_route_metric_get (self, ifindex, NM_DEVICE_TYPE_UNKNOWN,
|
||||
TRUE, &route_metric_default_aspired);
|
||||
|
||||
if (nm_config_device_state_write (ifindex,
|
||||
return nm_config_device_state_write (ifindex,
|
||||
managed_type,
|
||||
perm_hw_addr_fake,
|
||||
uuid,
|
||||
nm_owned,
|
||||
route_metric_default_aspired,
|
||||
route_metric_default_effective))
|
||||
g_hash_table_add (seen_ifindexes, GINT_TO_POINTER (ifindex));
|
||||
route_metric_default_effective);
|
||||
}
|
||||
|
||||
void
|
||||
nm_manager_write_device_state_all (NMManager *self)
|
||||
{
|
||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
||||
gs_unref_hashtable GHashTable *seen_ifindexes = NULL;
|
||||
NMDevice *device;
|
||||
|
||||
seen_ifindexes = g_hash_table_new (nm_direct_hash, NULL);
|
||||
|
||||
c_list_for_each_entry (device, &priv->devices_lst_head, devices_lst) {
|
||||
if (nm_manager_write_device_state (self, device)) {
|
||||
g_hash_table_add (seen_ifindexes,
|
||||
GINT_TO_POINTER (nm_device_get_ip_ifindex (device)));
|
||||
}
|
||||
}
|
||||
|
||||
nm_config_device_state_prune_unseen (seen_ifindexes);
|
||||
|
@@ -101,7 +101,8 @@ NMSettingsConnection **nm_manager_get_activatable_connections (NMManager *manage
|
||||
guint *out_len,
|
||||
gboolean sort);
|
||||
|
||||
void nm_manager_write_device_state (NMManager *manager);
|
||||
void nm_manager_write_device_state_all (NMManager *manager);
|
||||
gboolean nm_manager_write_device_state (NMManager *manager, NMDevice *device);
|
||||
|
||||
/* Device handling */
|
||||
|
||||
|
Reference in New Issue
Block a user