summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2014-09-08 11:17:58 -0500
committerDan Williams <dcbw@redhat.com>2014-09-11 12:50:16 -0500
commit11eb99e9a7fc1bf160143124a3738c6628cdc52f (patch)
tree47385f4e1bb349107c1772c316ab584cbaf0c758
parent51aa432283ea0b18833dbc682a0405b7a3b99514 (diff)
gre: port to internal device factory
-rw-r--r--src/Makefile.am2
-rw-r--r--src/devices/nm-device-gre.c36
-rw-r--r--src/devices/nm-device-gre.h12
-rw-r--r--src/nm-manager.c5
-rw-r--r--src/tests/Makefile.am2
5 files changed, 28 insertions, 29 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 8b8cb63647..252d653775 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -66,6 +66,7 @@ nm_device_sources = \
devices/nm-device-bond.c \
devices/nm-device-bridge.c \
devices/nm-device-ethernet.c \
+ devices/nm-device-gre.c \
devices/nm-device-infiniband.c \
devices/nm-device-macvlan.c \
devices/nm-device-veth.c \
@@ -95,7 +96,6 @@ nm_sources = \
devices/nm-device-factory.h \
devices/nm-device-generic.c \
devices/nm-device-generic.h \
- devices/nm-device-gre.c \
devices/nm-device-logging.h \
devices/nm-device-private.h \
devices/nm-device-tun.c \
diff --git a/src/devices/nm-device-gre.c b/src/devices/nm-device-gre.c
index eded6777a2..2f432c18f0 100644
--- a/src/devices/nm-device-gre.c
+++ b/src/devices/nm-device-gre.c
@@ -28,6 +28,7 @@
#include "nm-logging.h"
#include "nm-manager.h"
#include "nm-platform.h"
+#include "nm-device-factory.h"
#include "nm-device-gre-glue.h"
@@ -110,18 +111,6 @@ link_changed (NMDevice *device, NMPlatformLink *info)
/**************************************************************/
-NMDevice *
-nm_device_gre_new (NMPlatformLink *platform_device)
-{
- g_return_val_if_fail (platform_device != NULL, NULL);
-
- return (NMDevice *) g_object_new (NM_TYPE_DEVICE_GRE,
- NM_DEVICE_PLATFORM_DEVICE, platform_device,
- NM_DEVICE_TYPE_DESC, "Gre",
- NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_GENERIC,
- NULL);
-}
-
static void
nm_device_gre_init (NMDeviceGre *self)
{
@@ -269,3 +258,26 @@ nm_device_gre_class_init (NMDeviceGreClass *klass)
G_TYPE_FROM_CLASS (klass),
&dbus_glib_nm_device_gre_object_info);
}
+
+/*************************************************************/
+
+#define NM_TYPE_GRE_FACTORY (nm_gre_factory_get_type ())
+#define NM_GRE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_GRE_FACTORY, NMGreFactory))
+
+static NMDevice *
+new_link (NMDeviceFactory *factory, NMPlatformLink *plink, GError **error)
+{
+ if (plink->type == NM_LINK_TYPE_GRE || plink->type == NM_LINK_TYPE_GRETAP) {
+ return (NMDevice *) g_object_new (NM_TYPE_DEVICE_GRE,
+ NM_DEVICE_PLATFORM_DEVICE, plink,
+ NM_DEVICE_TYPE_DESC, "Gre",
+ NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_GENERIC,
+ NULL);
+ }
+ return NULL;
+}
+
+DEFINE_DEVICE_FACTORY_INTERNAL_WITH_DEVTYPE(GRE, Gre, gre, ETHERNET, \
+ factory_iface->new_link = new_link; \
+ )
+
diff --git a/src/devices/nm-device-gre.h b/src/devices/nm-device-gre.h
index b3f8b984c0..7acff5f7f5 100644
--- a/src/devices/nm-device-gre.h
+++ b/src/devices/nm-device-gre.h
@@ -45,19 +45,11 @@ G_BEGIN_DECLS
#define NM_DEVICE_GRE_TOS "tos"
#define NM_DEVICE_GRE_PATH_MTU_DISCOVERY "path-mtu-discovery"
-typedef struct {
- NMDeviceGeneric parent;
-} NMDeviceGre;
-
-typedef struct {
- NMDeviceGenericClass parent;
-
-} NMDeviceGreClass;
+typedef NMDeviceGeneric NMDeviceGre;
+typedef NMDeviceGenericClass NMDeviceGreClass;
GType nm_device_gre_get_type (void);
-NMDevice *nm_device_gre_new (NMPlatformLink *platform_device);
-
G_END_DECLS
#endif /* NM_DEVICE_GRE_H */
diff --git a/src/nm-manager.c b/src/nm-manager.c
index 1f955f2ab8..f608e5e1e3 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -41,7 +41,6 @@
#include "nm-device.h"
#include "nm-device-generic.h"
#include "nm-device-tun.h"
-#include "nm-device-gre.h"
#include "nm-setting-connection.h"
#include "nm-setting-wireless.h"
#include "nm-setting-vpn.h"
@@ -2111,10 +2110,6 @@ platform_link_added (NMManager *self,
case NM_LINK_TYPE_TAP:
device = nm_device_tun_new (plink);
break;
- case NM_LINK_TYPE_GRE:
- case NM_LINK_TYPE_GRETAP:
- device = nm_device_gre_new (plink);
- break;
case NM_LINK_TYPE_WWAN_ETHERNET:
/* WWAN pseudo-ethernet interfaces are handled automatically by
diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am
index b05d7eca76..4bea114786 100644
--- a/src/tests/Makefile.am
+++ b/src/tests/Makefile.am
@@ -99,7 +99,7 @@ TESTS = \
if ENABLE_TESTS
check-local:
- @for t in bond bridge ethernet infiniband macvlan veth vlan vxlan; do \
+ @for t in bond bridge ethernet gre infiniband macvlan veth vlan vxlan; do \
# Ensure the device subclass factory registration constructors exist \
# which could inadvertently break if src/Makefile.am gets changed \
if ! LC_ALL=C nm $(top_builddir)/src/NetworkManager | LC_ALL=C grep -q "register_device_factory_internal_$$t" ; then \