From 51aa432283ea0b18833dbc682a0405b7a3b99514 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Mon, 8 Sep 2014 11:13:42 -0500 Subject: [PATCH] vxlan: port to internal device factory --- src/Makefile.am | 2 +- src/devices/nm-device-vxlan.c | 36 +++++++++++++++++++++++------------ src/devices/nm-device-vxlan.h | 12 ++---------- src/nm-manager.c | 4 ---- src/tests/Makefile.am | 2 +- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 7bd441c568..8b8cb63647 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -70,6 +70,7 @@ nm_device_sources = \ devices/nm-device-macvlan.c \ devices/nm-device-veth.c \ devices/nm-device-vlan.c \ + devices/nm-device-vxlan.c \ $(NULL) nm_device_headers = \ @@ -98,7 +99,6 @@ nm_sources = \ devices/nm-device-logging.h \ devices/nm-device-private.h \ devices/nm-device-tun.c \ - devices/nm-device-vxlan.c \ \ dhcp-manager/nm-dhcp-client.c \ dhcp-manager/nm-dhcp-client.h \ diff --git a/src/devices/nm-device-vxlan.c b/src/devices/nm-device-vxlan.c index 7c92e2a384..ed6b8fa051 100644 --- a/src/devices/nm-device-vxlan.c +++ b/src/devices/nm-device-vxlan.c @@ -29,6 +29,7 @@ #include "nm-manager.h" #include "nm-platform.h" #include "nm-utils.h" +#include "nm-device-factory.h" #include "nm-device-vxlan-glue.h" @@ -133,18 +134,6 @@ link_changed (NMDevice *device, NMPlatformLink *info) /**************************************************************/ -NMDevice * -nm_device_vxlan_new (NMPlatformLink *platform_device) -{ - g_return_val_if_fail (platform_device != NULL, NULL); - - return (NMDevice *) g_object_new (NM_TYPE_DEVICE_VXLAN, - NM_DEVICE_PLATFORM_DEVICE, platform_device, - NM_DEVICE_TYPE_DESC, "Vxlan", - NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_GENERIC, - NULL); -} - static void nm_device_vxlan_init (NMDeviceVxlan *self) { @@ -357,3 +346,26 @@ nm_device_vxlan_class_init (NMDeviceVxlanClass *klass) G_TYPE_FROM_CLASS (klass), &dbus_glib_nm_device_vxlan_object_info); } + +/*************************************************************/ + +#define NM_TYPE_VXLAN_FACTORY (nm_vxlan_factory_get_type ()) +#define NM_VXLAN_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_VXLAN_FACTORY, NMVxlanFactory)) + +static NMDevice * +new_link (NMDeviceFactory *factory, NMPlatformLink *plink, GError **error) +{ + if (plink->type == NM_LINK_TYPE_VXLAN) { + return (NMDevice *) g_object_new (NM_TYPE_DEVICE_VXLAN, + NM_DEVICE_PLATFORM_DEVICE, plink, + NM_DEVICE_TYPE_DESC, "Vxlan", + NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_GENERIC, + NULL); + } + return NULL; +} + +DEFINE_DEVICE_FACTORY_INTERNAL_WITH_DEVTYPE(VXLAN, Vxlan, vxlan, GENERIC, \ + factory_iface->new_link = new_link; \ + ) + diff --git a/src/devices/nm-device-vxlan.h b/src/devices/nm-device-vxlan.h index 0e08571066..cc6081e657 100644 --- a/src/devices/nm-device-vxlan.h +++ b/src/devices/nm-device-vxlan.h @@ -51,19 +51,11 @@ G_BEGIN_DECLS #define NM_DEVICE_VXLAN_L2MISS "l2miss" #define NM_DEVICE_VXLAN_L3MISS "l3miss" -typedef struct { - NMDeviceGeneric parent; -} NMDeviceVxlan; - -typedef struct { - NMDeviceGenericClass parent; - -} NMDeviceVxlanClass; +typedef NMDeviceGeneric NMDeviceVxlan; +typedef NMDeviceGenericClass NMDeviceVxlanClass; GType nm_device_vxlan_get_type (void); -NMDevice *nm_device_vxlan_new (NMPlatformLink *platform_device); - G_END_DECLS #endif /* NM_DEVICE_VXLAN_H */ diff --git a/src/nm-manager.c b/src/nm-manager.c index e59047dd36..1f955f2ab8 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-vxlan.h" #include "nm-device-gre.h" #include "nm-setting-connection.h" #include "nm-setting-wireless.h" @@ -2112,9 +2111,6 @@ platform_link_added (NMManager *self, case NM_LINK_TYPE_TAP: device = nm_device_tun_new (plink); break; - case NM_LINK_TYPE_VXLAN: - device = nm_device_vxlan_new (plink); - break; case NM_LINK_TYPE_GRE: case NM_LINK_TYPE_GRETAP: device = nm_device_gre_new (plink); diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am index 14ffd0b97d..b05d7eca76 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; do \ + @for t in bond bridge ethernet 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 \