diff options
Diffstat (limited to 'src/core/devices/team')
| -rw-r--r-- | src/core/devices/team/nm-device-team.c | 62 | ||||
| -rw-r--r-- | src/core/devices/team/nm-device-team.h | 3 | ||||
| -rw-r--r-- | src/core/devices/team/nm-team-factory.c | 2 |
3 files changed, 41 insertions, 26 deletions
diff --git a/src/core/devices/team/nm-device-team.c b/src/core/devices/team/nm-device-team.c index 9eca008a..3e3fe52b 100644 --- a/src/core/devices/team/nm-device-team.c +++ b/src/core/devices/team/nm-device-team.c @@ -144,6 +144,7 @@ _update_port_config(NMDeviceTeam *self, const char *port_iface, const char *sani NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE(self); int err; + _LOGT(LOGD_TEAM, "setting port config: %s", sanitized_config); err = teamdctl_port_config_update_raw(priv->tdc, port_iface, sanitized_config); if (err != 0) { _LOGE(LOGD_TEAM, "failed to update config for port %s (err=%d)", port_iface, err); @@ -154,23 +155,20 @@ _update_port_config(NMDeviceTeam *self, const char *port_iface, const char *sani } static gboolean -ensure_teamd_connection(NMDevice *device) +ensure_teamd_connection(NMDevice *device, GError **error) { - NMDeviceTeam *self = NM_DEVICE_TEAM(device); - NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE(self); - gs_free_error GError *error = NULL; - const char *port_iface; - const char *port_config; - GHashTableIter iter; + NMDeviceTeam *self = NM_DEVICE_TEAM(device); + NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE(self); + const char *port_iface; + const char *port_config; + GHashTableIter iter; if (priv->tdc) return TRUE; - priv->tdc = _tdc_connect_new(self, nm_device_get_iface(device), &error); - if (!priv->tdc) { - _LOGE(LOGD_TEAM, "failed to connect to teamd: %s", error->message); + priv->tdc = _tdc_connect_new(self, nm_device_get_iface(device), error); + if (!priv->tdc) return FALSE; - } g_hash_table_iter_init(&iter, priv->port_configs); while (g_hash_table_iter_next(&iter, (gpointer *) &port_iface, (gpointer *) &port_config)) @@ -229,10 +227,17 @@ update_connection(NMDevice *device, NMConnection *connection) NMSettingTeam *s_team = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_TEAM); NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE(self); struct teamdctl *tdc = priv->tdc; + GError *error = NULL; /* Read the configuration only if not already set */ - if (!priv->config && ensure_teamd_connection(device)) - teamd_read_config(self); + if (!priv->config) { + if (ensure_teamd_connection(device, &error)) { + teamd_read_config(self); + } else { + _LOGD(LOGD_TEAM, "could not connect to teamd: %s", error->message); + g_clear_error(&error); + } + } /* Restore previous tdc state */ if (priv->tdc && !tdc) { @@ -258,9 +263,10 @@ master_update_slave_connection(NMDevice *device, gs_free_error GError *connect_error = NULL; int err = 0; struct teamdctl *tdc; - const char *team_port_config = NULL; - const char *iface = nm_device_get_iface(device); - const char *iface_slave = nm_device_get_iface(slave); + const char *team_port_config = NULL; + const char *iface = nm_device_get_iface(device); + const char *iface_slave = nm_device_get_iface(slave); + NMConnection *applied_connection = nm_device_get_applied_connection(device); tdc = _tdc_connect_new(self, iface, &connect_error); if (!tdc) { @@ -299,7 +305,7 @@ master_update_slave_connection(NMDevice *device, g_object_set(nm_connection_get_setting_connection(connection), NM_SETTING_CONNECTION_MASTER, - iface, + nm_connection_get_uuid(applied_connection), NM_SETTING_CONNECTION_SLAVE_TYPE, NM_SETTING_TEAM_SETTING_NAME, NULL); @@ -397,6 +403,7 @@ teamd_ready(NMDeviceTeam *self) NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE(self); NMDevice *device = NM_DEVICE(self); gboolean success; + GError *error = NULL; if (priv->kill_in_progress) { /* If we are currently killing teamd, we are not @@ -410,7 +417,11 @@ teamd_ready(NMDeviceTeam *self) * immediately. But if we are, and grabbing it failed, fail the * device activation. */ - success = ensure_teamd_connection(device); + success = ensure_teamd_connection(device, &error); + if (!success) { + _LOGW(LOGD_TEAM, "could not connect to teamd: %s", error->message); + g_clear_error(&error); + } if (nm_device_get_state(device) != NM_DEVICE_STATE_PREPARE || priv->stage1_state != NM_DEVICE_STAGE_STATE_PENDING) @@ -759,18 +770,20 @@ teamd_start(NMDeviceTeam *self) static NMActStageReturn act_stage1_prepare(NMDevice *device, NMDeviceStateReason *out_failure_reason) { - NMDeviceTeam *self = NM_DEVICE_TEAM(device); - NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE(self); - gs_free_error GError *error = NULL; - NMSettingTeam *s_team; - const char *cfg; + NMDeviceTeam *self = NM_DEVICE_TEAM(device); + NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE(self); + GError *error = NULL; + NMSettingTeam *s_team; + const char *cfg; if (nm_device_sys_iface_state_is_external(device)) return NM_ACT_STAGE_RETURN_SUCCESS; if (nm_device_sys_iface_state_is_external_or_assume(device)) { - if (ensure_teamd_connection(device)) + if (ensure_teamd_connection(device, &error)) return NM_ACT_STAGE_RETURN_SUCCESS; + _LOGD(LOGD_TEAM, "could not connect to teamd: %s", error->message); + g_clear_error(&error); } s_team = nm_device_get_applied_setting(device, NM_TYPE_SETTING_TEAM); @@ -803,6 +816,7 @@ act_stage1_prepare(NMDevice *device, NMDeviceStateReason *out_failure_reason) _LOGW(LOGD_TEAM, "existing teamd config mismatch; failed to kill existing teamd: %s", error->message); + g_clear_error(&error); NM_SET_OUT(out_failure_reason, NM_DEVICE_STATE_REASON_TEAMD_CONTROL_FAILED); return NM_ACT_STAGE_RETURN_FAILURE; } diff --git a/src/core/devices/team/nm-device-team.h b/src/core/devices/team/nm-device-team.h index 6f5cff93..e2a54c6e 100644 --- a/src/core/devices/team/nm-device-team.h +++ b/src/core/devices/team/nm-device-team.h @@ -9,7 +9,8 @@ #include "devices/nm-device.h" #define NM_TYPE_DEVICE_TEAM (nm_device_team_get_type()) -#define NM_DEVICE_TEAM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_DEVICE_TEAM, NMDeviceTeam)) +#define NM_DEVICE_TEAM(obj) \ + (_NM_G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_DEVICE_TEAM, NMDeviceTeam)) #define NM_DEVICE_TEAM_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST((klass), NM_TYPE_DEVICE_TEAM, NMDeviceTeamClass)) #define NM_IS_DEVICE_TEAM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), NM_TYPE_DEVICE_TEAM)) diff --git a/src/core/devices/team/nm-team-factory.c b/src/core/devices/team/nm-team-factory.c index b446cbd0..68ea914e 100644 --- a/src/core/devices/team/nm-team-factory.c +++ b/src/core/devices/team/nm-team-factory.c @@ -17,7 +17,7 @@ #define NM_TYPE_TEAM_FACTORY (nm_team_factory_get_type()) #define NM_TEAM_FACTORY(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_TEAM_FACTORY, NMTeamFactory)) + (_NM_G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_TEAM_FACTORY, NMTeamFactory)) #define NM_TEAM_FACTORY_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST((klass), NM_TYPE_TEAM_FACTORY, NMTeamFactoryClass)) #define NM_IS_TEAM_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), NM_TYPE_TEAM_FACTORY)) |