summaryrefslogtreecommitdiff
path: root/drivers/staging/lustre/lnet/lnet/config.c
diff options
context:
space:
mode:
authorAmir Shehata <amir.shehata@intel.com>2016-02-15 10:25:52 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-02-20 14:29:23 -0800
commit21602c7db4cfb296911b842365fde8a2edc02da2 (patch)
tree12c2aade62ee2b8afe5fd31e3ed3f4d7a353966d /drivers/staging/lustre/lnet/lnet/config.c
parent4407f6101ff7d2aafc32d6156a3e1733aec4f978 (diff)
staging: lustre: Dynamic LNet Configuration (DLC)
This is the first patch of a set of patches that enables DLC. This patch adds some cleanup in the config.c as well as some preparatory changes in peer.c to enable dynamic network configuration Signed-off-by: Amir Shehata <amir.shehata@intel.com> Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2456 Change-Id: I8c8bbf3b55acf4d76f22a8be587b553a70d31889 Reviewed-on: http://review.whamcloud.com/9830 Reviewed-by: Liang Zhen <liang.zhen@intel.com> Reviewed-by: James Simmons <uja.ornl@gmail.com> Reviewed-by: Oleg Drokin <oleg.drokin@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/lustre/lnet/lnet/config.c')
-rw-r--r--drivers/staging/lustre/lnet/lnet/config.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/drivers/staging/lustre/lnet/lnet/config.c b/drivers/staging/lustre/lnet/lnet/config.c
index e817eb3a91e9..bcc97b422be1 100644
--- a/drivers/staging/lustre/lnet/lnet/config.c
+++ b/drivers/staging/lustre/lnet/lnet/config.c
@@ -96,6 +96,8 @@ lnet_net_unique(__u32 net, struct list_head *nilist)
void
lnet_ni_free(struct lnet_ni *ni)
{
+ int i;
+
if (ni->ni_refs)
cfs_percpt_free(ni->ni_refs);
@@ -105,6 +107,10 @@ lnet_ni_free(struct lnet_ni *ni)
if (ni->ni_cpts)
cfs_expr_list_values_free(ni->ni_cpts, ni->ni_ncpts);
+ for (i = 0; i < LNET_MAX_INTERFACES && ni->ni_interfaces[i]; i++) {
+ LIBCFS_FREE(ni->ni_interfaces[i],
+ strlen(ni->ni_interfaces[i]) + 1);
+ }
LIBCFS_FREE(ni, sizeof(*ni));
}
@@ -199,8 +205,6 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
return -ENOMEM;
}
- the_lnet.ln_network_tokens = tokens;
- the_lnet.ln_network_tokens_nob = tokensize;
memcpy(tokens, networks, tokensize);
tmp = tokens;
str = tokens;
@@ -321,7 +325,23 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
goto failed;
}
- ni->ni_interfaces[niface++] = iface;
+ /*
+ * Allocate a separate piece of memory and copy
+ * into it the string, so we don't have
+ * a depencency on the tokens string. This way we
+ * can free the tokens at the end of the function.
+ * The newly allocated ni_interfaces[] can be
+ * freed when freeing the NI
+ */
+ LIBCFS_ALLOC(ni->ni_interfaces[niface],
+ strlen(iface) + 1);
+ if (!ni->ni_interfaces[niface]) {
+ CERROR("Can't allocate net interface name\n");
+ goto failed;
+ }
+ strncpy(ni->ni_interfaces[niface], iface,
+ strlen(iface));
+ niface++;
iface = comma;
} while (iface);
@@ -346,6 +366,8 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
}
LASSERT(!list_empty(nilist));
+
+ LIBCFS_FREE(tokens, tokensize);
return 0;
failed_syntax:
@@ -362,7 +384,6 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
cfs_expr_list_free(el);
LIBCFS_FREE(tokens, tokensize);
- the_lnet.ln_network_tokens = NULL;
return -EINVAL;
}