platform: request link after deleting inifiniband partition

After issuing the sysctl "delete_child", we must request the
link to get the platform cache in sync.
This commit is contained in:
Thomas Haller
2016-04-20 12:06:43 +02:00
parent b103af0f1e
commit d52a88a3f8

View File

@@ -176,6 +176,11 @@
* Forward declarations and enums * Forward declarations and enums
******************************************************************/ ******************************************************************/
typedef enum {
INFINIBAND_ACTION_CREATE_CHILD,
INFINIBAND_ACTION_DELETE_CHILD,
} InfinibandAction;
enum { enum {
DELAYED_ACTION_IDX_REFRESH_ALL_LINKS, DELAYED_ACTION_IDX_REFRESH_ALL_LINKS,
DELAYED_ACTION_IDX_REFRESH_ALL_IP4_ADDRESSES, DELAYED_ACTION_IDX_REFRESH_ALL_IP4_ADDRESSES,
@@ -5100,13 +5105,21 @@ 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 *out_partition_name) _infiniband_partition_action (NMPlatform *platform,
InfinibandAction action,
int parent,
int p_key,
const NMPlatformLink **out_link)
{ {
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform); NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
const NMPObject *obj_parent; const NMPObject *obj_parent;
const NMPObject *obj;
char path[NM_STRLEN ("/sys/class/net/%s/%s") + IFNAMSIZ + 100]; char path[NM_STRLEN ("/sys/class/net/%s/%s") + IFNAMSIZ + 100];
char id[20]; char id[20];
char name[IFNAMSIZ];
gboolean success;
nm_assert (NM_IN_SET (action, INFINIBAND_ACTION_CREATE_CHILD, INFINIBAND_ACTION_DELETE_CHILD));
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);
@@ -5115,45 +5128,44 @@ _infiniband_partition_action (NMPlatform *platform, int parent, int p_key, const
return FALSE; return FALSE;
} }
if (out_partition_name)
nm_utils_new_infiniband_name (out_partition_name, obj_parent->link.name, p_key);
nm_sprintf_buf (path, nm_sprintf_buf (path,
"/sys/class/net/%s/%s", "/sys/class/net/%s/%s",
NM_ASSERT_VALID_PATH_COMPONENT (obj_parent->link.name), NM_ASSERT_VALID_PATH_COMPONENT (obj_parent->link.name),
action); (action == INFINIBAND_ACTION_CREATE_CHILD
? "create_child"
: "delete_child"));
nm_sprintf_buf (id, "0x%04x", p_key); nm_sprintf_buf (id, "0x%04x", p_key);
return nm_platform_sysctl_set (platform, path, id); success = nm_platform_sysctl_set (platform, path, id);
} if (!success) {
if ( action == INFINIBAND_ACTION_DELETE_CHILD
&& errno == ENODEV)
static gboolean return TRUE;
infiniband_partition_add (NMPlatform *platform, int parent, int p_key, const NMPlatformLink **out_link)
{
const NMPObject *obj;
char name[IFNAMSIZ];
if (!_infiniband_partition_action (platform, parent, p_key, "create_child", name))
return FALSE; return FALSE;
}
nm_utils_new_infiniband_name (name, obj_parent->link.name, p_key);
do_request_link (platform, 0, name); do_request_link (platform, 0, name);
obj = nmp_cache_lookup_link_full (NM_LINUX_PLATFORM_GET_PRIVATE (platform)->cache, if (action == INFINIBAND_ACTION_DELETE_CHILD)
0, name, FALSE, NM_LINK_TYPE_INFINIBAND, NULL, NULL); return TRUE;
obj = nmp_cache_lookup_link_full (priv->cache, 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;
} }
static gboolean
infiniband_partition_add (NMPlatform *platform, int parent, int p_key, const NMPlatformLink **out_link)
{
return _infiniband_partition_action (platform, INFINIBAND_ACTION_CREATE_CHILD, parent, p_key, out_link);
}
static gboolean static gboolean
infiniband_partition_delete (NMPlatform *platform, int parent, int p_key) infiniband_partition_delete (NMPlatform *platform, int parent, int p_key)
{ {
if (!_infiniband_partition_action (platform, parent, p_key, "delete_child", NULL)) { return _infiniband_partition_action (platform, INFINIBAND_ACTION_DELETE_CHILD, parent, p_key, NULL);
if (errno != ENODEV)
return FALSE;
}
return TRUE;
} }
/******************************************************************/ /******************************************************************/