team: make team support a plugin

Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
Thomas Haller 2014-06-18 11:10:52 +02:00
parent dfe4b45f87
commit 38a83e15a2
11 changed files with 262 additions and 28 deletions

View file

@ -811,6 +811,7 @@ src/rdisc/tests/Makefile
src/devices/adsl/Makefile
src/devices/wimax/Makefile
src/devices/bluetooth/Makefile
src/devices/team/Makefile
src/devices/wifi/Makefile
src/devices/wifi/tests/Makefile
src/devices/wwan/Makefile

View file

@ -36,6 +36,7 @@
%global with_adsl 1
%global with_bluetooth 1
%global with_team 1
%global with_wifi 1
%global with_wimax 0
%global with_wwan 1
@ -59,8 +60,8 @@
%global with_wwan 0
%endif
%if 0%{?rhel} || (0%{?fedora} > 19)
%global with_teamctl 1
%if (0%{?fedora} && 0%{?fedora} <= 19)
%global with_team 0
%endif
@ -155,9 +156,6 @@ BuildRequires: ModemManager-glib-devel >= 1.0
%if 0%{?with_nmtui}
BuildRequires: newt-devel
%endif
%if 0%{?with_teamctl}
BuildRequires: teamd-devel
%endif
%description
@ -200,6 +198,19 @@ This package contains NetworkManager support for Bluetooth devices.
%endif
%if 0%{?with_team}
%package team
Summary: Team device plugin for NetworkManager
Group: System Environment/Base
BuildRequires: teamd-devel
Requires: %{name}%{?_isa} = %{epoch}:%{version}-%{release}
Obsoletes: NetworkManager < %{obsoletes_nmver}
%description team
This package contains NetworkManager support for team devices.
%endif
%if 0%{?with_wifi}
%package wifi
Summary: Wifi plugin for NetworkManager
@ -347,7 +358,7 @@ by nm-connection-editor and nm-applet in a non-graphical environment.
%else
--with-wext=no \
%endif
%if 0%{?with_teamctl}
%if 0%{?with_team}
--enable-teamdctl=yes \
%else
--enable-teamdctl=no \
@ -489,6 +500,12 @@ fi
%exclude %{_libdir}/%{name}/libnm-device-plugin-bluetooth.so
%endif
%if 0%{?with_team}
%files team
%defattr(-,root,root,0755)
%{_libdir}/%{name}/libnm-device-plugin-team.so
%endif
%if 0%{?with_wifi}
%files wifi
%defattr(-,root,root,0755)

View file

@ -53,8 +53,8 @@ src/devices/nm-device-bond.c
src/devices/nm-device-bridge.c
src/devices/nm-device-ethernet.c
src/devices/nm-device-infiniband.c
src/devices/nm-device-team.c
src/devices/nm-device-vlan.c
src/devices/team/nm-device-team.c
src/devices/wifi/nm-device-olpc-mesh.c
src/devices/wwan/nm-modem-broadband.c
src/devices/wwan/nm-modem-old.c

View file

@ -5,7 +5,8 @@ include $(GLIB_MAKEFILE)
SUBDIRS = \
. \
devices/adsl \
devices/wifi \
devices/team \
devices/wifi \
dhcp-manager \
ppp-manager \
settings/plugins
@ -84,8 +85,6 @@ nm_sources = \
devices/nm-device-macvlan.c \
devices/nm-device-macvlan.h \
devices/nm-device-private.h \
devices/nm-device-team.c \
devices/nm-device-team.h \
devices/nm-device-tun.c \
devices/nm-device-tun.h \
devices/nm-device-veth.c \
@ -296,7 +295,6 @@ glue_sources = \
nm-device-gre-glue.h \
nm-device-infiniband-glue.h \
nm-device-macvlan-glue.h \
nm-device-team-glue.h \
nm-device-tun-glue.h \
nm-device-veth-glue.h \
nm-device-vlan-glue.h \
@ -351,10 +349,6 @@ 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)
@ -375,10 +369,6 @@ 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)

View file

