[patch NetworkManager 06/11] nm-device-team: use libteamdctl



Signed-off-by: Jiri Pirko <jiri resnulli us>
---
 src/Makefile.am              |  8 ++++++++
 src/devices/nm-device-team.c | 28 +++++++++++++++++++++++++++-
 2 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 8370e5a..c90c12c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -381,6 +381,10 @@ if SESSION_TRACKING_CK
 AM_CPPFLAGS += -DCKDB_PATH=\"${CKDB_PATH}\"
 endif
 
+if WITH_TEAMDCTL
+AM_CPPFLAGS += ${LIBTEAMDCTL_CFLAGS}
+endif
+
 libNetworkManager_la_SOURCES = \
        $(nm_sources) \
        $(glue_sources)
@@ -403,6 +407,10 @@ if WITH_CONCHECK
 libNetworkManager_la_LIBADD += $(LIBSOUP_LIBS)
 endif
 
+if WITH_TEAMDCTL
+libNetworkManager_la_LIBADD += $(LIBTEAMDCTL_LIBS)
+endif
+
 NetworkManager_LDFLAGS = -rdynamic
 
 dbusservicedir = $(DBUS_SYS_DIR)
diff --git a/src/devices/nm-device-team.c b/src/devices/nm-device-team.c
index 06d4c53..797b2ec 100644
--- a/src/devices/nm-device-team.c
+++ b/src/devices/nm-device-team.c
@@ -27,8 +27,10 @@
 #include <glib.h>
 #include <glib/gi18n.h>
 #include <gio/gio.h>
-
 #include <netinet/ether.h>
+#if WITH_TEAMDCTL
+#include <teamdctl.h>
+#endif
 
 #include "nm-device-team.h"
 #include "nm-logging.h"
@@ -51,6 +53,9 @@ G_DEFINE_TYPE (NMDeviceTeam, nm_device_team, NM_TYPE_DEVICE)
 #define NM_TEAM_ERROR (nm_team_error_quark ())
 
 typedef struct {
+#if WITH_TEAMDCTL
+       struct teamdctl *tdc;
+#endif
        GPid teamd_pid;
        guint teamd_process_watch;
        guint teamd_timeout;
@@ -251,6 +256,13 @@ teamd_cleanup (NMDevice *dev)
                priv->teamd_pid = 0;
        }
 
+#if WITH_TEAMDCTL
+       if (priv->tdc) {
+               teamdctl_disconnect(priv->tdc);
+               teamdctl_free(priv->tdc);
+       }
+#endif
+
        teamd_timeout_remove (dev);
 
        priv->teamd_on_dbus = FALSE;
@@ -285,6 +297,20 @@ teamd_dbus_appeared (GDBusConnection *connection,
        nm_log_info (LOGD_TEAM, "(%s): teamd appeared on D-Bus", nm_device_get_iface (dev));
        priv->teamd_on_dbus = FALSE;
        teamd_timeout_remove (dev);
+#if WITH_TEAMDCTL
+       if (!priv->tdc) {
+               int err;
+
+               priv->tdc = teamdctl_alloc();
+               g_assert (priv->tdc);
+               err = teamdctl_connect(priv->tdc, nm_device_get_iface (dev), NULL, NULL);
+               if (err) {
+                       nm_log_err (LOGD_TEAM, "(%s): failed to connect to teamd", nm_device_get_iface (dev));
+                       teamdctl_free(priv->tdc);
+                       priv->tdc = NULL;
+               }
+       }
+#endif
        nm_device_activate_schedule_stage2_device_config (dev);
 }
 
-- 
1.8.3.1



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]