Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -682,3 +682,6 @@ test/util/opal_path_nfs
test/util/opal_path_nfs.out
test/util/opal_bit_ops
test/util/bipartite_graph

opal/test/reachable/reachable_netlink
opal/test/reachable/reachable_weighted
3 changes: 2 additions & 1 deletion opal/mca/reachable/base/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ headers += \

libmca_reachable_la_SOURCES += \
base/reachable_base_frame.c \
base/reachable_base_select.c
base/reachable_base_select.c \
base/reachable_base_alloc.c
4 changes: 4 additions & 0 deletions opal/mca/reachable/base/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ OPAL_DECLSPEC extern mca_base_framework_t opal_reachable_base_framework;
*/
OPAL_DECLSPEC int opal_reachable_base_select(void);

OPAL_DECLSPEC opal_reachable_t * opal_reachable_allocate(unsigned int num_local,
unsigned int num_remote);


END_C_DECLS

#endif
4 changes: 2 additions & 2 deletions opal/mca/reachable/base/owner.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
# owner: institution that is responsible for this package
# status: e.g. active, maintenance, unmaintained
#
owner: INTEL
status: unmaintained
owner: AMAZON
status: active
66 changes: 66 additions & 0 deletions opal/mca/reachable/base/reachable_base_alloc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright (c) 2017 Amazon.com, Inc. or its affiliates.
* All Rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/

#include "opal_config.h"

#include "opal/class/opal_object.h"

#include "opal/mca/reachable/reachable.h"
#include "opal/mca/reachable/base/base.h"


static void opal_reachable_construct(opal_reachable_t *reachable)
{
reachable->weights = NULL;
}


static void opal_reachable_destruct(opal_reachable_t * reachable)
{
if (NULL != reachable->memory) {
free(reachable->memory);
}
}


opal_reachable_t * opal_reachable_allocate(unsigned int num_local,
unsigned int num_remote)
{
char *memory;
unsigned int i;
opal_reachable_t *reachable = OBJ_NEW(opal_reachable_t);

reachable->num_local = num_local;
reachable->num_remote = num_remote;

/* allocate all the pieces of the two dimensional array in one
malloc, rather than a bunch of little allocations */
memory = malloc(sizeof(int*) * num_local +
num_local * (sizeof(int) * num_remote));
if (memory == NULL) return NULL;

reachable->memory = (void*)memory;
reachable->weights = (int**)reachable->memory;
memory += (sizeof(int*) * num_local);

for (i = 0; i < num_local; i++) {
reachable->weights[i] = (int*)memory;
memory += (sizeof(int) * num_remote);
}

return reachable;
}

OBJ_CLASS_INSTANCE(
opal_reachable_t,
opal_object_t,
opal_reachable_construct,
opal_reachable_destruct
);
1 change: 0 additions & 1 deletion opal/mca/reachable/netlink/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ sources = \
reachable_netlink.h \
reachable_netlink_component.c \
reachable_netlink_module.c \
libnl1_utils.h \
libnl3_utils.h \
libnl_utils.h \
reachable_netlink_utils_common.c
Expand Down
101 changes: 18 additions & 83 deletions opal/mca/reachable/netlink/configure.m4
Original file line number Diff line number Diff line change
Expand Up @@ -3,94 +3,15 @@
# Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
# Copyright (c) 2015-2016 Research Organization for Information Science
# and Technology (RIST). All rights reserved.
# Copyright (c) 2017 Amazon.com, Inc. or its affiliates.
# All Rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#

