2014-05-15 19:59:41 +04:00
|
|
|
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
|
2004-01-15 02:24:15 +03:00
|
|
|
/*
|
2005-11-05 22:57:48 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
2007-04-25 05:55:40 +04:00
|
|
|
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
2005-11-05 22:57:48 +03:00
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2015-06-24 06:59:57 +03:00
|
|
|
* Copyright (c) 2004-2009 High Performance Computing Center Stuttgart,
|
2004-11-28 23:09:25 +03:00
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 15:43:37 +03:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2008-11-05 21:45:42 +03:00
|
|
|
* Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved.
|
2015-02-12 23:09:49 +03:00
|
|
|
* Copyright (c) 2010-2015 Cisco Systems, Inc. All rights reserved.
|
2014-05-15 19:59:41 +04:00
|
|
|
* Copyright (c) 2014 Los Alamos National Security, LLC. All rights
|
|
|
|
* reserved.
|
2016-10-03 10:32:22 +03:00
|
|
|
* Copyright (c) 2015-2016 Research Organization for Information Science
|
2015-10-01 08:03:08 +03:00
|
|
|
* and Technology (RIST). All rights reserved.
|
2004-11-22 04:38:40 +03:00
|
|
|
* $COPYRIGHT$
|
2015-06-24 06:59:57 +03:00
|
|
|
*
|
2004-11-22 04:38:40 +03:00
|
|
|
* Additional copyrights may follow
|
2015-06-24 06:59:57 +03:00
|
|
|
*
|
2004-01-15 02:24:15 +03:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "opal_config.h"
|
2007-05-17 05:17:59 +04:00
|
|
|
|
2004-01-14 21:24:30 +03:00
|
|
|
#include <string.h>
|
2004-10-20 05:03:09 +04:00
|
|
|
#ifdef HAVE_UNISTD_H
|
2004-01-14 21:24:30 +03:00
|
|
|
#include <unistd.h>
|
2004-10-20 05:03:09 +04:00
|
|
|
#endif
|
2004-01-14 21:24:30 +03:00
|
|
|
#include <errno.h>
|
2004-10-20 05:03:09 +04:00
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
2004-01-14 21:24:30 +03:00
|
|
|
#include <sys/types.h>
|
2004-10-20 05:03:09 +04:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_SOCKET_H
|
2004-01-14 21:24:30 +03:00
|
|
|
#include <sys/socket.h>
|
2004-10-20 05:03:09 +04:00
|
|
|
#endif
|
2005-03-28 15:55:57 +04:00
|
|
|
#ifdef HAVE_SYS_SOCKIO_H
|
|
|
|
#include <sys/sockio.h>
|
|
|
|
#endif
|
2004-10-20 05:03:09 +04:00
|
|
|
#ifdef HAVE_SYS_IOCTL_H
|
2004-01-14 21:24:30 +03:00
|
|
|
#include <sys/ioctl.h>
|
2004-10-20 05:03:09 +04:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_NETINET_IN_H
|
2004-01-14 21:24:30 +03:00
|
|
|
#include <netinet/in.h>
|
2004-10-20 05:03:09 +04:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_ARPA_INET_H
|
2004-01-14 21:24:30 +03:00
|
|
|
#include <arpa/inet.h>
|
2004-10-20 05:03:09 +04:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_NET_IF_H
|
2007-01-24 20:31:49 +03:00
|
|
|
#if defined(__APPLE__) && defined(_LP64)
|
|
|
|
/* Apple engineering suggested using options align=power as a
|
|
|
|
workaround for a bug in OS X 10.4 (Tiger) that prevented ioctl(...,
|
|
|
|
SIOCGIFCONF, ...) from working properly in 64 bit mode on Power PC.
|
|
|
|
It turns out that the underlying issue is the size of struct
|
|
|
|
ifconf, which the kernel expects to be 12 and natural 64 bit
|
|
|
|
alignment would make 16. The same bug appears in 64 bit mode on
|
|
|
|
Intel macs, but align=power is a no-op there, so instead, use the
|
|
|
|
pack pragma to instruct the compiler to pack on 4 byte words, which
|
|
|
|
has the same effect as align=power for our needs and works on both
|
|
|
|
Intel and Power PC Macs. */
|
|
|
|
#pragma pack(push,4)
|
2005-08-02 19:14:41 +04:00
|
|
|
#endif
|
2004-01-14 21:24:30 +03:00
|
|
|
#include <net/if.h>
|
2007-01-24 20:31:49 +03:00
|
|
|
#if defined(__APPLE__) && defined(_LP64)
|
|
|
|
#pragma pack(pop)
|
2005-08-02 19:14:41 +04:00
|
|
|
#endif
|
2004-10-20 05:03:09 +04:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_NETDB_H
|
2004-01-14 21:24:30 +03:00
|
|
|
#include <netdb.h>
|
2004-10-20 05:03:09 +04:00
|
|
|
#endif
|
2007-04-25 05:55:40 +04:00
|
|
|
#ifdef HAVE_IFADDRS_H
|
|
|
|
#include <ifaddrs.h>
|
|
|
|
#endif
|
2011-06-05 23:16:42 +04:00
|
|
|
#include <ctype.h>
|
2007-04-25 05:55:40 +04:00
|
|
|
|
2005-07-03 20:22:16 +04:00
|
|
|
#include "opal/class/opal_list.h"
|
2005-07-04 05:36:20 +04:00
|
|
|
#include "opal/util/if.h"
|
2013-05-14 07:37:44 +04:00
|
|
|
#include "opal/util/net.h"
|
2005-07-04 03:31:27 +04:00
|
|
|
#include "opal/util/output.h"
|
2009-10-09 19:24:41 +04:00
|
|
|
#include "opal/util/argv.h"
|
2011-06-05 23:16:42 +04:00
|
|
|
#include "opal/util/show_help.h"
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "opal/constants.h"
|
2010-09-22 05:11:40 +04:00
|
|
|
|
|
|
|
#include "opal/mca/if/base/base.h"
|
2004-01-14 21:24:30 +03:00
|
|
|
|
2005-07-13 17:35:21 +04:00
|
|
|
#ifdef HAVE_STRUCT_SOCKADDR_IN
|
2005-07-13 08:16:03 +04:00
|
|
|
|
2007-04-25 05:55:40 +04:00
|
|
|
#ifndef MIN
|
|
|
|
# define MIN(a,b) ((a) < (b) ? (a) : (b))
|
|
|
|
#endif
|
2015-06-24 06:59:57 +03:00
|
|
|
|
2004-01-15 02:24:15 +03:00
|
|
|
/*
|
2015-06-24 06:59:57 +03:00
|
|
|
* Look for interface by name and returns its address
|
2004-01-15 02:24:15 +03:00
|
|
|
* as a dotted decimal formatted string.
|
|
|
|
*/
|
2004-01-14 21:24:30 +03:00
|
|
|
|
2007-05-17 05:17:59 +04:00
|
|
|
int opal_ifnametoaddr(const char* if_name, struct sockaddr* addr, int length)
|
2004-01-14 21:24:30 +03:00
|
|
|
{
|
2005-07-04 05:36:20 +04:00
|
|
|
opal_if_t* intf;
|
2010-09-22 05:11:40 +04:00
|
|
|
|
2010-07-27 17:46:55 +04:00
|
|
|
for (intf = (opal_if_t*)opal_list_get_first(&opal_if_list);
|
2005-07-04 05:36:20 +04:00
|
|
|
intf != (opal_if_t*)opal_list_get_end(&opal_if_list);
|
|
|
|
intf = (opal_if_t*)opal_list_get_next(intf)) {
|
2010-07-27 17:46:55 +04:00
|
|
|
if (strcmp(intf->if_name, if_name) == 0) {
|
2004-01-15 03:57:33 +03:00
|
|
|
memcpy(addr, &intf->if_addr, length);
|
2006-02-12 04:33:29 +03:00
|
|
|
return OPAL_SUCCESS;
|
2004-01-14 21:24:30 +03:00
|
|
|
}
|
|
|
|
}
|
2006-02-12 04:33:29 +03:00
|
|
|
return OPAL_ERROR;
|
2004-01-14 21:24:30 +03:00
|
|
|
}
|
|
|
|
|
2004-01-29 18:34:47 +03:00
|
|
|
|
|
|
|
/*
|
2015-06-24 06:59:57 +03:00
|
|
|
* Look for interface by name and returns its
|
2007-04-25 05:55:40 +04:00
|
|
|
* corresponding opal_list index.
|
2004-01-29 18:34:47 +03:00
|
|
|
*/
|
|
|
|
|
2005-07-04 05:36:20 +04:00
|
|
|
int opal_ifnametoindex(const char* if_name)
|
2004-01-29 18:34:47 +03:00
|
|
|
{
|
2005-07-04 05:36:20 +04:00
|
|
|
opal_if_t* intf;
|
2010-09-22 05:11:40 +04:00
|
|
|
|
2010-07-27 17:46:55 +04:00
|
|
|
for (intf = (opal_if_t*)opal_list_get_first(&opal_if_list);
|
2005-07-04 05:36:20 +04:00
|
|
|
intf != (opal_if_t*)opal_list_get_end(&opal_if_list);
|
|
|
|
intf = (opal_if_t*)opal_list_get_next(intf)) {
|
2010-07-27 17:46:55 +04:00
|
|
|
if (strcmp(intf->if_name, if_name) == 0) {
|
2004-01-29 18:34:47 +03:00
|
|
|
return intf->if_index;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-01-15 02:24:15 +03:00
|
|
|
/*
|
2015-06-24 06:59:57 +03:00
|
|
|
* Look for interface by name and returns its
|
2007-04-25 05:55:40 +04:00
|
|
|
* corresponding kernel index.
|
|
|
|
*/
|
|
|
|
|
2009-04-02 22:35:09 +04:00
|
|
|
int16_t opal_ifnametokindex(const char* if_name)
|
2007-04-25 05:55:40 +04:00
|
|
|
{
|
|
|
|
opal_if_t* intf;
|
2010-09-22 05:11:40 +04:00
|
|
|
|
2010-07-27 17:46:55 +04:00
|
|
|
for (intf = (opal_if_t*)opal_list_get_first(&opal_if_list);
|
2007-04-25 05:55:40 +04:00
|
|
|
intf != (opal_if_t*)opal_list_get_end(&opal_if_list);
|
|
|
|
intf = (opal_if_t*)opal_list_get_next(intf)) {
|
2010-07-27 17:46:55 +04:00
|
|
|
if (strcmp(intf->if_name, if_name) == 0) {
|
2007-04-25 05:55:40 +04:00
|
|
|
return intf->if_kernel_index;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2015-06-24 06:59:57 +03:00
|
|
|
* Look for interface by opal_list index and returns its
|
2007-04-25 05:55:40 +04:00
|
|
|
* corresponding kernel index.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int opal_ifindextokindex(int if_index)
|
|
|
|
{
|
|
|
|
opal_if_t* intf;
|
2010-09-22 05:11:40 +04:00
|
|
|
|
2010-07-27 17:46:55 +04:00
|
|
|
for (intf = (opal_if_t*)opal_list_get_first(&opal_if_list);
|
2007-04-25 05:55:40 +04:00
|
|
|
intf != (opal_if_t*)opal_list_get_end(&opal_if_list);
|
|
|
|
intf = (opal_if_t*)opal_list_get_next(intf)) {
|
2010-07-27 17:46:55 +04:00
|
|
|
if (if_index == intf->if_index) {
|
2007-04-25 05:55:40 +04:00
|
|
|
return intf->if_kernel_index;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Attempt to resolve the adddress (given as either IPv4/IPv6 string
|
|
|
|
* or hostname) and lookup corresponding interface.
|
2004-01-15 02:24:15 +03:00
|
|
|
*/
|
2004-01-14 21:24:30 +03:00
|
|
|
|
2005-07-04 05:36:20 +04:00
|
|
|
int opal_ifaddrtoname(const char* if_addr, char* if_name, int length)
|
2004-01-14 21:24:30 +03:00
|
|
|
{
|
2005-07-04 05:36:20 +04:00
|
|
|
opal_if_t* intf;
|
2007-04-25 05:55:40 +04:00
|
|
|
int error;
|
2008-01-17 15:29:12 +03:00
|
|
|
struct addrinfo hints, *res = NULL, *r;
|
2004-10-22 20:06:05 +04:00
|
|
|
|
2008-04-17 17:50:59 +04:00
|
|
|
/* if the user asked us not to resolve interfaces, then just return */
|
2010-09-22 05:11:40 +04:00
|
|
|
if (opal_if_do_not_resolve) {
|
2008-04-17 17:50:59 +04:00
|
|
|
/* return not found so ifislocal will declare
|
|
|
|
* the node to be non-local
|
|
|
|
*/
|
|
|
|
return OPAL_ERR_NOT_FOUND;
|
|
|
|
}
|
2015-06-24 06:59:57 +03:00
|
|
|
|
2007-04-25 05:55:40 +04:00
|
|
|
memset(&hints, 0, sizeof(hints));
|
|
|
|
hints.ai_family = PF_UNSPEC;
|
|
|
|
hints.ai_socktype = SOCK_STREAM;
|
|
|
|
error = getaddrinfo(if_addr, NULL, &hints, &res);
|
|
|
|
|
|
|
|
if (error) {
|
2008-01-17 13:01:52 +03:00
|
|
|
if (NULL != res) {
|
|
|
|
freeaddrinfo (res);
|
|
|
|
}
|
2007-04-25 05:55:40 +04:00
|
|
|
return OPAL_ERR_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (r = res; r != NULL; r = r->ai_next) {
|
2010-07-27 17:46:55 +04:00
|
|
|
for (intf = (opal_if_t*)opal_list_get_first(&opal_if_list);
|
2007-04-25 05:55:40 +04:00
|
|
|
intf != (opal_if_t*)opal_list_get_end(&opal_if_list);
|
|
|
|
intf = (opal_if_t*)opal_list_get_next(intf)) {
|
2015-06-24 06:59:57 +03:00
|
|
|
|
2007-04-25 05:55:40 +04:00
|
|
|
if (AF_INET == r->ai_family) {
|
|
|
|
struct sockaddr_in ipv4;
|
|
|
|
struct sockaddr_in *inaddr;
|
|
|
|
|
|
|
|
inaddr = (struct sockaddr_in*) &intf->if_addr;
|
|
|
|
memcpy (&ipv4, r->ai_addr, r->ai_addrlen);
|
2015-06-24 06:59:57 +03:00
|
|
|
|
2007-04-25 05:55:40 +04:00
|
|
|
if (inaddr->sin_addr.s_addr == ipv4.sin_addr.s_addr) {
|
|
|
|
strncpy(if_name, intf->if_name, length);
|
2015-02-12 23:09:49 +03:00
|
|
|
freeaddrinfo (res);
|
2007-04-25 05:55:40 +04:00
|
|
|
return OPAL_SUCCESS;
|
|
|
|
}
|
As per the RFC, bring in the ORTE async progress code and the rewrite of OOB:
*** THIS RFC INCLUDES A MINOR CHANGE TO THE MPI-RTE INTERFACE ***
Note: during the course of this work, it was necessary to completely separate the MPI and RTE progress engines. There were multiple places in the MPI layer where ORTE_WAIT_FOR_COMPLETION was being used. A new OMPI_WAIT_FOR_COMPLETION macro was created (defined in ompi/mca/rte/rte.h) that simply cycles across opal_progress until the provided flag becomes false. Places where the MPI layer blocked waiting for RTE to complete an event have been modified to use this macro.
***************************************************************************************
I am reissuing this RFC because of the time that has passed since its original release. Since its initial release and review, I have debugged it further to ensure it fully supports tests like loop_spawn. It therefore seems ready for merge back to the trunk. Given its prior review, I have set the timeout for one week.
The code is in https://bitbucket.org/rhc/ompi-oob2
WHAT: Rewrite of ORTE OOB
WHY: Support asynchronous progress and a host of other features
WHEN: Wed, August 21
SYNOPSIS:
The current OOB has served us well, but a number of limitations have been identified over the years. Specifically:
* it is only progressed when called via opal_progress, which can lead to hangs or recursive calls into libevent (which is not supported by that code)
* we've had issues when multiple NICs are available as the code doesn't "shift" messages between transports - thus, all nodes had to be available via the same TCP interface.
* the OOB "unloads" incoming opal_buffer_t objects during the transmission, thus preventing use of OBJ_RETAIN in the code when repeatedly sending the same message to multiple recipients
* there is no failover mechanism across NICs - if the selected NIC (or its attached switch) fails, we are forced to abort
* only one transport (i.e., component) can be "active"
The revised OOB resolves these problems:
* async progress is used for all application processes, with the progress thread blocking in the event library
* each available TCP NIC is supported by its own TCP module. The ability to asynchronously progress each module independently is provided, but not enabled by default (a runtime MCA parameter turns it "on")
* multi-address TCP NICs (e.g., a NIC with both an IPv4 and IPv6 address, or with virtual interfaces) are supported - reachability is determined by comparing the contact info for a peer against all addresses within the range covered by the address/mask pairs for the NIC.
* a message that arrives on one TCP NIC is automatically shifted to whatever NIC that is connected to the next "hop" if that peer cannot be reached by the incoming NIC. If no TCP module will reach the peer, then the OOB attempts to send the message via all other available components - if none can reach the peer, then an "error" is reported back to the RML, which then calls the errmgr for instructions.
* opal_buffer_t now conforms to standard object rules re OBJ_RETAIN as we no longer "unload" the incoming object
* NIC failure is reported to the TCP component, which then tries to resend the message across any other available TCP NIC. If that doesn't work, then the message is given back to the OOB base to try using other components. If all that fails, then the error is reported to the RML, which reports to the errmgr for instructions
* obviously from the above, multiple OOB components (e.g., TCP and UD) can be active in parallel
* the matching code has been moved to the RML (and out of the OOB/TCP component) so it is independent of transport
* routing is done by the individual OOB modules (as opposed to the RML). Thus, both routed and non-routed transports can simultaneously be active
* all blocking send/recv APIs have been removed. Everything operates asynchronously.
KNOWN LIMITATIONS:
* although provision is made for component failover as described above, the code for doing so has not been fully implemented yet. At the moment, if all connections for a given peer fail, the errmgr is notified of a "lost connection", which by default results in termination of the job if it was a lifeline
* the IPv6 code is present and compiles, but is not complete. Since the current IPv6 support in the OOB doesn't work anyway, I don't consider this a blocker
* routing is performed at the individual module level, yet the active routed component is selected on a global basis. We probably should update that to reflect that different transports may need/choose to route in different ways
* obviously, not every error path has been tested nor necessarily covered
* determining abnormal termination is more challenging than in the old code as we now potentially have multiple ways of connecting to a process. Ideally, we would declare "connection failed" when *all* transports can no longer reach the process, but that requires some additional (possibly complex) code. For now, the code replicates the old behavior only somewhat modified - i.e., if a module sees its connection fail, it checks to see if it is a lifeline. If so, it notifies the errmgr that the lifeline is lost - otherwise, it notifies the errmgr that a non-lifeline connection was lost.
* reachability is determined solely on the basis of a shared subnet address/mask - more sophisticated algorithms (e.g., the one used in the tcp btl) are required to handle routing via gateways
* the RML needs to assign sequence numbers to each message on a per-peer basis. The receiving RML will then deliver messages in order, thus preventing out-of-order messaging in the case where messages travel across different transports or a message needs to be redirected/resent due to failure of a NIC
This commit was SVN r29058.
2013-08-22 20:37:40 +04:00
|
|
|
}
|
|
|
|
#if OPAL_ENABLE_IPV6
|
|
|
|
else {
|
2007-05-17 05:17:59 +04:00
|
|
|
if (IN6_ARE_ADDR_EQUAL(&((struct sockaddr_in6*) &intf->if_addr)->sin6_addr,
|
2007-04-25 05:55:40 +04:00
|
|
|
&((struct sockaddr_in6*) r->ai_addr)->sin6_addr)) {
|
|
|
|
strncpy(if_name, intf->if_name, length);
|
2015-02-12 23:09:49 +03:00
|
|
|
freeaddrinfo (res);
|
2007-04-25 05:55:40 +04:00
|
|
|
return OPAL_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
As per the RFC, bring in the ORTE async progress code and the rewrite of OOB:
*** THIS RFC INCLUDES A MINOR CHANGE TO THE MPI-RTE INTERFACE ***
Note: during the course of this work, it was necessary to completely separate the MPI and RTE progress engines. There were multiple places in the MPI layer where ORTE_WAIT_FOR_COMPLETION was being used. A new OMPI_WAIT_FOR_COMPLETION macro was created (defined in ompi/mca/rte/rte.h) that simply cycles across opal_progress until the provided flag becomes false. Places where the MPI layer blocked waiting for RTE to complete an event have been modified to use this macro.
***************************************************************************************
I am reissuing this RFC because of the time that has passed since its original release. Since its initial release and review, I have debugged it further to ensure it fully supports tests like loop_spawn. It therefore seems ready for merge back to the trunk. Given its prior review, I have set the timeout for one week.
The code is in https://bitbucket.org/rhc/ompi-oob2
WHAT: Rewrite of ORTE OOB
WHY: Support asynchronous progress and a host of other features
WHEN: Wed, August 21
SYNOPSIS:
The current OOB has served us well, but a number of limitations have been identified over the years. Specifically:
* it is only progressed when called via opal_progress, which can lead to hangs or recursive calls into libevent (which is not supported by that code)
* we've had issues when multiple NICs are available as the code doesn't "shift" messages between transports - thus, all nodes had to be available via the same TCP interface.
* the OOB "unloads" incoming opal_buffer_t objects during the transmission, thus preventing use of OBJ_RETAIN in the code when repeatedly sending the same message to multiple recipients
* there is no failover mechanism across NICs - if the selected NIC (or its attached switch) fails, we are forced to abort
* only one transport (i.e., component) can be "active"
The revised OOB resolves these problems:
* async progress is used for all application processes, with the progress thread blocking in the event library
* each available TCP NIC is supported by its own TCP module. The ability to asynchronously progress each module independently is provided, but not enabled by default (a runtime MCA parameter turns it "on")
* multi-address TCP NICs (e.g., a NIC with both an IPv4 and IPv6 address, or with virtual interfaces) are supported - reachability is determined by comparing the contact info for a peer against all addresses within the range covered by the address/mask pairs for the NIC.
* a message that arrives on one TCP NIC is automatically shifted to whatever NIC that is connected to the next "hop" if that peer cannot be reached by the incoming NIC. If no TCP module will reach the peer, then the OOB attempts to send the message via all other available components - if none can reach the peer, then an "error" is reported back to the RML, which then calls the errmgr for instructions.
* opal_buffer_t now conforms to standard object rules re OBJ_RETAIN as we no longer "unload" the incoming object
* NIC failure is reported to the TCP component, which then tries to resend the message across any other available TCP NIC. If that doesn't work, then the message is given back to the OOB base to try using other components. If all that fails, then the error is reported to the RML, which reports to the errmgr for instructions
* obviously from the above, multiple OOB components (e.g., TCP and UD) can be active in parallel
* the matching code has been moved to the RML (and out of the OOB/TCP component) so it is independent of transport
* routing is done by the individual OOB modules (as opposed to the RML). Thus, both routed and non-routed transports can simultaneously be active
* all blocking send/recv APIs have been removed. Everything operates asynchronously.
KNOWN LIMITATIONS:
* although provision is made for component failover as described above, the code for doing so has not been fully implemented yet. At the moment, if all connections for a given peer fail, the errmgr is notified of a "lost connection", which by default results in termination of the job if it was a lifeline
* the IPv6 code is present and compiles, but is not complete. Since the current IPv6 support in the OOB doesn't work anyway, I don't consider this a blocker
* routing is performed at the individual module level, yet the active routed component is selected on a global basis. We probably should update that to reflect that different transports may need/choose to route in different ways
* obviously, not every error path has been tested nor necessarily covered
* determining abnormal termination is more challenging than in the old code as we now potentially have multiple ways of connecting to a process. Ideally, we would declare "connection failed" when *all* transports can no longer reach the process, but that requires some additional (possibly complex) code. For now, the code replicates the old behavior only somewhat modified - i.e., if a module sees its connection fail, it checks to see if it is a lifeline. If so, it notifies the errmgr that the lifeline is lost - otherwise, it notifies the errmgr that a non-lifeline connection was lost.
* reachability is determined solely on the basis of a shared subnet address/mask - more sophisticated algorithms (e.g., the one used in the tcp btl) are required to handle routing via gateways
* the RML needs to assign sequence numbers to each message on a per-peer basis. The receiving RML will then deliver messages in order, thus preventing out-of-order messaging in the case where messages travel across different transports or a message needs to be redirected/resent due to failure of a NIC
This commit was SVN r29058.
2013-08-22 20:37:40 +04:00
|
|
|
#endif
|
2007-04-25 05:55:40 +04:00
|
|
|
}
|
2008-01-17 15:29:12 +03:00
|
|
|
}
|
|
|
|
if (NULL != res) {
|
|
|
|
freeaddrinfo (res);
|
|
|
|
}
|
2004-01-14 21:24:30 +03:00
|
|
|
|
As per the RFC, bring in the ORTE async progress code and the rewrite of OOB:
*** THIS RFC INCLUDES A MINOR CHANGE TO THE MPI-RTE INTERFACE ***
Note: during the course of this work, it was necessary to completely separate the MPI and RTE progress engines. There were multiple places in the MPI layer where ORTE_WAIT_FOR_COMPLETION was being used. A new OMPI_WAIT_FOR_COMPLETION macro was created (defined in ompi/mca/rte/rte.h) that simply cycles across opal_progress until the provided flag becomes false. Places where the MPI layer blocked waiting for RTE to complete an event have been modified to use this macro.
***************************************************************************************
I am reissuing this RFC because of the time that has passed since its original release. Since its initial release and review, I have debugged it further to ensure it fully supports tests like loop_spawn. It therefore seems ready for merge back to the trunk. Given its prior review, I have set the timeout for one week.
The code is in https://bitbucket.org/rhc/ompi-oob2
WHAT: Rewrite of ORTE OOB
WHY: Support asynchronous progress and a host of other features
WHEN: Wed, August 21
SYNOPSIS:
The current OOB has served us well, but a number of limitations have been identified over the years. Specifically:
* it is only progressed when called via opal_progress, which can lead to hangs or recursive calls into libevent (which is not supported by that code)
* we've had issues when multiple NICs are available as the code doesn't "shift" messages between transports - thus, all nodes had to be available via the same TCP interface.
* the OOB "unloads" incoming opal_buffer_t objects during the transmission, thus preventing use of OBJ_RETAIN in the code when repeatedly sending the same message to multiple recipients
* there is no failover mechanism across NICs - if the selected NIC (or its attached switch) fails, we are forced to abort
* only one transport (i.e., component) can be "active"
The revised OOB resolves these problems:
* async progress is used for all application processes, with the progress thread blocking in the event library
* each available TCP NIC is supported by its own TCP module. The ability to asynchronously progress each module independently is provided, but not enabled by default (a runtime MCA parameter turns it "on")
* multi-address TCP NICs (e.g., a NIC with both an IPv4 and IPv6 address, or with virtual interfaces) are supported - reachability is determined by comparing the contact info for a peer against all addresses within the range covered by the address/mask pairs for the NIC.
* a message that arrives on one TCP NIC is automatically shifted to whatever NIC that is connected to the next "hop" if that peer cannot be reached by the incoming NIC. If no TCP module will reach the peer, then the OOB attempts to send the message via all other available components - if none can reach the peer, then an "error" is reported back to the RML, which then calls the errmgr for instructions.
* opal_buffer_t now conforms to standard object rules re OBJ_RETAIN as we no longer "unload" the incoming object
* NIC failure is reported to the TCP component, which then tries to resend the message across any other available TCP NIC. If that doesn't work, then the message is given back to the OOB base to try using other components. If all that fails, then the error is reported to the RML, which reports to the errmgr for instructions
* obviously from the above, multiple OOB components (e.g., TCP and UD) can be active in parallel
* the matching code has been moved to the RML (and out of the OOB/TCP component) so it is independent of transport
* routing is done by the individual OOB modules (as opposed to the RML). Thus, both routed and non-routed transports can simultaneously be active
* all blocking send/recv APIs have been removed. Everything operates asynchronously.
KNOWN LIMITATIONS:
* although provision is made for component failover as described above, the code for doing so has not been fully implemented yet. At the moment, if all connections for a given peer fail, the errmgr is notified of a "lost connection", which by default results in termination of the job if it was a lifeline
* the IPv6 code is present and compiles, but is not complete. Since the current IPv6 support in the OOB doesn't work anyway, I don't consider this a blocker
* routing is performed at the individual module level, yet the active routed component is selected on a global basis. We probably should update that to reflect that different transports may need/choose to route in different ways
* obviously, not every error path has been tested nor necessarily covered
* determining abnormal termination is more challenging than in the old code as we now potentially have multiple ways of connecting to a process. Ideally, we would declare "connection failed" when *all* transports can no longer reach the process, but that requires some additional (possibly complex) code. For now, the code replicates the old behavior only somewhat modified - i.e., if a module sees its connection fail, it checks to see if it is a lifeline. If so, it notifies the errmgr that the lifeline is lost - otherwise, it notifies the errmgr that a non-lifeline connection was lost.
* reachability is determined solely on the basis of a shared subnet address/mask - more sophisticated algorithms (e.g., the one used in the tcp btl) are required to handle routing via gateways
* the RML needs to assign sequence numbers to each message on a per-peer basis. The receiving RML will then deliver messages in order, thus preventing out-of-order messaging in the case where messages travel across different transports or a message needs to be redirected/resent due to failure of a NIC
This commit was SVN r29058.
2013-08-22 20:37:40 +04:00
|
|
|
/* if we get here, it wasn't found */
|
2006-02-12 04:33:29 +03:00
|
|
|
return OPAL_ERR_NOT_FOUND;
|
2004-01-14 21:24:30 +03:00
|
|
|
}
|
|
|
|
|
2013-04-25 23:40:34 +04:00
|
|
|
/*
|
|
|
|
* Attempt to resolve the address (given as either IPv4/IPv6 string
|
2013-05-14 07:37:44 +04:00
|
|
|
* or hostname) and return the kernel index of the interface
|
|
|
|
* on the same network as the specified address
|
2013-04-25 23:40:34 +04:00
|
|
|
*/
|
|
|
|
int16_t opal_ifaddrtokindex(const char* if_addr)
|
|
|
|
{
|
|
|
|
opal_if_t* intf;
|
|
|
|
int error;
|
|
|
|
struct addrinfo hints, *res = NULL, *r;
|
2014-05-15 19:59:41 +04:00
|
|
|
int if_kernel_index;
|
As per the RFC, bring in the ORTE async progress code and the rewrite of OOB:
*** THIS RFC INCLUDES A MINOR CHANGE TO THE MPI-RTE INTERFACE ***
Note: during the course of this work, it was necessary to completely separate the MPI and RTE progress engines. There were multiple places in the MPI layer where ORTE_WAIT_FOR_COMPLETION was being used. A new OMPI_WAIT_FOR_COMPLETION macro was created (defined in ompi/mca/rte/rte.h) that simply cycles across opal_progress until the provided flag becomes false. Places where the MPI layer blocked waiting for RTE to complete an event have been modified to use this macro.
***************************************************************************************
I am reissuing this RFC because of the time that has passed since its original release. Since its initial release and review, I have debugged it further to ensure it fully supports tests like loop_spawn. It therefore seems ready for merge back to the trunk. Given its prior review, I have set the timeout for one week.
The code is in https://bitbucket.org/rhc/ompi-oob2
WHAT: Rewrite of ORTE OOB
WHY: Support asynchronous progress and a host of other features
WHEN: Wed, August 21
SYNOPSIS:
The current OOB has served us well, but a number of limitations have been identified over the years. Specifically:
* it is only progressed when called via opal_progress, which can lead to hangs or recursive calls into libevent (which is not supported by that code)
* we've had issues when multiple NICs are available as the code doesn't "shift" messages between transports - thus, all nodes had to be available via the same TCP interface.
* the OOB "unloads" incoming opal_buffer_t objects during the transmission, thus preventing use of OBJ_RETAIN in the code when repeatedly sending the same message to multiple recipients
* there is no failover mechanism across NICs - if the selected NIC (or its attached switch) fails, we are forced to abort
* only one transport (i.e., component) can be "active"
The revised OOB resolves these problems:
* async progress is used for all application processes, with the progress thread blocking in the event library
* each available TCP NIC is supported by its own TCP module. The ability to asynchronously progress each module independently is provided, but not enabled by default (a runtime MCA parameter turns it "on")
* multi-address TCP NICs (e.g., a NIC with both an IPv4 and IPv6 address, or with virtual interfaces) are supported - reachability is determined by comparing the contact info for a peer against all addresses within the range covered by the address/mask pairs for the NIC.
* a message that arrives on one TCP NIC is automatically shifted to whatever NIC that is connected to the next "hop" if that peer cannot be reached by the incoming NIC. If no TCP module will reach the peer, then the OOB attempts to send the message via all other available components - if none can reach the peer, then an "error" is reported back to the RML, which then calls the errmgr for instructions.
* opal_buffer_t now conforms to standard object rules re OBJ_RETAIN as we no longer "unload" the incoming object
* NIC failure is reported to the TCP component, which then tries to resend the message across any other available TCP NIC. If that doesn't work, then the message is given back to the OOB base to try using other components. If all that fails, then the error is reported to the RML, which reports to the errmgr for instructions
* obviously from the above, multiple OOB components (e.g., TCP and UD) can be active in parallel
* the matching code has been moved to the RML (and out of the OOB/TCP component) so it is independent of transport
* routing is done by the individual OOB modules (as opposed to the RML). Thus, both routed and non-routed transports can simultaneously be active
* all blocking send/recv APIs have been removed. Everything operates asynchronously.
KNOWN LIMITATIONS:
* although provision is made for component failover as described above, the code for doing so has not been fully implemented yet. At the moment, if all connections for a given peer fail, the errmgr is notified of a "lost connection", which by default results in termination of the job if it was a lifeline
* the IPv6 code is present and compiles, but is not complete. Since the current IPv6 support in the OOB doesn't work anyway, I don't consider this a blocker
* routing is performed at the individual module level, yet the active routed component is selected on a global basis. We probably should update that to reflect that different transports may need/choose to route in different ways
* obviously, not every error path has been tested nor necessarily covered
* determining abnormal termination is more challenging than in the old code as we now potentially have multiple ways of connecting to a process. Ideally, we would declare "connection failed" when *all* transports can no longer reach the process, but that requires some additional (possibly complex) code. For now, the code replicates the old behavior only somewhat modified - i.e., if a module sees its connection fail, it checks to see if it is a lifeline. If so, it notifies the errmgr that the lifeline is lost - otherwise, it notifies the errmgr that a non-lifeline connection was lost.
* reachability is determined solely on the basis of a shared subnet address/mask - more sophisticated algorithms (e.g., the one used in the tcp btl) are required to handle routing via gateways
* the RML needs to assign sequence numbers to each message on a per-peer basis. The receiving RML will then deliver messages in order, thus preventing out-of-order messaging in the case where messages travel across different transports or a message needs to be redirected/resent due to failure of a NIC
This commit was SVN r29058.
2013-08-22 20:37:40 +04:00
|
|
|
size_t len;
|
2013-04-25 23:40:34 +04:00
|
|
|
|
|
|
|
memset(&hints, 0, sizeof(hints));
|
|
|
|
hints.ai_family = PF_UNSPEC;
|
|
|
|
hints.ai_socktype = SOCK_STREAM;
|
|
|
|
error = getaddrinfo(if_addr, NULL, &hints, &res);
|
|
|
|
|
|
|
|
if (error) {
|
|
|
|
if (NULL != res) {
|
|
|
|
freeaddrinfo (res);
|
|
|
|
}
|
|
|
|
return OPAL_ERR_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (r = res; r != NULL; r = r->ai_next) {
|
2014-05-15 19:59:41 +04:00
|
|
|
OPAL_LIST_FOREACH(intf, &opal_if_list, opal_if_t) {
|
As per the RFC, bring in the ORTE async progress code and the rewrite of OOB:
*** THIS RFC INCLUDES A MINOR CHANGE TO THE MPI-RTE INTERFACE ***
Note: during the course of this work, it was necessary to completely separate the MPI and RTE progress engines. There were multiple places in the MPI layer where ORTE_WAIT_FOR_COMPLETION was being used. A new OMPI_WAIT_FOR_COMPLETION macro was created (defined in ompi/mca/rte/rte.h) that simply cycles across opal_progress until the provided flag becomes false. Places where the MPI layer blocked waiting for RTE to complete an event have been modified to use this macro.
***************************************************************************************
I am reissuing this RFC because of the time that has passed since its original release. Since its initial release and review, I have debugged it further to ensure it fully supports tests like loop_spawn. It therefore seems ready for merge back to the trunk. Given its prior review, I have set the timeout for one week.
The code is in https://bitbucket.org/rhc/ompi-oob2
WHAT: Rewrite of ORTE OOB
WHY: Support asynchronous progress and a host of other features
WHEN: Wed, August 21
SYNOPSIS:
The current OOB has served us well, but a number of limitations have been identified over the years. Specifically:
* it is only progressed when called via opal_progress, which can lead to hangs or recursive calls into libevent (which is not supported by that code)
* we've had issues when multiple NICs are available as the code doesn't "shift" messages between transports - thus, all nodes had to be available via the same TCP interface.
* the OOB "unloads" incoming opal_buffer_t objects during the transmission, thus preventing use of OBJ_RETAIN in the code when repeatedly sending the same message to multiple recipients
* there is no failover mechanism across NICs - if the selected NIC (or its attached switch) fails, we are forced to abort
* only one transport (i.e., component) can be "active"
The revised OOB resolves these problems:
* async progress is used for all application processes, with the progress thread blocking in the event library
* each available TCP NIC is supported by its own TCP module. The ability to asynchronously progress each module independently is provided, but not enabled by default (a runtime MCA parameter turns it "on")
* multi-address TCP NICs (e.g., a NIC with both an IPv4 and IPv6 address, or with virtual interfaces) are supported - reachability is determined by comparing the contact info for a peer against all addresses within the range covered by the address/mask pairs for the NIC.
* a message that arrives on one TCP NIC is automatically shifted to whatever NIC that is connected to the next "hop" if that peer cannot be reached by the incoming NIC. If no TCP module will reach the peer, then the OOB attempts to send the message via all other available components - if none can reach the peer, then an "error" is reported back to the RML, which then calls the errmgr for instructions.
* opal_buffer_t now conforms to standard object rules re OBJ_RETAIN as we no longer "unload" the incoming object
* NIC failure is reported to the TCP component, which then tries to resend the message across any other available TCP NIC. If that doesn't work, then the message is given back to the OOB base to try using other components. If all that fails, then the error is reported to the RML, which reports to the errmgr for instructions
* obviously from the above, multiple OOB components (e.g., TCP and UD) can be active in parallel
* the matching code has been moved to the RML (and out of the OOB/TCP component) so it is independent of transport
* routing is done by the individual OOB modules (as opposed to the RML). Thus, both routed and non-routed transports can simultaneously be active
* all blocking send/recv APIs have been removed. Everything operates asynchronously.
KNOWN LIMITATIONS:
* although provision is made for component failover as described above, the code for doing so has not been fully implemented yet. At the moment, if all connections for a given peer fail, the errmgr is notified of a "lost connection", which by default results in termination of the job if it was a lifeline
* the IPv6 code is present and compiles, but is not complete. Since the current IPv6 support in the OOB doesn't work anyway, I don't consider this a blocker
* routing is performed at the individual module level, yet the active routed component is selected on a global basis. We probably should update that to reflect that different transports may need/choose to route in different ways
* obviously, not every error path has been tested nor necessarily covered
* determining abnormal termination is more challenging than in the old code as we now potentially have multiple ways of connecting to a process. Ideally, we would declare "connection failed" when *all* transports can no longer reach the process, but that requires some additional (possibly complex) code. For now, the code replicates the old behavior only somewhat modified - i.e., if a module sees its connection fail, it checks to see if it is a lifeline. If so, it notifies the errmgr that the lifeline is lost - otherwise, it notifies the errmgr that a non-lifeline connection was lost.
* reachability is determined solely on the basis of a shared subnet address/mask - more sophisticated algorithms (e.g., the one used in the tcp btl) are required to handle routing via gateways
* the RML needs to assign sequence numbers to each message on a per-peer basis. The receiving RML will then deliver messages in order, thus preventing out-of-order messaging in the case where messages travel across different transports or a message needs to be redirected/resent due to failure of a NIC
This commit was SVN r29058.
2013-08-22 20:37:40 +04:00
|
|
|
if (AF_INET == r->ai_family && AF_INET == intf->af_family) {
|
2013-04-25 23:40:34 +04:00
|
|
|
struct sockaddr_in ipv4;
|
As per the RFC, bring in the ORTE async progress code and the rewrite of OOB:
*** THIS RFC INCLUDES A MINOR CHANGE TO THE MPI-RTE INTERFACE ***
Note: during the course of this work, it was necessary to completely separate the MPI and RTE progress engines. There were multiple places in the MPI layer where ORTE_WAIT_FOR_COMPLETION was being used. A new OMPI_WAIT_FOR_COMPLETION macro was created (defined in ompi/mca/rte/rte.h) that simply cycles across opal_progress until the provided flag becomes false. Places where the MPI layer blocked waiting for RTE to complete an event have been modified to use this macro.
***************************************************************************************
I am reissuing this RFC because of the time that has passed since its original release. Since its initial release and review, I have debugged it further to ensure it fully supports tests like loop_spawn. It therefore seems ready for merge back to the trunk. Given its prior review, I have set the timeout for one week.
The code is in https://bitbucket.org/rhc/ompi-oob2
WHAT: Rewrite of ORTE OOB
WHY: Support asynchronous progress and a host of other features
WHEN: Wed, August 21
SYNOPSIS:
The current OOB has served us well, but a number of limitations have been identified over the years. Specifically:
* it is only progressed when called via opal_progress, which can lead to hangs or recursive calls into libevent (which is not supported by that code)
* we've had issues when multiple NICs are available as the code doesn't "shift" messages between transports - thus, all nodes had to be available via the same TCP interface.
* the OOB "unloads" incoming opal_buffer_t objects during the transmission, thus preventing use of OBJ_RETAIN in the code when repeatedly sending the same message to multiple recipients
* there is no failover mechanism across NICs - if the selected NIC (or its attached switch) fails, we are forced to abort
* only one transport (i.e., component) can be "active"
The revised OOB resolves these problems:
* async progress is used for all application processes, with the progress thread blocking in the event library
* each available TCP NIC is supported by its own TCP module. The ability to asynchronously progress each module independently is provided, but not enabled by default (a runtime MCA parameter turns it "on")
* multi-address TCP NICs (e.g., a NIC with both an IPv4 and IPv6 address, or with virtual interfaces) are supported - reachability is determined by comparing the contact info for a peer against all addresses within the range covered by the address/mask pairs for the NIC.
* a message that arrives on one TCP NIC is automatically shifted to whatever NIC that is connected to the next "hop" if that peer cannot be reached by the incoming NIC. If no TCP module will reach the peer, then the OOB attempts to send the message via all other available components - if none can reach the peer, then an "error" is reported back to the RML, which then calls the errmgr for instructions.
* opal_buffer_t now conforms to standard object rules re OBJ_RETAIN as we no longer "unload" the incoming object
* NIC failure is reported to the TCP component, which then tries to resend the message across any other available TCP NIC. If that doesn't work, then the message is given back to the OOB base to try using other components. If all that fails, then the error is reported to the RML, which reports to the errmgr for instructions
* obviously from the above, multiple OOB components (e.g., TCP and UD) can be active in parallel
* the matching code has been moved to the RML (and out of the OOB/TCP component) so it is independent of transport
* routing is done by the individual OOB modules (as opposed to the RML). Thus, both routed and non-routed transports can simultaneously be active
* all blocking send/recv APIs have been removed. Everything operates asynchronously.
KNOWN LIMITATIONS:
* although provision is made for component failover as described above, the code for doing so has not been fully implemented yet. At the moment, if all connections for a given peer fail, the errmgr is notified of a "lost connection", which by default results in termination of the job if it was a lifeline
* the IPv6 code is present and compiles, but is not complete. Since the current IPv6 support in the OOB doesn't work anyway, I don't consider this a blocker
* routing is performed at the individual module level, yet the active routed component is selected on a global basis. We probably should update that to reflect that different transports may need/choose to route in different ways
* obviously, not every error path has been tested nor necessarily covered
* determining abnormal termination is more challenging than in the old code as we now potentially have multiple ways of connecting to a process. Ideally, we would declare "connection failed" when *all* transports can no longer reach the process, but that requires some additional (possibly complex) code. For now, the code replicates the old behavior only somewhat modified - i.e., if a module sees its connection fail, it checks to see if it is a lifeline. If so, it notifies the errmgr that the lifeline is lost - otherwise, it notifies the errmgr that a non-lifeline connection was lost.
* reachability is determined solely on the basis of a shared subnet address/mask - more sophisticated algorithms (e.g., the one used in the tcp btl) are required to handle routing via gateways
* the RML needs to assign sequence numbers to each message on a per-peer basis. The receiving RML will then deliver messages in order, thus preventing out-of-order messaging in the case where messages travel across different transports or a message needs to be redirected/resent due to failure of a NIC
This commit was SVN r29058.
2013-08-22 20:37:40 +04:00
|
|
|
len = (r->ai_addrlen < sizeof(struct sockaddr_in)) ? r->ai_addrlen : sizeof(struct sockaddr_in);
|
|
|
|
memcpy(&ipv4, r->ai_addr, len);
|
2013-05-14 07:37:44 +04:00
|
|
|
if (opal_net_samenetwork((struct sockaddr*)&ipv4, (struct sockaddr*)&intf->if_addr, intf->if_mask)) {
|
2014-05-15 19:59:41 +04:00
|
|
|
if_kernel_index = intf->if_kernel_index;
|
|
|
|
freeaddrinfo (res);
|
|
|
|
return if_kernel_index;
|
2013-04-25 23:40:34 +04:00
|
|
|
}
|
2013-05-14 19:54:46 +04:00
|
|
|
}
|
As per the RFC, bring in the ORTE async progress code and the rewrite of OOB:
*** THIS RFC INCLUDES A MINOR CHANGE TO THE MPI-RTE INTERFACE ***
Note: during the course of this work, it was necessary to completely separate the MPI and RTE progress engines. There were multiple places in the MPI layer where ORTE_WAIT_FOR_COMPLETION was being used. A new OMPI_WAIT_FOR_COMPLETION macro was created (defined in ompi/mca/rte/rte.h) that simply cycles across opal_progress until the provided flag becomes false. Places where the MPI layer blocked waiting for RTE to complete an event have been modified to use this macro.
***************************************************************************************
I am reissuing this RFC because of the time that has passed since its original release. Since its initial release and review, I have debugged it further to ensure it fully supports tests like loop_spawn. It therefore seems ready for merge back to the trunk. Given its prior review, I have set the timeout for one week.
The code is in https://bitbucket.org/rhc/ompi-oob2
WHAT: Rewrite of ORTE OOB
WHY: Support asynchronous progress and a host of other features
WHEN: Wed, August 21
SYNOPSIS:
The current OOB has served us well, but a number of limitations have been identified over the years. Specifically:
* it is only progressed when called via opal_progress, which can lead to hangs or recursive calls into libevent (which is not supported by that code)
* we've had issues when multiple NICs are available as the code doesn't "shift" messages between transports - thus, all nodes had to be available via the same TCP interface.
* the OOB "unloads" incoming opal_buffer_t objects during the transmission, thus preventing use of OBJ_RETAIN in the code when repeatedly sending the same message to multiple recipients
* there is no failover mechanism across NICs - if the selected NIC (or its attached switch) fails, we are forced to abort
* only one transport (i.e., component) can be "active"
The revised OOB resolves these problems:
* async progress is used for all application processes, with the progress thread blocking in the event library
* each available TCP NIC is supported by its own TCP module. The ability to asynchronously progress each module independently is provided, but not enabled by default (a runtime MCA parameter turns it "on")
* multi-address TCP NICs (e.g., a NIC with both an IPv4 and IPv6 address, or with virtual interfaces) are supported - reachability is determined by comparing the contact info for a peer against all addresses within the range covered by the address/mask pairs for the NIC.
* a message that arrives on one TCP NIC is automatically shifted to whatever NIC that is connected to the next "hop" if that peer cannot be reached by the incoming NIC. If no TCP module will reach the peer, then the OOB attempts to send the message via all other available components - if none can reach the peer, then an "error" is reported back to the RML, which then calls the errmgr for instructions.
* opal_buffer_t now conforms to standard object rules re OBJ_RETAIN as we no longer "unload" the incoming object
* NIC failure is reported to the TCP component, which then tries to resend the message across any other available TCP NIC. If that doesn't work, then the message is given back to the OOB base to try using other components. If all that fails, then the error is reported to the RML, which reports to the errmgr for instructions
* obviously from the above, multiple OOB components (e.g., TCP and UD) can be active in parallel
* the matching code has been moved to the RML (and out of the OOB/TCP component) so it is independent of transport
* routing is done by the individual OOB modules (as opposed to the RML). Thus, both routed and non-routed transports can simultaneously be active
* all blocking send/recv APIs have been removed. Everything operates asynchronously.
KNOWN LIMITATIONS:
* although provision is made for component failover as described above, the code for doing so has not been fully implemented yet. At the moment, if all connections for a given peer fail, the errmgr is notified of a "lost connection", which by default results in termination of the job if it was a lifeline
* the IPv6 code is present and compiles, but is not complete. Since the current IPv6 support in the OOB doesn't work anyway, I don't consider this a blocker
* routing is performed at the individual module level, yet the active routed component is selected on a global basis. We probably should update that to reflect that different transports may need/choose to route in different ways
* obviously, not every error path has been tested nor necessarily covered
* determining abnormal termination is more challenging than in the old code as we now potentially have multiple ways of connecting to a process. Ideally, we would declare "connection failed" when *all* transports can no longer reach the process, but that requires some additional (possibly complex) code. For now, the code replicates the old behavior only somewhat modified - i.e., if a module sees its connection fail, it checks to see if it is a lifeline. If so, it notifies the errmgr that the lifeline is lost - otherwise, it notifies the errmgr that a non-lifeline connection was lost.
* reachability is determined solely on the basis of a shared subnet address/mask - more sophisticated algorithms (e.g., the one used in the tcp btl) are required to handle routing via gateways
* the RML needs to assign sequence numbers to each message on a per-peer basis. The receiving RML will then deliver messages in order, thus preventing out-of-order messaging in the case where messages travel across different transports or a message needs to be redirected/resent due to failure of a NIC
This commit was SVN r29058.
2013-08-22 20:37:40 +04:00
|
|
|
#if OPAL_ENABLE_IPV6
|
|
|
|
else if (AF_INET6 == r->ai_family && AF_INET6 == intf->af_family) {
|
|
|
|
struct sockaddr_in6 ipv6;
|
|
|
|
len = (r->ai_addrlen < sizeof(struct sockaddr_in6)) ? r->ai_addrlen : sizeof(struct sockaddr_in6);
|
|
|
|
memcpy(&ipv6, r->ai_addr, len);
|
|
|
|
if (opal_net_samenetwork((struct sockaddr*)((struct sockaddr_in6*)&intf->if_addr),
|
|
|
|
(struct sockaddr*)&ipv6, intf->if_mask)) {
|
2014-05-15 19:59:41 +04:00
|
|
|
if_kernel_index = intf->if_kernel_index;
|
|
|
|
freeaddrinfo (res);
|
|
|
|
return if_kernel_index;
|
2013-04-25 23:40:34 +04:00
|
|
|
}
|
|
|
|
}
|
2013-05-14 19:54:46 +04:00
|
|
|
#endif
|
2013-04-25 23:40:34 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (NULL != res) {
|
|
|
|
freeaddrinfo (res);
|
|
|
|
}
|
|
|
|
return OPAL_ERR_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
2004-01-15 02:24:15 +03:00
|
|
|
/*
|
|
|
|
* Return the number of discovered interface.
|
|
|
|
*/
|
2004-01-14 21:24:30 +03:00
|
|
|
|
2005-07-04 05:36:20 +04:00
|
|
|
int opal_ifcount(void)
|
2004-01-14 21:24:30 +03:00
|
|
|
{
|
2007-04-25 05:55:40 +04:00
|
|
|
return opal_list_get_size(&opal_if_list);
|
2004-01-14 21:24:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-01-15 02:24:15 +03:00
|
|
|
/*
|
2007-04-25 05:55:40 +04:00
|
|
|
* Return the opal_list interface index for the first
|
2004-01-15 02:24:15 +03:00
|
|
|
* interface in our list.
|
|
|
|
*/
|
2004-01-14 21:24:30 +03:00
|
|
|
|
2005-07-04 05:36:20 +04:00
|
|
|
int opal_ifbegin(void)
|
2004-01-14 21:24:30 +03:00
|
|
|
{
|
2005-07-04 05:36:20 +04:00
|
|
|
opal_if_t *intf;
|
2010-09-22 05:11:40 +04:00
|
|
|
|
2005-07-04 05:36:20 +04:00
|
|
|
intf = (opal_if_t*)opal_list_get_first(&opal_if_list);
|
2010-07-27 17:46:55 +04:00
|
|
|
if (NULL != intf)
|
2004-01-14 21:24:30 +03:00
|
|
|
return intf->if_index;
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-01-15 02:24:15 +03:00
|
|
|
/*
|
|
|
|
* Located the current position in the list by if_index and
|
|
|
|
* return the interface index of the next element in our list
|
|
|
|
* (if it exists).
|
|
|
|
*/
|
2004-01-14 21:24:30 +03:00
|
|
|
|
2005-07-04 05:36:20 +04:00
|
|
|
int opal_ifnext(int if_index)
|
2004-01-14 21:24:30 +03:00
|
|
|
{
|
2005-07-04 05:36:20 +04:00
|
|
|
opal_if_t *intf;
|
2010-09-22 05:11:40 +04:00
|
|
|
|
2010-07-27 17:46:55 +04:00
|
|
|
for (intf = (opal_if_t*)opal_list_get_first(&opal_if_list);
|
2005-07-04 05:36:20 +04:00
|
|
|
intf != (opal_if_t*)opal_list_get_end(&opal_if_list);
|
|
|
|
intf = (opal_if_t*)opal_list_get_next(intf)) {
|
2010-07-27 17:46:55 +04:00
|
|
|
if (intf->if_index == if_index) {
|
2004-07-07 18:01:55 +04:00
|
|
|
do {
|
2005-07-04 05:36:20 +04:00
|
|
|
opal_if_t* if_next = (opal_if_t*)opal_list_get_next(intf);
|
|
|
|
opal_if_t* if_end = (opal_if_t*)opal_list_get_end(&opal_if_list);
|
2004-07-07 20:28:01 +04:00
|
|
|
if (if_next == if_end) {
|
2004-07-07 18:01:55 +04:00
|
|
|
return -1;
|
2004-07-07 20:28:01 +04:00
|
|
|
}
|
|
|
|
intf = if_next;
|
2004-07-07 18:01:55 +04:00
|
|
|
} while(intf->if_index == if_index);
|
|
|
|
return intf->if_index;
|
2004-01-14 21:24:30 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-06-24 06:59:57 +03:00
|
|
|
/*
|
|
|
|
* Lookup the interface by opal_list index and return the
|
2004-01-15 02:24:15 +03:00
|
|
|
* primary address assigned to the interface.
|
|
|
|
*/
|
2004-01-14 21:24:30 +03:00
|
|
|
|
2007-05-17 05:17:59 +04:00
|
|
|
int opal_ifindextoaddr(int if_index, struct sockaddr* if_addr, unsigned int length)
|
2004-01-14 21:24:30 +03:00
|
|
|
{
|
2005-07-04 05:36:20 +04:00
|
|
|
opal_if_t* intf;
|
2010-09-22 05:11:40 +04:00
|
|
|
|
2010-07-27 17:46:55 +04:00
|
|
|
for (intf = (opal_if_t*)opal_list_get_first(&opal_if_list);
|
2013-10-26 04:47:14 +04:00
|
|
|
intf != (opal_if_t*)opal_list_get_end(&opal_if_list);
|
|
|
|
intf = (opal_if_t*)opal_list_get_next(intf)) {
|
2010-07-27 17:46:55 +04:00
|
|
|
if (intf->if_index == if_index) {
|
2007-04-25 05:55:40 +04:00
|
|
|
memcpy(if_addr, &intf->if_addr, MIN(length, sizeof (intf->if_addr)));
|
2006-02-12 04:33:29 +03:00
|
|
|
return OPAL_SUCCESS;
|
2004-01-14 21:24:30 +03:00
|
|
|
}
|
|
|
|
}
|
2006-02-12 04:33:29 +03:00
|
|
|
return OPAL_ERROR;
|
2004-01-14 21:24:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-06-24 06:59:57 +03:00
|
|
|
/*
|
|
|
|
* Lookup the interface by opal_list kindex and return the
|
2013-10-26 04:47:14 +04:00
|
|
|
* primary address assigned to the interface.
|
|
|
|
*/
|
|
|
|
int opal_ifkindextoaddr(int if_kindex, struct sockaddr* if_addr, unsigned int length)
|
|
|
|
{
|
|
|
|
opal_if_t* intf;
|
|
|
|
|
|
|
|
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)) {
|
|
|
|
if (intf->if_kernel_index == if_kindex) {
|
|
|
|
memcpy(if_addr, &intf->if_addr, MIN(length, sizeof (intf->if_addr)));
|
|
|
|
return OPAL_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return OPAL_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-06-24 06:59:57 +03:00
|
|
|
/*
|
|
|
|
* Lookup the interface by opal_list index and return the
|
2004-01-26 21:41:37 +03:00
|
|
|
* network mask assigned to the interface.
|
|
|
|
*/
|
|
|
|
|
2007-04-25 05:55:40 +04:00
|
|
|
int opal_ifindextomask(int if_index, uint32_t* if_mask, int length)
|
2004-01-26 21:41:37 +03:00
|
|
|
{
|
2005-07-04 05:36:20 +04:00
|
|
|
opal_if_t* intf;
|
2010-09-22 05:11:40 +04:00
|
|
|
|
2010-07-27 17:46:55 +04:00
|
|
|
for (intf = (opal_if_t*)opal_list_get_first(&opal_if_list);
|
2005-07-04 05:36:20 +04:00
|
|
|
intf != (opal_if_t*)opal_list_get_end(&opal_if_list);
|
|
|
|
intf = (opal_if_t*)opal_list_get_next(intf)) {
|
2010-07-27 17:46:55 +04:00
|
|
|
if (intf->if_index == if_index) {
|
2004-01-26 21:41:37 +03:00
|
|
|
memcpy(if_mask, &intf->if_mask, length);
|
2006-02-12 04:33:29 +03:00
|
|
|
return OPAL_SUCCESS;
|
2004-01-26 21:41:37 +03:00
|
|
|
}
|
|
|
|
}
|
2006-02-12 04:33:29 +03:00
|
|
|
return OPAL_ERROR;
|
2004-01-26 21:41:37 +03:00
|
|
|
}
|
|
|
|
|
2015-06-24 06:59:57 +03:00
|
|
|
/*
|
|
|
|
* Lookup the interface by opal_list index and return the
|
2013-04-18 02:32:32 +04:00
|
|
|
* MAC assigned to the interface.
|
|
|
|
*/
|
|
|
|
|
2013-04-25 19:21:53 +04:00
|
|
|
int opal_ifindextomac(int if_index, uint8_t mac[6])
|
2013-04-18 02:32:32 +04:00
|
|
|
{
|
|
|
|
opal_if_t* intf;
|
|
|
|
|
|
|
|
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)) {
|
|
|
|
if (intf->if_index == if_index) {
|
|
|
|
memcpy(mac, &intf->if_mac, 6);
|
|
|
|
return OPAL_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return OPAL_ERROR;
|
|
|
|
}
|
|
|
|
|
2015-06-24 06:59:57 +03:00
|
|
|
/*
|
|
|
|
* Lookup the interface by opal_list index and return the
|
2013-04-18 02:32:32 +04:00
|
|
|
* MTU assigned to the interface.
|
|
|
|
*/
|
|
|
|
|
2013-12-20 15:17:30 +04:00
|
|
|
int opal_ifindextomtu(int if_index, int *mtu)
|
2013-04-18 02:32:32 +04:00
|
|
|
{
|
|
|
|
opal_if_t* intf;
|
|
|
|
|
|
|
|
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)) {
|
|
|
|
if (intf->if_index == if_index) {
|
2013-12-20 15:17:30 +04:00
|
|
|
*mtu = intf->ifmtu;
|
2013-04-18 02:32:32 +04:00
|
|
|
return OPAL_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return OPAL_ERROR;
|
|
|
|
}
|
|
|
|
|
2015-06-24 06:59:57 +03:00
|
|
|
/*
|
|
|
|
* Lookup the interface by opal_list index and return the
|
2007-04-25 05:55:40 +04:00
|
|
|
* flags assigned to the interface.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int opal_ifindextoflags(int if_index, uint32_t* if_flags)
|
|
|
|
{
|
|
|
|
opal_if_t* intf;
|
2010-09-22 05:11:40 +04:00
|
|
|
|
2010-07-27 17:46:55 +04:00
|
|
|
for (intf = (opal_if_t*)opal_list_get_first(&opal_if_list);
|
2007-04-25 05:55:40 +04:00
|
|
|
intf != (opal_if_t*)opal_list_get_end(&opal_if_list);
|
|
|
|
intf = (opal_if_t*)opal_list_get_next(intf)) {
|
2010-07-27 17:46:55 +04:00
|
|
|
if (intf->if_index == if_index) {
|
2007-04-25 05:55:40 +04:00
|
|
|
memcpy(if_flags, &intf->if_flags, sizeof(uint32_t));
|
|
|
|
return OPAL_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return OPAL_ERROR;
|
|
|
|
}
|
|
|
|
|
2004-01-26 21:41:37 +03:00
|
|
|
|
|
|
|
|
2015-06-24 06:59:57 +03:00
|
|
|
/*
|
2007-04-25 05:55:40 +04:00
|
|
|
* Lookup the interface by opal_list index and return
|
2004-01-15 02:24:15 +03:00
|
|
|
* the associated name.
|
|
|
|
*/
|
2004-01-14 21:24:30 +03:00
|
|
|
|
2005-07-04 05:36:20 +04:00
|
|
|
int opal_ifindextoname(int if_index, char* if_name, int length)
|
2004-01-14 21:24:30 +03:00
|
|
|
{
|
2005-07-04 05:36:20 +04:00
|
|
|
opal_if_t *intf;
|
2010-09-22 05:11:40 +04:00
|
|
|
|
2010-07-27 17:46:55 +04:00
|
|
|
for (intf = (opal_if_t*)opal_list_get_first(&opal_if_list);
|
2005-07-04 05:36:20 +04:00
|
|
|
intf != (opal_if_t*)opal_list_get_end(&opal_if_list);
|
|
|
|
intf = (opal_if_t*)opal_list_get_next(intf)) {
|
2010-07-27 17:46:55 +04:00
|
|
|
if (intf->if_index == if_index) {
|
2004-01-14 21:24:30 +03:00
|
|
|
strncpy(if_name, intf->if_name, length);
|
2006-02-12 04:33:29 +03:00
|
|
|
return OPAL_SUCCESS;
|
2004-01-14 21:24:30 +03:00
|
|
|
}
|
|
|
|
}
|
2006-02-12 04:33:29 +03:00
|
|
|
return OPAL_ERROR;
|
2004-01-14 21:24:30 +03:00
|
|
|
}
|
2004-10-31 22:01:53 +03:00
|
|
|
|
2006-07-12 00:54:49 +04:00
|
|
|
|
2015-06-24 06:59:57 +03:00
|
|
|
/*
|
2007-04-25 05:55:40 +04:00
|
|
|
* Lookup the interface by kernel index and return
|
|
|
|
* the associated name.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int opal_ifkindextoname(int if_kindex, char* if_name, int length)
|
|
|
|
{
|
|
|
|
opal_if_t *intf;
|
2010-09-22 05:11:40 +04:00
|
|
|
|
2010-07-27 17:46:55 +04:00
|
|
|
for (intf = (opal_if_t*)opal_list_get_first(&opal_if_list);
|
2007-04-25 05:55:40 +04:00
|
|
|
intf != (opal_if_t*)opal_list_get_end(&opal_if_list);
|
|
|
|
intf = (opal_if_t*)opal_list_get_next(intf)) {
|
2010-07-27 17:46:55 +04:00
|
|
|
if (intf->if_kernel_index == if_kindex) {
|
2007-04-25 05:55:40 +04:00
|
|
|
strncpy(if_name, intf->if_name, length);
|
|
|
|
return OPAL_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return OPAL_ERROR;
|
|
|
|
}
|
|
|
|
|
2006-07-12 00:54:49 +04:00
|
|
|
|
2004-11-01 17:18:30 +03:00
|
|
|
#define ADDRLEN 100
|
2004-10-31 22:01:53 +03:00
|
|
|
bool
|
2007-07-22 23:19:01 +04:00
|
|
|
opal_ifislocal(const char *hostname)
|
2004-10-31 22:01:53 +03:00
|
|
|
{
|
As per the RFC, bring in the ORTE async progress code and the rewrite of OOB:
*** THIS RFC INCLUDES A MINOR CHANGE TO THE MPI-RTE INTERFACE ***
Note: during the course of this work, it was necessary to completely separate the MPI and RTE progress engines. There were multiple places in the MPI layer where ORTE_WAIT_FOR_COMPLETION was being used. A new OMPI_WAIT_FOR_COMPLETION macro was created (defined in ompi/mca/rte/rte.h) that simply cycles across opal_progress until the provided flag becomes false. Places where the MPI layer blocked waiting for RTE to complete an event have been modified to use this macro.
***************************************************************************************
I am reissuing this RFC because of the time that has passed since its original release. Since its initial release and review, I have debugged it further to ensure it fully supports tests like loop_spawn. It therefore seems ready for merge back to the trunk. Given its prior review, I have set the timeout for one week.
The code is in https://bitbucket.org/rhc/ompi-oob2
WHAT: Rewrite of ORTE OOB
WHY: Support asynchronous progress and a host of other features
WHEN: Wed, August 21
SYNOPSIS:
The current OOB has served us well, but a number of limitations have been identified over the years. Specifically:
* it is only progressed when called via opal_progress, which can lead to hangs or recursive calls into libevent (which is not supported by that code)
* we've had issues when multiple NICs are available as the code doesn't "shift" messages between transports - thus, all nodes had to be available via the same TCP interface.
* the OOB "unloads" incoming opal_buffer_t objects during the transmission, thus preventing use of OBJ_RETAIN in the code when repeatedly sending the same message to multiple recipients
* there is no failover mechanism across NICs - if the selected NIC (or its attached switch) fails, we are forced to abort
* only one transport (i.e., component) can be "active"
The revised OOB resolves these problems:
* async progress is used for all application processes, with the progress thread blocking in the event library
* each available TCP NIC is supported by its own TCP module. The ability to asynchronously progress each module independently is provided, but not enabled by default (a runtime MCA parameter turns it "on")
* multi-address TCP NICs (e.g., a NIC with both an IPv4 and IPv6 address, or with virtual interfaces) are supported - reachability is determined by comparing the contact info for a peer against all addresses within the range covered by the address/mask pairs for the NIC.
* a message that arrives on one TCP NIC is automatically shifted to whatever NIC that is connected to the next "hop" if that peer cannot be reached by the incoming NIC. If no TCP module will reach the peer, then the OOB attempts to send the message via all other available components - if none can reach the peer, then an "error" is reported back to the RML, which then calls the errmgr for instructions.
* opal_buffer_t now conforms to standard object rules re OBJ_RETAIN as we no longer "unload" the incoming object
* NIC failure is reported to the TCP component, which then tries to resend the message across any other available TCP NIC. If that doesn't work, then the message is given back to the OOB base to try using other components. If all that fails, then the error is reported to the RML, which reports to the errmgr for instructions
* obviously from the above, multiple OOB components (e.g., TCP and UD) can be active in parallel
* the matching code has been moved to the RML (and out of the OOB/TCP component) so it is independent of transport
* routing is done by the individual OOB modules (as opposed to the RML). Thus, both routed and non-routed transports can simultaneously be active
* all blocking send/recv APIs have been removed. Everything operates asynchronously.
KNOWN LIMITATIONS:
* although provision is made for component failover as described above, the code for doing so has not been fully implemented yet. At the moment, if all connections for a given peer fail, the errmgr is notified of a "lost connection", which by default results in termination of the job if it was a lifeline
* the IPv6 code is present and compiles, but is not complete. Since the current IPv6 support in the OOB doesn't work anyway, I don't consider this a blocker
* routing is performed at the individual module level, yet the active routed component is selected on a global basis. We probably should update that to reflect that different transports may need/choose to route in different ways
* obviously, not every error path has been tested nor necessarily covered
* determining abnormal termination is more challenging than in the old code as we now potentially have multiple ways of connecting to a process. Ideally, we would declare "connection failed" when *all* transports can no longer reach the process, but that requires some additional (possibly complex) code. For now, the code replicates the old behavior only somewhat modified - i.e., if a module sees its connection fail, it checks to see if it is a lifeline. If so, it notifies the errmgr that the lifeline is lost - otherwise, it notifies the errmgr that a non-lifeline connection was lost.
* reachability is determined solely on the basis of a shared subnet address/mask - more sophisticated algorithms (e.g., the one used in the tcp btl) are required to handle routing via gateways
* the RML needs to assign sequence numbers to each message on a per-peer basis. The receiving RML will then deliver messages in order, thus preventing out-of-order messaging in the case where messages travel across different transports or a message needs to be redirected/resent due to failure of a NIC
This commit was SVN r29058.
2013-08-22 20:37:40 +04:00
|
|
|
#if OPAL_ENABLE_IPV6
|
2007-04-25 05:55:40 +04:00
|
|
|
char addrname[NI_MAXHOST]; /* should be larger than ADDRLEN, but I think
|
|
|
|
they really mean IFNAMESIZE */
|
|
|
|
#else
|
|
|
|
char addrname[ADDRLEN + 1];
|
|
|
|
#endif
|
2005-06-01 23:30:05 +04:00
|
|
|
|
2011-01-10 19:29:42 +03:00
|
|
|
if (OPAL_SUCCESS == opal_ifaddrtoname(hostname, addrname, ADDRLEN)) {
|
|
|
|
return true;
|
|
|
|
}
|
2004-10-31 22:01:53 +03:00
|
|
|
|
2011-01-10 19:29:42 +03:00
|
|
|
return false;
|
2004-10-31 22:01:53 +03:00
|
|
|
}
|
2005-07-13 08:16:03 +04:00
|
|
|
|
2015-10-01 08:03:08 +03:00
|
|
|
static int parse_ipv4_dots(const char *addr, uint32_t* net, int* dots)
|
2009-10-09 19:24:41 +04:00
|
|
|
{
|
2011-06-06 07:08:02 +04:00
|
|
|
const char *start = addr, *end;
|
2009-10-09 19:24:41 +04:00
|
|
|
uint32_t n[]={0,0,0,0};
|
2011-06-07 15:33:22 +04:00
|
|
|
int i;
|
2009-10-09 19:24:41 +04:00
|
|
|
|
|
|
|
/* now assemble the address */
|
2011-06-07 15:33:22 +04:00
|
|
|
for( i = 0; i < 4; i++ ) {
|
2011-06-06 07:08:02 +04:00
|
|
|
n[i] = strtoul(start, (char**)&end, 10);
|
2011-06-07 15:33:22 +04:00
|
|
|
if( end == start ) {
|
|
|
|
/* this is not an error, but indicates that
|
|
|
|
* we were given a partial address - e.g.,
|
|
|
|
* 192.168 - usually indicating an IP range
|
|
|
|
* in CIDR notation. So just return what we have
|
|
|
|
*/
|
2011-06-06 07:08:02 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* did we read something sensible? */
|
|
|
|
if( n[i] > 255 ) {
|
2011-06-07 06:09:11 +04:00
|
|
|
return OPAL_ERR_NETWORK_NOT_PARSEABLE;
|
2011-06-06 07:08:02 +04:00
|
|
|
}
|
2011-06-07 07:20:01 +04:00
|
|
|
/* skip all the . */
|
|
|
|
for( start = end; '\0' != *start; start++ )
|
|
|
|
if( '.' != *start ) break;
|
2009-10-09 19:24:41 +04:00
|
|
|
}
|
2011-06-06 07:08:02 +04:00
|
|
|
*dots = i;
|
|
|
|
*net = OPAL_IF_ASSEMBLE_NETWORK(n[0], n[1], n[2], n[3]);
|
2011-06-07 15:33:22 +04:00
|
|
|
return OPAL_SUCCESS;
|
2009-10-09 19:24:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2011-05-04 01:59:51 +04:00
|
|
|
opal_iftupletoaddr(const char *inaddr, uint32_t *net, uint32_t *mask)
|
2009-10-09 19:24:41 +04:00
|
|
|
{
|
2011-06-06 07:08:02 +04:00
|
|
|
int pval, dots, rc = OPAL_SUCCESS;
|
|
|
|
const char *ptr;
|
2015-06-24 06:59:57 +03:00
|
|
|
|
2009-10-09 19:24:41 +04:00
|
|
|
/* if a mask was desired... */
|
|
|
|
if (NULL != mask) {
|
|
|
|
/* set default */
|
|
|
|
*mask = 0xFFFFFFFF;
|
2015-06-24 06:59:57 +03:00
|
|
|
|
2009-10-09 19:24:41 +04:00
|
|
|
/* if entry includes mask, split that off */
|
2011-05-04 01:59:51 +04:00
|
|
|
if (NULL != (ptr = strchr(inaddr, '/'))) {
|
2011-06-06 07:08:02 +04:00
|
|
|
ptr = ptr + 1; /* skip the / */
|
2009-10-09 19:24:41 +04:00
|
|
|
/* is the mask a tuple? */
|
2011-06-06 07:08:02 +04:00
|
|
|
if (NULL != strchr(ptr, '.')) {
|
2009-10-09 19:24:41 +04:00
|
|
|
/* yes - extract mask from it */
|
2011-06-06 07:08:02 +04:00
|
|
|
rc = parse_ipv4_dots(ptr, mask, &dots);
|
2009-10-09 19:24:41 +04:00
|
|
|
} else {
|
2011-05-04 01:59:51 +04:00
|
|
|
/* no - must be an int telling us how much of the addr to use: e.g., /16
|
|
|
|
* For more information please read http://en.wikipedia.org/wiki/Subnetwork.
|
2009-10-09 19:24:41 +04:00
|
|
|
*/
|
2011-06-06 07:08:02 +04:00
|
|
|
pval = strtol(ptr, NULL, 10);
|
2011-05-04 01:59:51 +04:00
|
|
|
if ((pval > 31) || (pval < 1)) {
|
2009-10-09 19:24:41 +04:00
|
|
|
opal_output(0, "opal_iftupletoaddr: unknown mask");
|
2011-06-07 06:09:11 +04:00
|
|
|
return OPAL_ERR_NETWORK_NOT_PARSEABLE;
|
2009-10-09 19:24:41 +04:00
|
|
|
}
|
2011-05-04 01:59:51 +04:00
|
|
|
*mask = 0xFFFFFFFF << (32 - pval);
|
2009-10-09 19:24:41 +04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* use the number of dots to determine it */
|
2011-06-07 06:09:11 +04:00
|
|
|
for (ptr = inaddr, pval = 0; '\0'!= *ptr; ptr++) {
|
|
|
|
if ('.' == *ptr) {
|
|
|
|
pval++;
|
|
|
|
}
|
|
|
|
}
|
2009-10-09 19:24:41 +04:00
|
|
|
/* if we have three dots, then we have four
|
|
|
|
* fields since it is a full address, so the
|
|
|
|
* default netmask is fine
|
|
|
|
*/
|
2011-06-07 06:09:11 +04:00
|
|
|
if (3 == pval) {
|
|
|
|
*mask = 0xFFFFFFFF;
|
|
|
|
} else if (2 == pval) { /* 2 dots */
|
|
|
|
*mask = 0xFFFFFF00;
|
|
|
|
} else if (1 == pval) { /* 1 dot */
|
|
|
|
*mask = 0xFFFF0000;
|
|
|
|
} else if (0 == pval) { /* no dots */
|
|
|
|
*mask = 0xFF000000;
|
|
|
|
} else {
|
|
|
|
opal_output(0, "opal_iftupletoaddr: unknown mask");
|
|
|
|
return OPAL_ERR_NETWORK_NOT_PARSEABLE;
|
2009-10-09 19:24:41 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-06-24 06:59:57 +03:00
|
|
|
|
2009-10-09 19:24:41 +04:00
|
|
|
/* if network addr is desired... */
|
|
|
|
if (NULL != net) {
|
|
|
|
/* now assemble the address */
|
2011-06-06 07:08:02 +04:00
|
|
|
rc = parse_ipv4_dots(inaddr, net, &dots);
|
2009-10-09 19:24:41 +04:00
|
|
|
}
|
2015-06-24 06:59:57 +03:00
|
|
|
|
2011-06-06 07:08:02 +04:00
|
|
|
return rc;
|
2009-10-09 19:24:41 +04:00
|
|
|
}
|
|
|
|
|
2015-06-24 06:59:57 +03:00
|
|
|
/*
|
2009-10-09 19:24:41 +04:00
|
|
|
* Determine if the specified interface is loopback
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool opal_ifisloopback(int if_index)
|
|
|
|
{
|
|
|
|
opal_if_t* intf;
|
2015-06-24 06:59:57 +03:00
|
|
|
|
2010-07-27 17:46:55 +04:00
|
|
|
for (intf = (opal_if_t*)opal_list_get_first(&opal_if_list);
|
2009-10-09 19:24:41 +04:00
|
|
|
intf != (opal_if_t*)opal_list_get_end(&opal_if_list);
|
|
|
|
intf = (opal_if_t*)opal_list_get_next(intf)) {
|
2010-07-27 17:46:55 +04:00
|
|
|
if (intf->if_index == if_index) {
|
2009-10-09 19:24:41 +04:00
|
|
|
if ((intf->if_flags & IFF_LOOPBACK) != 0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-06-05 23:16:42 +04:00
|
|
|
/* Determine if an interface matches any entry in the given list, taking
|
|
|
|
* into account that the list entries could be given as named interfaces,
|
|
|
|
* IP addrs, or subnet+mask
|
|
|
|
*/
|
2013-10-26 04:47:14 +04:00
|
|
|
int opal_ifmatches(int kidx, char **nets)
|
2011-06-05 23:16:42 +04:00
|
|
|
{
|
|
|
|
bool named_if;
|
2011-06-07 06:09:11 +04:00
|
|
|
int i, rc;
|
2011-06-05 23:16:42 +04:00
|
|
|
size_t j;
|
2013-10-26 04:47:14 +04:00
|
|
|
int kindex;
|
2011-06-05 23:16:42 +04:00
|
|
|
struct sockaddr_in inaddr;
|
|
|
|
uint32_t addr, netaddr, netmask;
|
|
|
|
|
|
|
|
/* get the address info for the given network in case we need it */
|
2013-10-26 04:47:14 +04:00
|
|
|
if (OPAL_SUCCESS != (rc = opal_ifkindextoaddr(kidx, (struct sockaddr*)&inaddr, sizeof(inaddr)))) {
|
2011-06-07 06:09:11 +04:00
|
|
|
return rc;
|
2011-06-05 23:16:42 +04:00
|
|
|
}
|
|
|
|
addr = ntohl(inaddr.sin_addr.s_addr);
|
|
|
|
|
|
|
|
for (i=0; NULL != nets[i]; i++) {
|
|
|
|
/* if the specified interface contains letters in it, then it
|
|
|
|
* was given as an interface name and not an IP tuple
|
|
|
|
*/
|
|
|
|
named_if = false;
|
|
|
|
for (j=0; j < strlen(nets[i]); j++) {
|
|
|
|
if (isalpha(nets[i][j]) && '.' != nets[i][j]) {
|
|
|
|
named_if = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (named_if) {
|
2013-10-26 04:47:14 +04:00
|
|
|
if (0 > (kindex = opal_ifnametokindex(nets[i]))) {
|
2011-06-05 23:16:42 +04:00
|
|
|
continue;
|
|
|
|
}
|
2013-10-26 04:47:14 +04:00
|
|
|
if (kindex == kidx) {
|
2011-06-07 06:09:11 +04:00
|
|
|
return OPAL_SUCCESS;
|
2011-06-05 23:16:42 +04:00
|
|
|
}
|
|
|
|
} else {
|
2011-06-07 06:09:11 +04:00
|
|
|
if (OPAL_SUCCESS != (rc = opal_iftupletoaddr(nets[i], &netaddr, &netmask))) {
|
2011-06-05 23:16:42 +04:00
|
|
|
opal_show_help("help-opal-util.txt", "invalid-net-mask", true, nets[i]);
|
2011-06-07 06:09:11 +04:00
|
|
|
return rc;
|
2011-06-05 23:16:42 +04:00
|
|
|
}
|
|
|
|
if (netaddr == (addr & netmask)) {
|
2011-06-07 06:09:11 +04:00
|
|
|
return OPAL_SUCCESS;
|
2011-06-05 23:16:42 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* get here if not found */
|
2011-06-07 06:09:11 +04:00
|
|
|
return OPAL_ERR_NOT_FOUND;
|
2011-06-05 23:16:42 +04:00
|
|
|
}
|
|
|
|
|
2012-11-16 08:02:29 +04:00
|
|
|
void opal_ifgetaliases(char ***aliases)
|
|
|
|
{
|
|
|
|
opal_if_t* intf;
|
|
|
|
char ipv4[INET_ADDRSTRLEN];
|
|
|
|
struct sockaddr_in *addr;
|
|
|
|
#if OPAL_ENABLE_IPV6
|
|
|
|
char ipv6[INET6_ADDRSTRLEN];
|
|
|
|
struct sockaddr_in6 *addr6;
|
|
|
|
#endif
|
|
|
|
|
2012-11-16 18:28:30 +04:00
|
|
|
/* set default answer */
|
|
|
|
*aliases = NULL;
|
|
|
|
|
2012-11-16 08:02:29 +04:00
|
|
|
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)) {
|
|
|
|
addr = (struct sockaddr_in*) &intf->if_addr;
|
|
|
|
/* ignore purely loopback interfaces */
|
|
|
|
if ((intf->if_flags & IFF_LOOPBACK) != 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (addr->sin_family == AF_INET) {
|
|
|
|
inet_ntop(AF_INET, &(addr->sin_addr.s_addr), ipv4, INET_ADDRSTRLEN);
|
|
|
|
opal_argv_append_nosize(aliases, ipv4);
|
|
|
|
}
|
|
|
|
#if OPAL_ENABLE_IPV6
|
|
|
|
else {
|
|
|
|
addr6 = (struct sockaddr_in6*) &intf->if_addr;
|
|
|
|
inet_ntop(AF_INET6, &(addr6->sin6_addr), ipv6, INET6_ADDRSTRLEN);
|
|
|
|
opal_argv_append_nosize(aliases, ipv6);
|
|
|
|
}
|
|
|
|
#endif
|
2015-06-24 06:59:57 +03:00
|
|
|
}
|
2012-11-16 08:02:29 +04:00
|
|
|
}
|
2007-04-25 22:06:06 +04:00
|
|
|
|
2005-07-13 08:16:03 +04:00
|
|
|
#else /* HAVE_STRUCT_SOCKADDR_IN */
|
|
|
|
|
|
|
|
/* if we don't have struct sockaddr_in, we don't have traditional
|
2010-09-22 05:11:40 +04:00
|
|
|
ethernet devices. Just make everything a no-op error call */
|
2005-07-13 08:16:03 +04:00
|
|
|
|
|
|
|
int
|
2015-06-24 06:59:57 +03:00
|
|
|
opal_ifnametoaddr(const char* if_name,
|
2007-05-17 05:17:59 +04:00
|
|
|
struct sockaddr* if_addr, int size)
|
2005-07-13 08:16:03 +04:00
|
|
|
{
|
2006-02-12 04:33:29 +03:00
|
|
|
return OPAL_ERR_NOT_SUPPORTED;
|
2005-07-13 08:16:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2015-06-24 06:59:57 +03:00
|
|
|
opal_ifaddrtoname(const char* if_addr,
|
2005-07-13 08:16:03 +04:00
|
|
|
char* if_name, int size)
|
|
|
|
{
|
2006-02-12 04:33:29 +03:00
|
|
|
return OPAL_ERR_NOT_SUPPORTED;
|
2005-07-13 08:16:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-07-13 17:20:22 +04:00
|
|
|
opal_ifnametoindex(const char* if_name)
|
2005-07-13 08:16:03 +04:00
|
|
|
{
|
2006-02-12 04:33:29 +03:00
|
|
|
return OPAL_ERR_NOT_SUPPORTED;
|
2005-07-13 08:16:03 +04:00
|
|
|
}
|
|
|
|
|
2009-04-02 22:35:09 +04:00
|
|
|
int16_t
|
2007-04-25 05:55:40 +04:00
|
|
|
opal_ifnametokindex(const char* if_name)
|
|
|
|
{
|
|
|
|
return OPAL_ERR_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
opal_ifindextokindex(int if_index)
|
|
|
|
{
|
|
|
|
return OPAL_ERR_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
2005-07-13 08:16:03 +04:00
|
|
|
int
|
2005-07-13 17:20:22 +04:00
|
|
|
opal_ifcount(void)
|
2005-07-13 08:16:03 +04:00
|
|
|
{
|
2006-02-12 04:33:29 +03:00
|
|
|
return OPAL_ERR_NOT_SUPPORTED;
|
2005-07-13 08:16:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-07-13 17:20:22 +04:00
|
|
|
opal_ifbegin(void)
|
2005-07-13 08:16:03 +04:00
|
|
|
{
|
2006-02-12 04:33:29 +03:00
|
|
|
return OPAL_ERR_NOT_SUPPORTED;
|
2005-07-13 08:16:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-07-13 17:20:22 +04:00
|
|
|
opal_ifnext(int if_index)
|
2005-07-13 08:16:03 +04:00
|
|
|
{
|
2006-02-12 04:33:29 +03:00
|
|
|
return OPAL_ERR_NOT_SUPPORTED;
|
2005-07-13 08:16:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-07-13 17:20:22 +04:00
|
|
|
opal_ifindextoname(int if_index, char* if_name, int length)
|
2005-07-13 08:16:03 +04:00
|
|
|
{
|
2006-02-12 04:33:29 +03:00
|
|
|
return OPAL_ERR_NOT_SUPPORTED;
|
2005-07-13 08:16:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-04-25 05:55:40 +04:00
|
|
|
opal_ifkindextoname(int kif_index, char* if_name, int length)
|
2005-07-13 08:16:03 +04:00
|
|
|
{
|
2006-02-12 04:33:29 +03:00
|
|
|
return OPAL_ERR_NOT_SUPPORTED;
|
2005-07-13 08:16:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-05-17 05:17:59 +04:00
|
|
|
opal_ifindextoaddr(int if_index, struct sockaddr* if_addr, unsigned int length)
|
2007-04-25 05:55:40 +04:00
|
|
|
{
|
|
|
|
return OPAL_ERR_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-05-09 08:46:21 +04:00
|
|
|
opal_ifindextomask(int if_index, uint32_t* if_addr, int length)
|
2005-07-13 08:16:03 +04:00
|
|
|
{
|
2006-02-12 04:33:29 +03:00
|
|
|
return OPAL_ERR_NOT_SUPPORTED;
|
2005-07-13 08:16:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2007-07-22 23:19:01 +04:00
|
|
|
opal_ifislocal(const char *hostname)
|
2006-07-12 00:54:49 +04:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-01-07 21:14:03 +03:00
|
|
|
int
|
2013-01-30 03:02:26 +04:00
|
|
|
opal_iftupletoaddr(const char *inaddr, uint32_t *net, uint32_t *mask)
|
2009-10-09 19:24:41 +04:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2010-01-07 21:14:03 +03:00
|
|
|
|
2011-06-07 06:09:11 +04:00
|
|
|
int opal_ifmatches(int idx, char **nets)
|
2011-06-05 23:16:42 +04:00
|
|
|
{
|
2011-06-07 06:09:11 +04:00
|
|
|
return OPAL_ERR_NOT_SUPPORTED;
|
2011-06-05 23:16:42 +04:00
|
|
|
}
|
|
|
|
|
2012-11-16 08:02:29 +04:00
|
|
|
void opal_ifgetaliases(char ***aliases)
|
|
|
|
{
|
2012-11-16 18:28:30 +04:00
|
|
|
/* set default answer */
|
|
|
|
*aliases = NULL;
|
2012-11-16 08:02:29 +04:00
|
|
|
}
|
|
|
|
|
2005-07-13 08:16:03 +04:00
|
|
|
#endif /* HAVE_STRUCT_SOCKADDR_IN */
|
2007-04-25 23:08:07 +04:00
|
|
|
|