platform: use nm_utils_new_infiniband_name()
This commit is contained in:
@@ -709,12 +709,13 @@ static gboolean
|
|||||||
infiniband_partition_add (NMPlatform *platform, int parent, int p_key, const NMPlatformLink **out_link)
|
infiniband_partition_add (NMPlatform *platform, int parent, int p_key, const NMPlatformLink **out_link)
|
||||||
{
|
{
|
||||||
NMFakePlatformLink *device, *parent_device;
|
NMFakePlatformLink *device, *parent_device;
|
||||||
gs_free char *name = NULL;
|
char name[IFNAMSIZ];
|
||||||
|
|
||||||
parent_device = link_get (platform, parent);
|
parent_device = link_get (platform, parent);
|
||||||
g_return_val_if_fail (parent_device != NULL, FALSE);
|
g_return_val_if_fail (parent_device != NULL, FALSE);
|
||||||
|
|
||||||
name = g_strdup_printf ("%s.%04x", parent_device->link.name, p_key);
|
nm_utils_new_infiniband_name (name, parent_device->link.name, p_key);
|
||||||
|
|
||||||
if (!link_add (platform, name, NM_LINK_TYPE_INFINIBAND, NULL, 0, out_link))
|
if (!link_add (platform, name, NM_LINK_TYPE_INFINIBAND, NULL, 0, out_link))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@@ -726,7 +727,6 @@ infiniband_partition_add (NMPlatform *platform, int parent, int p_key, const NMP
|
|||||||
device->lnk->lnk_infiniband.p_key = p_key;
|
device->lnk->lnk_infiniband.p_key = p_key;
|
||||||
device->lnk->lnk_infiniband.mode = "datagram";
|
device->lnk->lnk_infiniband.mode = "datagram";
|
||||||
device->link.parent = parent;
|
device->link.parent = parent;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -739,7 +739,7 @@ infiniband_partition_delete (NMPlatform *platform, int parent, int p_key)
|
|||||||
parent_device = link_get (platform, parent);
|
parent_device = link_get (platform, parent);
|
||||||
g_return_val_if_fail (parent_device != NULL, FALSE);
|
g_return_val_if_fail (parent_device != NULL, FALSE);
|
||||||
|
|
||||||
name = g_strdup_printf ("%s.%04x", parent_device->link.name, p_key);
|
nm_utils_new_infiniband_name (name, parent_device->link.name, p_key);
|
||||||
return link_delete (platform, nm_platform_link_get_ifindex (platform, name));
|
return link_delete (platform, nm_platform_link_get_ifindex (platform, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -5100,7 +5100,7 @@ link_release (NMPlatform *platform, int master, int slave)
|
|||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_infiniband_partition_action (NMPlatform *platform, int parent, int p_key, const char *action, char **ifname)
|
_infiniband_partition_action (NMPlatform *platform, int parent, int p_key, const char *action, char *out_partition_name)
|
||||||
{
|
{
|
||||||
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
||||||
const NMPObject *obj_parent;
|
const NMPObject *obj_parent;
|
||||||
@@ -5110,10 +5110,13 @@ _infiniband_partition_action (NMPlatform *platform, int parent, int p_key, const
|
|||||||
nm_assert (p_key > 0 && p_key <= 0xffff && p_key != 0x8000);
|
nm_assert (p_key > 0 && p_key <= 0xffff && p_key != 0x8000);
|
||||||
|
|
||||||
obj_parent = nmp_cache_lookup_link (priv->cache, parent);
|
obj_parent = nmp_cache_lookup_link (priv->cache, parent);
|
||||||
if (!obj_parent || !obj_parent->link.name[0])
|
if (!obj_parent || !obj_parent->link.name[0]) {
|
||||||
g_return_val_if_reached (FALSE);
|
errno = ENOENT;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
*ifname = g_strdup_printf ("%s.%04x", obj_parent->link.name, p_key);
|
if (out_partition_name)
|
||||||
|
nm_utils_new_infiniband_name (out_partition_name, obj_parent->link.name, p_key);
|
||||||
|
|
||||||
path = g_strdup_printf ("/sys/class/net/%s/%s",
|
path = g_strdup_printf ("/sys/class/net/%s/%s",
|
||||||
NM_ASSERT_VALID_PATH_COMPONENT (obj_parent->link.name),
|
NM_ASSERT_VALID_PATH_COMPONENT (obj_parent->link.name),
|
||||||
@@ -5128,15 +5131,15 @@ static gboolean
|
|||||||
infiniband_partition_add (NMPlatform *platform, int parent, int p_key, const NMPlatformLink **out_link)
|
infiniband_partition_add (NMPlatform *platform, int parent, int p_key, const NMPlatformLink **out_link)
|
||||||
{
|
{
|
||||||
const NMPObject *obj;
|
const NMPObject *obj;
|
||||||
gs_free char *ifname = NULL;
|
char name[IFNAMSIZ];
|
||||||
|
|
||||||
if (!_infiniband_partition_action (platform, parent, p_key, "create_child", &ifname))
|
if (!_infiniband_partition_action (platform, parent, p_key, "create_child", name))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
do_request_link (platform, 0, ifname);
|
do_request_link (platform, 0, name);
|
||||||
|
|
||||||
obj = nmp_cache_lookup_link_full (NM_LINUX_PLATFORM_GET_PRIVATE (platform)->cache,
|
obj = nmp_cache_lookup_link_full (NM_LINUX_PLATFORM_GET_PRIVATE (platform)->cache,
|
||||||
0, ifname, FALSE, NM_LINK_TYPE_INFINIBAND, NULL, NULL);
|
0, name, FALSE, NM_LINK_TYPE_INFINIBAND, NULL, NULL);
|
||||||
if (out_link)
|
if (out_link)
|
||||||
*out_link = obj ? &obj->link : NULL;
|
*out_link = obj ? &obj->link : NULL;
|
||||||
return !!obj;
|
return !!obj;
|
||||||
@@ -5145,9 +5148,7 @@ infiniband_partition_add (NMPlatform *platform, int parent, int p_key, const NMP
|
|||||||
static gboolean
|
static gboolean
|
||||||
infiniband_partition_delete (NMPlatform *platform, int parent, int p_key)
|
infiniband_partition_delete (NMPlatform *platform, int parent, int p_key)
|
||||||
{
|
{
|
||||||
gs_free char *ifname = NULL;
|
if (!_infiniband_partition_action (platform, parent, p_key, "delete_child", NULL)) {
|
||||||
|
|
||||||
if (!_infiniband_partition_action (platform, parent, p_key, "delete_child", &ifname)) {
|
|
||||||
if (errno != ENODEV)
|
if (errno != ENODEV)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@@ -1895,7 +1895,7 @@ _infiniband_add_add_or_delete (NMPlatform *self,
|
|||||||
gboolean add,
|
gboolean add,
|
||||||
const NMPlatformLink **out_link)
|
const NMPlatformLink **out_link)
|
||||||
{
|
{
|
||||||
gs_free char *name = NULL;
|
char name[IFNAMSIZ];
|
||||||
const NMPlatformLink *parent_link;
|
const NMPlatformLink *parent_link;
|
||||||
NMPlatformError plerr;
|
NMPlatformError plerr;
|
||||||
|
|
||||||
@@ -1915,7 +1915,7 @@ _infiniband_add_add_or_delete (NMPlatform *self,
|
|||||||
if (parent_link->type != NM_LINK_TYPE_INFINIBAND)
|
if (parent_link->type != NM_LINK_TYPE_INFINIBAND)
|
||||||
return NM_PLATFORM_ERROR_WRONG_TYPE;
|
return NM_PLATFORM_ERROR_WRONG_TYPE;
|
||||||
|
|
||||||
name = g_strdup_printf ("%s.%04x", parent_link->name, p_key);
|
nm_utils_new_infiniband_name (name, parent_link->name, p_key);
|
||||||
|
|
||||||
if (add) {
|
if (add) {
|
||||||
plerr = _link_add_check_existing (self, name, NM_LINK_TYPE_INFINIBAND, out_link);
|
plerr = _link_add_check_existing (self, name, NM_LINK_TYPE_INFINIBAND, out_link);
|
||||||
|
Reference in New Issue
Block a user