mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-10-15 04:24:32 +00:00
infiniband: port to internal device factory
This commit is contained in:
parent
2a55c450bd
commit
6d190f92d5
|
@ -64,6 +64,7 @@ noinst_LTLIBRARIES = libNetworkManager.la
|
|||
|
||||
nm_device_sources = \
|
||||
devices/nm-device-ethernet.c \
|
||||
devices/nm-device-infiniband.c \
|
||||
devices/nm-device-veth.c \
|
||||
$(NULL)
|
||||
|
||||
|
@ -92,7 +93,6 @@ nm_sources = \
|
|||
devices/nm-device-generic.c \
|
||||
devices/nm-device-generic.h \
|
||||
devices/nm-device-gre.c \
|
||||
devices/nm-device-infiniband.c \
|
||||
devices/nm-device-logging.h \
|
||||
devices/nm-device-macvlan.c \
|
||||
devices/nm-device-private.h \
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "nm-activation-request.h"
|
||||
#include "nm-ip4-config.h"
|
||||
#include "nm-platform.h"
|
||||
#include "nm-device-factory.h"
|
||||
|
||||
#include "nm-device-infiniband-glue.h"
|
||||
|
||||
|
@ -69,53 +70,6 @@ nm_device_infiniband_init (NMDeviceInfiniband * self)
|
|||
{
|
||||
}
|
||||
|
||||
NMDevice *
|
||||
nm_device_infiniband_new (NMPlatformLink *platform_device)
|
||||
{
|
||||
g_return_val_if_fail (platform_device != NULL, NULL);
|
||||
|
||||
return (NMDevice *) g_object_new (NM_TYPE_DEVICE_INFINIBAND,
|
||||
NM_DEVICE_PLATFORM_DEVICE, platform_device,
|
||||
NM_DEVICE_TYPE_DESC, "InfiniBand",
|
||||
NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_INFINIBAND,
|
||||
NULL);
|
||||
}
|
||||
|
||||
NMDevice *
|
||||
nm_device_infiniband_new_partition (NMConnection *connection,
|
||||
NMDevice *parent)
|
||||
{
|
||||
NMSettingInfiniband *s_infiniband;
|
||||
int p_key, parent_ifindex;
|
||||
const char *iface;
|
||||
|
||||
g_return_val_if_fail (connection != NULL, NULL);
|
||||
g_return_val_if_fail (NM_IS_DEVICE_INFINIBAND (parent), NULL);
|
||||
|
||||
s_infiniband = nm_connection_get_setting_infiniband (connection);
|
||||
|
||||
iface = nm_setting_infiniband_get_virtual_interface_name (s_infiniband);
|
||||
g_return_val_if_fail (iface != NULL, NULL);
|
||||
|
||||
parent_ifindex = nm_device_get_ifindex (parent);
|
||||
p_key = nm_setting_infiniband_get_p_key (s_infiniband);
|
||||
|
||||
if ( !nm_platform_infiniband_partition_add (parent_ifindex, p_key)
|
||||
&& nm_platform_get_error () != NM_PLATFORM_ERROR_EXISTS) {
|
||||
nm_log_warn (LOGD_DEVICE | LOGD_INFINIBAND, "(%s): failed to add InfiniBand P_Key interface for '%s': %s",
|
||||
iface, nm_connection_get_id (connection),
|
||||
nm_platform_get_error_msg ());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (NMDevice *) g_object_new (NM_TYPE_DEVICE_INFINIBAND,
|
||||
NM_DEVICE_IFACE, iface,
|
||||
NM_DEVICE_DRIVER, nm_device_get_driver (parent),
|
||||
NM_DEVICE_TYPE_DESC, "InfiniBand",
|
||||
NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_INFINIBAND,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static guint32
|
||||
get_generic_capabilities (NMDevice *dev)
|
||||
{
|
||||
|
@ -344,3 +298,66 @@ nm_device_infiniband_class_init (NMDeviceInfinibandClass *klass)
|
|||
|
||||
dbus_g_error_domain_register (NM_INFINIBAND_ERROR, NULL, NM_TYPE_INFINIBAND_ERROR);
|
||||
}
|
||||
|
||||
/*************************************************************/
|
||||
|
||||
#define NM_TYPE_INFINIBAND_FACTORY (nm_infiniband_factory_get_type ())
|
||||
#define NM_INFINIBAND_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_INFINIBAND_FACTORY, NMInfinibandFactory))
|
||||
|
||||
static NMDevice *
|
||||
new_link (NMDeviceFactory *factory, NMPlatformLink *plink, GError **error)
|
||||
{
|
||||
if (plink->type == NM_LINK_TYPE_INFINIBAND) {
|
||||
return (NMDevice *) g_object_new (NM_TYPE_DEVICE_INFINIBAND,
|
||||
NM_DEVICE_PLATFORM_DEVICE, plink,
|
||||
NM_DEVICE_TYPE_DESC, "InfiniBand",
|
||||
NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_INFINIBAND,
|
||||
NULL);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static NMDevice *
|
||||
create_virtual_device_for_connection (NMDeviceFactory *factory,
|
||||
NMConnection *connection,
|
||||
NMDevice *parent,
|
||||
GError **error)
|
||||
{
|
||||
NMSettingInfiniband *s_infiniband;
|
||||
int p_key, parent_ifindex;
|
||||
const char *iface;
|
||||
|
||||
if (!nm_connection_is_type (connection, NM_SETTING_INFINIBAND_SETTING_NAME))
|
||||
return NULL;
|
||||
|
||||
g_return_val_if_fail (NM_IS_DEVICE_INFINIBAND (parent), NULL);
|
||||
|
||||
s_infiniband = nm_connection_get_setting_infiniband (connection);
|
||||
|
||||
iface = nm_setting_infiniband_get_virtual_interface_name (s_infiniband);
|
||||
g_return_val_if_fail (iface != NULL, NULL);
|
||||
|
||||
parent_ifindex = nm_device_get_ifindex (parent);
|
||||
p_key = nm_setting_infiniband_get_p_key (s_infiniband);
|
||||
|
||||
if ( !nm_platform_infiniband_partition_add (parent_ifindex, p_key)
|
||||
&& nm_platform_get_error () != NM_PLATFORM_ERROR_EXISTS) {
|
||||
nm_log_warn (LOGD_DEVICE | LOGD_INFINIBAND, "(%s): failed to add InfiniBand P_Key interface for '%s': %s",
|
||||
iface, nm_connection_get_id (connection),
|
||||
nm_platform_get_error_msg ());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (NMDevice *) g_object_new (NM_TYPE_DEVICE_INFINIBAND,
|
||||
NM_DEVICE_IFACE, iface,
|
||||
NM_DEVICE_DRIVER, nm_device_get_driver (parent),
|
||||
NM_DEVICE_TYPE_DESC, "InfiniBand",
|
||||
NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_INFINIBAND,
|
||||
NULL);
|
||||
}
|
||||
|
||||
DEFINE_DEVICE_FACTORY_INTERNAL(INFINIBAND, Infiniband, infiniband, \
|
||||
factory_iface->new_link = new_link; \
|
||||
factory_iface->create_virtual_device_for_connection = create_virtual_device_for_connection;
|
||||
)
|
||||
|
||||
|
|
|
@ -40,22 +40,11 @@ typedef enum {
|
|||
NM_INFINIBAND_ERROR_CONNECTION_INCOMPATIBLE, /*< nick=ConnectionIncompatible >*/
|
||||
} NMInfinibandError;
|
||||
|
||||
typedef struct {
|
||||
NMDevice parent;
|
||||
} NMDeviceInfiniband;
|
||||
|
||||
typedef struct {
|
||||
NMDeviceClass parent;
|
||||
|
||||
} NMDeviceInfinibandClass;
|
||||
|
||||
typedef NMDevice NMDeviceInfiniband;
|
||||
typedef NMDeviceClass NMDeviceInfinibandClass;
|
||||
|
||||
GType nm_device_infiniband_get_type (void);
|
||||
|
||||
NMDevice *nm_device_infiniband_new (NMPlatformLink *platform_device);
|
||||
NMDevice *nm_device_infiniband_new_partition (NMConnection *connection,
|
||||
NMDevice *parent);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* NM_DEVICE_INFINIBAND_H */
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
#include "nm-dbus-manager.h"
|
||||
#include "nm-vpn-manager.h"
|
||||
#include "nm-device.h"
|
||||
#include "nm-device-infiniband.h"
|
||||
#include "nm-device-bond.h"
|
||||
#include "nm-device-bridge.h"
|
||||
#include "nm-device-vlan.h"
|
||||
|
@ -1057,8 +1056,6 @@ system_create_virtual_device (NMManager *self, NMConnection *connection)
|
|||
device = nm_device_bridge_new_for_connection (connection);
|
||||
} else if (nm_connection_is_type (connection, NM_SETTING_VLAN_SETTING_NAME)) {
|
||||
device = nm_device_vlan_new_for_connection (connection, parent);
|
||||
} else if (nm_connection_is_type (connection, NM_SETTING_INFINIBAND_SETTING_NAME)) {
|
||||
device = nm_device_infiniband_new_partition (connection, parent);
|
||||
} else {
|
||||
for (iter = priv->factories; iter; iter = iter->next) {
|
||||
device = nm_device_factory_create_virtual_device_for_connection (NM_DEVICE_FACTORY (iter->data),
|
||||
|
@ -2126,9 +2123,6 @@ platform_link_added (NMManager *self,
|
|||
NMDevice *parent;
|
||||
|
||||
switch (plink->type) {
|
||||
case NM_LINK_TYPE_INFINIBAND:
|
||||
device = nm_device_infiniband_new (plink);
|
||||
break;
|
||||
case NM_LINK_TYPE_BOND:
|
||||
device = nm_device_bond_new (plink);
|
||||
break;
|
||||
|
|
|
@ -99,7 +99,7 @@ TESTS = \
|
|||
if ENABLE_TESTS
|
||||
|
||||
check-local:
|
||||
@for t in ethernet veth; do \
|
||||
@for t in ethernet infiniband 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…
Reference in a new issue