mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 15:48:06 +02:00
veth: port to internal device factory
We must port NMDeviceVeth before NMDeviceEthernet because veth is an ethernet subclass and uses symbols from nm-device-ethernet.c.
This commit is contained in:
parent
0bc1b5138a
commit
388e53b180
5 changed files with 28 additions and 28 deletions
|
|
@ -63,6 +63,7 @@ NetworkManager_LDADD = libNetworkManager.la
|
|||
noinst_LTLIBRARIES = libNetworkManager.la
|
||||
|
||||
nm_device_sources = \
|
||||
devices/nm-device-veth.c \
|
||||
$(NULL)
|
||||
|
||||
nm_device_headers = \
|
||||
|
|
@ -96,7 +97,6 @@ nm_sources = \
|
|||
devices/nm-device-macvlan.c \
|
||||
devices/nm-device-private.h \
|
||||
devices/nm-device-tun.c \
|
||||
devices/nm-device-veth.c \
|
||||
devices/nm-device-vlan.c \
|
||||
devices/nm-device-vxlan.c \
|
||||
\
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
#include "nm-manager.h"
|
||||
#include "nm-platform.h"
|
||||
#include "nm-dbus-manager.h"
|
||||
#include "nm-device-factory.h"
|
||||
|
||||
#include "nm-device-veth-glue.h"
|
||||
|
||||
|
|
@ -98,18 +99,6 @@ get_peer (NMDeviceVeth *self)
|
|||
|
||||
/**************************************************************/
|
||||
|
||||
NMDevice *
|
||||
nm_device_veth_new (NMPlatformLink *platform_device)
|
||||
{
|
||||
g_return_val_if_fail (platform_device != NULL, NULL);
|
||||
|
||||
return (NMDevice *) g_object_new (NM_TYPE_DEVICE_VETH,
|
||||
NM_DEVICE_PLATFORM_DEVICE, platform_device,
|
||||
NM_DEVICE_TYPE_DESC, "Veth",
|
||||
NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_ETHERNET,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_device_veth_init (NMDeviceVeth *self)
|
||||
{
|
||||
|
|
@ -170,3 +159,26 @@ nm_device_veth_class_init (NMDeviceVethClass *klass)
|
|||
G_TYPE_FROM_CLASS (klass),
|
||||
&dbus_glib_nm_device_veth_object_info);
|
||||
}
|
||||
|
||||
/*************************************************************/
|
||||
|
||||
#define NM_TYPE_VETH_FACTORY (nm_veth_factory_get_type ())
|
||||
#define NM_VETH_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_VETH_FACTORY, NMVethFactory))
|
||||
|
||||
static NMDevice *
|
||||
new_link (NMDeviceFactory *factory, NMPlatformLink *plink, GError **error)
|
||||
{
|
||||
if (plink->type == NM_LINK_TYPE_VETH) {
|
||||
return (NMDevice *) g_object_new (NM_TYPE_DEVICE_VETH,
|
||||
NM_DEVICE_PLATFORM_DEVICE, plink,
|
||||
NM_DEVICE_TYPE_DESC, "Veth",
|
||||
NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_ETHERNET,
|
||||
NULL);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DEFINE_DEVICE_FACTORY_INTERNAL_WITH_DEVTYPE(VETH, Veth, veth, ETHERNET, \
|
||||
factory_iface->new_link = new_link; \
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -36,19 +36,11 @@ G_BEGIN_DECLS
|
|||
|
||||
#define NM_DEVICE_VETH_PEER "peer"
|
||||
|
||||
typedef struct {
|
||||
NMDeviceEthernet parent;
|
||||
} NMDeviceVeth;
|
||||
|
||||
typedef struct {
|
||||
NMDeviceEthernetClass parent;
|
||||
|
||||
} NMDeviceVethClass;
|
||||
typedef NMDeviceEthernet NMDeviceVeth;
|
||||
typedef NMDeviceEthernetClass NMDeviceVethClass;
|
||||
|
||||
GType nm_device_veth_get_type (void);
|
||||
|
||||
NMDevice *nm_device_veth_new (NMPlatformLink *platform_device);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* NM_DEVICE_VETH_H */
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@
|
|||
#include "nm-device-bridge.h"
|
||||
#include "nm-device-vlan.h"
|
||||
#include "nm-device-generic.h"
|
||||
#include "nm-device-veth.h"
|
||||
#include "nm-device-tun.h"
|
||||
#include "nm-device-macvlan.h"
|
||||
#include "nm-device-vxlan.h"
|
||||
|
|
@ -2157,9 +2156,6 @@ platform_link_added (NMManager *self,
|
|||
} else
|
||||
nm_log_err (LOGD_HW, "(%s): failed to get VLAN parent ifindex", plink->name);
|
||||
break;
|
||||
case NM_LINK_TYPE_VETH:
|
||||
device = nm_device_veth_new (plink);
|
||||
break;
|
||||
case NM_LINK_TYPE_TUN:
|
||||
case NM_LINK_TYPE_TAP:
|
||||
device = nm_device_tun_new (plink);
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ TESTS = \
|
|||
if ENABLE_TESTS
|
||||
|
||||
check-local:
|
||||
@for t in ; do \
|
||||
@for t in veth; 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 \
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue