1
1

reachable: remove libnl-1 support from netlink

The netlink reachable component has never been released in a usable
form, but had code copied from usNIC to support both libnl-1 and
libnl-3.  If nothing else, this code was a little buggy in
handling the case where libnl-3 but not libnl-route-3 were
installed.  Jeff and I decided to drop libnl-1 support from the
netlink reachable component, given that it's getting pretty old
and the weighted component provides the same information that
the TCP BTL and OOB are using today, so libnl-1 customers won't
see a step backwards from where they are today.

Signed-off-by: Brian Barrett <bbarrett@mazon.com>
Этот коммит содержится в:
Brian Barrett 2017-09-15 04:32:51 +00:00
родитель 3f8d294191
Коммит a543e7f130
4 изменённых файлов: 18 добавлений и 189 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -3,6 +3,8 @@
# 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
@ -10,87 +12,6 @@
# $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])
# ------------------------------------------------
@ -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()
])

Просмотреть файл

@ -1,99 +0,0 @@
/*
* 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)
*
* LICENSE_BEGIN
*
* BSD license:
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
*
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* LICENSE_END
*
*
*/
#ifndef LIBNL1_UTILS_H
#define LIBNL1_UTILS_H
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
#include <netlink/netlink.h>
#include <netlink/route/rtnl.h>
#include <netlink/route/route.h>
typedef struct nl_handle NL_HANDLE;
#define NLMSG_SIZE(size) nlmsg_msg_size(size)
#define NL_GETERROR(err) nl_geterror()
#define NL_HANDLE_ALLOC nl_handle_alloc
#define NL_HANDLE_FREE nl_handle_destroy
#define NL_DISABLE_SEQ_CHECK nl_disable_sequence_check
#define INC_CB_MSGCNT(arg) \
do { \
arg->msg_cnt++; \
} while (0)
/*
* the return value of nl_recvmsgs_default does not tell
* whether it returns because of successful read or socket
* timeout. This is a limitation in libnl1. So we compare
* message count before and after the call to decide if there
* is no new message arriving. In this case, this function
* needs to terminate to prevent the caller from
* blocking forever.
* NL_CB_MSG_IN traps every received message, so
* there should be no premature exit
*/
#define NL_RECVMSGS(nlh, cb_arg, rc, err, out) \
do { \
int msg_cnt = cb_arg.msg_cnt; \
err = nl_recvmsgs_default(nlh); \
if (err < 0) { \
opal_output(0, "Failed to receive netlink reply message, error %s\n", \
NL_GETERROR(err)); \
goto out; \
} \
if (msg_cnt == cb_arg.msg_cnt) {\
err = rc; \
goto out; \
} \
} while (0)
struct opal_reachable_netlink_rt_cb_arg {
uint32_t nh_addr;
int oif;
int found;
int msg_cnt;
struct opal_reachable_netlink_sk *unlsk;
};
#endif /* LIBNL1_UTILS_H */

Просмотреть файл

@ -46,13 +46,7 @@
#ifndef LIBNL_UTILS_H
#define LIBNL_UTILS_H
#if !defined (OPAL_HAVE_LIBNL3)
#error You must define OPAL_HAVE_LIBNL3 to 0 or 1 before including libnl_utils.h
#elif OPAL_HAVE_LIBNL3
#include "libnl3_utils.h"
#else
#include "libnl1_utils.h"
#endif
struct opal_reachable_netlink_sk {
NL_HANDLE *nlh;