core: add 'device-ifindex-changed' signal

NMManager now emits a 'device-ifindex-changed' whenever
a device ifindex gets changed.

https://bugzilla.redhat.com/show_bug.cgi?id=1870691

Signed-off-by: Antonio Cardace <acardace@redhat.com>
This commit is contained in:
Antonio Cardace 2021-01-19 18:57:58 +01:00
parent 84dc705159
commit 374cc96126
No known key found for this signature in database
GPG key ID: 6BF80ABD43E377D3
3 changed files with 22 additions and 0 deletions

View file

@ -2885,6 +2885,8 @@ _set_ifindex(NMDevice *self, int ifindex, gboolean is_ip_ifindex)
if (!is_ip_ifindex)
_notify(self, PROP_IFINDEX);
if (priv->manager)
nm_manager_emit_device_ifindex_changed(priv->manager, self);
return TRUE;
}

View file

@ -102,6 +102,7 @@ enum {
ACTIVE_CONNECTION_ADDED,
ACTIVE_CONNECTION_REMOVED,
CONFIGURE_QUIT,
DEVICE_IFINDEX_CHANGED,
LAST_SIGNAL
};
@ -7622,6 +7623,12 @@ nm_manager_set_capability(NMManager *self, NMCapability cap)
_notify(self, PROP_CAPABILITIES);
}
void
nm_manager_emit_device_ifindex_changed(NMManager *self, NMDevice *device)
{
g_signal_emit(self, signals[DEVICE_IFINDEX_CHANGED], 0, device);
}
/*****************************************************************************/
NM_DEFINE_SINGLETON_REGISTER(NMManager);
@ -8675,4 +8682,15 @@ nm_manager_class_init(NMManagerClass *manager_class)
NULL,
G_TYPE_NONE,
0);
signals[DEVICE_IFINDEX_CHANGED] = g_signal_new(NM_MANAGER_DEVICE_IFINDEX_CHANGED,
G_OBJECT_CLASS_TYPE(object_class),
G_SIGNAL_RUN_FIRST,
0,
NULL,
NULL,
NULL,
G_TYPE_NONE,
1,
NM_TYPE_DEVICE);
}

View file

@ -50,6 +50,7 @@
/* Signals */
#define NM_MANAGER_DEVICE_ADDED "device-added"
#define NM_MANAGER_DEVICE_REMOVED "device-removed"
#define NM_MANAGER_DEVICE_IFINDEX_CHANGED "device-ifindex-changed"
#define NM_MANAGER_USER_PERMISSIONS_CHANGED "user-permissions-changed"
#define NM_MANAGER_ACTIVE_CONNECTION_ADDED "active-connection-added"
@ -180,6 +181,7 @@ gboolean nm_manager_deactivate_connection(NMManager * manager,
GError ** error);
void nm_manager_set_capability(NMManager *self, NMCapability cap);
void nm_manager_emit_device_ifindex_changed(NMManager *self, NMDevice *device);
NMDevice *nm_manager_get_device(NMManager *self, const char *ifname, NMDeviceType device_type);
gboolean nm_manager_remove_device(NMManager *self, const char *ifname, NMDeviceType device_type);