diff --git a/configure.ac b/configure.ac index a7f60ff616..b20f2dc639 100644 --- a/configure.ac +++ b/configure.ac @@ -396,7 +396,7 @@ fi AM_CONDITIONAL(WITH_WIMAX, test "${enable_wimax}" = "yes") # Teamd control checks -PKG_CHECK_MODULES(LIBTEAMDCTL, [libteamdctl], [have_teamdctl=yes],[have_teamdctl=no]) +PKG_CHECK_MODULES(LIBTEAMDCTL, [libteamdctl >= 1.9], [have_teamdctl=yes],[have_teamdctl=no]) AC_ARG_ENABLE(teamdctl, AS_HELP_STRING([--enable-teamdctl], [enable Teamd control support]), [enable_teamdctl=${enableval}], [enable_teamdctl=${have_teamdctl}]) if (test "${enable_teamdctl}" = "yes"); then diff --git a/src/devices/nm-device-team.c b/src/devices/nm-device-team.c index df37cee308..1cc7641f3c 100644 --- a/src/devices/nm-device-team.c +++ b/src/devices/nm-device-team.c @@ -209,8 +209,9 @@ ensure_teamd_connection (NMDevice *self) priv->tdc = teamdctl_alloc (); g_assert (priv->tdc); err = teamdctl_connect (priv->tdc, nm_device_get_iface (self), NULL, NULL); - if (err) { - nm_log_err (LOGD_TEAM, "(%s): failed to connect to teamd", nm_device_get_iface (self)); + if (err != 0) { + nm_log_err (LOGD_TEAM, "(%s): failed to connect to teamd (err=%d)", + nm_device_get_iface (self), err); teamdctl_free (priv->tdc); priv->tdc = NULL; } @@ -230,17 +231,19 @@ update_connection (NMDevice *device, NMConnection *connection) nm_connection_add_setting (connection, (NMSetting *) s_team); g_object_set (G_OBJECT (s_team), NM_SETTING_TEAM_INTERFACE_NAME, iface, NULL); } + g_object_set (G_OBJECT (s_team), NM_SETTING_TEAM_CONFIG, NULL, NULL); #if WITH_TEAMDCTL if (ensure_teamd_connection (device)) { - char *config; + const char *config = NULL; + int err; - config = teamdctl_config_get_raw (NM_DEVICE_TEAM_GET_PRIVATE (device)->tdc); - if (config) + err = teamdctl_config_get_raw_direct (NM_DEVICE_TEAM_GET_PRIVATE (device)->tdc, + (char **)&config); + if (err == 0) g_object_set (G_OBJECT (s_team), NM_SETTING_TEAM_CONFIG, config, NULL); else - nm_log_err (LOGD_TEAM, "(%s): failed to read teamd config", iface); - g_free (config); + nm_log_err (LOGD_TEAM, "(%s): failed to read teamd config (err=%d)", iface, err); } #endif } @@ -253,12 +256,13 @@ nm_team_update_slave_connection (NMDevice *slave, NMConnection *connection) NMSettingTeamPort *s_port; const char *iface = nm_device_get_iface (slave); char *port_config = NULL; - gboolean success = FALSE; + gboolean with_teamdctl = FALSE; + int err = 0; #if WITH_TEAMDCTL const char *master_iface; int master_ifindex; struct teamdctl *tdc; - int err; + const char *team_port_config = NULL; #endif g_return_val_if_fail (NM_IS_DEVICE (slave), FALSE); @@ -274,14 +278,15 @@ nm_team_update_slave_connection (NMDevice *slave, NMConnection *connection) g_assert (tdc); err = teamdctl_connect (tdc, master_iface, NULL, NULL); if (err) { - nm_log_err (LOGD_TEAM, "(%s): failed to connect to teamd for master %s", - iface, master_iface); + nm_log_err (LOGD_TEAM, "(%s): failed to connect to teamd for master %s (err=%d)", + iface, master_iface, err); teamdctl_free (tdc); return FALSE; } - /* FIXME: wait for libteamd to implement getting port config */ -/* port_config = teamdctl_port_config_get_raw (tdc, iface); */ + err = teamdctl_port_config_get_raw_direct (tdc, iface, (char **)&team_port_config); + port_config = g_strdup (team_port_config); teamdctl_free (tdc); + with_teamdctl = TRUE; #endif s_port = nm_connection_get_setting_team_port (connection); @@ -290,14 +295,20 @@ nm_team_update_slave_connection (NMDevice *slave, NMConnection *connection) nm_connection_add_setting (connection, NM_SETTING (s_port)); } - if (port_config) { - g_object_set (G_OBJECT (s_port), NM_SETTING_TEAM_PORT_CONFIG, port_config, NULL); - free (port_config); - success = TRUE; - } else - nm_log_err (LOGD_TEAM, "(%s): failed to read teamd port configuration", iface); + g_object_set (G_OBJECT (s_port), NM_SETTING_TEAM_PORT_CONFIG, port_config, NULL); + g_free (port_config); - return success; + if (!with_teamdctl || err != 0) { + if (!with_teamdctl) + nm_log_err (LOGD_TEAM, "(%s): failed to read teamd port configuration " + " (compiled without libteamdctl support)", iface); + else + nm_log_err (LOGD_TEAM, "(%s): failed to read teamd port configuration (err=%d)", + iface, err); + return FALSE; + } + + return TRUE; } /******************************************************************/ @@ -670,8 +681,9 @@ enslave_slave (NMDevice *device, int err; err = teamdctl_port_config_update_raw (priv->tdc, slave_iface, config); - if (err) { - nm_log_err (LOGD_TEAM, "(%s): failed to update config for port %s", iface, slave_iface); + if (err != 0) { + nm_log_err (LOGD_TEAM, "(%s): failed to update config for port %s (err=%d)", + iface, slave_iface, err); return FALSE; } }