From 3631e4e9362a3ef8360fab3b77de2b65b7ac5fa9 Mon Sep 17 00:00:00 2001 From: Ralph Castain <rhc@open-mpi.org> Date: Wed, 22 Sep 2010 01:11:40 +0000 Subject: [PATCH] Revert remaining svn kruft from r23764 This commit was SVN r23786. The following SVN revision numbers were found above: r23764 --> open-mpi/ompi@40a2bfa238582ca882d94541c0edad152ddc8084 --- ompi/tools/ompi_info/components.c | 30 +- ompi/tools/ompi_info/ompi_info.c | 3 +- ompi/tools/ompi_info/param.c | 1 - opal/runtime/opal_cr.c | 4 +- opal/runtime/opal_finalize.c | 7 +- opal/tools/wrappers/opal_wrapper.c | 18 + .../wrappers/opalc++-wrapper-data.txt.in | 1 + .../tools/wrappers/opalcc-wrapper-data.txt.in | 1 + opal/util/if.c | 911 ++---------------- opal/util/if.h | 9 - orte/mca/errmgr/hnp/errmgr_hnp.c | 34 +- orte/mca/notifier/hnp/notifier_hnp_module.c | 55 +- orte/tools/orte-info/components.c | 10 + orte/tools/orte-info/orte-info.c | 1 + orte/tools/wrappers/orte_wrapper_script.in | 18 +- .../wrappers/ortec++-wrapper-data.txt.in | 1 + .../tools/wrappers/ortecc-wrapper-data.txt.in | 1 + 17 files changed, 184 insertions(+), 921 deletions(-) diff --git a/ompi/tools/ompi_info/components.c b/ompi/tools/ompi_info/components.c index 3d8267bc65..43a87c3a56 100644 --- a/ompi/tools/ompi_info/components.c +++ b/ompi/tools/ompi_info/components.c @@ -9,7 +9,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. - * Copyright (c) 2006-2010 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2006-2009 Cisco Systems, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -56,6 +56,7 @@ #endif #include "opal/runtime/opal.h" #include "opal/dss/dss.h" +#include "opal/mca/if/base/base.h" #include "ompi/mca/allocator/base/base.h" #include "ompi/mca/coll/base/base.h" @@ -76,7 +77,6 @@ #include "ompi/mca/pubsub/base/base.h" #include "ompi/mca/dpm/base/base.h" #include "ompi/mca/op/base/base.h" -#include "ompi/mca/vprotocol/base/base.h" #if OPAL_ENABLE_FT_CR == 1 #include "ompi/mca/crcp/crcp.h" @@ -177,7 +177,6 @@ void ompi_info_open_components(void) char **env_save=NULL; bool need_close_components = false; ompi_info_component_map_t *map; - char *include_list; if (opened_components) { return; @@ -347,7 +346,15 @@ void ompi_info_open_components(void) map->components = &opal_compress_base_components_available; opal_pointer_array_add(&component_map, map); #endif - + + if (OPAL_SUCCESS != opal_if_base_open()) { + goto error; + } + map = OBJ_NEW(ompi_info_component_map_t); + map->type = strdup("if"); + map->components = &opal_if_components; + opal_pointer_array_add(&component_map, map); + /* OPAL's installdirs base open has already been called as part of * opal_init_util() back in main(). */ @@ -570,21 +577,6 @@ void ompi_info_open_components(void) map->components = &mca_pml_base_components_available; opal_pointer_array_add(&component_map, map); - /* According to vprotocol_base.c, the first char cannot be 0 or - the function will do nothing. Weird. The value must also be - malloc'ed, because mca_vprotocol_close() will free() it. */ - include_list = strdup("bogus"); - if (NULL == include_list) { - goto error; - } - if (OMPI_SUCCESS != mca_vprotocol_base_open(include_list)) { - goto error; - } - map = OBJ_NEW(ompi_info_component_map_t); - map->type = strdup("vprotocol"); - map->components = &mca_vprotocol_base_components_available; - opal_pointer_array_add(&component_map, map); - /* No need to call the bml_base_open() because the ob1 pml calls it. * mca_bml_base_open(); */ diff --git a/ompi/tools/ompi_info/ompi_info.c b/ompi/tools/ompi_info/ompi_info.c index 3a4487aad8..b961069b17 100644 --- a/ompi/tools/ompi_info/ompi_info.c +++ b/ompi/tools/ompi_info/ompi_info.c @@ -203,6 +203,8 @@ int main(int argc, char *argv[]) opal_pointer_array_add(&mca_types, "crs"); opal_pointer_array_add(&mca_types, "compress"); #endif + opal_pointer_array_add(&mca_types, "if"); + opal_pointer_array_add(&mca_types, "dpm"); opal_pointer_array_add(&mca_types, "pubsub"); opal_pointer_array_add(&mca_types, "allocator"); @@ -218,7 +220,6 @@ int main(int argc, char *argv[]) opal_pointer_array_add(&mca_types, "osc"); opal_pointer_array_add(&mca_types, "op"); opal_pointer_array_add(&mca_types, "common"); - opal_pointer_array_add(&mca_types, "vprotocol"); #if OPAL_ENABLE_FT_CR == 1 opal_pointer_array_add(&mca_types, "crcp"); #endif diff --git a/ompi/tools/ompi_info/param.c b/ompi/tools/ompi_info/param.c index 7fe2fde335..9b60439568 100644 --- a/ompi/tools/ompi_info/param.c +++ b/ompi/tools/ompi_info/param.c @@ -834,7 +834,6 @@ void ompi_info_do_config(bool want_all) ompi_info_out("Symbol vis. support", "options:visibility", symbol_visibility); ompi_info_out("MPI extensions", "options:mpi_ext", OMPI_MPIEXT_COMPONENTS); - ompi_info_out("MPI contribs", "options:mpi_contrib", OMPI_MPI_CONTRIBS); ompi_info_out("FT Checkpoint support", "options:ft_support", ft_support); free(ft_support); diff --git a/opal/runtime/opal_cr.c b/opal/runtime/opal_cr.c index 5c2dd3111e..9d4ebe01cc 100644 --- a/opal/runtime/opal_cr.c +++ b/opal/runtime/opal_cr.c @@ -50,7 +50,6 @@ #include "opal/util/opal_environ.h" #include "opal/util/output.h" #include "opal/util/malloc.h" -#include "opal/util/if.h" #include "opal/util/keyval_parse.h" #include "opal/util/opal_environ.h" #include "opal/util/argv.h" @@ -61,6 +60,7 @@ #include "opal/runtime/opal.h" #include "opal/constants.h" +#include "opal/mca/if/base/base.h" #include "opal/mca/memcpy/base/base.h" #include "opal/mca/memory/base/base.h" #include "opal/mca/timer/base/base.h" @@ -773,7 +773,7 @@ int opal_cr_coord(int state) /* * Flush if() functionality, since it caches system specific info. */ - opal_iffinalize(); + opal_if_base_close(); /* Since opal_ifinit() is not exposed, the necessary * functions will call it when needed. Just make sure we * finalized this code so we don't get old socket addrs. diff --git a/opal/runtime/opal_finalize.c b/opal/runtime/opal_finalize.c index b897427e30..10928d0875 100644 --- a/opal/runtime/opal_finalize.c +++ b/opal/runtime/opal_finalize.c @@ -26,7 +26,6 @@ #include "opal/util/trace.h" #include "opal/util/output.h" #include "opal/util/malloc.h" -#include "opal/util/if.h" #include "opal/util/net.h" #include "opal/util/keyval_parse.h" #include "opal/util/show_help.h" @@ -34,6 +33,7 @@ #include "opal/mca/base/base.h" #include "opal/runtime/opal.h" #include "opal/constants.h" +#include "opal/mca/if/base/base.h" #include "opal/mca/installdirs/base/base.h" #include "opal/mca/memcpy/base/base.h" #include "opal/mca/memory/base/base.h" @@ -66,9 +66,8 @@ opal_finalize_util(void) /* Clear out all the registered MCA params */ mca_base_param_finalize(); - /* close interfaces code. This is lazy opened, but protected from - close when not opened internally */ - opal_iffinalize(); + /* close interfaces code. */ + opal_if_base_close(); opal_net_finalize(); diff --git a/opal/tools/wrappers/opal_wrapper.c b/opal/tools/wrappers/opal_wrapper.c index 6c1dd4f3d8..c3743f52f4 100644 --- a/opal/tools/wrappers/opal_wrapper.c +++ b/opal/tools/wrappers/opal_wrapper.c @@ -12,6 +12,7 @@ * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2007 Los Alamos National Security, LLC. All rights * reserved. + * Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -75,6 +76,7 @@ struct options_data_t { char *module_option; char **preproc_flags; char **comp_flags; + char **comp_flags_prefix; char **link_flags; char **libs; char *req_file; @@ -116,6 +118,8 @@ options_data_init(struct options_data_t *data) data->preproc_flags[0] = NULL; data->comp_flags = (char **) malloc(sizeof(char*)); data->comp_flags[0] = NULL; + data->comp_flags_prefix = (char **) malloc(sizeof(char*)); + data->comp_flags_prefix[0] = NULL; data->link_flags = (char **) malloc(sizeof(char*)); data->link_flags[0] = NULL; data->libs = (char **) malloc(sizeof(char*)); @@ -142,6 +146,7 @@ options_data_free(struct options_data_t *data) if (NULL != data->module_option) free(data->module_option); opal_argv_free(data->preproc_flags); opal_argv_free(data->comp_flags); + opal_argv_free(data->comp_flags_prefix); opal_argv_free(data->link_flags); opal_argv_free(data->libs); if (NULL != data->req_file) free(data->req_file); @@ -298,6 +303,13 @@ data_callback(const char *key, const char *value) values); expand_flags(options_data[parse_options_idx].comp_flags); opal_argv_free(values); + } else if (0 == strcmp(key, "compiler_flags_prefix")) { + char **values = opal_argv_split(value, ' '); + opal_argv_insert(&options_data[parse_options_idx].comp_flags_prefix, + opal_argv_count(options_data[parse_options_idx].comp_flags_prefix), + values); + expand_flags(options_data[parse_options_idx].comp_flags_prefix); + opal_argv_free(values); } else if (0 == strcmp(key, "linker_flags")) { char **values = opal_argv_split(value, ' '); opal_argv_insert(&options_data[parse_options_idx].link_flags, @@ -712,6 +724,12 @@ main(int argc, char *argv[]) exec_argc = 0; } + if (flags & COMP_WANT_COMPILE) { + opal_argv_insert(&exec_argv, exec_argc, + options_data[user_data_idx].comp_flags_prefix); + exec_argc = opal_argv_count(exec_argv); + } + /* Per https://svn.open-mpi.org/trac/ompi/ticket/2201, add all the user arguments before anything else. */ opal_argv_insert(&exec_argv, exec_argc, user_argv); diff --git a/opal/tools/wrappers/opalc++-wrapper-data.txt.in b/opal/tools/wrappers/opalc++-wrapper-data.txt.in index 9c71262766..3224ff5587 100644 --- a/opal/tools/wrappers/opalc++-wrapper-data.txt.in +++ b/opal/tools/wrappers/opalc++-wrapper-data.txt.in @@ -14,6 +14,7 @@ compiler_flags_env=CXXFLAGS compiler=@CXX@ extra_includes=@OPAL_WRAPPER_EXTRA_INCLUDES@ preprocessor_flags=@OPAL_WRAPPER_EXTRA_CPPFLAGS@ +compiler_flags_prefix=@OPAL_WRAPPER_EXTRA_CXXFLAGS_PREFIX@ compiler_flags=@OPAL_WRAPPER_EXTRA_CXXFLAGS@ linker_flags=@OPAL_WRAPPER_EXTRA_LDFLAGS@ libs=-lopen-pal @OPAL_WRAPPER_EXTRA_LIBS@ diff --git a/opal/tools/wrappers/opalcc-wrapper-data.txt.in b/opal/tools/wrappers/opalcc-wrapper-data.txt.in index 22a4f86958..3e951a7635 100644 --- a/opal/tools/wrappers/opalcc-wrapper-data.txt.in +++ b/opal/tools/wrappers/opalcc-wrapper-data.txt.in @@ -14,6 +14,7 @@ compiler_flags_env=CFLAGS compiler=@CC@ extra_includes=@OPAL_WRAPPER_EXTRA_INCLUDES@ preprocessor_flags=@OPAL_WRAPPER_EXTRA_CPPFLAGS@ +compiler_flags_prefix=@OPAL_WRAPPER_EXTRA_CFLAGS_PREFIX@ compiler_flags=@OPAL_WRAPPER_EXTRA_CFLAGS@ linker_flags=@OPAL_WRAPPER_EXTRA_LDFLAGS@ libs=-lopen-pal @OPAL_WRAPPER_EXTRA_LIBS@ diff --git a/opal/util/if.c b/opal/util/if.c index 394c709c4c..c64d34cd0e 100644 --- a/opal/util/if.c +++ b/opal/util/if.c @@ -74,7 +74,8 @@ #include "opal/util/output.h" #include "opal/util/argv.h" #include "opal/constants.h" -#include "opal/mca/base/mca_base_param.h" + +#include "opal/mca/if/base/base.h" #ifdef HAVE_STRUCT_SOCKADDR_IN @@ -82,803 +83,6 @@ # define MIN(a,b) ((a) < (b) ? (a) : (b)) #endif -/* - * Define INADDR_NONE if we don't have it. Solaris is the only system - * where I have found that it does not exist, and the man page for - * inet_addr() says that it returns -1 upon failure. On Linux and - * other systems with INADDR_NONE, it's just a #define to -1 anyway. - * So just #define it to -1 here if it doesn't already exist. - */ - -#if !defined(INADDR_NONE) -#define INADDR_NONE -1 -#endif - -typedef struct opal_if_t { - opal_list_item_t super; - char if_name[IF_NAMESIZE]; - int if_index; - uint16_t if_kernel_index; -#ifndef __WINDOWS__ - int if_flags; -#else - u_long if_flags; -#endif - int if_speed; - struct sockaddr_storage if_addr; - uint32_t if_mask; -#ifdef __WINDOWS__ - struct sockaddr_in if_bcast; -#endif - uint32_t if_bandwidth; -} opal_if_t; - -static OBJ_CLASS_INSTANCE(opal_if_t, opal_list_item_t, NULL, NULL); -static opal_list_t opal_if_list; -static bool already_done = false; -static bool do_not_resolve = false; -static bool retain_loopback = false; - -#define DEFAULT_NUMBER_INTERFACES 10 -#define MAX_IFCONF_SIZE 10 * 1024 * 1024 - -/* convert a netmask (in network byte order) to CIDR notation */ -static int prefix (uint32_t netmask) -{ - uint32_t mask = ntohl(netmask); - int plen = 0; - - if (0 == mask) { - plen = 32; - } else { - while ((mask % 2) == 0) { - plen += 1; - mask /= 2; - } - } - - return (32 - plen); -} - -/* - * Discover the list of configured interfaces. Don't care about any - * interfaces that are not up or are local loopbacks. - */ - -static int opal_ifinit(void) -{ -#ifndef __WINDOWS__ - int flag; - - if (already_done) { - return OPAL_SUCCESS; - } - already_done = true; - - mca_base_param_reg_int_name("opal", "if_do_not_resolve", - "If nonzero, do not attempt to resolve interfaces", - false, false, (int)false, &flag); - do_not_resolve = OPAL_INT_TO_BOOL(flag); - - mca_base_param_reg_int_name("opal", "if_retain_loopback", - "If nonzero, retain loopback interfaces", - false, false, (int)false, &flag); - retain_loopback = OPAL_INT_TO_BOOL(flag); - - OBJ_CONSTRUCT(&opal_if_list, opal_list_t); - -#if defined(__NetBSD__) || defined(__FreeBSD__) || \ - defined(__OpenBSD__) || defined(__DragonFly__) - /* configure using getifaddrs(3) */ - { - struct ifaddrs **ifadd_list; - struct ifaddrs *cur_ifaddrs; - struct sockaddr_in* sin_addr; - - /* - * the manpage claims that getifaddrs() allocates the memory, - * and freeifaddrs() is later used to release the allocated memory. - * however, without this malloc the call to getifaddrs() segfaults - */ - ifadd_list = (struct ifaddrs **) malloc(sizeof(struct ifaddrs*)); - - /* create the linked list of ifaddrs structs */ - if (getifaddrs(ifadd_list) < 0) { - opal_output(0, "opal_ifinit: getifaddrs() failed with error=%d\n", - errno); - return OPAL_ERROR; - } - - for (cur_ifaddrs = *ifadd_list; NULL != cur_ifaddrs; - cur_ifaddrs = cur_ifaddrs->ifa_next) { - opal_if_t *intf; - struct in_addr a4; - - /* skip non- af_inet interface addresses */ - if (AF_INET != cur_ifaddrs->ifa_addr->sa_family) { - continue; - } - - /* skip interface if it is down (IFF_UP not set) */ - if (0 == (cur_ifaddrs->ifa_flags & IFF_UP)) { - continue; - } - - /* skip interface if it is a loopback device (IFF_LOOPBACK set) */ - if (!retain_loopback && 0 != (cur_ifaddrs->ifa_flags & IFF_LOOPBACK)) { - continue; - } - - /* or if it is a point-to-point interface */ - /* TODO: do we really skip p2p? */ - if (0 != (cur_ifaddrs->ifa_flags & IFF_POINTOPOINT)) { - continue; - } - - sin_addr = (struct sockaddr_in *) cur_ifaddrs->ifa_addr; - - intf = OBJ_NEW(opal_if_t); - if (NULL == intf) { - opal_output(0, "opal_ifinit: unable to allocate %lu bytes\n", - (int) sizeof(opal_if_t)); - return OPAL_ERR_OUT_OF_RESOURCE; - } - - /* fill values into the opal_if_t */ - memcpy(&a4, &(sin_addr->sin_addr), sizeof(struct in_addr)); - - strncpy(intf->if_name, cur_ifaddrs->ifa_name, IF_NAMESIZE); - intf->if_index = opal_list_get_size(&opal_if_list) + 1; - ((struct sockaddr_in*) &intf->if_addr)->sin_addr = a4; - ((struct sockaddr_in*) &intf->if_addr)->sin_family = AF_INET; - ((struct sockaddr_in*) &intf->if_addr)->sin_len = cur_ifaddrs->ifa_addr->sa_len; - - intf->if_mask = prefix( sin_addr->sin_addr.s_addr); - intf->if_flags = cur_ifaddrs->ifa_flags; - - intf->if_kernel_index = - (uint16_t) if_nametoindex(cur_ifaddrs->ifa_name); - - opal_list_append(&opal_if_list, &(intf->super)); - } /* of for loop over ifaddrs list */ - } - /* End of various flavors of BSD */ -#else - /* Beginning of !(various flavors of BSD) */ - { - int sd; - int lastlen, num, rem; - char *ptr; - struct ifconf ifconf; - int ifc_len; - bool successful_locate = false; - - /* Create the internet socket to test with. Must use AF_INET; - using AF_UNSPEC or AF_INET6 will cause everything to - fail. */ - if ((sd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - opal_output(0, "opal_ifinit: socket() failed with errno=%d\n", - errno); - return OPAL_ERROR; - } - - /* - * Get Network Interface configuration - * - * Some notes on the behavior of ioctl(..., SIOCGIFCONF,...) - * when not enough space is allocated for all the entries. - * - * - Solaris returns -1, errno EINVAL if there is not enough - * space - * - OS X returns 0, sets .ifc_len to the space used by the - * by the entries that did fit. - * - Linux returns 0, sets .ifc_len to the space required to - * hold all the entries (although it only writes what will - * fit in the buffer of .ifc_len passed to the function). - * - FreeBSD returns 0, sets .ifc_len to 0. - * - * Everyone else seems to do one of the four. - */ - lastlen = 0; - ifc_len = sizeof(struct ifreq) * DEFAULT_NUMBER_INTERFACES; - do { - ifconf.ifc_len = ifc_len; - ifconf.ifc_req = malloc(ifc_len); - if (NULL == ifconf.ifc_req) { - close(sd); - return OPAL_ERROR; - } - - /* initialize the memory so valgrind and purify won't - * complain. Since this isn't performance critical, just - * always memset. - */ - memset(ifconf.ifc_req, 0, ifconf.ifc_len); - - if (ioctl(sd, SIOCGIFCONF, &ifconf) < 0) { - /* if we got an einval, we probably don't have enough - space. so we'll fall down and try to expand our - space */ - if (errno != EINVAL && lastlen != 0) { - opal_output(0, "opal_ifinit: ioctl(SIOCGIFCONF) \ - failed with errno=%d", - errno); - free(ifconf.ifc_req); - close(sd); - return OPAL_ERROR; - } - } else { - /* if ifc_len is 0 or different than what we set it to - at call to ioctl, try again with a bigger buffer. - else stop */ - if (ifconf.ifc_len == lastlen && ifconf.ifc_len > 0) { - /* we didn't expand. we're done */ - successful_locate = true; - break; - } - lastlen = ifconf.ifc_len; - } - - /* Yes, we overflowed (or had an EINVAL on the ioctl). - Loop back around and try again with a bigger buffer */ - free(ifconf.ifc_req); - ifc_len = (ifc_len == 0) ? 1 : ifc_len * 2; - } while (ifc_len < MAX_IFCONF_SIZE); - if (!successful_locate) { - opal_output(0, "opal_ifinit: unable to find network interfaces."); - return OPAL_ERR_FATAL; - } - - /* - * Setup indexes - */ - ptr = (char*) ifconf.ifc_req; - rem = ifconf.ifc_len; - num = 0; - - /* loop through all interfaces */ - while (rem > 0) { - struct ifreq* ifr = (struct ifreq*) ptr; - opal_if_t *intf; - int length; - - intf = OBJ_NEW(opal_if_t); - if (NULL == intf) { - opal_output(0, "opal_ifinit: unable to allocated %lu bytes\n", (unsigned long)sizeof(opal_if_t)); - free(ifconf.ifc_req); - close(sd); - return OPAL_ERR_OUT_OF_RESOURCE; - } - - /* compute offset for entries */ -#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN - length = sizeof(struct sockaddr); - - if (ifr->ifr_addr.sa_len > length) { - length = ifr->ifr_addr.sa_len; - } - - length += sizeof(ifr->ifr_name); -#else - length = sizeof(struct ifreq); -#endif - - rem -= length; - ptr += length; - - /* see if we like this entry */ - if (AF_INET != ifr->ifr_addr.sa_family) { - continue; - } - - if (ioctl(sd, SIOCGIFFLAGS, ifr) < 0) { - opal_output(0, "opal_ifinit: ioctl(SIOCGIFFLAGS) failed with errno=%d", errno); - continue; - } - if ((ifr->ifr_flags & IFF_UP) == 0) { - continue; - } -#ifdef IFF_SLAVE - /* Is this a slave to a load balancer or bonded channel? - If so, don't use it -- pick up the master instead */ - if ((ifr->ifr_flags & IFF_SLAVE) != 0) { - continue; - } -#endif -#if 0 - if (!retain_loopback && (ifr->ifr_flags & IFF_LOOPBACK) != 0) { - continue; - } -#endif - - /* copy entry over into our data structure */ - strcpy(intf->if_name, ifr->ifr_name); - intf->if_flags = ifr->ifr_flags; - - /* every new address gets its own internal if_index */ - intf->if_index = opal_list_get_size(&opal_if_list)+1; - - /* assign the kernel index to distinguish different NICs */ -#ifndef SIOCGIFINDEX - intf->if_kernel_index = intf->if_index; -#else - if (ioctl(sd, SIOCGIFINDEX, ifr) < 0) { - opal_output(0,"opal_ifinit: ioctl(SIOCGIFINDEX) failed with errno=%d", errno); - continue; - } -#if defined(ifr_ifindex) - intf->if_kernel_index = ifr->ifr_ifindex; -#elif defined(ifr_index) - intf->if_kernel_index = ifr->ifr_index; -#else - intf->if_kernel_index = -1; -#endif -#endif /* SIOCGIFINDEX */ - - /* This call returns IPv4 addresses only. Use SIOCGLIFADDR - instead */ - if (ioctl(sd, SIOCGIFADDR, ifr) < 0) { - opal_output(0, "opal_ifinit: ioctl(SIOCGIFADDR) failed with errno=%d", errno); - break; - } - if (AF_INET != ifr->ifr_addr.sa_family) { - continue; - } - - /* based on above, we know this is an IPv4 address... */ - memcpy(&intf->if_addr, &ifr->ifr_addr, sizeof(struct sockaddr_in)); - - if (ioctl(sd, SIOCGIFNETMASK, ifr) < 0) { - opal_output(0, "opal_ifinit: ioctl(SIOCGIFNETMASK) failed with errno=%d", errno); - continue; - } - - /* generate CIDR and assign to netmask */ - intf->if_mask = prefix(((struct sockaddr_in*) &ifr->ifr_addr)->sin_addr.s_addr); - - opal_list_append(&opal_if_list, &(intf->super)); - } - free(ifconf.ifc_req); - close(sd); - } -#endif /* anything other than {Net,Open,Free}BSD and DragonFly */ - -#if OPAL_WANT_IPV6 -#ifdef __linux__ /* Linux does not have SIOCGL*, so parse - /proc/net/if_inet6 instead */ - { - FILE *f; - if ((f = fopen("/proc/net/if_inet6", "r"))) { - char ifname[IF_NAMESIZE]; - unsigned int idx, pfxlen, scope, dadstat; - struct in6_addr a6; - int iter; - uint32_t flag; - unsigned int addrbyte[16]; - - while (fscanf(f, "%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x %x %x %x %x %20s\n", - &addrbyte[0], &addrbyte[1], &addrbyte[2], &addrbyte[3], - &addrbyte[4], &addrbyte[5], &addrbyte[6], &addrbyte[7], - &addrbyte[8], &addrbyte[9], &addrbyte[10], &addrbyte[11], - &addrbyte[12], &addrbyte[13], &addrbyte[14], &addrbyte[15], - &idx, &pfxlen, &scope, &dadstat, ifname) != EOF) { - opal_if_t *intf; - - /* we don't want any other scope than global */ - if (scope != 0) { - continue; - } - - intf = OBJ_NEW(opal_if_t); - if (NULL == intf) { - opal_output(0, "opal_ifinit: unable to allocate %lu bytes\n", - (unsigned long)sizeof(opal_if_t)); - fclose(f); - return OPAL_ERR_OUT_OF_RESOURCE; - } - - for (iter = 0; iter < 16; iter++) { - a6.s6_addr[iter] = addrbyte[iter]; - } - - /* now construct the opal_if_t */ - strncpy(intf->if_name, ifname, IF_NAMESIZE); - intf->if_index = opal_list_get_size(&opal_if_list)+1; - intf->if_kernel_index = (uint16_t) idx; - ((struct sockaddr_in6*) &intf->if_addr)->sin6_addr = a6; - ((struct sockaddr_in6*) &intf->if_addr)->sin6_family = AF_INET6; - ((struct sockaddr_in6*) &intf->if_addr)->sin6_scope_id = scope; - intf->if_mask = pfxlen; - if (OPAL_SUCCESS == opal_ifindextoflags(opal_ifnametoindex (ifname), &flag)) { - intf->if_flags = flag; - } else { - intf->if_flags = IFF_UP; - } - - /* copy new interface information to heap and append - to list */ - opal_list_append(&opal_if_list, &(intf->super)); - } /* of while */ - fclose(f); - } - } -#endif - -/* - * the bsd ipv6 code below has only been tested on netbsd and linux (glibc>=2.4) - * - * - getifaddrs() has been included in glibc-2.4, so we can finally use - * it in linux, too. - * - getifaddrs() should be the prefered way to access interface / address - * pairs whenever it is available, for both IPv4 and IPv6 - * TODO: - more testing - * - let configure decide whether getifaddrs() is available, - * and use it when available, independent of operating system - */ - - - -#if defined( __NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) || \ - defined(__386BSD__) || defined(__bsdi__) || defined(__APPLE__) -/* || defined(__linux__) */ - - { - struct ifaddrs **ifadd_list; - struct ifaddrs *cur_ifaddrs; - struct sockaddr_in6* sin_addr; - - /* - * the manpage claims that getifaddrs() allocates the memory, - * and freeifaddrs() is later used to release the allocated memory. - * however, without this malloc the call to getifaddrs() segfaults - */ - ifadd_list = (struct ifaddrs **) malloc(sizeof(struct ifaddrs*)); - - /* create the linked list of ifaddrs structs */ - if (getifaddrs(ifadd_list) < 0) { - opal_output(0, "opal_ifinit: getifaddrs() failed with error=%d\n", - errno); - return OPAL_ERROR; - } - - for (cur_ifaddrs = *ifadd_list; NULL != cur_ifaddrs; - cur_ifaddrs = cur_ifaddrs->ifa_next) { - opal_if_t *intf; - struct in6_addr a6; - - /* skip non-ipv6 interface addresses */ - if (AF_INET6 != cur_ifaddrs->ifa_addr->sa_family) { -#if 0 - printf("skipping non-ipv6 interface %s.\n", cur_ifaddrs->ifa_name); -#endif - continue; - } - - /* skip interface if it is down (IFF_UP not set) */ - if (0 == (cur_ifaddrs->ifa_flags & IFF_UP)) { -#if 0 - printf("skipping non-up interface %s.\n", cur_ifaddrs->ifa_name); -#endif - continue; - } - - /* skip interface if it is a loopback device (IFF_LOOPBACK set) */ - if (!retain_loopback && 0 != (cur_ifaddrs->ifa_flags & IFF_LOOPBACK)) { - continue; - } - - /* or if it is a point-to-point interface */ - /* TODO: do we really skip p2p? */ - if (0!= (cur_ifaddrs->ifa_flags & IFF_POINTOPOINT)) { -#if 0 - printf("skipping loopback interface %s.\n", cur_ifaddrs->ifa_name); -#endif - continue; - } - - sin_addr = (struct sockaddr_in6 *) cur_ifaddrs->ifa_addr; - intf = OBJ_NEW(opal_if_t); - if (NULL == intf) { - opal_output(0, "opal_ifinit: unable to allocate %lu bytes\n", - sizeof(opal_if_t)); - return OPAL_ERR_OUT_OF_RESOURCE; - } - - /* - * skip IPv6 address starting with fe80:, as this is supposed to be - * link-local scope. sockaddr_in6->sin6_scope_id doesn't always work - * TODO: test whether scope id is set to a sensible value on - * linux and/or bsd (including osx) - * - * MacOSX: fe80::... has a scope of 0, but ifconfig -a shows - * a scope of 4 on that particular machine, - * so the scope returned by getifaddrs() isn't working properly - */ - - if ((IN6_IS_ADDR_LINKLOCAL (&sin_addr->sin6_addr))) { -#if 0 - printf("skipping link-local ipv6 address on interface \ - %s with scope %d.\n", - cur_ifaddrs->ifa_name, sin_addr->sin6_scope_id); -#endif - continue; - } - -#if 0 - char *addr_name = (char *) malloc(48*sizeof(char)); - inet_ntop(AF_INET6, &sin_addr->sin6_addr, addr_name, 48*sizeof(char)); - opal_output(0, "ipv6 capable interface %s discovered, address %s.\n", - cur_ifaddrs->ifa_name, addr_name); - free(addr_name); -#endif - - /* fill values into the opal_if_t */ - memcpy(&a6, &(sin_addr->sin6_addr), sizeof(struct in6_addr)); - - strncpy(intf->if_name, cur_ifaddrs->ifa_name, IF_NAMESIZE); - intf->if_index = opal_list_get_size(&opal_if_list) + 1; - ((struct sockaddr_in6*) &intf->if_addr)->sin6_addr = a6; - ((struct sockaddr_in6*) &intf->if_addr)->sin6_family = AF_INET6; - - /* since every scope != 0 is ignored, we just set the scope to 0 */ - ((struct sockaddr_in6*) &intf->if_addr)->sin6_scope_id = 0; - - /* - * hardcoded netmask, adrian says that's ok - */ - intf->if_mask = 64; - intf->if_flags = cur_ifaddrs->ifa_flags; - - /* - * FIXME: figure out how to gain access to the kernel index - * (or create our own), getifaddrs() does not contain such - * data - */ - intf->if_kernel_index = - (uint16_t) if_nametoindex(cur_ifaddrs->ifa_name); - opal_list_append(&opal_if_list, &(intf->super)); - } /* of for loop over ifaddrs list */ - } -#endif /* bsd, macosx */ - - -#ifdef __sun__ - /* Solaris IPv6 interface discovery */ - { - int i; - int sd; - int error; - uint16_t kindex; - struct lifnum lifnum; - struct lifconf lifconf; - struct lifreq *lifreq, lifquery; - - sd = socket (AF_INET6, SOCK_DGRAM, 0); - if (sd < 0) { - opal_output (0, "opal_ifinit: unable to open IPv6 socket\n"); - return OPAL_ERROR; - } - - /* we only ask for IPv6; IPv4 discovery has already been done */ - lifnum.lifn_family = AF_INET6; - lifnum.lifn_flags = 0; - lifnum.lifn_count = 0; - - /* get the number of interfaces in the system */ - error = ioctl (sd, SIOCGLIFNUM, &lifnum); - if (error < 0) { - opal_output (0, - "opal_ifinit: ioctl SIOCGLIFNUM failed with errno=%d\n", errno); - return OPAL_ERROR; - } - - memset (&lifconf, 0, sizeof (struct lifconf)); - memset (&lifquery, 0, sizeof (struct lifreq)); - lifconf.lifc_family = AF_INET6; - lifconf.lifc_flags = 0; - lifconf.lifc_len = lifnum.lifn_count * sizeof (struct lifreq) * 2; - lifconf.lifc_buf = malloc (lifconf.lifc_len); - if (NULL == lifconf.lifc_buf) { - opal_output (0, "opal_ifinit: IPv6 discovery: malloc() failed\n"); - return OPAL_ERR_OUT_OF_RESOURCE; - } - - memset (lifconf.lifc_buf, 0, lifconf.lifc_len); - - error = ioctl (sd, SIOCGLIFCONF, &lifconf); - if (error < 0) { - opal_output (0, - "opal_ifinit: IPv6 SIOCGLIFCONF failed with errno=%d\n", errno); - } - - for (i = 0; i + sizeof (struct lifreq) <= lifconf.lifc_len; - i += sizeof (*lifreq)) { - - lifreq = (struct lifreq *)((caddr_t)lifconf.lifc_buf + i); - strncpy (lifquery.lifr_name, lifreq->lifr_name, - sizeof (lifquery.lifr_name)); - - /* lookup kernel index */ - error = ioctl (sd, SIOCGLIFINDEX, &lifquery); - if (error < 0) { - opal_output (0, - "opal_ifinit: SIOCGLIFINDEX failed with errno=%d\n", errno); - return OPAL_ERROR; - } - kindex = lifquery.lifr_index; - - /* lookup interface flags */ - error = ioctl (sd, SIOCGLIFFLAGS, &lifquery); - if (error < 0) { - opal_output (0, - "opal_ifinit: SIOCGLIFFLAGS failed with errno=%d\n", errno); - return OPAL_ERROR; - } - - if (AF_INET6 == lifreq->lifr_addr.ss_family) { - struct sockaddr_in6* my_addr = (struct sockaddr_in6*) &lifreq->lifr_addr; - /* we surely want to check for sin6_scope_id, but Solaris - does not set it correctly, so we have to look for - global scope. For now, global is anything which is - neither loopback nor link local. - - Bug, FIXME: site-local, multicast, ... missing - Check for 2000::/3? - */ - if ( (!retain_loopback && !IN6_IS_ADDR_LOOPBACK (&my_addr->sin6_addr)) && - (! IN6_IS_ADDR_LINKLOCAL (&my_addr->sin6_addr))) { - /* create interface for newly found address */ - opal_if_t *intf; - - intf = OBJ_NEW(opal_if_t); - if (NULL == intf) { - opal_output (0, - "opal_ifinit: unable to allocate %d bytes\n", - sizeof (opal_if_t)); - return OPAL_ERR_OUT_OF_RESOURCE; - } - - strncpy (intf->if_name, lifreq->lifr_name, IF_NAMESIZE); - intf->if_index = opal_list_get_size(&opal_if_list)+1; - memcpy(&intf->if_addr, my_addr, sizeof (*my_addr)); - intf->if_mask = 64; - /* lifrq flags are uint64_t */ - intf->if_flags = - (uint32_t)(0x00000000ffffffff) & lifquery.lifr_flags; - - /* append to list */ - opal_list_append (&opal_if_list, &(intf->super)); - } - } - } /* for */ - - if (NULL != lifconf.lifc_buf) { - free (lifconf.lifc_buf); - } - } -#endif /* __sun__ */ - -#endif /* OPAL_WANT_IPV6 */ - -#else /* __WINDOWS__ implementation begins */ - { - /* - 1. check if the interface info list is already populated. If so, return - 2. get the interface information which is required using WSAIoctl - 3. construct opal_if_list and populate it with the list of interfaces we have - CAVEAT: Does not support the following options which are supported in SIOCGIFCONF - - kernel table index - - interface name - */ - - #define MAX_INTERFACES 10 /* Anju: for now assume there are no more than this */ - SOCKET sd; - INTERFACE_INFO if_list[MAX_INTERFACES]; - int num_interfaces; - unsigned long num_bytes_returned; - int i; - unsigned int interface_counter = 0; - opal_if_t *intf; - - /* return if this has been done before */ - if (already_done) { - return OPAL_SUCCESS; - } - already_done = true; - - /* create a socket */ - sd = WSASocket (AF_INET, SOCK_DGRAM, IPPROTO_UDP, NULL, 0, 0); - if (sd == SOCKET_ERROR) { - opal_output(0, "opal_ifinit: WSASocket failed with errno=%d\n",WSAGetLastError()); - return OPAL_ERROR; - } - - /* get the information about the interfaces */ - if (SOCKET_ERROR == WSAIoctl (sd, - SIO_GET_INTERFACE_LIST, - NULL, - 0, - &if_list, - sizeof (if_list), - &num_bytes_returned, - 0, - 0)) { - opal_output(0, "opal_ifinit: WSAIoctl failed with errno=%d\n",WSAGetLastError()); - return OPAL_ERROR; - } - - /* create and populate opal_if_list */ - OBJ_CONSTRUCT (&opal_if_list, opal_list_t); - - /* loop through all the interfaces and create the list */ - num_interfaces = num_bytes_returned / sizeof (INTERFACE_INFO); - for (i = 0; i < num_interfaces; ++i) { - /* do all this only if the interface is up, and skip loopback interface */ - if (0 != (if_list[i].iiFlags & IFF_UP) - && (!retain_loopback && 0 == (if_list[i].iiFlags & IFF_LOOPBACK))) { - - intf = OBJ_NEW(opal_if_t); - if (NULL == intf) { - opal_output (0,"opal_ifinit: Unable to malloc %d bytes",sizeof(opal_list_t)); - return OPAL_ERR_OUT_OF_RESOURCE; - } - - /* fill in the interface address */ - memcpy(&intf->if_addr, &(if_list[i].iiAddress), - sizeof(intf->if_addr)); - - /* fill in the netmask information */ - memcpy(&intf->if_mask, &(if_list[i].iiNetmask), - sizeof(intf->if_mask)); - - /* fill in the bcast address */ - memcpy(&intf->if_bcast, &(if_list[i].iiBroadcastAddress), - sizeof(intf->if_bcast)); - - /* fill in the flags */ - intf->if_flags = if_list[i].iiFlags; - - /* fill in the index in the table */ - intf->if_index = opal_list_get_size(&opal_if_list)+1; - - /* fill in the kernel index */ - intf->if_kernel_index = intf->if_index; - - /* generate the interface name, e.g. eth0, eth1, ..... */ - sprintf(intf->if_name, "eth%u", interface_counter++); - - /* copy all this into a persistent form and store it in the list */ - opal_list_append(&opal_if_list, &(intf->super)); - } - } - } -#endif - return OPAL_SUCCESS; -} - - -/* - * Finalize the list of configured interfaces to free malloc'd memory - */ - -int opal_iffinalize(void) -{ - if (already_done) { -#ifndef __WINDOWS__ - opal_if_t *intf_ptr; - - while (NULL != - (intf_ptr = (opal_if_t*)opal_list_remove_first(&opal_if_list))) { - OBJ_RELEASE(intf_ptr); - } - OBJ_DESTRUCT(&opal_if_list); -#endif - already_done = false; - } - return OPAL_SUCCESS; -} - - /* * Look for interface by name and returns its address * as a dotted decimal formatted string. @@ -887,9 +91,10 @@ int opal_iffinalize(void) int opal_ifnametoaddr(const char* if_name, struct sockaddr* addr, int length) { opal_if_t* intf; - int rc = opal_ifinit(); - if (rc != OPAL_SUCCESS) - return rc; + + if (OPAL_SUCCESS != opal_if_base_open()) { + return OPAL_ERROR; + } for (intf = (opal_if_t*)opal_list_get_first(&opal_if_list); intf != (opal_if_t*)opal_list_get_end(&opal_if_list); @@ -911,9 +116,10 @@ int opal_ifnametoaddr(const char* if_name, struct sockaddr* addr, int length) int opal_ifnametoindex(const char* if_name) { opal_if_t* intf; - int rc = opal_ifinit(); - if (rc != OPAL_SUCCESS) - return rc; + + if (OPAL_SUCCESS != opal_if_base_open()) { + return -1; + } for (intf = (opal_if_t*)opal_list_get_first(&opal_if_list); intf != (opal_if_t*)opal_list_get_end(&opal_if_list); @@ -934,9 +140,10 @@ int opal_ifnametoindex(const char* if_name) int16_t opal_ifnametokindex(const char* if_name) { opal_if_t* intf; - int rc = opal_ifinit(); - if (rc != OPAL_SUCCESS) - return rc; + + if (OPAL_SUCCESS != opal_if_base_open()) { + return -1; + } for (intf = (opal_if_t*)opal_list_get_first(&opal_if_list); intf != (opal_if_t*)opal_list_get_end(&opal_if_list); @@ -957,9 +164,10 @@ int16_t opal_ifnametokindex(const char* if_name) int opal_ifindextokindex(int if_index) { opal_if_t* intf; - int rc = opal_ifinit(); - if (rc != OPAL_SUCCESS) - return rc; + + if (OPAL_SUCCESS != opal_if_base_open()) { + return -1; + } for (intf = (opal_if_t*)opal_list_get_first(&opal_if_list); intf != (opal_if_t*)opal_list_get_end(&opal_if_list); @@ -980,7 +188,6 @@ int opal_ifindextokindex(int if_index) int opal_ifaddrtoname(const char* if_addr, char* if_name, int length) { opal_if_t* intf; - int rc; #if OPAL_WANT_IPV6 int error; struct addrinfo hints, *res = NULL, *r; @@ -993,19 +200,18 @@ int opal_ifaddrtoname(const char* if_addr, char* if_name, int length) struct hostent *h; #endif - rc = opal_ifinit(); - if (OPAL_SUCCESS != rc) { - return rc; - } - /* if the user asked us not to resolve interfaces, then just return */ - if (do_not_resolve) { + if (opal_if_do_not_resolve) { /* return not found so ifislocal will declare * the node to be non-local */ return OPAL_ERR_NOT_FOUND; } + if (OPAL_SUCCESS != opal_if_base_open()) { + return OPAL_ERROR; + } + #if OPAL_WANT_IPV6 memset(&hints, 0, sizeof(hints)); hints.ai_family = PF_UNSPEC; @@ -1076,8 +282,10 @@ int opal_ifaddrtoname(const char* if_addr, char* if_name, int length) int opal_ifcount(void) { - if (opal_ifinit() != OPAL_SUCCESS) - return (-1); + if (OPAL_SUCCESS != opal_if_base_open()) { + return 0; + } + return opal_list_get_size(&opal_if_list); } @@ -1090,8 +298,11 @@ int opal_ifcount(void) int opal_ifbegin(void) { opal_if_t *intf; - if (opal_ifinit() != OPAL_SUCCESS) - return (-1); + + if (OPAL_SUCCESS != opal_if_base_open()) { + return -1; + } + intf = (opal_if_t*)opal_list_get_first(&opal_if_list); if (NULL != intf) return intf->if_index; @@ -1108,8 +319,10 @@ int opal_ifbegin(void) int opal_ifnext(int if_index) { opal_if_t *intf; - if (opal_ifinit() != OPAL_SUCCESS) - return (-1); + + if (OPAL_SUCCESS != opal_if_base_open()) { + return -1; + } for (intf = (opal_if_t*)opal_list_get_first(&opal_if_list); intf != (opal_if_t*)opal_list_get_end(&opal_if_list); @@ -1138,9 +351,10 @@ int opal_ifnext(int if_index) int opal_ifindextoaddr(int if_index, struct sockaddr* if_addr, unsigned int length) { opal_if_t* intf; - int rc = opal_ifinit(); - if (rc != OPAL_SUCCESS) - return rc; + + if (OPAL_SUCCESS != opal_if_base_open()) { + return OPAL_ERROR; + } for (intf = (opal_if_t*)opal_list_get_first(&opal_if_list); intf != (opal_if_t*)opal_list_get_end(&opal_if_list); @@ -1162,9 +376,10 @@ int opal_ifindextoaddr(int if_index, struct sockaddr* if_addr, unsigned int leng int opal_ifindextomask(int if_index, uint32_t* if_mask, int length) { opal_if_t* intf; - int rc = opal_ifinit(); - if (rc != OPAL_SUCCESS) - return rc; + + if (OPAL_SUCCESS != opal_if_base_open()) { + return OPAL_ERROR; + } for (intf = (opal_if_t*)opal_list_get_first(&opal_if_list); intf != (opal_if_t*)opal_list_get_end(&opal_if_list); @@ -1187,9 +402,10 @@ int opal_ifindextomask(int if_index, uint32_t* if_mask, int length) int opal_ifindextoflags(int if_index, uint32_t* if_flags) { opal_if_t* intf; - int rc = opal_ifinit(); - if (rc != OPAL_SUCCESS) - return rc; + + if (OPAL_SUCCESS != opal_if_base_open()) { + return OPAL_ERROR; + } for (intf = (opal_if_t*)opal_list_get_first(&opal_if_list); intf != (opal_if_t*)opal_list_get_end(&opal_if_list); @@ -1212,9 +428,10 @@ int opal_ifindextoflags(int if_index, uint32_t* if_flags) int opal_ifindextoname(int if_index, char* if_name, int length) { opal_if_t *intf; - int rc = opal_ifinit(); - if (rc != OPAL_SUCCESS) - return rc; + + if (OPAL_SUCCESS != opal_if_base_open()) { + return OPAL_ERROR; + } for (intf = (opal_if_t*)opal_list_get_first(&opal_if_list); intf != (opal_if_t*)opal_list_get_end(&opal_if_list); @@ -1236,9 +453,10 @@ int opal_ifindextoname(int if_index, char* if_name, int length) int opal_ifkindextoname(int if_kindex, char* if_name, int length) { opal_if_t *intf; - int rc = opal_ifinit(); - if (rc != OPAL_SUCCESS) - return rc; + + if (OPAL_SUCCESS != opal_if_base_open()) { + return OPAL_ERROR; + } for (intf = (opal_if_t*)opal_list_get_first(&opal_if_list); intf != (opal_if_t*)opal_list_get_end(&opal_if_list); @@ -1379,11 +597,11 @@ opal_iftupletoaddr(char *inaddr, uint32_t *net, uint32_t *mask) bool opal_ifisloopback(int if_index) { opal_if_t* intf; - int rc = opal_ifinit(); - if (rc != OPAL_SUCCESS) { - return rc; - } + if (OPAL_SUCCESS != opal_if_base_open()) { + return OPAL_ERROR; + } + for (intf = (opal_if_t*)opal_list_get_first(&opal_if_list); intf != (opal_if_t*)opal_list_get_end(&opal_if_list); intf = (opal_if_t*)opal_list_get_next(intf)) { @@ -1400,8 +618,7 @@ bool opal_ifisloopback(int if_index) #else /* HAVE_STRUCT_SOCKADDR_IN */ /* if we don't have struct sockaddr_in, we don't have traditional - ethernet devices. Just make everything a no-op error call (except - for finalize, which will return successfully) */ + ethernet devices. Just make everything a no-op error call */ int opal_ifnametoaddr(const char* if_name, @@ -1483,12 +700,6 @@ opal_ifislocal(const char *hostname) return false; } -int -opal_iffinalize(void) -{ - return OPAL_SUCCESS; -} - int opal_iftupletoaddr(char *inaddr, uint32_t *net, uint32_t *mask) { diff --git a/opal/util/if.h b/opal/util/if.h index 7d604d0ee9..65efa62952 100644 --- a/opal/util/if.h +++ b/opal/util/if.h @@ -170,15 +170,6 @@ OPAL_DECLSPEC int opal_ifindextoflags(int if_index, uint32_t*); */ OPAL_DECLSPEC bool opal_ifislocal(const char *hostname); -/** - * Finalize the functions to release malloc'd data - * - * @param none - * @return OPAL_SUCCESS if no problems encountered - * @return OPAL_ERROR if data could not be released - */ -OPAL_DECLSPEC int opal_iffinalize(void); - /** * Convert a dot-delimited network tuple to an IP address * diff --git a/orte/mca/errmgr/hnp/errmgr_hnp.c b/orte/mca/errmgr/hnp/errmgr_hnp.c index e2c0cd5b2c..01c9f59a99 100644 --- a/orte/mca/errmgr/hnp/errmgr_hnp.c +++ b/orte/mca/errmgr/hnp/errmgr_hnp.c @@ -36,6 +36,7 @@ #include "orte/mca/sensor/sensor.h" #include "orte/mca/routed/routed.h" #include "orte/mca/debugger/base/base.h" +#include "orte/mca/notifier/notifier.h" #include "orte/util/error_strings.h" #include "orte/util/name_fns.h" @@ -990,7 +991,8 @@ static void check_job_complete(orte_job_t *jdata) orte_std_cntr_t index; bool one_still_alive; orte_vpid_t non_zero=0, lowest=0; - + char *msg; + #if 0 /* Check if FileM is active. If so then keep processing. */ OPAL_ACQUIRE_THREAD(&orte_filem_base_lock, &orte_filem_base_cond, &orte_filem_base_is_active); @@ -1225,7 +1227,7 @@ static void check_job_complete(orte_job_t *jdata) * This can happen if a ctrl-c hits in the "wrong" place * while launching */ -CHECK_DAEMONS: + CHECK_DAEMONS: if (jdata == NULL || jdata->jobid == ORTE_PROC_MY_NAME->jobid) { if (0 == orte_routed.num_routes()) { /* orteds are done! */ @@ -1301,6 +1303,9 @@ CHECK_DAEMONS: * then go ahead and release it. We cannot release it if it * abnormally terminated as mpirun needs the info so it can * report appropriately to the user + * + * NOTE: do not release the primary job (j=1) so we + * can pretty-print completion message */ if (NULL != jdata && job->jobid == jdata->jobid && (jdata->state == ORTE_JOB_STATE_TERMINATED || @@ -1309,8 +1314,10 @@ CHECK_DAEMONS: * pointer array internal accounting * is maintained! */ - opal_pointer_array_set_item(orte_job_data, j, NULL); /* ensure the array has a NULL */ - OBJ_RELEASE(jdata); + if (1 < j) { + opal_pointer_array_set_item(orte_job_data, j, NULL); /* ensure the array has a NULL */ + OBJ_RELEASE(jdata); + } continue; } /* if the job is flagged to not be monitored, skip it */ @@ -1356,6 +1363,25 @@ CHECK_DAEMONS: * wasn't already set by an error condition */ ORTE_UPDATE_EXIT_STATUS(0); + /* provide a notifier message if that framework is active - ignored otherwise */ + if (NULL != (job = (orte_job_t*)opal_pointer_array_get_item(orte_job_data, 1))) { + if (NULL == job->name) { + job->name = strdup(orte_process_info.nodename); + } + if (NULL == job->instance) { + asprintf(&job->instance, "%d", orte_process_info.pid); + } + if (0 == orte_exit_status) { + asprintf(&msg, "Job %s:%s complete", job->name, job->instance); + orte_notifier.log(ORTE_NOTIFIER_INFO, 0, msg); + } else { + asprintf(&msg, "Job %s:%s terminated abnormally", job->name, job->instance); + orte_notifier.log(ORTE_NOTIFIER_ALERT, orte_exit_status, msg); + } + free(msg); + /* this job object will be release during finalize */ + } + orte_jobs_complete(); /* if I am the only daemon alive, then I can exit now */ if (0 == orte_routed.num_routes()) { diff --git a/orte/mca/notifier/hnp/notifier_hnp_module.c b/orte/mca/notifier/hnp/notifier_hnp_module.c index 8692686e66..6b3cc6e834 100644 --- a/orte/mca/notifier/hnp/notifier_hnp_module.c +++ b/orte/mca/notifier/hnp/notifier_hnp_module.c @@ -37,15 +37,12 @@ #include "opal/dss/dss.h" #include "opal/dss/dss_types.h" +#include "orte/util/show_help.h" #include "orte/runtime/orte_globals.h" #include "orte/mca/errmgr/errmgr.h" #include "orte/mca/notifier/base/base.h" #include "notifier_hnp.h" -/* Global variables */ -opal_pointer_array_t orte_notifier_hnp_tables; -opal_mutex_t orte_notifier_hnp_tables_lock; - /* Static API's */ static int init(void); static void finalize(void); @@ -258,19 +255,6 @@ static int init(void) return rc; } - /* Construct a list of SOS tables, one for each process. - ADK: Since we are not doing proper error trace analysis - and/or aggregation, each process maintains a separate SOS - table and individually sends each entry in the table to - the HNP. */ - /* - OBJ_CONSTRUCT(&orte_notifier_hnp_tables, opal_pointer_array_t); - opal_pointer_array_init(&orte_notifier_hnp_tables, - orte_process_info.num_procs, - INT32_MAX, 8); - OBJ_CONSTRUCT(&orte_notifier_hnp_tables_lock, opal_mutex_t); - */ - #if OPAL_ENABLE_DEBUG /* If we're debugging, also add an exception handler -- just to watch for problems in the RML */ @@ -290,9 +274,6 @@ static void finalize(void) { /* If I'm the HNP, then cancel the non-blocking RML receive */ if (ORTE_PROC_IS_HNP) { - OBJ_DESTRUCT(&orte_notifier_hnp_tables); - OBJ_DESTRUCT(&orte_notifier_hnp_tables_lock); - orte_rml.recv_cancel(ORTE_NAME_WILDCARD, ORTE_RML_TAG_NOTIFIER_HNP); } } @@ -305,8 +286,13 @@ static void mylog(orte_notifier_base_severity_t severity, int errcode, /* If there was a message, output it */ vasprintf(&output, msg, ap); - if (NULL != output && !ORTE_PROC_IS_HNP) { - send_command(severity, errcode, output); + if (NULL != output) { + if (ORTE_PROC_IS_HNP) { + /* output it locally */ + orte_show_help("opal_sos_reporter.txt", "notifier message", false, output); + } else { + send_command(severity, errcode, output); + } free(output); } } @@ -318,8 +304,13 @@ static void myhelplog(orte_notifier_base_severity_t severity, int errcode, output = opal_show_help_vstring(filename, topic, false, ap); - if (NULL != output && !ORTE_PROC_IS_HNP) { - send_command(severity, errcode, output); + if (NULL != output) { + if (ORTE_PROC_IS_HNP) { + /* output it locally */ + orte_show_help("opal_sos_reporter.txt", "notifier message", false, output); + } else { + send_command(severity, errcode, output); + } free(output); } } @@ -330,13 +321,23 @@ static void mypeerlog(orte_notifier_base_severity_t severity, int errcode, { char *buf = orte_notifier_base_peer_log(errcode, peer_proc, msg, ap); - if (NULL != buf && !ORTE_PROC_IS_HNP) { - send_command(severity, errcode, buf); + if (NULL != buf) { + if (ORTE_PROC_IS_HNP) { + /* output it locally */ + orte_show_help("opal_sos_reporter.txt", "notifier message", false, buf); + } else { + send_command(severity, errcode, buf); + } free(buf); } } static void myeventlog(const char *msg) { - send_command(ORTE_NOTIFIER_NOTICE, ORTE_SUCCESS, (char *)msg); + if (ORTE_PROC_IS_HNP) { + /* output it locally */ + orte_show_help("opal_sos_reporter.txt", "notifier message", false, (char*)msg); + } else { + send_command(ORTE_NOTIFIER_NOTICE, ORTE_SUCCESS, (char *)msg); + } } diff --git a/orte/tools/orte-info/components.c b/orte/tools/orte-info/components.c index 647385eb8b..276e3522b0 100644 --- a/orte/tools/orte-info/components.c +++ b/orte/tools/orte-info/components.c @@ -53,6 +53,7 @@ #endif #include "opal/runtime/opal.h" #include "opal/dss/dss.h" +#include "opal/mca/if/base/base.h" #include "orte/mca/errmgr/errmgr.h" #include "orte/mca/errmgr/base/base.h" @@ -298,6 +299,15 @@ void orte_info_open_components(void) map->components = &opal_crs_base_components_available; opal_pointer_array_add(&component_map, map); #endif + + if (OPAL_SUCCESS != opal_if_base_open()) { + goto error; + } + map = OBJ_NEW(orte_info_component_map_t); + map->type = strdup("if"); + map->components = &opal_if_components; + opal_pointer_array_add(&component_map, map); + /* OPAL's installdirs base open has already been called as part of * opal_init_util() back in main(). diff --git a/orte/tools/orte-info/orte-info.c b/orte/tools/orte-info/orte-info.c index 2b40ce4f6a..537a2fe6f9 100644 --- a/orte/tools/orte-info/orte-info.c +++ b/orte/tools/orte-info/orte-info.c @@ -196,6 +196,7 @@ int main(int argc, char *argv[]) #if OPAL_ENABLE_FT_CR == 1 opal_pointer_array_add(&mca_types, "crs"); #endif + opal_pointer_array_add(&mca_types, "if"); #if !ORTE_DISABLE_FULL_SUPPORT opal_pointer_array_add(&mca_types, "debugger"); diff --git a/orte/tools/wrappers/orte_wrapper_script.in b/orte/tools/wrappers/orte_wrapper_script.in index 2fad9c2e69..6a203d7c40 100644 --- a/orte/tools/wrappers/orte_wrapper_script.in +++ b/orte/tools/wrappers/orte_wrapper_script.in @@ -2,10 +2,11 @@ # -*- perl -*- # # Copyright (c) 2009-2010 Cisco Systems, Inc. All rights reserved. +# Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved. # $COPYRIGHT$ -# +# # Additional copyrights may follow -# +# # $HEADER$ # @@ -30,7 +31,9 @@ my $CXX = "@CXX@"; my $extra_includes = "@ORTE_WRAPPER_EXTRA_INCLUDES@"; my $extra_cppflags = "@ORTE_WRAPPER_EXTRA_CPPFLAGS@"; my $extra_cflags = "@ORTE_WRAPPER_EXTRA_CFLAGS@"; +my $extra_cflags_prefix = "@ORTE_WRAPPER_EXTRA_CFLAGS_PREFIX@"; my $extra_cxxflags = "@ORTE_WRAPPER_EXTRA_CXXFLAGS@"; +my $extra_cxxflags_prefix = "@ORTE_WRAPPER_EXTRA_CXXFLAGS_PREFIX@"; my $extra_ldflags = "@ORTE_WRAPPER_EXTRA_LDFLAGS@"; my $extra_libs = "@ORTE_WRAPPER_EXTRA_LIBS@"; #my $cxx_lib = "@ORTE_WRAPPER_CXX_LIB@"; @@ -43,6 +46,7 @@ my $lang = "none"; my $comp = ""; # this is a sentinal from configure my $preproc_flags = $include_flag . $includedir; my $comp_flags = ""; +my $comp_flags_prefix = ""; my $linker_flags = $libdir_flag . $libdir . " " . $extra_ldflags; my $libs = "-lopen-rte -lopen-pal " . $extra_libs; @@ -78,12 +82,14 @@ if (basename($0) eq "ortecc") { $comp = check_env("CC", $CC); $preproc_flags .= " " . add_extra_includes(); $comp_flags = $extra_cflags; + $comp_flags_prefix = $extra_cflags_prefix; # no special libs for C } elsif (basename($0) eq "ortec++") { $lang = "C++"; $comp = check_env("CXX", $CXX); $preproc_flags .= " " . add_extra_includes(); $comp_flags = $extra_cxxflags; + $comp_flags_prefix = $extra_cxxflags_prefix; # $libs = $cxx_lib . " " . $libs; } @@ -142,8 +148,12 @@ my @exec_argv = (); # assemble command push(@exec_argv, split(' ', $comp)); -# Per https://svn.open-mpi.org/trac/ompi/ticket/2201, add all the user -# arguments before anything else. +# Per tickets https://svn.open-mpi.org/trac/ompi/ticket/2474, and +# https://svn.open-mpi.org/trac/ompi/ticket/2201, construct command +# with some system arguments before user arguments and some after. +if ($want_compile == 1) { + push(@exec_argv, split(' ', $comp_flags_prefix)); +} push(@exec_argv, @appargs); if ($want_preproc == 1) { push(@exec_argv, split(' ', $preproc_flags)); diff --git a/orte/tools/wrappers/ortec++-wrapper-data.txt.in b/orte/tools/wrappers/ortec++-wrapper-data.txt.in index 8240f0f4be..b262d12089 100644 --- a/orte/tools/wrappers/ortec++-wrapper-data.txt.in +++ b/orte/tools/wrappers/ortec++-wrapper-data.txt.in @@ -14,6 +14,7 @@ compiler_flags_env=CXXFLAGS compiler=@CXX@ extra_includes=@ORTE_WRAPPER_EXTRA_INCLUDES@ preprocessor_flags=@ORTE_WRAPPER_EXTRA_CPPFLAGS@ +compiler_flags_prefix=@ORTE_WRAPPER_EXTRA_CXXFLAGS_PREFIX@ compiler_flags=@ORTE_WRAPPER_EXTRA_CXXFLAGS@ linker_flags=@ORTE_WRAPPER_EXTRA_LDFLAGS@ libs=-lopen-rte @ORTE_WRAPPER_EXTRA_LIBS@ diff --git a/orte/tools/wrappers/ortecc-wrapper-data.txt.in b/orte/tools/wrappers/ortecc-wrapper-data.txt.in index 831d87d578..d030f1ab4d 100644 --- a/orte/tools/wrappers/ortecc-wrapper-data.txt.in +++ b/orte/tools/wrappers/ortecc-wrapper-data.txt.in @@ -14,6 +14,7 @@ compiler_flags_env=CFLAGS compiler=@CC@ extra_includes=@ORTE_WRAPPER_EXTRA_INCLUDES@ preprocessor_flags=@ORTE_WRAPPER_EXTRA_CPPFLAGS@ +compiler_flags_prefix=@ORTE_WRAPPER_EXTRA_CFLAGS_PREFIX@ compiler_flags=@ORTE_WRAPPER_EXTRA_CFLAGS@ linker_flags=@ORTE_WRAPPER_EXTRA_LDFLAGS@ libs=-lopen-rte @ORTE_WRAPPER_EXTRA_LIBS@