summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2014-09-08 11:11:19 -0500
committerDan Williams <dcbw@redhat.com>2014-09-11 12:50:16 -0500
commit1cf7b6d3dd9a1774df4a0bb783a6b07915d60021 (patch)
tree1daf82d79eb56cc7578a7233c195b1a2804b4523
parent15db28e74b4aef9f536a578487eb172e3f132f48 (diff)
downloadNetworkManager-1cf7b6d3dd9a1774df4a0bb783a6b07915d60021.tar.gz
macvlan: port to internal device factory
-rw-r--r--src/Makefile.am2
-rw-r--r--src/devices/nm-device-macvlan.c36
-rw-r--r--src/devices/nm-device-macvlan.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 9a9c2b052c..7bd441c568 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -67,6 +67,7 @@ nm_device_sources = \
devices/nm-device-bridge.c \
devices/nm-device-ethernet.c \
devices/nm-device-infiniband.c \
+ devices/nm-device-macvlan.c \
devices/nm-device-veth.c \
devices/nm-device-vlan.c \
$(NULL)
@@ -95,7 +96,6 @@ nm_sources = \
devices/nm-device-generic.h \
devices/nm-device-gre.c \
devices/nm-device-logging.h \
- devices/nm-device-macvlan.c \
devices/nm-device-private.h \
devices/nm-device-tun.c \
devices/nm-device-vxlan.c \
diff --git a/src/devices/nm-device-macvlan.c b/src/devices/nm-device-macvlan.c
index cd49a9b50f..bcd3861774 100644
--- a/src/devices/nm-device-macvlan.c
+++ b/src/devices/nm-device-macvlan.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-macvlan-glue.h"
@@ -91,18 +92,6 @@ link_changed (NMDevice *device, NMPlatformLink *info)
/**************************************************************/
-NMDevice *
-nm_device_macvlan_new (NMPlatformLink *platform_device)
-{
- g_return_val_if_fail (platform_device != NULL, NULL);
-
- return (NMDevice *) g_object_new (NM_TYPE_DEVICE_MACVLAN,
- NM_DEVICE_PLATFORM_DEVICE, platform_device,
- NM_DEVICE_TYPE_DESC, "Macvlan",
- NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_GENERIC,
- NULL);
-}
-
static void
nm_device_macvlan_init (NMDeviceMacvlan *self)
{
@@ -179,3 +168,26 @@ nm_device_macvlan_class_init (NMDeviceMacvlanClass *klass)
G_TYPE_FROM_CLASS (klass),
&dbus_glib_nm_device_macvlan_object_info);
}
+
+/*************************************************************/
+
+#define NM_TYPE_MACVLAN_FACTORY (nm_macvlan_factory_get_type ())
+#define NM_MACVLAN_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_MACVLAN_FACTORY, NMMacvlanFactory))
+
+static NMDevice *
+new_link (NMDeviceFactory *factory, NMPlatformLink *plink, GError **error)
+{
+ if (plink->type == NM_LINK_TYPE_MACVLAN || plink->type == NM_LINK_TYPE_MACVTAP) {
+ return (NMDevice *) g_object_new (NM_TYPE_DEVICE_MACVLAN,
+ NM_DEVICE_PLATFORM_DEVICE, plink,
+ NM_DEVICE_TYPE_DESC, "Macvlan",
+ NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_GENERIC,
+ NULL);
+ }
+ return NULL;
+}
+
+DEFINE_DEVICE_FACTORY_INTERNAL_WITH_DEVTYPE(MACVLAN, Macvlan, macvlan, ETHERNET, \
+ factory_iface->new_link = new_link; \
+ )
+
diff --git a/src/devices/nm-device-macvlan.h b/src/devices/nm-device-macvlan.h
index 1e350ce1b3..24f15437c3 100644
--- a/src/devices/nm-device-macvlan.h
+++ b/src/devices/nm-device-macvlan.h
@@ -38,19 +38,11 @@ G_BEGIN_DECLS
#define NM_DEVICE_MACVLAN_MODE "mode"
#define NM_DEVICE_MACVLAN_NO_PROMISC "no-promisc"
-typedef struct {
- NMDeviceGeneric parent;
-} NMDeviceMacvlan;
-
-typedef struct {
- NMDeviceGenericClass parent;
-
-} NMDeviceMacvlanClass;
+typedef NMDeviceGeneric NMDeviceMacvlan;
+typedef NMDeviceGenericClass NMDeviceMacvlanClass;
GType nm_device_macvlan_get_type (void);
-NMDevice *nm_device_macvlan_new (NMPlatformLink *platform_device);
-
G_END_DECLS
#endif /* NM_DEVICE_MACVLAN_H */
diff --git a/src/nm-manager.c b/src/nm-manager.c
index e793867764..e59047dd36 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-macvlan.h"
#include "nm-device-vxlan.h"
#include "nm-device-gre.h"
#include "nm-setting-connection.h"
@@ -2113,10 +2112,6 @@ platform_link_added (NMManager *self,
case NM_LINK_TYPE_TAP:
device = nm_device_tun_new (plink);
break;
- case NM_LINK_TYPE_MACVLAN:
- case NM_LINK_TYPE_MACVTAP:
- device = nm_device_macvlan_new (plink);
- break;
case NM_LINK_TYPE_VXLAN:
device = nm_device_vxlan_new (plink);
break;
diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am
index 6a634f82ea..14ffd0b97d 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 veth vlan; do \
+ @for t in bond bridge ethernet infiniband macvlan veth vlan; 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 \