@ -0,0 +1,74 @@
include $(GLIB_MAKEFILE)
@GNOME_CODE_COVERAGE_RULES@
AM_CPPFLAGS = \
-I${top_srcdir}/src \
-I${top_builddir}/src \
-I${top_srcdir}/src/logging \
-I${top_srcdir}/src/devices \
-I${top_srcdir}/src/settings \
-I${top_srcdir}/src/platform \
-I${top_srcdir}/src/posix-signals \
-I${top_builddir}/include \
-I${top_srcdir}/include \
-I${top_builddir}/libnm-util \
-I${top_srcdir}/libnm-util \
-DG_LOG_DOMAIN=\""NetworkManager-team"\" \
-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
$(DBUS_CFLAGS) \
$(POLKIT_CFLAGS) \
$(LIBNL_CFLAGS) \
$(GUDEV_CFLAGS)
if WITH_TEAMDCTL
AM_CPPFLAGS += ${LIBTEAMDCTL_CFLAGS}
endif
GLIB_GENERATED = nm-team-enum-types.h nm-team-enum-types.c
GLIB_MKENUMS_H_FLAGS = --identifier-prefix NM
GLIB_MKENUMS_C_FLAGS = --identifier-prefix NM
nm_team_enum_types_sources = $(srcdir)/nm-device-team.h
glue_sources = \
nm-device-team-glue.h
%-glue.h: $(top_srcdir)/introspection/%.xml
$(AM_V_GEN) dbus-binding-tool --prefix=$(subst -,_,$(subst -glue.h,,$@)) --mode=glib-server --output=$@ $<
BUILT_SOURCES = $(GLIB_GENERATED) $(glue_sources)
pkglib_LTLIBRARIES = libnm-device-plugin-team.la
SYMBOL_VIS_FILE=$(srcdir)/exports.ver
libnm_device_plugin_team_la_SOURCES = \
nm-device-team.c \
nm-device-team.h \
nm-team-factory.c \
nm-team-factory.h \
\
$(BUILT_SOURCES)
libnm_device_plugin_team_la_LDFLAGS = \
-module -avoid-version \
-Wl,--version-script=$(SYMBOL_VIS_FILE)
libnm_device_plugin_team_la_LIBADD = \
$(DBUS_LIBS) \
$(GUDEV_LIBS)
if WITH_TEAMDCTL
libnm_device_plugin_team_la_LIBADD += $(LIBTEAMDCTL_LIBS)
endif
CLEANFILES = $(BUILT_SOURCES)
EXTRA_DIST = $(SYMBOL_VIS_FILE)
if ENABLE_TESTS
check-local:
$(top_srcdir)/tools/check-exports.sh $(builddir)/.libs/libnm-device-plugin-team.so $(SYMBOL_VIS_FILE)
endif

View file

@ -0,0 +1,7 @@
{
global:
nm_device_factory_create;
nm_device_factory_get_device_type;
local:
*;
};

View file