dnl
dnl Portions of this software copied from libfabric
dnl (https://github.com/ofiwg/libfabric)
dnl

dnl BSD license
dnl
dnl Redistribution and use in source and binary forms, with or without
dnl modification, are permitted provided that the following conditions
dnl are met:
dnl
dnl * Redistributions of source code must retain the above copyright
dnl notice, this list of conditions and the following disclaimer.
dnl
dnl * Redistributions in binary form must reproduce the above
dnl copyright notice, this list of conditions and the following
dnl disclaimer in the documentation and/or other materials provided
dnl with the distribution.
dnl
dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
dnl "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
dnl FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
dnl COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
dnl INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
dnl BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
dnl LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
dnl CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
dnl LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
dnl ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
dnl POSSIBILITY OF SUCH DAMAGE.

dnl Check for libnl; prefer version 3 instead of version 1. Abort (i.e.,
dnl AC_MSG_ERROR) if neither libnl v1 or v3 can be found.
dnl
dnl Outputs:
dnl
dnl - Set $1 to the CPPFLAGS necessary to compile with libnl
dnl - Set $2 to the LIBS necessary to link with libnl
dnl - If $3 is 1, AC_MSG_ERROR (i.e., abort) if neither libnl or
dnl libnl3 can be found
dnl - Set OPAL_HAVE_LIBNL3 to 1 if libnl v3 will be used; 0 if libnl v1 will be used
dnl - AC_SUBST $OPAL_HAVE_LIBNL3
dnl - AC_DEFINE OPAL_HAVE_LIBNL3
dnl
dnl --------------------------------------------------------
AC_DEFUN([OPAL_REACHABLE_NETLINK_CHECK_LIBNL_Vx],[

# Default to a numeric value (this value gets AC_DEFINEd)
OPAL_HAVE_LIBNL3=0

###################################################
# NOTE: We *must* check for libnl3 before libnl.
###################################################

AS_IF([test $opal_libnl_version -ne 1],
[OPAL_CHECK_LIBNL_V3([$opal_libnl_location], [opal_reachable_netlink])])
AS_IF([test $opal_libnl_version -ne 3 &&
test -z "$opal_reachable_netlink_LIBS"],
[OPAL_CHECK_LIBNL_V1([$opal_libnl_location], [opal_reachable_netlink])])

AS_IF([test "$opal_want_libnl" = "yes" &&
test "$opal_reachable_netlink_LIBS" = ""],
[AC_MSG_WARN([--with-libnl specified, but not found])
AC_MSG_ERROR([Cannot continue])])

# Final result
AC_SUBST([OPAL_HAVE_LIBNL3])
AC_DEFINE_UNQUOTED([OPAL_HAVE_LIBNL3], [$OPAL_HAVE_LIBNL3],
[Whether we have libl v1 or libnl v3])

AC_SUBST([opal_reachable_netlink_CPPFLAGS])
AC_SUBST([opal_reachable_netlink_LDFLAGS])
AC_SUBST([opal_reachable_netlink_LIBS])

AS_IF([test "$opal_reachable_netlink_LIBS" = ""],
[opal_reachable_netlink_happy=0])
])

dnl ==============================================================

# MCA_opal_reachable_netlink_CONFIG([action-if-can-compile],
# [action-if-cant-compile])
# ------------------------------------------------
Expand All @@ -106,12 +27,26 @@ AC_DEFUN([MCA_opal_reachable_netlink_CONFIG],[
#include <net/if.h>
])

AS_IF([test $opal_reachable_netlink_happy -eq 1],
[OPAL_REACHABLE_NETLINK_CHECK_LIBNL_Vx])
# this is terrible, but libnl-1 and libnl-3 are incompatible in
# weird ways, and once there are libraries in LIBS for one, the
# other is hard to get right. So if someone has already decided
# we have libnl version 1, get out. Otherwise, see if we have
# libnl-3, which is the only version supported by the netlink
# component.
AS_IF([test $opal_libnl_version -eq 1],
[opal_reachable_netlink_happy=0],
[OPAL_CHECK_LIBNL_V3([$opal_libnl_location],
[opal_reachable_netlink])
AS_IF([test "$OPAL_HAVE_LIBNL3" != "1"],
[opal_reachable_netlink_happy=0])])

AS_IF([test $opal_reachable_netlink_happy -eq 1],
[$1],
[$2])

AC_SUBST([opal_reachable_netlink_CPPFLAGS])
AC_SUBST([opal_reachable_netlink_LDFLAGS])
AC_SUBST([opal_reachable_netlink_LIBS])

OPAL_VAR_SCOPE_POP()
])
97 changes: 0 additions & 97 deletions opal/mca/reachable/netlink/libnl1_utils.h

This file was deleted.

8 changes: 5 additions & 3 deletions opal/mca/reachable/netlink/libnl3_utils.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/*
* Copyright (c) 2014, Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2017 Amazon.com, Inc. or its affiliates.
* All Rights reserved.
*
* Portions of this software copied from libfabric
* (https://github.com/ofiwg/libfabric)
Expand Down Expand Up @@ -69,12 +71,12 @@ typedef struct nl_sock NL_HANDLE;
} \
} while (0)

struct usnic_rt_cb_arg {
uint32_t nh_addr;
struct opal_reachable_netlink_rt_cb_arg {
int oif;
int found;
int has_gateway;
int replied;
struct usnic_nl_sk *unlsk;
struct opal_reachable_netlink_sk *unlsk;
};

#endif /* LIBNL3_UTILS_H */
Loading