From cced4fdc73bfb5ee111204ee33bfb3e36becdafe Mon Sep 17 00:00:00 2001 From: Boris Karasev Date: Wed, 24 Jan 2018 10:14:48 +0200 Subject: [PATCH 1/3] Sync to PMIx v2.1.0rc2 Signed-off-by: Boris Karasev --- opal/mca/pmix/pmix2x/pmix/VERSION | 6 +- .../pmix/pmix2x/pmix/etc/pmix-mca-params.conf | 4 +- opal/mca/pmix/pmix2x/pmix/include/pmi.h | 7 +- opal/mca/pmix/pmix2x/pmix/include/pmi2.h | 7 +- opal/mca/pmix/pmix2x/pmix/src/Makefile.am | 13 +- .../pmix/src/atomics/sys/powerpc/atomic.h | 4 +- .../pmix2x/pmix/src/client/Makefile.include | 5 +- .../pmix2x/pmix/src/include/pmix_globals.c | 1 + .../pmix2x/pmix/src/include/pmix_globals.h | 1 + .../pmix/src/mca/base/pmix_mca_base_var.h | 70 ++--- .../pmix2x/pmix/src/mca/gds/ds12/gds_dstore.c | 188 ++++++++++-- .../pmix2x/pmix/src/mca/gds/hash/gds_hash.c | 10 +- .../pmix/src/mca/psec/base/psec_base_select.c | 13 +- .../pmix/src/mca/psec/munge/Makefile.am | 8 +- .../pmix/src/mca/psec/munge/psec_munge.c | 28 +- .../pmix2x/pmix/src/mca/psec/none/psec_none.c | 14 + .../pmix2x/pmix/src/mca/ptl/tcp/ptl_tcp.c | 8 +- .../pmix/src/mca/ptl/tcp/ptl_tcp_component.c | 8 +- .../pmix2x/pmix/src/mca/ptl/usock/ptl_usock.c | 77 ++++- .../src/mca/ptl/usock/ptl_usock_component.c | 267 ++++++++++++------ .../pmix2x/pmix/src/runtime/Makefile.include | 4 +- .../pmix2x/pmix/src/server/pmix_server_get.c | 32 +-- .../pmix2x/pmix/src/server/pmix_server_ops.c | 11 +- .../pmix2x/pmix/src/threads/Makefile.include | 2 +- opal/mca/pmix/pmix2x/pmix/test/Makefile.am | 4 +- opal/mca/pmix/pmix2x/pmix/test/pmi2_client.c | 30 +- opal/mca/pmix/pmix2x/pmix/test/pmi_client.c | 30 +- 27 files changed, 603 insertions(+), 249 deletions(-) diff --git a/opal/mca/pmix/pmix2x/pmix/VERSION b/opal/mca/pmix/pmix2x/pmix/VERSION index 3abf41a2aaa..b280469dc98 100644 --- a/opal/mca/pmix/pmix2x/pmix/VERSION +++ b/opal/mca/pmix/pmix2x/pmix/VERSION @@ -30,7 +30,7 @@ greek= # command, or with the date (if "git describe" fails) in the form of # "date". -repo_rev=git1617e76 +repo_rev=git9212bbc # If tarball_version is not empty, it is used as the version string in # the tarball filename, regardless of all other versions listed in @@ -44,7 +44,7 @@ tarball_version= # The date when this release was created -date="Oct 31, 2017" +date="Jan 16, 2018" # The shared library version of each of PMIx's public libraries. # These versions are maintained in accordance with the "Library @@ -75,6 +75,6 @@ date="Oct 31, 2017" # Version numbers are described in the Libtool current:revision:age # format. -libpmix_so_version=3:3:1 +libpmix_so_version=3:10:1 libpmi_so_version=1:0:0 libpmi2_so_version=1:0:0 diff --git a/opal/mca/pmix/pmix2x/pmix/etc/pmix-mca-params.conf b/opal/mca/pmix/pmix2x/pmix/etc/pmix-mca-params.conf index 9d4f80572c7..794dc52e440 100644 --- a/opal/mca/pmix/pmix2x/pmix/etc/pmix-mca-params.conf +++ b/opal/mca/pmix/pmix2x/pmix/etc/pmix-mca-params.conf @@ -10,7 +10,7 @@ # Copyright (c) 2004-2005 The Regents of the University of California. # All rights reserved. # Copyright (c) 2006-2017 Cisco Systems, Inc. All rights reserved -# Copyright (c) 2017 Intel, Inc. All rights reserved. +# Copyright (c) 2017-2018 Intel, Inc. All rights reserved. # $COPYRIGHT$ # # Additional copyrights may follow @@ -53,7 +53,7 @@ # directory. For example: # Change component loading path -# component_path = /usr/local/lib/pmix:~/my_pmix_components +# mca_base_component_path = /usr/local/lib/pmix:~/my_pmix_components # See "pinfo --param all all --level 9" for a full listing of PMIx # MCA parameters available and their default values. diff --git a/opal/mca/pmix/pmix2x/pmix/include/pmi.h b/opal/mca/pmix/pmix2x/pmix/include/pmi.h index dda46feca77..dedd34211b6 100644 --- a/opal/mca/pmix/pmix2x/pmix/include/pmi.h +++ b/opal/mca/pmix/pmix2x/pmix/include/pmi.h @@ -48,11 +48,8 @@ #ifndef PMI_H #define PMI_H -#ifdef PMIX_HAVE_VISIBILITY -#define PMIX_EXPORT __attribute__((__visibility__("default"))) -#else -#define PMIX_EXPORT -#endif +/* Structure and constant definitions */ +#include /* prototypes for the PMI interface in MPICH2 */ diff --git a/opal/mca/pmix/pmix2x/pmix/include/pmi2.h b/opal/mca/pmix/pmix2x/pmix/include/pmi2.h index f7eb3376ace..0d4d45927e0 100644 --- a/opal/mca/pmix/pmix2x/pmix/include/pmi2.h +++ b/opal/mca/pmix/pmix2x/pmix/include/pmi2.h @@ -7,11 +7,8 @@ #ifndef PMI2_H_INCLUDED #define PMI2_H_INCLUDED -#ifdef PMIX_HAVE_VISIBILITY -#define PMIX_EXPORT __attribute__((__visibility__("default"))) -#else -#define PMIX_EXPORT -#endif +/* Structure and constant definitions */ +#include #define PMI2_MAX_KEYLEN 64 #define PMI2_MAX_VALLEN 1024 diff --git a/opal/mca/pmix/pmix2x/pmix/src/Makefile.am b/opal/mca/pmix/pmix2x/pmix/src/Makefile.am index c215cde1160..acf37ff2ff1 100644 --- a/opal/mca/pmix/pmix2x/pmix/src/Makefile.am +++ b/opal/mca/pmix/pmix2x/pmix/src/Makefile.am @@ -43,6 +43,10 @@ nodist_headers = EXTRA_DIST = dist_pmixdata_DATA = +# place to capture sources for backward compatibility libs +pmi1_sources = +pmi2_sources = + libpmix_la_LIBADD = \ mca/base/libpmix_mca_base.la \ $(MCA_pmix_FRAMEWORK_LIBS) \ @@ -73,10 +77,15 @@ libpmix_la_LDFLAGS = -version-info $(libpmix_so_version) if WANT_PMI_BACKWARD lib_LTLIBRARIES += libpmi.la libpmi2.la -libpmi_la_SOURCES = $(headers) $(sources) +libpmi_la_SOURCES = $(headers) $(sources) $(pmi1_sources) libpmi_la_LDFLAGS = -version-info $(libpmi_so_version) -libpmi2_la_SOURCES = $(headers) $(sources) +libpmi_la_LIBADD = $(libpmix_la_LIBADD) +libpmi_la_DEPENDENCIES = $(libpmi_la_LIBADD) + +libpmi2_la_SOURCES = $(headers) $(sources) $(pmi2_sources) libpmi2_la_LDFLAGS = -version-info $(libpmi2_so_version) +libpmi2_la_LIBADD = $(libpmix_la_LIBADD) +libpmi2_la_DEPENDENCIES = $(libpmi2_la_LIBADD) endif endif !PMIX_EMBEDDED_MODE diff --git a/opal/mca/pmix/pmix2x/pmix/src/atomics/sys/powerpc/atomic.h b/opal/mca/pmix/pmix2x/pmix/src/atomics/sys/powerpc/atomic.h index 9682b9e62af..4e39a43ee33 100644 --- a/opal/mca/pmix/pmix2x/pmix/src/atomics/sys/powerpc/atomic.h +++ b/opal/mca/pmix/pmix2x/pmix/src/atomics/sys/powerpc/atomic.h @@ -84,7 +84,7 @@ void pmix_atomic_rmb(void) static inline void pmix_atomic_wmb(void) { - PMIXRMB(); + PMIXWMB(); } static inline @@ -110,7 +110,7 @@ void pmix_atomic_isync(void) #pragma mc_func pmix_atomic_rmb { "7c2004ac" } /* lwsync */ #pragma reg_killed_by pmix_atomic_rmb /* none */ -#pragma mc_func pmix_atomic_wmb { "7c0006ac" } /* eieio */ +#pragma mc_func pmix_atomic_wmb { "7c2004ac" } /* lwsync */ #pragma reg_killed_by pmix_atomic_wmb /* none */ #endif diff --git a/opal/mca/pmix/pmix2x/pmix/src/client/Makefile.include b/opal/mca/pmix/pmix2x/pmix/src/client/Makefile.include index 0bf6efed743..80801cc4aaf 100644 --- a/opal/mca/pmix/pmix2x/pmix/src/client/Makefile.include +++ b/opal/mca/pmix/pmix2x/pmix/src/client/Makefile.include @@ -23,7 +23,8 @@ sources += \ client/pmix_client_connect.c if WANT_PMI_BACKWARD -sources += \ - client/pmi1.c \ +pmi1_sources += \ + client/pmi1.c +pmi2_sources += \ client/pmi2.c endif diff --git a/opal/mca/pmix/pmix2x/pmix/src/include/pmix_globals.c b/opal/mca/pmix/pmix2x/pmix/src/include/pmix_globals.c index 15d56e6268b..4d2fa8aea0b 100644 --- a/opal/mca/pmix/pmix2x/pmix/src/include/pmix_globals.c +++ b/opal/mca/pmix/pmix2x/pmix/src/include/pmix_globals.c @@ -124,6 +124,7 @@ static void pcon(pmix_peer_t *p) PMIX_CONSTRUCT(&p->send_queue, pmix_list_t); p->send_msg = NULL; p->recv_msg = NULL; + p->commit_cnt = 0; } static void pdes(pmix_peer_t *p) { diff --git a/opal/mca/pmix/pmix2x/pmix/src/include/pmix_globals.h b/opal/mca/pmix/pmix2x/pmix/src/include/pmix_globals.h index 36af6e2d92d..54e19d5ad8a 100644 --- a/opal/mca/pmix/pmix2x/pmix/src/include/pmix_globals.h +++ b/opal/mca/pmix/pmix2x/pmix/src/include/pmix_globals.h @@ -177,6 +177,7 @@ typedef struct pmix_peer_t { pmix_list_t send_queue; /**< list of messages to send */ pmix_ptl_send_t *send_msg; /**< current send in progress */ pmix_ptl_recv_t *recv_msg; /**< current recv in progress */ + int commit_cnt; } pmix_peer_t; PMIX_CLASS_DECLARATION(pmix_peer_t); diff --git a/opal/mca/pmix/pmix2x/pmix/src/mca/base/pmix_mca_base_var.h b/opal/mca/pmix/pmix2x/pmix/src/mca/base/pmix_mca_base_var.h index 328cdb1f520..c23a7b757e3 100644 --- a/opal/mca/pmix/pmix2x/pmix/src/mca/base/pmix_mca_base_var.h +++ b/opal/mca/pmix/pmix2x/pmix/src/mca/base/pmix_mca_base_var.h @@ -95,7 +95,7 @@ typedef enum { PMIX_MCA_BASE_VAR_TYPE_MAX } pmix_mca_base_var_type_t; -extern const char *pmix_var_type_names[]; +PMIX_EXPORT extern const char *pmix_var_type_names[]; /** * Source of an MCA variable's value @@ -298,7 +298,7 @@ BEGIN_C_DECLS /** * Object declarayion for pmix_mca_base_var_t */ -PMIX_CLASS_DECLARATION(pmix_mca_base_var_t); +PMIX_EXPORT PMIX_CLASS_DECLARATION(pmix_mca_base_var_t); /** * Initialize the MCA variable system. @@ -309,7 +309,7 @@ PMIX_CLASS_DECLARATION(pmix_mca_base_var_t); * invoked internally (by pmix_mca_base_open()) and is only documented * here for completeness. */ -int pmix_mca_base_var_init(void); +PMIX_EXPORT int pmix_mca_base_var_init(void); /** * Register an MCA variable @@ -489,7 +489,7 @@ PMIX_EXPORT int pmix_mca_base_var_register_synonym (int synonym_for, const char * * If an enumerator is associated with this variable it will be dereferenced. */ -int pmix_mca_base_var_deregister(int vari); +PMIX_EXPORT int pmix_mca_base_var_deregister(int vari); /** @@ -512,9 +512,9 @@ int pmix_mca_base_var_deregister(int vari); * Note: The value can be changed by the registering code without using * the pmix_mca_base_var_* interface so the source may be incorrect. */ -int pmix_mca_base_var_get_value (int vari, void *value, - pmix_mca_base_var_source_t *source, - const char **source_file); +PMIX_EXPORT int pmix_mca_base_var_get_value (int vari, void *value, + pmix_mca_base_var_source_t *source, + const char **source_file); /** * Sets an "override" value for an integer MCA variable. @@ -537,9 +537,9 @@ int pmix_mca_base_var_get_value (int vari, void *value, * a synonym the variable the synonym represents) if the value is * settable. */ -int pmix_mca_base_var_set_value (int vari, const void *value, size_t size, - pmix_mca_base_var_source_t source, - const char *source_file); +PMIX_EXPORT int pmix_mca_base_var_set_value (int vari, const void *value, size_t size, + pmix_mca_base_var_source_t source, + const char *source_file); /** * Get the string name corresponding to the MCA variable @@ -554,8 +554,8 @@ int pmix_mca_base_var_set_value (int vari, const void *value, size_t size, * The string that is returned is owned by the caller; if * appropriate, it must be eventually freed by the caller. */ -int pmix_mca_base_var_env_name(const char *param_name, - char **env_name); +PMIX_EXPORT int pmix_mca_base_var_env_name(const char *param_name, + char **env_name); /** * Find the index for an MCA variable based on its names. @@ -574,10 +574,10 @@ int pmix_mca_base_var_env_name(const char *param_name, * of any registered variable. The returned index can be used with * pmix_mca_base_var_get() and pmix_mca_base_var_get_value(). */ -int pmix_mca_base_var_find (const char *project_name, - const char *type_name, - const char *component_name, - const char *param_name); +PMIX_EXPORT int pmix_mca_base_var_find (const char *project_name, + const char *type_name, + const char *component_name, + const char *param_name); /** * Find the index for a variable based on its full name @@ -587,7 +587,7 @@ int pmix_mca_base_var_find (const char *project_name, * * See pmix_mca_base_var_find(). */ -int pmix_mca_base_var_find_by_name (const char *full_name, int *vari); +PMIX_EXPORT int pmix_mca_base_var_find_by_name (const char *full_name, int *vari); /** * Check that two MCA variables were not both set to non-default @@ -617,13 +617,13 @@ int pmix_mca_base_var_find_by_name (const char *full_name, int *vari); * are not MCA_BASE_VAR_SOURCE_DEFAULT. * @returns PMIX_SUCCESS otherwise. */ -int pmix_mca_base_var_check_exclusive (const char *project, - const char *type_a, - const char *component_a, - const char *param_a, - const char *type_b, - const char *component_b, - const char *param_b); +PMIX_EXPORT int pmix_mca_base_var_check_exclusive (const char *project, + const char *type_a, + const char *component_a, + const char *param_a, + const char *type_b, + const char *component_b, + const char *param_b); /** * Set or unset a flag on a variable. @@ -636,8 +636,8 @@ int pmix_mca_base_var_check_exclusive (const char *project, * @returns PMIX_ERR_BAD_PARAM If the variable is not registered. * @returns PMIX_ERROR Otherwise */ -int pmix_mca_base_var_set_flag(int vari, pmix_mca_base_var_flag_t flag, - bool set); +PMIX_EXPORT int pmix_mca_base_var_set_flag(int vari, pmix_mca_base_var_flag_t flag, + bool set); /** * Obtain basic info on a single variable (name, help message, etc) @@ -651,7 +651,7 @@ int pmix_mca_base_var_set_flag(int vari, pmix_mca_base_var_flag_t flag, * The returned pointer belongs to the MCA variable system. Do not * modify/free/retain the pointer. */ -int pmix_mca_base_var_get (int vari, const pmix_mca_base_var_t **var); +PMIX_EXPORT int pmix_mca_base_var_get (int vari, const pmix_mca_base_var_t **var); /** * Obtain the number of variables that have been registered. @@ -664,7 +664,7 @@ int pmix_mca_base_var_get (int vari, const pmix_mca_base_var_t **var); * returned is equal to the number of calls to pmix_mca_base_var_register with * unique names. ie. two calls with the same name will not affect the count. */ -int pmix_mca_base_var_get_count (void); +PMIX_EXPORT int pmix_mca_base_var_get_count (void); /** * Obtain a list of enironment variables describing the all @@ -683,8 +683,8 @@ int pmix_mca_base_var_get_count (void); * its output is in terms of an argv-style array of key=value * strings, suitable for using in an environment. */ -int pmix_mca_base_var_build_env(char ***env, int *num_env, - bool internal); +PMIX_EXPORT int pmix_mca_base_var_build_env(char ***env, int *num_env, + bool internal); /** * Shut down the MCA variable system (normally only invoked by the @@ -700,7 +700,7 @@ int pmix_mca_base_var_build_env(char ***env, int *num_env, * when the process is shutting down (e.g., during MPI_FINALIZE). It * is only documented here for completeness. */ -int pmix_mca_base_var_finalize(void); +PMIX_EXPORT int pmix_mca_base_var_finalize(void); typedef enum { /* Dump human-readable strings */ @@ -721,19 +721,19 @@ typedef enum { * This function returns an array of strings describing the variable. All strings * and the array must be freed by the caller. */ -int pmix_mca_base_var_dump(int vari, char ***out, pmix_mca_base_var_dump_type_t output_type); +PMIX_EXPORT int pmix_mca_base_var_dump(int vari, char ***out, pmix_mca_base_var_dump_type_t output_type); #define MCA_COMPILETIME_VER "print_compiletime_version" #define MCA_RUNTIME_VER "print_runtime_version" -int pmix_mca_base_var_cache_files (bool rel_path_search); +PMIX_EXPORT int pmix_mca_base_var_cache_files (bool rel_path_search); /* * Parse a provided list of envars and add their local value, or * their assigned value, to the provided argv */ -int pmix_mca_base_var_process_env_list(char ***argv); -int pmix_mca_base_var_process_env_list_from_file(char ***argv); +PMIX_EXPORT int pmix_mca_base_var_process_env_list(char ***argv); +PMIX_EXPORT int pmix_mca_base_var_process_env_list_from_file(char ***argv); END_C_DECLS diff --git a/opal/mca/pmix/pmix2x/pmix/src/mca/gds/ds12/gds_dstore.c b/opal/mca/pmix/pmix2x/pmix/src/mca/gds/ds12/gds_dstore.c index cdebc3fe8a6..4e3ba090f04 100644 --- a/opal/mca/pmix/pmix2x/pmix/src/mca/gds/ds12/gds_dstore.c +++ b/opal/mca/pmix/pmix2x/pmix/src/mca/gds/ds12/gds_dstore.c @@ -63,17 +63,104 @@ #define ESH_KV_SIZE(addr) \ __extension__ ({ \ size_t sz; \ - memcpy(&sz, addr, sizeof(size_t)); \ + if (PMIX_PROC_IS_V1(_client_peer())) { \ + sz = ESH_KV_SIZE_V12(addr); \ + } else { \ + sz = ESH_KV_SIZE_V20(addr); \ + } \ sz; \ }) #define ESH_KNAME_PTR(addr) \ __extension__ ({ \ - char *name_ptr = (char *)addr + sizeof(size_t); \ + char *name_ptr; \ + if (PMIX_PROC_IS_V1(_client_peer())) { \ + name_ptr = ESH_KNAME_PTR_V12(addr); \ + } else { \ + name_ptr = ESH_KNAME_PTR_V20(addr); \ + } \ name_ptr; \ }) #define ESH_KNAME_LEN(key) \ +__extension__ ({ \ + size_t len; \ + if (PMIX_PROC_IS_V1(_client_peer())) { \ + len = ESH_KNAME_LEN_V12(key); \ + } else { \ + len = ESH_KNAME_LEN_V20(key); \ + } \ + len; \ +}) + +#define ESH_DATA_PTR(addr) \ +__extension__ ({ \ + uint8_t *data_ptr; \ + if (PMIX_PROC_IS_V1(_client_peer())) { \ + data_ptr = ESH_DATA_PTR_V12(addr); \ + } else { \ + data_ptr = ESH_DATA_PTR_V20(addr); \ + } \ + data_ptr; \ +}) + +#define ESH_DATA_SIZE(addr, data_ptr) \ +__extension__ ({ \ + size_t sz; \ + if (PMIX_PROC_IS_V1(_client_peer())) { \ + sz = ESH_DATA_SIZE_V12(addr); \ + } else { \ + sz = ESH_DATA_SIZE_V20(addr, data_ptr); \ + } \ + sz; \ +}) + +#define ESH_KEY_SIZE(key, size) \ +__extension__ ({ \ + size_t len; \ + if (PMIX_PROC_IS_V1(_client_peer())) { \ + len = ESH_KEY_SIZE_V12(key, size); \ + } else { \ + len = ESH_KEY_SIZE_V20(key, size); \ + } \ + len; \ +}) + +#define EXT_SLOT_SIZE() \ +__extension__ ({ \ + size_t sz; \ + if (PMIX_PROC_IS_V1(_client_peer())) { \ + sz = EXT_SLOT_SIZE_V12(); \ + } else { \ + sz = EXT_SLOT_SIZE_V20(); \ + } \ + sz; \ +}) + +#define ESH_PUT_KEY(addr, key, buffer, size) \ +__extension__ ({ \ + if (PMIX_PROC_IS_V1(_client_peer())) { \ + ESH_PUT_KEY_V12(addr, key, buffer, size); \ + } else { \ + ESH_PUT_KEY_V20(addr, key, buffer, size); \ + } \ +}) + +/* PMIx v2.x dstore specific macro */ +#define ESH_KV_SIZE_V20(addr) \ +__extension__ ({ \ + size_t sz; \ + memcpy(&sz, addr, sizeof(size_t)); \ + sz; \ +}) + +#define ESH_KNAME_PTR_V20(addr) \ +__extension__ ({ \ + char *name_ptr = (char *)addr + sizeof(size_t); \ + name_ptr; \ +}) + +#define ESH_KNAME_LEN_V20(key) \ __extension__ ({ \ size_t kname_len = strlen(key) + 1; \ size_t len = (kname_len < ESH_MIN_KEY_LEN) ? \ @@ -81,23 +168,25 @@ __extension__ ({ \ len; \ }) -#define ESH_DATA_PTR(addr) \ +#define ESH_DATA_PTR_V20(addr) \ __extension__ ({ \ - size_t kname_len = ESH_KNAME_LEN(ESH_KNAME_PTR(addr)); \ + size_t kname_len = \ + ESH_KNAME_LEN_V20(ESH_KNAME_PTR_V20(addr)); \ uint8_t *data_ptr = addr + sizeof(size_t) + kname_len; \ data_ptr; \ }) -#define ESH_DATA_SIZE(addr, data_ptr) \ +#define ESH_DATA_SIZE_V20(addr, data_ptr) \ __extension__ ({ \ - size_t sz = ESH_KV_SIZE(addr); \ + size_t sz = ESH_KV_SIZE_V20(addr); \ size_t data_size = sz - (data_ptr - addr); \ data_size; \ }) -#define ESH_KEY_SIZE(key, size) \ +#define ESH_KEY_SIZE_V20(key, size) \ __extension__ ({ \ - size_t len = sizeof(size_t) + ESH_KNAME_LEN(key) + size;\ + size_t len = \ + sizeof(size_t) + ESH_KNAME_LEN_V20(key) + size; \ len; \ }) @@ -105,18 +194,85 @@ __extension__ ({ \ * new data were added for the same process during * next commit */ -#define EXT_SLOT_SIZE() \ - (ESH_KEY_SIZE(ESH_REGION_EXTENSION, sizeof(size_t))) +#define EXT_SLOT_SIZE_V20() \ + (ESH_KEY_SIZE_V20(ESH_REGION_EXTENSION, sizeof(size_t))) -#define ESH_PUT_KEY(addr, key, buffer, size) \ +#define ESH_PUT_KEY_V20(addr, key, buffer, size) \ __extension__ ({ \ - size_t sz = ESH_KEY_SIZE(key, size); \ + size_t sz = ESH_KEY_SIZE_V20(key, size); \ memcpy(addr, &sz, sizeof(size_t)); \ - memset(addr + sizeof(size_t), 0, ESH_KNAME_LEN(key)); \ + memset(addr + sizeof(size_t), 0, \ + ESH_KNAME_LEN_V20(key)); \ strncpy((char *)addr + sizeof(size_t), \ - key, ESH_KNAME_LEN(key)); \ - memcpy(addr + sizeof(size_t) + ESH_KNAME_LEN(key), \ + key, ESH_KNAME_LEN_V20(key)); \ + memcpy(addr + sizeof(size_t) + ESH_KNAME_LEN_V20(key), \ + buffer, size); \ +}) + +/* PMIx v1.2 dstore specific macro */ +#define ESH_KEY_SIZE_V12(key, size) \ +__extension__ ({ \ + size_t len = strlen(key) + 1 + sizeof(size_t) + size; \ + len; \ +}) + +/* in ext slot new offset will be stored in case if + * new data were added for the same process during + * next commit + */ +#define EXT_SLOT_SIZE_V12() \ + (ESH_KEY_SIZE_V12(ESH_REGION_EXTENSION, sizeof(size_t))) + +#define ESH_KV_SIZE_V12(addr) \ +__extension__ ({ \ + size_t sz; \ + memcpy(&sz, addr + \ + ESH_KNAME_LEN_V12(ESH_KNAME_PTR_V12(addr)), \ + sizeof(size_t)); \ + sz += ESH_KNAME_LEN_V12(ESH_KNAME_PTR_V12(addr)) + \ + sizeof(size_t); \ + sz; \ +}) + +#define ESH_KNAME_PTR_V12(addr) \ +__extension__ ({ \ + char *name_ptr = (char *)addr; \ + name_ptr; \ +}) + +#define ESH_KNAME_LEN_V12(key) \ +__extension__ ({ \ + size_t len = strlen((char*)key) + 1; \ + len; \ +}) + +#define ESH_DATA_PTR_V12(addr) \ +__extension__ ({ \ + uint8_t *data_ptr = \ + addr + \ + sizeof(size_t) + \ + ESH_KNAME_LEN_V12(ESH_KNAME_PTR_V12(addr)); \ + data_ptr; \ +}) + +#define ESH_DATA_SIZE_V12(addr) \ +__extension__ ({ \ + size_t data_size; \ + memcpy(&data_size, \ + addr + ESH_KNAME_LEN_V12(ESH_KNAME_PTR_V12(addr)), \ + sizeof(size_t)); \ + data_size; \ +}) + +#define ESH_PUT_KEY_V12(addr, key, buffer, size) \ +__extension__ ({ \ + size_t sz = size; \ + memset(addr, 0, ESH_KNAME_LEN_V12(key)); \ + strncpy((char *)addr, key, ESH_KNAME_LEN_V12(key)); \ + memcpy(addr + ESH_KNAME_LEN_V12(key), &sz, \ + sizeof(size_t)); \ + memcpy(addr + ESH_KNAME_LEN_V12(key) + sizeof(size_t), \ buffer, size); \ }) @@ -3086,7 +3242,7 @@ static void _client_compat_save(pmix_peer_t *peer) static inline pmix_peer_t * _client_peer(void) { if (NULL == _clients_peer) { - return pmix_client_globals.myserver; + return pmix_globals.mypeer; } return _clients_peer; } diff --git a/opal/mca/pmix/pmix2x/pmix/src/mca/gds/hash/gds_hash.c b/opal/mca/pmix/pmix2x/pmix/src/mca/gds/hash/gds_hash.c index 1e94c2c72b6..e6041aceafd 100644 --- a/opal/mca/pmix/pmix2x/pmix/src/mca/gds/hash/gds_hash.c +++ b/opal/mca/pmix/pmix2x/pmix/src/mca/gds/hash/gds_hash.c @@ -426,6 +426,7 @@ pmix_status_t hash_cache_job_info(struct pmix_nspace_t *ns, /* an array of data pertaining to a specific proc */ if (PMIX_DATA_ARRAY != info[n].value.type) { PMIX_ERROR_LOG(PMIX_ERR_BAD_PARAM); + rc = PMIX_ERR_TYPE_MISMATCH; goto release; } size = info[n].value.data.darray->size; @@ -433,6 +434,7 @@ pmix_status_t hash_cache_job_info(struct pmix_nspace_t *ns, /* first element of the array must be the rank */ if (0 != strcmp(iptr[0].key, PMIX_RANK) || PMIX_PROC_RANK != iptr[0].value.type) { + rc = PMIX_ERR_TYPE_MISMATCH; PMIX_ERROR_LOG(PMIX_ERR_BAD_PARAM); goto release; } @@ -458,7 +460,7 @@ pmix_status_t hash_cache_job_info(struct pmix_nspace_t *ns, if (NULL == tmp) { PMIX_ERROR_LOG(PMIX_ERR_NOMEM); rc = PMIX_ERR_NOMEM; - return rc; + goto release; } kp2->value->type = PMIX_COMPRESSED_STRING; free(kp2->value->data.string); @@ -493,10 +495,10 @@ pmix_status_t hash_cache_job_info(struct pmix_nspace_t *ns, if (PMIX_STRING_SIZE_CHECK(kp2->value)) { if (pmix_util_compress_string(kp2->value->data.string, &tmp, &len)) { if (NULL == tmp) { - PMIX_ERROR_LOG(PMIX_ERR_NOMEM); - PMIX_RELEASE(kp2); rc = PMIX_ERR_NOMEM; - return rc; + PMIX_ERROR_LOG(rc); + PMIX_RELEASE(kp2); + goto release; } kp2->value->type = PMIX_COMPRESSED_STRING; free(kp2->value->data.string); diff --git a/opal/mca/pmix/pmix2x/pmix/src/mca/psec/base/psec_base_select.c b/opal/mca/pmix/pmix2x/pmix/src/mca/psec/base/psec_base_select.c index 8792bd46792..5d92f3a34f8 100644 --- a/opal/mca/pmix/pmix2x/pmix/src/mca/psec/base/psec_base_select.c +++ b/opal/mca/pmix/pmix2x/pmix/src/mca/psec/base/psec_base_select.c @@ -74,12 +74,21 @@ int pmix_psec_base_select(void) if (PMIX_SUCCESS != rc || NULL == module) { pmix_output_verbose(5, pmix_psec_base_framework.framework_output, "mca:psec:select: Skipping component [%s]. Query failed to return a module", - component->pmix_mca_component_name ); + component->pmix_mca_component_name); + continue; + } + nmodule = (pmix_psec_module_t*) module; + + /* give the module a chance to init */ + if (NULL != nmodule->init && PMIX_SUCCESS != nmodule->init()) { + /* failed to init, so skip it */ + pmix_output_verbose(5, pmix_psec_base_framework.framework_output, + "mca:psec:select: Skipping component [%s]. Failed to init", + component->pmix_mca_component_name); continue; } /* If we got a module, keep it */ - nmodule = (pmix_psec_module_t*) module; /* add to the list of selected modules */ newmodule = PMIX_NEW(pmix_psec_base_active_module_t); newmodule->pri = priority; diff --git a/opal/mca/pmix/pmix2x/pmix/src/mca/psec/munge/Makefile.am b/opal/mca/pmix/pmix2x/pmix/src/mca/psec/munge/Makefile.am index a756c8b19de..5f01461190c 100644 --- a/opal/mca/pmix/pmix2x/pmix/src/mca/psec/munge/Makefile.am +++ b/opal/mca/pmix/pmix2x/pmix/src/mca/psec/munge/Makefile.am @@ -19,6 +19,8 @@ # $HEADER$ # +AM_CPPFLAGS = $(psec_munge_CPPFLAGS) + headers = psec_munge.h sources = \ psec_munge_component.c \ @@ -43,8 +45,10 @@ endif mcacomponentdir = $(pmixlibdir) mcacomponent_LTLIBRARIES = $(component) mca_psec_munge_la_SOURCES = $(component_sources) -mca_psec_munge_la_LDFLAGS = -module -avoid-version +mca_psec_munge_la_LDFLAGS = -module -avoid-version $(psec_munge_LDFLAGS) +mca_psec_munge_la_LIBADD = $(psec_munge_LIBS) noinst_LTLIBRARIES = $(lib) libmca_psec_munge_la_SOURCES = $(lib_sources) -libmca_psec_munge_la_LDFLAGS = -module -avoid-version +libmca_psec_munge_la_LDFLAGS = -module -avoid-version $(psec_munge_LDFLAGS) +libmca_psec_munge_la_LIBADD = $(psec_munge_LIBS) diff --git a/opal/mca/pmix/pmix2x/pmix/src/mca/psec/munge/psec_munge.c b/opal/mca/pmix/pmix2x/pmix/src/mca/psec/munge/psec_munge.c index 3d0a533226c..0742ad2ad6b 100644 --- a/opal/mca/pmix/pmix2x/pmix/src/mca/psec/munge/psec_munge.c +++ b/opal/mca/pmix/pmix2x/pmix/src/mca/psec/munge/psec_munge.c @@ -25,6 +25,7 @@ #endif #include +#include "src/threads/threads.h" #include "src/mca/psec/psec.h" #include "psec_munge.h" @@ -37,15 +38,14 @@ static pmix_status_t validate_cred(int sd, uid_t uid, gid_t gid, char *cred, size_t len); pmix_psec_module_t pmix_munge_module = { - "munge", - munge_init, - munge_finalize, - create_cred, - NULL, - validate_cred, - NULL + .name = "munge", + .init = munge_init, + .finalize = munge_finalize, + .create_cred = create_cred, + .validate_cred = validate_cred }; +static pmix_lock_t lock; static char *mycred = NULL; static bool initialized = false; static bool refresh = false; @@ -57,6 +57,9 @@ static pmix_status_t munge_init(void) pmix_output_verbose(2, pmix_globals.debug_output, "psec: munge init"); + PMIX_CONSTRUCT_LOCK(&lock); + lock.active = false; + /* attempt to get a credential as a way of checking that * the munge server is available - cache the credential * for later use */ @@ -67,6 +70,7 @@ static pmix_status_t munge_init(void) munge_strerror(rc)); return PMIX_ERR_SERVER_NOT_AVAIL; } + initialized = true; return PMIX_SUCCESS; @@ -74,6 +78,8 @@ static pmix_status_t munge_init(void) static void munge_finalize(void) { + PMIX_ACQUIRE_THREAD(&lock); + pmix_output_verbose(2, pmix_globals.debug_output, "psec: munge finalize"); if (initialized) { @@ -82,6 +88,8 @@ static void munge_finalize(void) mycred = NULL; } } + PMIX_RELEASE_THREAD(&lock); + PMIX_DESTRUCT_LOCK(&lock); } static pmix_status_t create_cred(pmix_listener_protocol_t protocol, @@ -89,6 +97,8 @@ static pmix_status_t create_cred(pmix_listener_protocol_t protocol, { int rc; + PMIX_ACQUIRE_THREAD(&lock); + pmix_output_verbose(2, pmix_globals.debug_output, "psec: munge create_cred"); @@ -107,12 +117,14 @@ static pmix_status_t create_cred(pmix_listener_protocol_t protocol, pmix_output_verbose(2, pmix_globals.debug_output, "psec: munge failed to create credential: %s", munge_strerror(rc)); - return NULL; + PMIX_RELEASE_THREAD(&lock); + return PMIX_ERR_NOT_SUPPORTED; } *cred = strdup(mycred); *len = strlen(mycred) + 1; } } + PMIX_RELEASE_THREAD(&lock); return PMIX_SUCCESS; } diff --git a/opal/mca/pmix/pmix2x/pmix/src/mca/psec/none/psec_none.c b/opal/mca/pmix/pmix2x/pmix/src/mca/psec/none/psec_none.c index de0f71d50ef..d5769aec146 100644 --- a/opal/mca/pmix/pmix2x/pmix/src/mca/psec/none/psec_none.c +++ b/opal/mca/pmix/pmix2x/pmix/src/mca/psec/none/psec_none.c @@ -1,6 +1,8 @@ /* * Copyright (c) 2015-2017 Intel, Inc. All rights reserved. * Copyright (c) 2016 IBM Corporation. All rights reserved. + * Copyright (c) 2017 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * * $COPYRIGHT$ * @@ -29,6 +31,8 @@ static pmix_status_t none_init(void); static void none_finalize(void); +static pmix_status_t create_cred(pmix_listener_protocol_t protocol, + char **cred, size_t *len); static pmix_status_t validate_cred(int sd, uid_t uid, gid_t gid, pmix_listener_protocol_t protocol, char *cred, size_t len); @@ -37,6 +41,7 @@ pmix_psec_module_t pmix_none_module = { .name = "none", .init = none_init, .finalize = none_finalize, + .create_cred = create_cred, .validate_cred = validate_cred }; @@ -53,6 +58,15 @@ static void none_finalize(void) "psec: none finalize"); } +static pmix_status_t create_cred(pmix_listener_protocol_t protocol, + char **cred, size_t *len) +{ + *cred = NULL; + *len = 0; + + return PMIX_SUCCESS; +} + static pmix_status_t validate_cred(int sd, uid_t uid, gid_t gid, pmix_listener_protocol_t protocol, char *cred, size_t len) diff --git a/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/tcp/ptl_tcp.c b/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/tcp/ptl_tcp.c index a900230c3bf..1c46e2923e6 100644 --- a/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/tcp/ptl_tcp.c +++ b/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/tcp/ptl_tcp.c @@ -528,10 +528,16 @@ static pmix_status_t parse_uri_file(char *filename, pmix_client_globals.myserver->proc_type = PMIX_PROC_SERVER | PMIX_PROC_V20; pmix_output_verbose(2, pmix_ptl_base_framework.framework_output, "V20 SERVER DETECTED"); - } else if (0 == strncmp(p2, "v2.1", strlen("v2.1"))) { + } else if (0 == strncmp(p2, "v2.1", strlen("v2.1")) || + 0 == strncmp(p2, "2.1", strlen("2.1"))) { pmix_client_globals.myserver->proc_type = PMIX_PROC_SERVER | PMIX_PROC_V21; pmix_output_verbose(2, pmix_ptl_base_framework.framework_output, "V21 SERVER DETECTED"); + } else if (0 == strncmp(p2, "3", strlen("3")) || + 0 == strncmp(p2, "v3", strlen("v3"))) { + pmix_client_globals.myserver->proc_type = PMIX_PROC_SERVER | PMIX_PROC_V3; + pmix_output_verbose(2, pmix_ptl_base_framework.framework_output, + "V3 SERVER DETECTED"); } else { pmix_output_verbose(2, pmix_ptl_base_framework.framework_output, "UNKNOWN SERVER VERSION DETECTED: %s", p2); diff --git a/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/tcp/ptl_tcp_component.c b/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/tcp/ptl_tcp_component.c index 1f1d3e89b2a..69ae60e55dd 100644 --- a/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/tcp/ptl_tcp_component.c +++ b/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/tcp/ptl_tcp_component.c @@ -625,6 +625,9 @@ static pmix_status_t setup_listener(pmix_info_t info[], size_t ninfo, CLOSE_THE_SOCKET(lt->socket); goto sockerror; } + pmix_output_verbose(2, pmix_ptl_base_framework.framework_output, + "WRITING SYSTEM FILE %s", + mca_ptl_tcp_component.system_filename); fp = fopen(mca_ptl_tcp_component.system_filename, "w"); if (NULL == fp) { pmix_output(0, "Impossible to open the file %s in write mode\n", mca_ptl_tcp_component.system_filename); @@ -637,7 +640,7 @@ static pmix_status_t setup_listener(pmix_info_t info[], size_t ninfo, /* output my nspace and rank plus the URI */ fprintf(fp, "%s\n", lt->uri); - /* add a flag that indicates we accept v2.1 protocols */ + /* add a flag that indicates we accept v3.0 protocols */ fprintf(fp, "v%s\n", PMIX_VERSION); fclose(fp); /* set the file mode */ @@ -659,6 +662,9 @@ static pmix_status_t setup_listener(pmix_info_t info[], size_t ninfo, CLOSE_THE_SOCKET(lt->socket); goto sockerror; } + pmix_output_verbose(2, pmix_ptl_base_framework.framework_output, + "WRITING TOOL FILE %s", + mca_ptl_tcp_component.session_filename); fp = fopen(mca_ptl_tcp_component.session_filename, "w"); if (NULL == fp) { pmix_output(0, "Impossible to open the file %s in write mode\n", mca_ptl_tcp_component.session_filename); diff --git a/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/usock/ptl_usock.c b/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/usock/ptl_usock.c index ca76b94358b..443a4088db2 100644 --- a/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/usock/ptl_usock.c +++ b/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/usock/ptl_usock.c @@ -114,27 +114,31 @@ static pmix_status_t connect_to_peer(struct pmix_peer_t *peer, /* if we don't have a path to the daemon rendezvous point, * then we need to return an error */ - if (NULL == (evar = getenv("PMIX_SERVER_URI"))) { + if (NULL != (evar = getenv("PMIX_SERVER_URI2USOCK"))) { + /* this is a v2.1+ server */ + pmix_globals.mypeer->nptr->compat.bfrops = pmix_bfrops_base_assign_module("v21"); + if (NULL == pmix_globals.mypeer->nptr->compat.bfrops) { + return PMIX_ERR_INIT; + } + } else if (NULL != (evar = getenv("PMIX_SERVER_URI"))) { + /* this is a pre-v2.1 server - must use the v12 bfrops module */ + pmix_globals.mypeer->nptr->compat.bfrops = pmix_bfrops_base_assign_module("v12"); + if (NULL == pmix_globals.mypeer->nptr->compat.bfrops) { + return PMIX_ERR_INIT; + } + } else { /* let the caller know that the server isn't available */ return PMIX_ERR_SERVER_NOT_AVAIL; } + /* the server will be using the same bfrops as us */ + pmix_client_globals.myserver->nptr->compat.bfrops = pmix_globals.mypeer->nptr->compat.bfrops; + uri = pmix_argv_split(evar, ':'); if (3 != pmix_argv_count(uri)) { pmix_argv_free(uri); PMIX_ERROR_LOG(PMIX_ERROR); return PMIX_ERROR; } - /* definitely a v1 server */ - pmix_client_globals.myserver->proc_type = PMIX_PROC_SERVER | PMIX_PROC_V1; - /* must use the v12 bfrops module */ - pmix_globals.mypeer->nptr->compat.bfrops = pmix_bfrops_base_assign_module("v12"); - if (NULL == pmix_globals.mypeer->nptr->compat.bfrops) { - pmix_argv_free(uri); - return PMIX_ERR_INIT; - } - /* the server will be using the same */ - pmix_client_globals.myserver->nptr->compat.bfrops = pmix_globals.mypeer->nptr->compat.bfrops; - /* set the server nspace */ if (NULL == pmix_client_globals.myserver->info) { pmix_client_globals.myserver->info = PMIX_NEW(pmix_rank_info_t); @@ -272,6 +276,8 @@ static pmix_status_t send_connect_ack(int sd) size_t sdsize=0, csize=0, len; char *cred = NULL; pmix_status_t rc; + char *sec, *bfrops, *gds; + pmix_bfrop_buffer_type_t bftype; pmix_output_verbose(2, pmix_ptl_base_framework.framework_output, "pmix: SEND CONNECT ACK"); @@ -292,8 +298,24 @@ static pmix_status_t send_connect_ack(int sd) return rc; } + /* add the name of our active sec module - we selected it + * in pmix_client.c prior to entering here */ + sec = pmix_globals.mypeer->nptr->compat.psec->name; + + /* add our active bfrops module name */ + bfrops = pmix_globals.mypeer->nptr->compat.bfrops->version; + /* and the type of buffer we are using */ + bftype = pmix_globals.mypeer->nptr->compat.type; + + /* add our active gds module for working with the server */ + gds = (char*)pmix_client_globals.myserver->nptr->compat.gds->name; + /* set the number of bytes to be read beyond the header */ - hdr.nbytes = sdsize + strlen(PMIX_VERSION) + 1 + len; // must NULL terminate the VERSION string! + hdr.nbytes = sdsize + (strlen(PMIX_VERSION) + 1) + \ + (sizeof(size_t) + len) + \ + (strlen(sec) + 1) + \ + (strlen(bfrops) + 1) + sizeof(bftype) + \ + (strlen(gds) + 1); // must NULL terminate the strings! /* create a space for our message */ sdsize = (sizeof(hdr) + hdr.nbytes); @@ -309,16 +331,41 @@ static pmix_status_t send_connect_ack(int sd) csize=0; memcpy(msg, &hdr, sizeof(pmix_usock_hdr_t)); csize += sizeof(pmix_usock_hdr_t); + /* pass our nspace */ memcpy(msg+csize, pmix_globals.myid.nspace, strlen(pmix_globals.myid.nspace)); csize += strlen(pmix_globals.myid.nspace)+1; + /* pass our rank */ memcpy(msg+csize, &pmix_globals.myid.rank, sizeof(int)); csize += sizeof(int); + + /* pass our version string */ memcpy(msg+csize, PMIX_VERSION, strlen(PMIX_VERSION)); csize += strlen(PMIX_VERSION)+1; - if (NULL != cred) { - memcpy(msg+csize, cred, strlen(cred)); // leaves last position in msg set to NULL + + /* pass the size of the credential */ + memcpy(msg+csize, &len, sizeof(size_t)); + csize += sizeof(size_t); + if (0 < len) { + memcpy(msg+csize, cred, len); + csize += len; } + /* pass our active sec module */ + memcpy(msg+csize, sec, strlen(sec)); + csize += strlen(sec)+1; + + /* provide our active bfrops module */ + memcpy(msg+csize, bfrops, strlen(bfrops)); + csize += strlen(bfrops)+1; + + /* provide the bfrops type */ + memcpy(msg+csize, &bftype, sizeof(bftype)); + csize += sizeof(bftype); + + /* provide the gds module */ + memcpy(msg+csize, gds, strlen(gds)); + + /* send the entire msg across */ if (PMIX_SUCCESS != pmix_ptl_base_send_blocking(sd, msg, sdsize)) { free(msg); if (NULL != cred) { diff --git a/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/usock/ptl_usock_component.c b/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/usock/ptl_usock_component.c index 7c493c83cc2..a0040e1bf60 100644 --- a/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/usock/ptl_usock_component.c +++ b/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/usock/ptl_usock_component.c @@ -104,7 +104,6 @@ PMIX_EXPORT pmix_ptl_usock_component_t mca_ptl_usock_component = { static void connection_handler(int sd, short args, void *cbdata); static void listener_cb(int incoming_sd, void *cbdata); -static char *sec_mode = NULL; pmix_status_t component_open(void) { @@ -133,9 +132,6 @@ pmix_status_t component_open(void) pmix_status_t component_close(void) { - if (NULL != sec_mode) { - free(sec_mode); - } if (NULL != mca_ptl_usock_component.tmpdir) { free(mca_ptl_usock_component.tmpdir); } @@ -176,7 +172,7 @@ static pmix_status_t setup_listener(pmix_info_t info[], size_t ninfo, socklen_t addrlen; struct sockaddr_un *address; bool disabled = false; - char *secmods, **options, *pmix_pid; + char *pmix_pid; pid_t mypid; pmix_output_verbose(2, pmix_ptl_base_framework.framework_output, @@ -211,17 +207,6 @@ static pmix_status_t setup_listener(pmix_info_t info[], size_t ninfo, address = (struct sockaddr_un*)&mca_ptl_usock_component.connection; address->sun_family = AF_UNIX; - /* any client we hear from will be using v1.x protocols. This - * means that they cannot tell us what security module they - * are using as this wasn't included in their handshake. So - * the best we can assume is that they are using the highest - * priority default we have */ - secmods = pmix_psec_base_get_available_modules(); - options = pmix_argv_split(secmods, ','); - sec_mode = strdup(options[0]); - pmix_argv_free(options); - free(secmods); - /* define the listener */ lt = PMIX_NEW(pmix_listener_t); @@ -242,7 +227,7 @@ static pmix_status_t setup_listener(pmix_info_t info[], size_t ninfo, snprintf(address->sun_path, sizeof(address->sun_path)-1, "%s", pmix_pid); free(pmix_pid); /* set the URI */ - lt->varname = strdup("PMIX_SERVER_URI"); + lt->varname = strdup("PMIX_SERVER_URI:PMIX_SERVER_URI2USOCK"); if (0 > asprintf(<->uri, "%s:%lu:%s", pmix_globals.myid.nspace, (unsigned long)pmix_globals.myid.rank, address->sun_path)) { PMIX_RELEASE(lt); @@ -349,57 +334,10 @@ static void listener_cb(int incoming_sd, void *cbdata) pmix_event_active(&pending_connection->ev, EV_WRITE, 1); } -/* Parse init-ack message: - * NSPACE<0>VERSION<0>[CRED<0>] - */ -static pmix_status_t parse_connect_ack (char *msg, unsigned int len, - char **nspace, unsigned int *rank, - char **version, char **cred) -{ - unsigned int msglen; - - PMIX_STRNLEN(msglen, msg, len); - if (msglen < len) { - *nspace = msg; - msg += strlen(*nspace) + 1; - len -= strlen(*nspace) + 1; - } else { - return PMIX_ERR_BAD_PARAM; - } - - PMIX_STRNLEN(msglen, msg, len); - if (msglen <= len) { - memcpy(rank, msg, sizeof(int)); - msg += sizeof(int); - len -= sizeof(int); - } else { - return PMIX_ERR_BAD_PARAM; - } - - PMIX_STRNLEN(msglen, msg, len); - if (msglen < len) { - *version = msg; - msg += strlen(*version) + 1; - len -= strlen(*version) + 1; - } else { - return PMIX_ERR_BAD_PARAM; - } - - PMIX_STRNLEN(msglen, msg, len); - if (msglen < len) - *cred = msg; - else { - *cred = NULL; - } - - return PMIX_SUCCESS; -} - - static void connection_handler(int sd, short args, void *cbdata) { pmix_pending_connection_t *pnd = (pmix_pending_connection_t*)cbdata; - char *msg, *nspace, *version, *cred; + char *msg, *ptr, *nspace, *version, *cred, *sec, *bfrops, *gds; pmix_status_t rc; unsigned int rank; pmix_usock_hdr_t hdr; @@ -409,6 +347,12 @@ static void connection_handler(int sd, short args, void *cbdata) bool found; pmix_proc_t proc; size_t len; + pmix_bfrop_buffer_type_t bftype; + char **vers; + int major, minor, rel; + unsigned int msglen; + pmix_info_t ginfo; + size_t credlen; /* acquire the object */ PMIX_ACQUIRE_OBJECT(pnd); @@ -448,11 +392,140 @@ static void connection_handler(int sd, short args, void *cbdata) PMIX_RELEASE(pnd); return; } + len = hdr.nbytes; + ptr = msg; + + /* extract the nspace of the requestor */ + PMIX_STRNLEN(msglen, ptr, len); + if (msglen < len) { + nspace = ptr; + ptr += strlen(nspace) + 1; + len -= strlen(nspace) + 1; + } else { + free(msg); + CLOSE_THE_SOCKET(pnd->sd); + PMIX_RELEASE(pnd); + return; + } - if (PMIX_SUCCESS != (rc = parse_connect_ack(msg, hdr.nbytes, &nspace, - &rank, &version, &cred))) { + /* extract the rank */ + PMIX_STRNLEN(msglen, ptr, len); + if (msglen <= len) { + memcpy(&rank, ptr, sizeof(int)); + ptr += sizeof(int); + len -= sizeof(int); + } else { + free(msg); + CLOSE_THE_SOCKET(pnd->sd); + PMIX_RELEASE(pnd); + return; + } + + /* get their version string */ + PMIX_STRNLEN(msglen, ptr, len); + if (msglen < len) { + version = ptr; + ptr += strlen(version) + 1; + len -= strlen(version) + 1; + } else { + free(msg); + CLOSE_THE_SOCKET(pnd->sd); + PMIX_RELEASE(pnd); + return; + } + + /* check the version - we do NOT support anything less than + * v1.2.5 */ + vers = pmix_argv_split(version, '.'); + major = strtol(vers[0], NULL, 10); + minor = strtol(vers[1], NULL, 10); + rel = strtol(vers[2], NULL, 10); + pmix_argv_free(vers); + if (1 == major && (2 != minor || 5 > rel)) { pmix_output_verbose(2, pmix_ptl_base_framework.framework_output, - "error parsing connect-ack from client ON SOCKET %d", pnd->sd); + "connection request from client of unsupported version %s", version); + free(msg); + CLOSE_THE_SOCKET(pnd->sd); + PMIX_RELEASE(pnd); + return; + } + + /* get any provided credential */ + if (1 == major || (2 == major && 0 == minor)) { + PMIX_STRNLEN(msglen, ptr, len); + if (msglen < len) { + cred = ptr; + ptr += strlen(cred) + 1; + len -= strlen(cred) + 1; + } else { + free(msg); + CLOSE_THE_SOCKET(pnd->sd); + PMIX_RELEASE(pnd); + return; + } + } else { + if (sizeof(size_t) < len) { + memcpy(&credlen, ptr, sizeof(size_t)); + ptr += sizeof(size_t); + len -= sizeof(size_t); + } else { + free(msg); + CLOSE_THE_SOCKET(pnd->sd); + PMIX_RELEASE(pnd); + return; + } + if (0 < credlen) { + cred = ptr; + ptr += credlen; + len -= credlen; + } + } + + /* get their sec module */ + PMIX_STRNLEN(msglen, ptr, len); + if (msglen < len) { + sec = ptr; + ptr += strlen(sec) + 1; + len -= strlen(sec) + 1; + } else { + free(msg); + CLOSE_THE_SOCKET(pnd->sd); + PMIX_RELEASE(pnd); + return; + } + + /* get their bfrops module */ + PMIX_STRNLEN(msglen, ptr, len); + if (msglen < len) { + bfrops = ptr; + ptr += strlen(bfrops) + 1; + len -= strlen(bfrops) + 1; + } else { + free(msg); + CLOSE_THE_SOCKET(pnd->sd); + PMIX_RELEASE(pnd); + return; + } + + /* get their buffer type */ + if (0 < len) { + bftype = ptr[0]; + ptr += 1; + len -= 1; + } else { + free(msg); + CLOSE_THE_SOCKET(pnd->sd); + PMIX_RELEASE(pnd); + return; + } + + /* get their gds module */ + PMIX_STRNLEN(msglen, ptr, len); + if (msglen < len) { + gds = ptr; + ptr += strlen(gds) + 1; + len -= strlen(gds) + 1; + } else { free(msg); CLOSE_THE_SOCKET(pnd->sd); PMIX_RELEASE(pnd); @@ -463,11 +536,6 @@ static void connection_handler(int sd, short args, void *cbdata) "connect-ack recvd from peer %s:%d:%s on socket %d", nspace, rank, version, pnd->sd); - /* do not check the version - we only retain it at this - * time in case we need to check it at some future date. - * For now, our intent is to retain backward compatibility - * and so we will assume that all versions are compatible. */ - /* see if we know this nspace */ nptr = NULL; PMIX_LIST_FOREACH(tmp, &pmix_server_globals.nspaces, pmix_nspace_t) { @@ -509,8 +577,25 @@ static void connection_handler(int sd, short args, void *cbdata) rc = PMIX_ERR_NOMEM; goto error; } - /* mark it as being a v1 type */ - psave->proc_type = PMIX_PROC_CLIENT | PMIX_PROC_V1; + /* mark it as being a client of the correct type */ + if (1 == major) { + psave->proc_type = PMIX_PROC_CLIENT | PMIX_PROC_V1; + } else if (2 == major && 0 == minor) { + psave->proc_type = PMIX_PROC_CLIENT | PMIX_PROC_V20; + } else if (2 == major && 1 == minor) { + psave->proc_type = PMIX_PROC_CLIENT | PMIX_PROC_V21; + } else if (3 == major) { + psave->proc_type = PMIX_PROC_CLIENT | PMIX_PROC_V3; + } else { + /* we don't recognize this version */ + pmix_output_verbose(2, pmix_ptl_base_framework.framework_output, + "connection request from client of unrecognized version %s", version); + free(msg); + PMIX_RELEASE(psave); + CLOSE_THE_SOCKET(pnd->sd); + PMIX_RELEASE(pnd); + return; + } /* add the nspace tracker */ PMIX_RETAIN(nptr); psave->nptr = nptr; @@ -531,7 +616,7 @@ static void connection_handler(int sd, short args, void *cbdata) info->peerid = psave->index; /* get the appropriate compatibility modules */ - nptr->compat.psec = pmix_psec_base_assign_module(sec_mode); + nptr->compat.psec = pmix_psec_base_assign_module(sec); if (NULL == nptr->compat.psec) { free(msg); info->proc_cnt--; @@ -541,8 +626,9 @@ static void connection_handler(int sd, short args, void *cbdata) /* send an error reply to the client */ goto error; } - /* we need the v1.2 bfrops module */ - nptr->compat.bfrops = pmix_bfrops_base_assign_module("v12"); + + /* set the bfrops module to match this peer */ + nptr->compat.bfrops = pmix_bfrops_base_assign_module(bfrops); if (NULL == nptr->compat.bfrops) { free(msg); info->proc_cnt--; @@ -552,16 +638,20 @@ static void connection_handler(int sd, short args, void *cbdata) /* send an error reply to the client */ goto error; } - /* we have no way of knowing their buffer type, so take our default */ - nptr->compat.type = pmix_bfrops_globals.default_type; + /* set the buffer type */ + nptr->compat.type = bftype; - /* take the highest priority gds module - in the absence of any info, - * we assume they can handle both dstore and hash */ - nptr->compat.gds = pmix_gds_base_assign_module(NULL, 0); + /* set the gds module to match this peer */ + if (NULL != gds) { + PMIX_INFO_LOAD(&ginfo, PMIX_GDS_MODULE, gds, PMIX_STRING); + nptr->compat.gds = pmix_gds_base_assign_module(&ginfo, 1); + PMIX_INFO_DESTRUCT(&ginfo); + } else { + nptr->compat.gds = pmix_gds_base_assign_module(NULL, 0); + } if (NULL == nptr->compat.gds) { free(msg); info->proc_cnt--; - PMIX_RELEASE(info); pmix_pointer_array_set_item(&pmix_server_globals.clients, psave->index, NULL); PMIX_RELEASE(psave); /* send an error reply to the client */ @@ -579,13 +669,16 @@ static void connection_handler(int sd, short args, void *cbdata) } else { len = strlen(cred); } + /* the macro will send the status result to the client */ PMIX_PSEC_VALIDATE_CONNECTION(rc, psave, PMIX_PROTOCOL_V1, cred, len); + /* now done with the msg */ + free(msg); + if (PMIX_SUCCESS != rc) { pmix_output_verbose(2, pmix_ptl_base_framework.framework_output, "validation of client credentials failed: %s", PMIx_Error_string(rc)); - free(msg); info->proc_cnt--; PMIX_RELEASE(info); pmix_pointer_array_set_item(&pmix_server_globals.clients, psave->index, NULL); @@ -595,7 +688,6 @@ static void connection_handler(int sd, short args, void *cbdata) PMIX_RELEASE(pnd); return; } - free(msg); /* send the client's array index */ if (PMIX_SUCCESS != (rc = pmix_ptl_base_send_blocking(pnd->sd, (char*)&psave->index, sizeof(int)))) { @@ -642,6 +734,9 @@ static void connection_handler(int sd, short args, void *cbdata) return; error: + if (NULL != cred) { + free(cred); + } /* send an error reply to the client */ if (PMIX_SUCCESS != pmix_ptl_base_send_blocking(pnd->sd, (char*)&rc, sizeof(int))) { PMIX_ERROR_LOG(rc); diff --git a/opal/mca/pmix/pmix2x/pmix/src/runtime/Makefile.include b/opal/mca/pmix/pmix2x/pmix/src/runtime/Makefile.include index 9c1c170dab3..3e4e3c0b056 100644 --- a/opal/mca/pmix/pmix2x/pmix/src/runtime/Makefile.include +++ b/opal/mca/pmix/pmix2x/pmix/src/runtime/Makefile.include @@ -12,7 +12,7 @@ # All rights reserved. # Copyright (c) 2012 Los Alamos National Security, LLC. # All rights reserved. -# Copyright (c) 2014-2016 Intel, Inc. All rights reserved +# Copyright (c) 2014-2017 Intel, Inc. All rights reserved. # Copyright (c) 2014 Cisco Systems, Inc. All rights reserved. # $COPYRIGHT$ # @@ -29,7 +29,7 @@ headers += \ runtime/pmix_rte.h \ runtime/pmix_progress_threads.h -libpmix_la_SOURCES += \ +sources += \ runtime/pmix_finalize.c \ runtime/pmix_init.c \ runtime/pmix_params.c \ diff --git a/opal/mca/pmix/pmix2x/pmix/src/server/pmix_server_get.c b/opal/mca/pmix/pmix2x/pmix/src/server/pmix_server_get.c index a09c3b80824..dfe741d3dfd 100644 --- a/opal/mca/pmix/pmix2x/pmix/src/server/pmix_server_get.c +++ b/opal/mca/pmix/pmix2x/pmix/src/server/pmix_server_get.c @@ -518,35 +518,22 @@ static pmix_status_t _satisfy_request(pmix_nspace_t *nptr, pmix_rank_t rank, *local = true; } if (PMIX_RANK_WILDCARD != rank) { + peer = NULL; /* see if the requested rank is local */ PMIX_LIST_FOREACH(iptr, &nptr->ranks, pmix_rank_info_t) { if (rank == iptr->pname.rank) { scope = PMIX_LOCAL; - break; - } - } - if (PMIX_LOCAL == scope) { - /* must have found a local rank - * we need the personality module for a client from this - * nspace, but it doesn't matter which one as they all - * must use the same GDS module. We don't know the GDS - * module, however, until _after_ the first local client - * connects to us. Since the nspace of the requestor may - * not match the nspace of the proc whose info is being - * requested, we cannot be sure this will have occurred. - * So we have to loop again to see if someone has connected */ - peer = NULL; - PMIX_LIST_FOREACH(iptr, &nptr->ranks, pmix_rank_info_t) { if (0 <= iptr->peerid) { peer = (pmix_peer_t*)pmix_pointer_array_get_item(&pmix_server_globals.clients, iptr->peerid); - break; } + if (NULL == peer) { + /* this rank has not connected yet, so this request needs to be held */ + return PMIX_ERR_NOT_FOUND; + } + break; } - if (NULL == peer) { - /* nobody has connected yet, so this request needs to be held */ - return PMIX_ERR_NOT_FOUND; - } - } else { + } + if (PMIX_LOCAL != scope) { /* this must be a remote rank */ if (local) { *local = false; @@ -623,6 +610,9 @@ static pmix_status_t _satisfy_request(pmix_nspace_t *nptr, pmix_rank_t rank, /* retrieve the data for the specific rank they are asking about */ if (PMIX_RANK_WILDCARD != rank) { + if (!peer->commit_cnt) { + return PMIX_ERR_NOT_FOUND; + } proc.rank = rank; PMIX_CONSTRUCT(&cb, pmix_cb_t); /* this is a local request, so give the gds the option diff --git a/opal/mca/pmix/pmix2x/pmix/src/server/pmix_server_ops.c b/opal/mca/pmix/pmix2x/pmix/src/server/pmix_server_ops.c index beaed4e6467..29fb193e603 100644 --- a/opal/mca/pmix/pmix2x/pmix/src/server/pmix_server_ops.c +++ b/opal/mca/pmix/pmix2x/pmix/src/server/pmix_server_ops.c @@ -226,6 +226,9 @@ pmix_status_t pmix_server_commit(pmix_peer_t *peer, pmix_buffer_t *buf) /* mark us as having successfully received a blob from this proc */ info->modex_recvd = true; + /* update the commit counter */ + peer->commit_cnt++; + /* see if anyone remote is waiting on this data - could be more than one */ PMIX_LIST_FOREACH_SAFE(dcd, dcdnext, &pmix_server_globals.remote_pnd, pmix_dmdx_remote_t) { if (0 != strncmp(dcd->cd->proc.nspace, nptr->nspace, PMIX_MAX_NSLEN)) { @@ -248,7 +251,7 @@ pmix_status_t pmix_server_commit(pmix_peer_t *peer, pmix_buffer_t *buf) PMIX_LIST_FOREACH(kp, &cb.kvs, pmix_kval_t) { /* we pack this in our native BFROPS form as it * will be sent to another daemon */ - PMIX_BFROPS_PACK(rc, pmix_globals.mypeer, &pbkt, &kp, 1, PMIX_KVAL); + PMIX_BFROPS_PACK(rc, pmix_globals.mypeer, &pbkt, kp, 1, PMIX_KVAL); } PMIX_UNLOAD_BUFFER(&pbkt, data, sz); } @@ -264,7 +267,11 @@ pmix_status_t pmix_server_commit(pmix_peer_t *peer, pmix_buffer_t *buf) } } /* see if anyone local is waiting on this data- could be more than one */ - return pmix_pending_resolve(nptr, info->pname.rank, PMIX_SUCCESS, NULL); + rc = pmix_pending_resolve(nptr, info->pname.rank, PMIX_SUCCESS, NULL); + if (PMIX_SUCCESS != rc) { + PMIX_ERROR_LOG(rc); + } + return rc; } /* get an existing object for tracking LOCAL participation in a collective diff --git a/opal/mca/pmix/pmix2x/pmix/src/threads/Makefile.include b/opal/mca/pmix/pmix2x/pmix/src/threads/Makefile.include index d0d41f1c577..8e1562dd658 100644 --- a/opal/mca/pmix/pmix2x/pmix/src/threads/Makefile.include +++ b/opal/mca/pmix/pmix2x/pmix/src/threads/Makefile.include @@ -32,7 +32,7 @@ headers += \ threads/wait_sync.h \ threads/thread_usage.h -libpmix_la_SOURCES += \ +sources += \ threads/mutex.c \ threads/thread.c \ threads/wait_sync.c diff --git a/opal/mca/pmix/pmix2x/pmix/test/Makefile.am b/opal/mca/pmix/pmix2x/pmix/test/Makefile.am index f96895a9de5..9140989a4e9 100644 --- a/opal/mca/pmix/pmix2x/pmix/test/Makefile.am +++ b/opal/mca/pmix/pmix2x/pmix/test/Makefile.am @@ -51,13 +51,13 @@ pmi_client_SOURCES = $(headers) \ pmi_client.c pmi_client_LDFLAGS = $(PMIX_PKG_CONFIG_LDFLAGS) pmi_client_LDADD = \ - $(top_builddir)/src/libpmix.la + $(top_builddir)/src/libpmi.la pmi2_client_SOURCES = $(headers) \ pmi2_client.c pmi2_client_LDFLAGS = $(PMIX_PKG_CONFIG_LDFLAGS) pmi2_client_LDADD = \ - $(top_builddir)/src/libpmix.la + $(top_builddir)/src/libpmi2.la endif pmix_client_SOURCES = $(headers) \ diff --git a/opal/mca/pmix/pmix2x/pmix/test/pmi2_client.c b/opal/mca/pmix/pmix2x/pmix/test/pmi2_client.c index a7a944e5573..e82c9408aae 100644 --- a/opal/mca/pmix/pmix2x/pmix/test/pmi2_client.c +++ b/opal/mca/pmix/pmix2x/pmix/test/pmi2_client.c @@ -27,17 +27,17 @@ static int _verbose = 1; static void log_fatal(const char *format, ...) { va_list arglist; - char **output = NULL; + char *output = NULL; va_start(arglist, format); if (_verbose > 0) { - if (0 > vasprintf(output, format, arglist) || - NULL == output || NULL == *output) { + if (0 > vasprintf(&output, format, arglist) || + NULL == output) { va_end(arglist); return; } - fprintf(stderr, "FATAL: %s", *output); - free(*output); + fprintf(stderr, "FATAL: %s", output); + free(output); } va_end(arglist); } @@ -45,17 +45,17 @@ static void log_fatal(const char *format, ...) static void log_error(const char *format, ...) { va_list arglist; - char **output = NULL; + char *output = NULL; va_start(arglist, format); if (_verbose > 0) { - if (0 > vasprintf(output, format, arglist) || - NULL == output || NULL == *output) { + if (0 > vasprintf(&output, format, arglist) || + NULL == output) { va_end(arglist); return; } - fprintf(stderr, "ERROR: %s", *output); - free(*output); + fprintf(stderr, "ERROR: %s", output); + free(output); } va_end(arglist); } @@ -63,17 +63,17 @@ static void log_error(const char *format, ...) static void log_info(const char *format, ...) { va_list arglist; - char **output = NULL; + char *output = NULL; va_start(arglist, format); if (_verbose > 0) { - if (0 > vasprintf(output, format, arglist) || - NULL == output || NULL == *output) { + if (0 > vasprintf(&output, format, arglist) || + NULL == output) { va_end(arglist); return; } - fprintf(stderr, "INFO: %s", *output); - free(*output); + fprintf(stderr, "INFO: %s", output); + free(output); } va_end(arglist); } diff --git a/opal/mca/pmix/pmix2x/pmix/test/pmi_client.c b/opal/mca/pmix/pmix2x/pmix/test/pmi_client.c index cfc9d9d6b8b..721ade50bd2 100644 --- a/opal/mca/pmix/pmix2x/pmix/test/pmi_client.c +++ b/opal/mca/pmix/pmix2x/pmix/test/pmi_client.c @@ -27,17 +27,17 @@ static int _verbose = 1; static void log_fatal(const char *format, ...) { va_list arglist; - char **output = NULL; + char *output = NULL; va_start(arglist, format); if (_verbose > 0) { - if (0 > vasprintf(output, format, arglist) || - NULL == output || NULL == *output) { + if (0 > vasprintf(&output, format, arglist) || + NULL == output) { va_end(arglist); return; } - fprintf(stderr, "FATAL: %s", *output); - free(*output); + fprintf(stderr, "FATAL: %s", output); + free(output); } va_end(arglist); } @@ -45,17 +45,17 @@ static void log_fatal(const char *format, ...) static void log_error(const char *format, ...) { va_list arglist; - char **output = NULL; + char *output = NULL; va_start(arglist, format); if (_verbose > 0) { - if (0 > vasprintf(output, format, arglist) || - NULL == output || NULL == *output) { + if (0 > vasprintf(&output, format, arglist) || + NULL == output) { va_end(arglist); return; } - fprintf(stderr, "ERROR: %s", *output); - free(*output); + fprintf(stderr, "ERROR: %s", output); + free(output); } va_end(arglist); } @@ -63,17 +63,17 @@ static void log_error(const char *format, ...) static void log_info(const char *format, ...) { va_list arglist; - char **output = NULL; + char *output = NULL; va_start(arglist, format); if (_verbose > 0) { - if (0 > vasprintf(output, format, arglist) || - NULL == output || NULL == *output) { + if (0 > vasprintf(&output, format, arglist) || + NULL == output) { va_end(arglist); return; } - fprintf(stderr, "INFO: %s", *output); - free(*output); + fprintf(stderr, "INFO: %s", output); + free(output); } va_end(arglist); } From 41b17013839342b6c058e64cf89454b4d22c9075 Mon Sep 17 00:00:00 2001 From: Ralph Castain Date: Thu, 1 Feb 2018 18:48:43 -0800 Subject: [PATCH 2/3] Update to official PMIx v2.1.0 release Signed-off-by: Ralph Castain --- opal/mca/pmix/pmix2x/pmix/NEWS | 36 +++- opal/mca/pmix/pmix2x/pmix/VERSION | 4 +- opal/mca/pmix/pmix2x/pmix/examples/client.c | 129 ++++++++++----- .../pmix/pmix2x/pmix/include/pmix_common.h.in | 31 +++- .../pmix/pmix2x/pmix/include/pmix_rename.h.in | 2 +- .../pmix/pmix2x/pmix/src/client/pmix_client.c | 11 +- .../pmix2x/pmix/src/client/pmix_client_ops.h | 4 +- .../pmix/pmix2x/pmix/src/common/pmix_data.c | 156 +++++++++++++++--- .../pmix2x/pmix/src/include/pmix_globals.c | 3 +- .../pmix2x/pmix/src/include/pmix_globals.h | 5 +- .../pmix/src/mca/base/pmix_mca_base_open.c | 2 +- .../pmix2x/pmix/src/mca/gds/hash/gds_hash.c | 46 +++--- .../pmix/src/mca/preg/native/preg_native.c | 6 +- .../pmix/pmix2x/pmix/src/mca/ptl/base/base.h | 3 +- .../pmix/src/mca/ptl/base/ptl_base_frame.c | 13 +- .../pmix/src/mca/ptl/base/ptl_base_sendrecv.c | 9 +- .../pmix/src/mca/ptl/tcp/ptl_tcp_component.c | 25 ++- .../pmix2x/pmix/src/mca/ptl/usock/ptl_usock.c | 9 +- .../src/mca/ptl/usock/ptl_usock_component.c | 11 +- .../pmix/src/runtime/help-pmix-runtime.txt | 12 +- .../mca/pmix/pmix2x/pmix/src/tool/pmix_tool.c | 11 +- opal/mca/pmix/pmix2x/pmix/src/util/output.c | 2 +- 22 files changed, 421 insertions(+), 109 deletions(-) mode change 100755 => 100644 opal/mca/pmix/pmix2x/pmix/include/pmix_rename.h.in diff --git a/opal/mca/pmix/pmix2x/pmix/NEWS b/opal/mca/pmix/pmix2x/pmix/NEWS index 2e793f9c697..70392cf787b 100644 --- a/opal/mca/pmix/pmix2x/pmix/NEWS +++ b/opal/mca/pmix/pmix2x/pmix/NEWS @@ -1,4 +1,4 @@ -Copyright (c) 2015-2017 Intel, Inc. All rights reserved. +Copyright (c) 2015-2018 Intel, Inc. All rights reserved. Copyright (c) 2017 IBM Corporation. All rights reserved. $COPYRIGHT$ @@ -21,7 +21,7 @@ example, a bug might be fixed in the master, and then moved to the current release as well as the "stable" bug fix release branch. -2.1.0 -- 26 Oct 2017 +2.1.0 -- 1 Feb 2018 ---------------------- **** NOTE: This release contains the first implementation of cross-version **** support. Servers using v2.1.0 are capable of supporting clients using @@ -32,6 +32,30 @@ current release as well as the "stable" bug fix release branch. - Enable support for remote tool connections (PR #540, #542) - Cleanup libevent configure logi to support default install paths (PR #541) - Debounce "unreachable" notifications for tools when they disconnect (PR #544) +- Enable the regex generator to support node names that include multiple + sets of numbers + + +2.0.3 -- 1 Feb 2018 +---------------------- +- Fix event notification so all sides of multi-library get notified + of other library's existence +- Update syslog protection to support Mac High Sierra OS +- Remove usock component - unable to support v1.x clients due + to datatype differences +- Cleanup security handshake +- Cleanup separation of PMI-1/2 libraries and PMIx symbols +- Protect against overly-large messages +- Update data buffer APIs to support cross-version operations +- Protect receive callbacks from NULL and/or empty buffers as this + can occur when the peer on a connection disappears. +- Fix tool connection search so it properly descends into the directory + tree while searching for the server's contact file. +- Fix store_local so it doesn't reject a new nspace as that can happen + when working with tools +- Ensure we always complete PMIx_Finalize - don't return if something + goes wrong in the middle of the procedure +- Fix several tool connection issues 2.0.2 -- 19 Oct 2017 @@ -115,6 +139,14 @@ current release as well as the "stable" bug fix release branch. and to themselves +1.2.5 -- 1 Feb 2018 +---------------------- +- Fix cross-version issue when v1.2 client interacts with v2.1 server (PR #564) +- Update client connection for cross-version support (PR #591) +- Fix write memory barrier ASM for PowerPC (PR #606) +- Add protection from overly-large messages + + 1.2.4 -- 13 Oct. 2017 ---------------------- - Silence some unnecessary warning messages (PR #487) diff --git a/opal/mca/pmix/pmix2x/pmix/VERSION b/opal/mca/pmix/pmix2x/pmix/VERSION index b280469dc98..0d2520e2ec9 100644 --- a/opal/mca/pmix/pmix2x/pmix/VERSION +++ b/opal/mca/pmix/pmix2x/pmix/VERSION @@ -30,7 +30,7 @@ greek= # command, or with the date (if "git describe" fails) in the form of # "date". -repo_rev=git9212bbc +repo_rev=git79b2db3 # If tarball_version is not empty, it is used as the version string in # the tarball filename, regardless of all other versions listed in @@ -44,7 +44,7 @@ tarball_version= # The date when this release was created -date="Jan 16, 2018" +date="Feb 01, 2018" # The shared library version of each of PMIx's public libraries. # These versions are maintained in accordance with the "Library diff --git a/opal/mca/pmix/pmix2x/pmix/examples/client.c b/opal/mca/pmix/pmix2x/pmix/examples/client.c index f411e8b5939..7e38608950c 100644 --- a/opal/mca/pmix/pmix2x/pmix/examples/client.c +++ b/opal/mca/pmix/pmix2x/pmix/examples/client.c @@ -13,7 +13,7 @@ * All rights reserved. * Copyright (c) 2009-2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2011 Oak Ridge National Labs. All rights reserved. - * Copyright (c) 2013-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2013-2018 Intel, Inc. All rights reserved. * Copyright (c) 2015 Mellanox Technologies, Inc. All rights reserved. * $COPYRIGHT$ * @@ -97,11 +97,11 @@ int main(int argc, char **argv) int rc; pmix_value_t value; pmix_value_t *val = &value; - char *tmp; + char *tmp, *ptr, *p; pmix_proc_t proc; - uint32_t nprocs, n; + uint32_t nprocs, m, n, local_cnt, *localpeers; pmix_info_t *info; - bool flag; + bool flag, local; volatile int active; pmix_status_t dbg = PMIX_ERR_DEBUGGER_RELEASE; @@ -196,7 +196,7 @@ int main(int argc, char **argv) value.type = PMIX_UINT64; value.data.uint64 = 1234; if (PMIX_SUCCESS != (rc = PMIx_Put(PMIX_LOCAL, tmp, &value))) { - fprintf(stderr, "Client ns %s rank %d: PMIx_Put internal failed: %d\n", myproc.nspace, myproc.rank, rc); + fprintf(stderr, "Client ns %s rank %d: PMIx_Put local failed: %d\n", myproc.nspace, myproc.rank, rc); goto done; } free(tmp); @@ -207,7 +207,7 @@ int main(int argc, char **argv) value.type = PMIX_STRING; value.data.string = "1234"; if (PMIX_SUCCESS != (rc = PMIx_Put(PMIX_REMOTE, tmp, &value))) { - fprintf(stderr, "Client ns %s rank %d: PMIx_Put internal failed: %d\n", myproc.nspace, myproc.rank, rc); + fprintf(stderr, "Client ns %s rank %d: PMIx_Put remote failed: %d\n", myproc.nspace, myproc.rank, rc); goto done; } free(tmp); @@ -230,53 +230,96 @@ int main(int argc, char **argv) } PMIX_INFO_FREE(info, 1); + /* get the number of local peers */ + if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, PMIX_LOCAL_SIZE, NULL, 0, &val))) { + fprintf(stderr, "Client ns %s rank %d: PMIx_Get PMIX_LOCAL_SIZE failed: %d", myproc.nspace, myproc.rank, rc); + goto done; + } + local_cnt = val->data.uint32; + PMIX_VALUE_RELEASE(val); + + /* create an array for the peers */ + localpeers = (uint32_t*)malloc(local_cnt * sizeof(int)); + + /* get the list of local peers */ + if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, PMIX_LOCAL_PEERS, NULL, 0, &val))) { + fprintf(stderr, "Client ns %s rank %d: PMIx_Get PMIX_LOCAL_PEERS failed: %d", myproc.nspace, myproc.rank, rc); + goto done; + } + ptr = strdup(val->data.string); + PMIX_VALUE_RELEASE(val); + + /* populate the peers array */ + p = strtok(ptr, ","); + localpeers[0] = strtoul(p, NULL, 10); + for (n=1; n < local_cnt; n++) { + p = strtok(NULL, ","); + localpeers[n] = strtoul(p, NULL, 10); + } + free(ptr); + /* check the returned data */ for (n=0; n < nprocs; n++) { - if (0 > asprintf(&tmp, "%s-%d-local", myproc.nspace, myproc.rank)) { - exit(1); + if (n == myproc.rank) { + continue; } - if (PMIX_SUCCESS != (rc = PMIx_Get(&myproc, tmp, NULL, 0, &val))) { - fprintf(stderr, "Client ns %s rank %d: PMIx_Get %s failed: %d\n", myproc.nspace, myproc.rank, tmp, rc); - goto done; - } - if (PMIX_UINT64 != val->type) { - fprintf(stderr, "Client ns %s rank %d: PMIx_Get %s returned wrong type: %d\n", myproc.nspace, myproc.rank, tmp, val->type); - PMIX_VALUE_RELEASE(val); - free(tmp); - goto done; + proc.rank = n; + local = false; + for (m=0; m < local_cnt; m++) { + if (localpeers[m] == proc.rank) { + local = true; + break; + } } - if (1234 != val->data.uint64) { - fprintf(stderr, "Client ns %s rank %d: PMIx_Get %s returned wrong value: %d\n", myproc.nspace, myproc.rank, tmp, (int)val->data.uint64); + if (local) { + if (0 > asprintf(&tmp, "%s-%d-local", proc.nspace, proc.rank)) { + exit(1); + } + if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, tmp, NULL, 0, &val))) { + fprintf(stderr, "Client ns %s rank %d: PMIx_Get %s failed: %d\n", myproc.nspace, myproc.rank, tmp, rc); + goto done; + } + if (PMIX_UINT64 != val->type) { + fprintf(stderr, "Client ns %s rank %d: PMIx_Get %s returned wrong type: %d\n", myproc.nspace, myproc.rank, tmp, val->type); + PMIX_VALUE_RELEASE(val); + free(tmp); + goto done; + } + if (1234 != val->data.uint64) { + fprintf(stderr, "Client ns %s rank %d: PMIx_Get %s returned wrong value: %d\n", myproc.nspace, myproc.rank, tmp, (int)val->data.uint64); + PMIX_VALUE_RELEASE(val); + free(tmp); + goto done; + } + fprintf(stderr, "Client ns %s rank %d: PMIx_Get %s returned correct\n", myproc.nspace, myproc.rank, tmp); PMIX_VALUE_RELEASE(val); free(tmp); - goto done; - } - fprintf(stderr, "Client ns %s rank %d: PMIx_Get %s returned correct\n", myproc.nspace, myproc.rank, tmp); - PMIX_VALUE_RELEASE(val); - free(tmp); - if (0 > asprintf(&tmp, "%s-%d-remote", myproc.nspace, myproc.rank)) { - exit(1); - } - if (PMIX_SUCCESS != (rc = PMIx_Get(&myproc, tmp, NULL, 0, &val))) { - fprintf(stderr, "Client ns %s rank %d: PMIx_Get %s failed: %d\n", myproc.nspace, myproc.rank, tmp, rc); - goto done; - } - if (PMIX_STRING != val->type) { - fprintf(stderr, "Client ns %s rank %d: PMIx_Get %s returned wrong type: %d\n", myproc.nspace, myproc.rank, tmp, val->type); - PMIX_VALUE_RELEASE(val); - free(tmp); - goto done; - } - if (0 != strcmp(val->data.string, "1234")) { - fprintf(stderr, "Client ns %s rank %d: PMIx_Get %s returned wrong value: %s\n", myproc.nspace, myproc.rank, tmp, val->data.string); + } else { + if (0 > asprintf(&tmp, "%s-%d-remote", proc.nspace, proc.rank)) { + exit(1); + } + if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, tmp, NULL, 0, &val))) { + fprintf(stderr, "Client ns %s rank %d: PMIx_Get %s failed: %d\n", myproc.nspace, myproc.rank, tmp, rc); + goto done; + } + if (PMIX_STRING != val->type) { + fprintf(stderr, "Client ns %s rank %d: PMIx_Get %s returned wrong type: %d\n", myproc.nspace, myproc.rank, tmp, val->type); + PMIX_VALUE_RELEASE(val); + free(tmp); + goto done; + } + if (0 != strcmp(val->data.string, "1234")) { + fprintf(stderr, "Client ns %s rank %d: PMIx_Get %s returned wrong value: %s\n", myproc.nspace, myproc.rank, tmp, val->data.string); + PMIX_VALUE_RELEASE(val); + free(tmp); + goto done; + } + fprintf(stderr, "Client ns %s rank %d: PMIx_Get %s returned correct\n", myproc.nspace, myproc.rank, tmp); PMIX_VALUE_RELEASE(val); free(tmp); - goto done; } - fprintf(stderr, "Client ns %s rank %d: PMIx_Get %s returned correct\n", myproc.nspace, myproc.rank, tmp); - PMIX_VALUE_RELEASE(val); - free(tmp); } + free(localpeers); done: /* finalize us */ diff --git a/opal/mca/pmix/pmix2x/pmix/include/pmix_common.h.in b/opal/mca/pmix/pmix2x/pmix/include/pmix_common.h.in index adbeb672d33..77aa987370a 100644 --- a/opal/mca/pmix/pmix2x/pmix/include/pmix_common.h.in +++ b/opal/mca/pmix/pmix2x/pmix/include/pmix_common.h.in @@ -1,6 +1,6 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* - * Copyright (c) 2013-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2013-2018 Intel, Inc. All rights reserved. * Copyright (c) 2016-2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2016 IBM Corporation. All rights reserved. @@ -1675,7 +1675,6 @@ PMIX_EXPORT const char* PMIx_Get_version(void); PMIX_EXPORT pmix_status_t PMIx_Store_internal(const pmix_proc_t *proc, const char *key, pmix_value_t *val); - /** * Top-level interface function to pack one or more values into a * buffer. @@ -1694,6 +1693,17 @@ PMIX_EXPORT pmix_status_t PMIx_Store_internal(const pmix_proc_t *proc, * will return an error code (generated upon unpacking) - * the error cannot be detected during packing. * + * The identity of the intended recipient of the packed buffer (i.e., the + * process that will be unpacking it) is used solely to resolve any data type + * differences between PMIx versions. The recipient must, therefore, be + * known to the user prior to calling the pack function so that the + * PMIx library is aware of the version the recipient is using. + * + * @param *target Pointer to a pmix_proc_t structure containing the + * nspace/rank of the process that will be unpacking the final buffer. + * A NULL value may be used to indicate that the target is based on + * the same PMIx version as the caller. + * * @param *buffer A pointer to the buffer into which the value is to * be packed. * @@ -1727,7 +1737,8 @@ PMIX_EXPORT pmix_status_t PMIx_Store_internal(const pmix_proc_t *proc, * status_code = PMIx_Data_pack(buffer, &src, 1, PMIX_INT32); * @endcode */ -PMIX_EXPORT pmix_status_t PMIx_Data_pack(pmix_data_buffer_t *buffer, +PMIX_EXPORT pmix_status_t PMIx_Data_pack(const pmix_proc_t *target, + pmix_data_buffer_t *buffer, void *src, int32_t num_vals, pmix_data_type_t type); @@ -1774,6 +1785,17 @@ PMIX_EXPORT pmix_status_t PMIx_Data_pack(pmix_data_buffer_t *buffer, * will return an error code generated upon unpacking - these errors * cannot be detected during packing. * + * The identity of the source of the packed buffer (i.e., the + * process that packed it) is used solely to resolve any data type + * differences between PMIx versions. The source must, therefore, be + * known to the user prior to calling the unpack function so that the + * PMIx library is aware of the version the source used. + * + * @param *source Pointer to a pmix_proc_t structure containing the + * nspace/rank of the process that packed the provided buffer. + * A NULL value may be used to indicate that the source is based on + * the same PMIx version as the caller. + * * @param *buffer A pointer to the buffer from which the value will be * extracted. * @@ -1823,7 +1845,8 @@ PMIX_EXPORT pmix_status_t PMIx_Data_pack(pmix_data_buffer_t *buffer, * * @endcode */ -PMIX_EXPORT pmix_status_t PMIx_Data_unpack(pmix_data_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t PMIx_Data_unpack(const pmix_proc_t *source, + pmix_data_buffer_t *buffer, void *dest, int32_t *max_num_values, pmix_data_type_t type); diff --git a/opal/mca/pmix/pmix2x/pmix/include/pmix_rename.h.in b/opal/mca/pmix/pmix2x/pmix/include/pmix_rename.h.in old mode 100755 new mode 100644 index f58edd298cf..3f52f02d1af --- a/opal/mca/pmix/pmix2x/pmix/include/pmix_rename.h.in +++ b/opal/mca/pmix/pmix2x/pmix/include/pmix_rename.h.in @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Intel, Inc. All rights reserved + * Copyright (c) 2016-2018 Intel, Inc. All rights reserved. * Copyright (c) 2016 Research Organization for Information Science * and Technology (RIST). All rights reserved. * $COPYRIGHT$ diff --git a/opal/mca/pmix/pmix2x/pmix/src/client/pmix_client.c b/opal/mca/pmix/pmix2x/pmix/src/client/pmix_client.c index 50673eb0b23..a61c0594eb3 100644 --- a/opal/mca/pmix/pmix2x/pmix/src/client/pmix_client.c +++ b/opal/mca/pmix/pmix2x/pmix/src/client/pmix_client.c @@ -1,6 +1,6 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* - * Copyright (c) 2014-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. * Copyright (c) 2014-2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2014 Artem Y. Polyakov . @@ -397,6 +397,8 @@ PMIX_EXPORT pmix_status_t PMIx_Init(pmix_proc_t *proc, /* setup the globals */ PMIX_CONSTRUCT(&pmix_client_globals.pending_requests, pmix_list_t); + PMIX_CONSTRUCT(&pmix_client_globals.peers, pmix_pointer_array_t); + pmix_pointer_array_init(&pmix_client_globals.peers, 1, INT_MAX, 1); pmix_client_globals.myserver = PMIX_NEW(pmix_peer_t); if (NULL == pmix_client_globals.myserver) { PMIX_RELEASE_THREAD(&pmix_global_lock); @@ -649,6 +651,8 @@ PMIX_EXPORT pmix_status_t PMIx_Finalize(const pmix_info_t info[], size_t ninfo) size_t n; pmix_client_timeout_t tev; struct timeval tv = {2, 0}; + pmix_peer_t *peer; + int i; PMIX_ACQUIRE_THREAD(&pmix_global_lock); if (1 != pmix_globals.init_cntr) { @@ -737,6 +741,11 @@ PMIX_EXPORT pmix_status_t PMIx_Finalize(const pmix_info_t info[], size_t ninfo) } PMIX_LIST_DESTRUCT(&pmix_client_globals.pending_requests); + for (i=0; i < pmix_client_globals.peers.size; i++) { + if (NULL != (peer = (pmix_peer_t*)pmix_pointer_array_get_item(&pmix_client_globals.peers, i))) { + PMIX_RELEASE(peer); + } + } if (0 <= pmix_client_globals.myserver->sd) { CLOSE_THE_SOCKET(pmix_client_globals.myserver->sd); diff --git a/opal/mca/pmix/pmix2x/pmix/src/client/pmix_client_ops.h b/opal/mca/pmix/pmix2x/pmix/src/client/pmix_client_ops.h index 159d0a16036..4561b0a619a 100644 --- a/opal/mca/pmix/pmix2x/pmix/src/client/pmix_client_ops.h +++ b/opal/mca/pmix/pmix2x/pmix/src/client/pmix_client_ops.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2015-2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -15,6 +15,7 @@ #include "src/threads/threads.h" #include "src/class/pmix_list.h" +#include "src/class/pmix_pointer_array.h" #include "src/include/pmix_globals.h" BEGIN_C_DECLS @@ -22,6 +23,7 @@ BEGIN_C_DECLS typedef struct { pmix_peer_t *myserver; // messaging support to/from my server pmix_list_t pending_requests; // list of pmix_cb_t pending data requests + pmix_pointer_array_t peers; // array of pmix_peer_t cached for data ops } pmix_client_globals_t; PMIX_EXPORT extern pmix_client_globals_t pmix_client_globals; diff --git a/opal/mca/pmix/pmix2x/pmix/src/common/pmix_data.c b/opal/mca/pmix/pmix2x/pmix/src/common/pmix_data.c index 69263a556b4..f1e9c00cec5 100644 --- a/opal/mca/pmix/pmix2x/pmix/src/common/pmix_data.c +++ b/opal/mca/pmix/pmix2x/pmix/src/common/pmix_data.c @@ -11,7 +11,7 @@ * All rights reserved. * Copyright (c) 2007-2012 Los Alamos National Security, LLC. * All rights reserved. - * Copyright (c) 2014-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -31,24 +31,27 @@ #include #endif -#include +#include #include #include "src/mca/bfrops/bfrops.h" #include "src/include/pmix_globals.h" - -#define PMIX_EMBED_DATA_BUFFER(b, db) \ - do { \ - (b)->base_ptr = (db)->base_ptr; \ - (b)->pack_ptr = (db)->pack_ptr; \ - (b)->unpack_ptr = (db)->unpack_ptr; \ - (b)->bytes_allocated = (db)->bytes_allocated; \ - (b)->bytes_used = (db)->bytes_used; \ - (db)->base_ptr = NULL; \ - (db)->pack_ptr = NULL; \ - (db)->unpack_ptr = NULL; \ - (db)->bytes_allocated = 0; \ - (db)->bytes_used = 0; \ +#include "src/server/pmix_server_ops.h" +#include "src/client/pmix_client_ops.h" + +#define PMIX_EMBED_DATA_BUFFER(b, db) \ + do { \ + (b)->type = pmix_globals.mypeer->nptr->compat.type; \ + (b)->base_ptr = (db)->base_ptr; \ + (b)->pack_ptr = (db)->pack_ptr; \ + (b)->unpack_ptr = (db)->unpack_ptr; \ + (b)->bytes_allocated = (db)->bytes_allocated; \ + (b)->bytes_used = (db)->bytes_used; \ + (db)->base_ptr = NULL; \ + (db)->pack_ptr = NULL; \ + (db)->unpack_ptr = NULL; \ + (db)->bytes_allocated = 0; \ + (db)->bytes_used = 0; \ } while (0) #define PMIX_EXTRACT_DATA_BUFFER(b, db) \ @@ -65,12 +68,121 @@ (b)->bytes_used = 0; \ } while (0) -PMIX_EXPORT pmix_status_t PMIx_Data_pack(pmix_data_buffer_t *buffer, +static pmix_peer_t* find_peer(const pmix_proc_t *proc) +{ + pmix_status_t rc; + pmix_peer_t *peer; + pmix_proc_t wildcard; + pmix_value_t *value; + int i; + + if (NULL == proc) { + return pmix_globals.mypeer; + } + + if (PMIX_PROC_IS_SERVER(pmix_globals.mypeer)) { + /* see if we know this proc */ + for (i=0; i < pmix_server_globals.clients.size; i++) { + if (NULL != (peer = (pmix_peer_t*)pmix_pointer_array_get_item(&pmix_server_globals.clients, i))) { + continue; + } + if (0 == strncmp(proc->nspace, peer->nptr->nspace, PMIX_MAX_NSLEN)) { + return peer; + } + } + /* didn't find it, so try to get the library version of the target + * from the host - the result will be cached, so we will only have + * to retrieve it once */ + (void)strncpy(wildcard.nspace, proc->nspace, PMIX_MAX_NSLEN); + wildcard.rank = PMIX_RANK_WILDCARD; + if (PMIX_SUCCESS != (rc = PMIx_Get(&wildcard, PMIX_BFROPS_MODULE, NULL, 0, &value))) { + /* couldn't get it - nothing we can do */ + return NULL; + } + /* setup a peer for this nspace */ + peer = PMIX_NEW(pmix_peer_t); + if (NULL == peer) { + PMIX_RELEASE(value); + return NULL; + } + peer->nptr = PMIX_NEW(pmix_nspace_t); + if (NULL == peer->nptr) { + PMIX_RELEASE(peer); + PMIX_RELEASE(value); + return NULL; + } + peer->nptr->nspace = strdup(proc->nspace); + /* assign a module to it based on the returned version */ + peer->nptr->compat.bfrops = pmix_bfrops_base_assign_module(value->data.string); + PMIX_RELEASE(value); + if (NULL == peer->nptr->compat.bfrops) { + PMIX_RELEASE(peer); + return NULL; + } + /* cache the peer object */ + pmix_pointer_array_add(&pmix_server_globals.clients, peer); + return peer; + } + + // we are a client or tool + + /* If the target is for the server, then + * pack it using that peer. */ + if (0 == strncmp(proc->nspace, pmix_client_globals.myserver->info->pname.nspace, PMIX_MAX_NSLEN)) { + return pmix_client_globals.myserver; + } + + /* if the target is another member of my nspace, then + * they must be using the same version */ + if (0 == strncmp(proc->nspace, pmix_globals.myid.nspace, PMIX_MAX_NSLEN)) { + return pmix_globals.mypeer; + } + + /* try to get the library version of this peer - the result will be + * cached, so we will only have to retrieve it once */ + (void)strncpy(wildcard.nspace, proc->nspace, PMIX_MAX_NSLEN); + wildcard.rank = PMIX_RANK_WILDCARD; + if (PMIX_SUCCESS != (rc = PMIx_Get(&wildcard, PMIX_BFROPS_MODULE, NULL, 0, &value))) { + /* couldn't get it - nothing we can do */ + return NULL; + } + /* setup a peer for this nspace */ + peer = PMIX_NEW(pmix_peer_t); + if (NULL == peer) { + PMIX_RELEASE(value); + return NULL; + } + peer->nptr = PMIX_NEW(pmix_nspace_t); + if (NULL == peer->nptr) { + PMIX_RELEASE(peer); + PMIX_RELEASE(value); + return NULL; + } + peer->nptr->nspace = strdup(proc->nspace); + /* assign a module to it based on the returned version */ + peer->nptr->compat.bfrops = pmix_bfrops_base_assign_module(value->data.string); + PMIX_RELEASE(value); + if (NULL == peer->nptr->compat.bfrops) { + PMIX_RELEASE(peer); + return NULL; + } + /* need to cache the peer someplace so we can clean it + * up later */ + return peer; +} + +PMIX_EXPORT pmix_status_t PMIx_Data_pack(const pmix_proc_t *target, + pmix_data_buffer_t *buffer, void *src, int32_t num_vals, pmix_data_type_t type) { pmix_status_t rc; pmix_buffer_t buf; + pmix_peer_t *peer; + + if (NULL == (peer = find_peer(target))) { + return PMIX_ERR_NOT_SUPPORTED; + } /* setup the host */ PMIX_CONSTRUCT(&buf, pmix_buffer_t); @@ -79,7 +191,7 @@ PMIX_EXPORT pmix_status_t PMIx_Data_pack(pmix_data_buffer_t *buffer, PMIX_EMBED_DATA_BUFFER(&buf, buffer); /* pack the value */ - PMIX_BFROPS_PACK(rc, pmix_globals.mypeer, + PMIX_BFROPS_PACK(rc, peer, &buf, src, num_vals, type); /* extract the data buffer - the pointers may have changed */ @@ -90,12 +202,18 @@ PMIX_EXPORT pmix_status_t PMIx_Data_pack(pmix_data_buffer_t *buffer, } -PMIX_EXPORT pmix_status_t PMIx_Data_unpack(pmix_data_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t PMIx_Data_unpack(const pmix_proc_t *source, + pmix_data_buffer_t *buffer, void *dest, int32_t *max_num_values, pmix_data_type_t type) { pmix_status_t rc; pmix_buffer_t buf; + pmix_peer_t *peer; + + if (NULL == (peer = find_peer(source))) { + return PMIX_ERR_NOT_SUPPORTED; + } /* setup the host */ PMIX_CONSTRUCT(&buf, pmix_buffer_t); @@ -104,7 +222,7 @@ PMIX_EXPORT pmix_status_t PMIx_Data_unpack(pmix_data_buffer_t *buffer, void *des PMIX_EMBED_DATA_BUFFER(&buf, buffer); /* unpack the value */ - PMIX_BFROPS_UNPACK(rc, pmix_globals.mypeer, + PMIX_BFROPS_UNPACK(rc, peer, &buf, dest, max_num_values, type); /* extract the data buffer - the pointers may have changed */ diff --git a/opal/mca/pmix/pmix2x/pmix/src/include/pmix_globals.c b/opal/mca/pmix/pmix2x/pmix/src/include/pmix_globals.c index 4d2fa8aea0b..34c8635d9dd 100644 --- a/opal/mca/pmix/pmix2x/pmix/src/include/pmix_globals.c +++ b/opal/mca/pmix/pmix2x/pmix/src/include/pmix_globals.c @@ -1,6 +1,6 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* - * Copyright (c) 2014-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. * Copyright (c) 2014-2017 Research Organization for Information Science * Copyright (c) 2014-2017 Intel, Inc. All rights reserved. * and Technology (RIST). All rights reserved. @@ -57,6 +57,7 @@ static void nscon(pmix_nspace_t *p) p->nspace = NULL; p->nlocalprocs = 0; p->all_registered = false; + p->version_stored = false; p->jobbkt = NULL; p->ndelivered = 0; PMIX_CONSTRUCT(&p->ranks, pmix_list_t); diff --git a/opal/mca/pmix/pmix2x/pmix/src/include/pmix_globals.h b/opal/mca/pmix/pmix2x/pmix/src/include/pmix_globals.h index 54e19d5ad8a..2541b7d3de6 100644 --- a/opal/mca/pmix/pmix2x/pmix/src/include/pmix_globals.h +++ b/opal/mca/pmix/pmix2x/pmix/src/include/pmix_globals.h @@ -10,7 +10,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. - * Copyright (c) 2014-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -50,6 +50,8 @@ BEGIN_C_DECLS #define PMIX_MAX_CRED_SIZE 131072 // set max at 128kbytes #define PMIX_MAX_ERR_CONSTANT INT_MIN +/* internal-only attributes */ +#define PMIX_BFROPS_MODULE "pmix.bfrops.mod" // (char*) name of bfrops plugin in-use by a given nspace /* define an internal-only process name that has * a dynamically-sized nspace field to save memory */ @@ -125,6 +127,7 @@ typedef struct { char *nspace; size_t nlocalprocs; bool all_registered; // all local ranks have been defined + bool version_stored; // the version string used by this nspace has been stored pmix_buffer_t *jobbkt; // packed version of jobinfo size_t ndelivered; // count of #local clients that have received the jobinfo pmix_list_t ranks; // list of pmix_rank_info_t for connection support of my clients diff --git a/opal/mca/pmix/pmix2x/pmix/src/mca/base/pmix_mca_base_open.c b/opal/mca/pmix/pmix2x/pmix/src/mca/base/pmix_mca_base_open.c index f55d7f37351..77c9fdf1842 100644 --- a/opal/mca/pmix/pmix2x/pmix/src/mca/base/pmix_mca_base_open.c +++ b/opal/mca/pmix/pmix2x/pmix/src/mca/base/pmix_mca_base_open.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2008 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, diff --git a/opal/mca/pmix/pmix2x/pmix/src/mca/gds/hash/gds_hash.c b/opal/mca/pmix/pmix2x/pmix/src/mca/gds/hash/gds_hash.c index e6041aceafd..95bcec0a089 100644 --- a/opal/mca/pmix/pmix2x/pmix/src/mca/gds/hash/gds_hash.c +++ b/opal/mca/pmix/pmix2x/pmix/src/mca/gds/hash/gds_hash.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2015-2018 Intel, Inc. All rights reserved. * Copyright (c) 2016 IBM Corporation. All rights reserved. * * $COPYRIGHT$ @@ -112,6 +112,7 @@ typedef struct { pmix_hash_table_t internal; pmix_hash_table_t remote; pmix_hash_table_t local; + bool gdata_added; } pmix_hash_trkr_t; static void htcon(pmix_hash_trkr_t *p) @@ -124,6 +125,7 @@ static void htcon(pmix_hash_trkr_t *p) pmix_hash_table_init(&p->remote, 256); PMIX_CONSTRUCT(&p->local, pmix_hash_table_t); pmix_hash_table_init(&p->local, 256); + p->gdata_added = false; } static void htdes(pmix_hash_trkr_t *p) { @@ -515,26 +517,29 @@ pmix_status_t hash_cache_job_info(struct pmix_nspace_t *ns, } /* now add any global data that was provided */ - PMIX_LIST_FOREACH(kvptr, &pmix_server_globals.gdata, pmix_kval_t) { - /* sadly, the data cannot simultaneously exist on two lists, - * so we must make a copy of it here */ - kp2 = PMIX_NEW(pmix_kval_t); - if (NULL == kp2) { - rc = PMIX_ERR_NOMEM; - goto release; - } - kp2->key = strdup(kvptr->key); - PMIX_VALUE_XFER(rc, kp2->value, kvptr->value); - if (PMIX_SUCCESS != rc) { - PMIX_ERROR_LOG(rc); - PMIX_RELEASE(kp2); - goto release; - } - if (PMIX_SUCCESS != (rc = pmix_hash_store(ht, PMIX_RANK_WILDCARD, kp2))) { - PMIX_ERROR_LOG(rc); - PMIX_RELEASE(kp2); - break; + if (!trk->gdata_added) { + PMIX_LIST_FOREACH(kvptr, &pmix_server_globals.gdata, pmix_kval_t) { + /* sadly, the data cannot simultaneously exist on two lists, + * so we must make a copy of it here */ + kp2 = PMIX_NEW(pmix_kval_t); + if (NULL == kp2) { + rc = PMIX_ERR_NOMEM; + goto release; + } + kp2->key = strdup(kvptr->key); + PMIX_VALUE_XFER(rc, kp2->value, kvptr->value); + if (PMIX_SUCCESS != rc) { + PMIX_ERROR_LOG(rc); + PMIX_RELEASE(kp2); + goto release; + } + if (PMIX_SUCCESS != (rc = pmix_hash_store(ht, PMIX_RANK_WILDCARD, kp2))) { + PMIX_ERROR_LOG(rc); + PMIX_RELEASE(kp2); + break; + } } + trk->gdata_added = true; } release: @@ -1153,7 +1158,6 @@ static pmix_status_t hash_store_modex(struct pmix_nspace_t *nspace, { pmix_nspace_t *ns = (pmix_nspace_t*)nspace; pmix_hash_trkr_t *trk, *t; - pmix_server_caddy_t *scd; pmix_status_t rc = PMIX_SUCCESS; int32_t cnt; pmix_buffer_t pbkt; diff --git a/opal/mca/pmix/pmix2x/pmix/src/mca/preg/native/preg_native.c b/opal/mca/pmix/pmix2x/pmix/src/mca/preg/native/preg_native.c index 12187b03c28..cc11453f5d8 100644 --- a/opal/mca/pmix/pmix2x/pmix/src/mca/preg/native/preg_native.c +++ b/opal/mca/pmix/pmix2x/pmix/src/mca/preg/native/preg_native.c @@ -1,6 +1,8 @@ /* * Copyright (c) 2015-2017 Intel, Inc. All rights reserved. * Copyright (c) 2016 IBM Corporation. All rights reserved. + * Copyright (c) 2018 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * * $COPYRIGHT$ * @@ -106,7 +108,6 @@ static pmix_status_t generate_node_regex(const char *input, len = strlen(vptr); startnum = -1; memset(prefix, 0, PMIX_MAX_NODE_PREFIX); - numdigits = 0; for (i=0, j=0; i < len; i++) { if (!isalpha(vptr[i])) { /* found a non-alpha char */ @@ -120,7 +121,6 @@ static pmix_status_t generate_node_regex(const char *input, /* count the size of the numeric field - but don't * add the digits to the prefix */ - numdigits++; if (startnum < 0) { /* okay, this defines end of the prefix */ startnum = i; @@ -147,8 +147,10 @@ static pmix_status_t generate_node_regex(const char *input, vnum = strtol(&vptr[startnum], &sfx, 10); if (NULL != sfx) { suffix = strdup(sfx); + numdigits = (int)(sfx - &vptr[startnum]); } else { suffix = NULL; + numdigits = (int)strlen(&vptr[startnum]); } /* is this value already on our list? */ found = false; diff --git a/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/base/base.h b/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/base/base.h index 80bac4e5c3b..97754b4cb1e 100644 --- a/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/base/base.h +++ b/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/base/base.h @@ -11,7 +11,7 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2012 Los Alamos National Security, Inc. All rights reserved. - * Copyright (c) 2014-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. * $COPYRIGHT$ @@ -79,6 +79,7 @@ struct pmix_ptl_globals_t { bool listen_thread_active; pmix_list_t listeners; uint32_t current_tag; + size_t max_msg_size; }; typedef struct pmix_ptl_globals_t pmix_ptl_globals_t; diff --git a/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/base/ptl_base_frame.c b/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/base/ptl_base_frame.c index 705c3f3f3d1..2f1fd4f6a07 100644 --- a/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/base/ptl_base_frame.c +++ b/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/base/ptl_base_frame.c @@ -11,7 +11,7 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2012-2013 Los Alamos National Security, Inc. All rights reserved. - * Copyright (c) 2014-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. * Copyright (c) 2015-2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. * $COPYRIGHT$ @@ -53,12 +53,23 @@ #include "src/mca/ptl/base/static-components.h" +#define PMIX_MAX_MSG_SIZE 16 + /* Instantiate the global vars */ pmix_ptl_globals_t pmix_ptl_globals = {{{0}}}; int pmix_ptl_base_output = -1; +static size_t max_msg_size = PMIX_MAX_MSG_SIZE; + static int pmix_ptl_register(pmix_mca_base_register_flag_t flags) { + pmix_mca_base_var_register("pmix", "ptl", "base", "max_msg_size", + "Max size (in Mbytes) of a client/server msg", + PMIX_MCA_BASE_VAR_TYPE_SIZE_T, NULL, 0, 0, + PMIX_INFO_LVL_2, + PMIX_MCA_BASE_VAR_SCOPE_READONLY, + &max_msg_size); + pmix_ptl_globals.max_msg_size = max_msg_size * 1024 * 1024; return PMIX_SUCCESS; } diff --git a/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/base/ptl_base_sendrecv.c b/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/base/ptl_base_sendrecv.c index 97149094c97..c953a4651ff 100644 --- a/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/base/ptl_base_sendrecv.c +++ b/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/base/ptl_base_sendrecv.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. * Copyright (c) 2014 Artem Y. Polyakov . * All rights reserved. * Copyright (c) 2015-2017 Research Organization for Information Science @@ -44,6 +44,7 @@ #include "src/client/pmix_client_ops.h" #include "src/server/pmix_server_ops.h" #include "src/util/error.h" +#include "src/util/show_help.h" #include "src/mca/ptl/base/base.h" @@ -458,6 +459,12 @@ void pmix_ptl_base_recv_handler(int sd, short flags, void *cbdata) pmix_output_verbose(2, pmix_ptl_base_framework.framework_output, "ptl:base:recv:handler allocate data region of size %lu", (unsigned long)peer->recv_msg->hdr.nbytes); + if (pmix_ptl_globals.max_msg_size < peer->recv_msg->hdr.nbytes) { + pmix_show_help("help-pmix-runtime.txt", "ptl:msg_size", true, + (unsigned long)peer->recv_msg->hdr.nbytes, + (unsigned long)pmix_ptl_globals.max_msg_size); + goto err_close; + } /* allocate the data region */ peer->recv_msg->data = (char*)malloc(peer->recv_msg->hdr.nbytes); memset(peer->recv_msg->data, 0, peer->recv_msg->hdr.nbytes); diff --git a/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/tcp/ptl_tcp_component.c b/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/tcp/ptl_tcp_component.c index 69ae60e55dd..c886341e40b 100644 --- a/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/tcp/ptl_tcp_component.c +++ b/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/tcp/ptl_tcp_component.c @@ -12,7 +12,7 @@ * All rights reserved. * Copyright (c) 2015 Los Alamos National Security, LLC. All rights * reserved. - * Copyright (c) 2016-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2016-2018 Intel, Inc. All rights reserved. * Copyright (c) 2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. * $COPYRIGHT$ @@ -1206,8 +1206,8 @@ static void connection_handler(int sd, short args, void *cbdata) } else { peer->nptr->compat.gds = pmix_gds_base_assign_module(NULL, 0); } - free(msg); // can now release the data buffer if (NULL == peer->nptr->compat.gds) { + free(msg); info->proc_cnt--; pmix_pointer_array_set_item(&pmix_server_globals.clients, peer->index, NULL); PMIX_RELEASE(peer); @@ -1215,6 +1215,17 @@ static void connection_handler(int sd, short args, void *cbdata) goto error; } + /* if we haven't previously stored the version for this + * nspace, do so now */ + if (!nptr->version_stored) { + PMIX_INFO_LOAD(&ginfo, PMIX_BFROPS_MODULE, peer->nptr->compat.bfrops->version, PMIX_STRING); + PMIX_GDS_CACHE_JOB_INFO(rc, pmix_globals.mypeer, peer->nptr, &ginfo, 1); + PMIX_INFO_DESTRUCT(&ginfo); + nptr->version_stored = true; + } + + free(msg); // can now release the data buffer + /* the choice of PTL module is obviously us */ peer->nptr->compat.ptl = &pmix_ptl_tcp_module; @@ -1430,6 +1441,7 @@ static void process_cbfunc(int sd, short args, void *cbdata) /* set the gds */ PMIX_INFO_LOAD(&ginfo, PMIX_GDS_MODULE, pnd->gds, PMIX_STRING); peer->nptr->compat.gds = pmix_gds_base_assign_module(&ginfo, 1); + PMIX_INFO_DESTRUCT(&ginfo); if (NULL == peer->nptr->compat.gds) { PMIX_RELEASE(peer); pmix_list_remove_item(&pmix_server_globals.nspaces, &nptr->super); @@ -1438,6 +1450,15 @@ static void process_cbfunc(int sd, short args, void *cbdata) goto done; } + /* if we haven't previously stored the version for this + * nspace, do so now */ + if (!peer->nptr->version_stored) { + PMIX_INFO_LOAD(&ginfo, PMIX_BFROPS_MODULE, peer->nptr->compat.bfrops->version, PMIX_STRING); + PMIX_GDS_CACHE_JOB_INFO(rc, pmix_globals.mypeer, peer->nptr, &ginfo, 1); + PMIX_INFO_DESTRUCT(&ginfo); + nptr->version_stored = true; + } + /* validate the connection */ PMIX_PSEC_VALIDATE_CONNECTION(rc, peer, PMIX_PROTOCOL_V2, diff --git a/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/usock/ptl_usock.c b/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/usock/ptl_usock.c index 443a4088db2..daf795cf054 100644 --- a/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/usock/ptl_usock.c +++ b/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/usock/ptl_usock.c @@ -13,7 +13,7 @@ * Copyright (c) 2011-2014 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2011-2013 Los Alamos National Security, LLC. All rights * reserved. - * Copyright (c) 2013-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2013-2018 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -49,6 +49,7 @@ #include "src/util/argv.h" #include "src/util/error.h" +#include "src/util/show_help.h" #include "src/client/pmix_client_ops.h" #include "src/include/pmix_globals.h" #include "src/include/pmix_socket_errno.h" @@ -751,6 +752,12 @@ void pmix_usock_recv_handler(int sd, short flags, void *cbdata) pmix_output_verbose(2, pmix_ptl_base_framework.framework_output, "usock:recv:handler allocate data region of size %lu", (unsigned long)peer->recv_msg->hdr.nbytes); + if (pmix_ptl_globals.max_msg_size < peer->recv_msg->hdr.nbytes) { + pmix_show_help("help-pmix-runtime.txt", "ptl:msg_size", true, + (unsigned long)peer->recv_msg->hdr.nbytes, + (unsigned long)pmix_ptl_globals.max_msg_size); + goto err_close; + } /* allocate the data region */ peer->recv_msg->data = (char*)malloc(peer->recv_msg->hdr.nbytes); memset(peer->recv_msg->data, 0, peer->recv_msg->hdr.nbytes); diff --git a/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/usock/ptl_usock_component.c b/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/usock/ptl_usock_component.c index a0040e1bf60..06b2b6e54ef 100644 --- a/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/usock/ptl_usock_component.c +++ b/opal/mca/pmix/pmix2x/pmix/src/mca/ptl/usock/ptl_usock_component.c @@ -12,7 +12,7 @@ * All rights reserved. * Copyright (c) 2015 Los Alamos National Security, LLC. All rights * reserved. - * Copyright (c) 2016-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2016-2018 Intel, Inc. All rights reserved. * Copyright (c) 2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. * $COPYRIGHT$ @@ -658,6 +658,15 @@ static void connection_handler(int sd, short args, void *cbdata) goto error; } + /* if we haven't previously stored the version for this + * nspace, do so now */ + if (!nptr->version_stored) { + PMIX_INFO_LOAD(&ginfo, PMIX_BFROPS_MODULE, nptr->compat.bfrops->version, PMIX_STRING); + PMIX_GDS_CACHE_JOB_INFO(rc, pmix_globals.mypeer, nptr, &ginfo, 1); + PMIX_INFO_DESTRUCT(&ginfo); + nptr->version_stored = true; + } + /* the choice of PTL module was obviously made by the connecting * tool as we received this request via that channel, so simply * record it here for future use */ diff --git a/opal/mca/pmix/pmix2x/pmix/src/runtime/help-pmix-runtime.txt b/opal/mca/pmix/pmix2x/pmix/src/runtime/help-pmix-runtime.txt index dcd9c1cd69c..8a8899d33f1 100644 --- a/opal/mca/pmix/pmix2x/pmix/src/runtime/help-pmix-runtime.txt +++ b/opal/mca/pmix/pmix2x/pmix/src/runtime/help-pmix-runtime.txt @@ -12,7 +12,7 @@ # All rights reserved. # Copyright (c) 2011 Oak Ridge National Labs. All rights reserved. # Copyright (c) 2014 Cisco Systems, Inc. All rights reserved. -# Copyright (c) 2017 Intel, Inc. All rights reserved. +# Copyright (c) 2017-2018 Intel, Inc. All rights reserved. # $COPYRIGHT$ # # Additional copyrights may follow @@ -58,3 +58,13 @@ by any of the following: that includes at least one usable plugin for this framework. Please check your installation and environment. +# +[ptl:message-too-large] +A message has been received that exceeds the size limit: + + Message size: %lu + Size limit: %lu + +The limit is enforced to protect against bad actors. If you believe that +the message was likely legitimate, then adjust the message size by +setting the ptl_base_max_msg_size MCA parameter. diff --git a/opal/mca/pmix/pmix2x/pmix/src/tool/pmix_tool.c b/opal/mca/pmix/pmix2x/pmix/src/tool/pmix_tool.c index ee43788ea54..31b1981871f 100644 --- a/opal/mca/pmix/pmix2x/pmix/src/tool/pmix_tool.c +++ b/opal/mca/pmix/pmix2x/pmix/src/tool/pmix_tool.c @@ -1,6 +1,6 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* - * Copyright (c) 2014-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. * Copyright (c) 2014-2016 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2014 Artem Y. Polyakov . @@ -239,6 +239,8 @@ PMIX_EXPORT int PMIx_tool_init(pmix_proc_t *proc, } PMIX_CONSTRUCT(&pmix_client_globals.pending_requests, pmix_list_t); + PMIX_CONSTRUCT(&pmix_client_globals.peers, pmix_pointer_array_t); + pmix_pointer_array_init(&pmix_client_globals.peers, 1, INT_MAX, 1); pmix_client_globals.myserver = PMIX_NEW(pmix_peer_t); pmix_client_globals.myserver->nptr = PMIX_NEW(pmix_nspace_t); @@ -684,6 +686,8 @@ PMIX_EXPORT pmix_status_t PMIx_tool_finalize(void) pmix_status_t rc; pmix_tool_timeout_t tev; struct timeval tv = {2, 0}; + int n; + pmix_peer_t *peer; PMIX_ACQUIRE_THREAD(&pmix_global_lock); if (1 != pmix_globals.init_cntr) { @@ -754,6 +758,11 @@ PMIX_EXPORT pmix_status_t PMIx_tool_finalize(void) PMIX_RELEASE(pmix_client_globals.myserver); PMIX_LIST_DESTRUCT(&pmix_client_globals.pending_requests); + for (n=0; n < pmix_client_globals.peers.size; n++) { + if (NULL != (peer = (pmix_peer_t*)pmix_pointer_array_get_item(&pmix_client_globals.peers, n))) { + PMIX_RELEASE(peer); + } + } /* shutdown services */ pmix_rte_finalize(); diff --git a/opal/mca/pmix/pmix2x/pmix/src/util/output.c b/opal/mca/pmix/pmix2x/pmix/src/util/output.c index a7f9cf463ad..1d3d4148dcd 100644 --- a/opal/mca/pmix/pmix2x/pmix/src/util/output.c +++ b/opal/mca/pmix/pmix2x/pmix/src/util/output.c @@ -2,7 +2,7 @@ * Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2008 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2006 High Performance Computing Center Stuttgart, From 2fc57136e85d9ca46b39fa5f3831c01548db6276 Mon Sep 17 00:00:00 2001 From: Ralph Castain Date: Thu, 1 Feb 2018 18:59:53 -0800 Subject: [PATCH 3/3] Silence redefinition warning Signed-off-by: Ralph Castain --- opal/mca/pmix/pmix2x/pmix2x.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/opal/mca/pmix/pmix2x/pmix2x.h b/opal/mca/pmix/pmix2x/pmix2x.h index 40280be238c..19683d0a656 100644 --- a/opal/mca/pmix/pmix2x/pmix2x.h +++ b/opal/mca/pmix/pmix2x/pmix2x.h @@ -1,6 +1,6 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* - * Copyright (c) 2014-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. * Copyright (c) 2014-2015 Mellanox Technologies, Inc. * All rights reserved. * Copyright (c) 2016 Research Organization for Information Science @@ -38,6 +38,9 @@ BEGIN_C_DECLS #ifdef OPAL_C_HAVE_VISIBILITY + #ifdef PMIX_HAVE_VISIBILITY + #undef PMIX_HAVE_VISIBILITY + #endif #define PMIX_HAVE_VISIBILITY 1 #else #undef PMIX_HAVE_VISIBILITY