@ -42,6 +42,7 @@
#include "nm-dbus-glib-types.h"
#include "nm-dbus-manager.h"
#include "nm-enum-types.h"
#include "nm-team-enum-types.h"
#include "nm-posix-signals.h"
#include "nm-device-team-glue.h"
@ -780,7 +781,7 @@ nm_device_team_new (NMPlatformLink *platform_device)
}
NMDevice *
nm_device_team_new_for_connection (NMConnection *connection)
nm_device_team_new_for_connection (NMConnection *connection, GError **error)
{
const char *iface;
@ -791,7 +792,10 @@ nm_device_team_new_for_connection (NMConnection *connection)
if ( !nm_platform_team_add (iface)
&& nm_platform_get_error () != NM_PLATFORM_ERROR_EXISTS) {
nm_log_warn (LOGD_DEVICE | LOGD_TEAM, "(%s): failed to create team master interface for '%s': %s",
g_set_error (error,
NM_DEVICE_TEAM_ERROR,
NM_DEVICE_TEAM_ERROR_PLATFORM_FAILURE,
"failed to create team master interface '%s' for connection '%s': %s",
iface, nm_connection_get_id (connection),
nm_platform_get_error_msg ());
return NULL;

View file

@ -40,6 +40,7 @@ typedef enum {
NM_DEVICE_TEAM_ERROR_CONNECTION_INCOMPATIBLE, /*< nick=ConnectionIncompatible >*/
NM_DEVICE_TEAM_ERROR_TEAMCTL_FAILURE, /*< nick=TeamCtlFailure >*/
NM_DEVICE_TEAM_ERROR_NO_SUPPORT, /*< nick=NoSupport >*/
NM_DEVICE_TEAM_ERROR_PLATFORM_FAILURE, /*< nick=PlatformFailure >*/
} NMTeamError;
#define NM_DEVICE_TEAM_SLAVES "slaves"
@ -57,7 +58,7 @@ typedef struct {
GType nm_device_team_get_type (void);
NMDevice *nm_device_team_new (NMPlatformLink *platform_device);
NMDevice *nm_device_team_new_for_connection (NMConnection *connection);
NMDevice *nm_device_team_new_for_connection (NMConnection *connection, GError **error);
G_END_DECLS

View file

@ -0,0 +1,109 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2014 Red Hat, Inc.
*/
#include <string.h>
#include <gmodule.h>
#include "config.h"
#include "nm-device-factory.h"
#include "nm-team-factory.h"
#include "nm-device-team.h"
#include "nm-logging.h"
static GType nm_team_factory_get_type (void);
static void device_factory_interface_init (NMDeviceFactory *factory_iface);
G_DEFINE_TYPE_EXTENDED (NMTeamFactory, nm_team_factory, G_TYPE_OBJECT, 0,
G_IMPLEMENT_INTERFACE (NM_TYPE_DEVICE_FACTORY, device_factory_interface_init))
#define NM_TEAM_FACTORY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_TEAM_FACTORY, NMTeamFactoryPrivate))
typedef struct {
char dummy;
} NMTeamFactoryPrivate;
/************************************************************************/
static NMDevice *
new_link (NMDeviceFactory *factory, NMPlatformLink *plink, GError **error)
{
if (plink->type == NM_LINK_TYPE_TEAM)
return nm_device_team_new (plink);
return NULL;
}
static NMDevice *
create_virtual_device_for_connection (NMDeviceFactory *factory,
NMConnection *connection,
GError **error)
{
if (nm_connection_is_type (connection, NM_SETTING_TEAM_SETTING_NAME))
return nm_device_team_new_for_connection (connection, error);
return NULL;
}
/************************************************************************/
#define PLUGIN_TYPE NM_DEVICE_TYPE_TEAM
G_MODULE_EXPORT NMDeviceFactory *
nm_device_factory_create (GError **error)
{
return (NMDeviceFactory *) g_object_new (NM_TYPE_TEAM_FACTORY, NULL);
}
G_MODULE_EXPORT NMDeviceType
nm_device_factory_get_device_type (void)
{
return PLUGIN_TYPE;
}
/************************************************************************/
static void
nm_team_factory_init (NMTeamFactory *self)
{
}
static void
device_factory_interface_init (NMDeviceFactory *factory_iface)
{
factory_iface->new_link = new_link;
factory_iface->create_virtual_device_for_connection = create_virtual_device_for_connection;
}
static void
dispose (GObject *object)
{
/* Chain up to the parent class */
G_OBJECT_CLASS (nm_team_factory_parent_class)->dispose (object);
}
static void
nm_team_factory_class_init (NMTeamFactoryClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (object_class, sizeof (NMTeamFactoryPrivate));
object_class->dispose = dispose;
}

View file

@ -0,0 +1,37 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2014 Red Hat, Inc.
*/
#ifndef NM_TEAM_FACTORY_H
#define NM_TEAM_FACTORY_H
#include <glib-object.h>
#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))
typedef struct {
GObject parent;
} NMTeamFactory;
typedef struct {
GObjectClass parent;
} NMTeamFactoryClass;
#endif /* NM_TEAM_FACTORY_H */

View file

@ -43,7 +43,6 @@
#include "nm-device-ethernet.h"
#include "nm-device-infiniband.h"
#include "nm-device-bond.h"
#include "nm-device-team.h"
#include "nm-device-bridge.h"
#include "nm-device-vlan.h"
#include "nm-device-generic.h"
@ -1103,8 +1102,6 @@ system_create_virtual_device (NMManager *self, NMConnection *connection)
if (nm_connection_is_type (connection, NM_SETTING_BOND_SETTING_NAME)) {
device = nm_device_bond_new_for_connection (connection);
} else if (nm_connection_is_type (connection, NM_SETTING_TEAM_SETTING_NAME)) {
device = nm_device_team_new_for_connection (connection);
} else if (nm_connection_is_type (connection, NM_SETTING_BRIDGE_SETTING_NAME)) {
device = nm_device_bridge_new_for_connection (connection);
} else if (nm_connection_is_type (connection, NM_SETTING_VLAN_SETTING_NAME)) {
@ -2146,9 +2143,6 @@ platform_link_added (NMManager *self,
case NM_LINK_TYPE_BOND:
device = nm_device_bond_new (plink);
break;
case NM_LINK_TYPE_TEAM:
device = nm_device_team_new (plink);
break;
case NM_LINK_TYPE_BRIDGE:
device = nm_device_bridge_new (plink);
break;