From 7cb1daa8d9e65ec7807481d0c29bbb5c6ac5b78c Mon Sep 17 00:00:00 2001 From: Jason Gunthorpe Date: Mon, 29 Aug 2016 22:07:00 -0600 Subject: [PATCH 01/28] Be consistent about defining NDEBUG We setup the two standard CMake build_types so that Release includes NDEBUG and RelWithDebInfo does not (by default CMake sets it in both). The recommendation is for packagers to use Release (by setting -DCMAKE_BUILD_TYPE=Release) and developers use RelWithDebInfo (the default) This also replaces the default flags for Release with the RelWithDebInfo, flags (-O2 -g -DNDEBUG) which is what we consider suitable for packaging. The CMake default of -O3 is not tested. Note that all the packaging systems I looked at force NDEBUG into the CFLAGS. Signed-off-by: Jason Gunthorpe --- CMakeLists.txt | 5 +++++ buildlib/RDMA_BuildType.cmake | 41 +++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 buildlib/RDMA_BuildType.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index a829cd477..06dd98203 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,9 @@ # Common options passed to cmake are: # -DCMAKE_EXPORT_COMPILE_COMMANDS=1 # Write a compile_commands.json file for clang tooling +# -DCMAKE_BUILD_TYPE=RelWithDebInfo +# Change the optimization level, Debug disables optimization, +# Release is for packagers # -DENABLE_VALGRIND=1 (default disabled) # Embed valgrind notations, this has a tiny negative performance impact # -DENABLE_RESOLVE_NEIGH=0 (default enabled) @@ -58,12 +61,14 @@ include(CheckCCompilerFlag) include(CheckIncludeFile) include(CheckTypeSize) include(RDMA_EnableCStd) +include(RDMA_BuildType) include(RDMA_DoFixup) include(publish_headers) include(rdma_functions) #------------------------- # Setup the basic C compiler +RDMA_BuildType() include_directories(${BUILD_INCLUDE}) # FIXME: Eliminate HAVE_CONFIG_H, we always have it. add_definitions(-DHAVE_CONFIG_H) diff --git a/buildlib/RDMA_BuildType.cmake b/buildlib/RDMA_BuildType.cmake new file mode 100644 index 000000000..4f7485c39 --- /dev/null +++ b/buildlib/RDMA_BuildType.cmake @@ -0,0 +1,41 @@ +# COPYRIGHT (c) 2015 Obsidian Research Corporation. See COPYING file + +function(RDMA_BuildType) + set(build_types Debug Release RelWithDebInfo MinSizeRel) + + # Set the default build type to RelWithDebInfo. Since RDMA is typically used + # in performance contexts it doesn't make much sense to have the default build + # turn off the optimizer. + if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE String + "Options are ${build_types}" + FORCE + ) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${build_types}) + endif() + + # Release should be used by packagers, it is the same as the default RelWithDebInfo, + # this means it uses -O2 and -DNDEBUG (not -O3) + foreach (language CXX C) + set(VAR_TO_MODIFY "CMAKE_${language}_FLAGS_RELEASE") + if ("${${VAR_TO_MODIFY}}" STREQUAL "${${VAR_TO_MODIFY}_INIT}") + set(${VAR_TO_MODIFY} "${CMAKE_${language}_FLAGS_RELWITHDEBINFO_INIT}" + CACHE STRING "Default flags for Release configuration" FORCE) + endif() + endforeach() + + # RelWithDebInfo should be used by developers, it is the same as Release but + # with the -DNDEBUG removed + foreach (language CXX C) + set(VAR_TO_MODIFY "CMAKE_${language}_FLAGS_RELWITHDEBINFO") + if (${${VAR_TO_MODIFY}} STREQUAL ${${VAR_TO_MODIFY}_INIT}) + string(REGEX REPLACE "(^| )[/-]D *NDEBUG($| )" + " " + replacement + "${${VAR_TO_MODIFY}}" + ) + set(${VAR_TO_MODIFY} "${replacement}" + CACHE STRING "Default flags for RelWithDebInfo configuration" FORCE) + endif() + endforeach() +endfunction() From 35c52fe1dce718f497e59795ac913d0c1f45b02c Mon Sep 17 00:00:00 2001 From: Jason Gunthorpe Date: Sat, 27 Aug 2016 15:09:07 -0600 Subject: [PATCH 02/28] Switch valgrind memcheck.h to on by default We now recommend that this source be built with valgrind memcheck.h present, so use it automatically if it is available. Users looking to remove this tiny overhead can build with -DENABLE_VALGRIND=0 Downstream packagers should ensure the build is done with valgrind headers available. NOTE: Fedora/CentOS have shipped with valgrind turn on in their packaging, so for most users this is no change. Signed-off-by: Jason Gunthorpe --- CMakeLists.txt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 06dd98203..be82c2896 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,8 +10,8 @@ # -DCMAKE_BUILD_TYPE=RelWithDebInfo # Change the optimization level, Debug disables optimization, # Release is for packagers -# -DENABLE_VALGRIND=1 (default disabled) -# Embed valgrind notations, this has a tiny negative performance impact +# -DENABLE_VALGRIND=0 (default enabled) +# Disable valgrind notations, this has a tiny positive performance impact # -DENABLE_RESOLVE_NEIGH=0 (default enabled) # Do not link to libnl and do not resolve neighbours internally for Ethernet, # and do not build iwpmd. @@ -189,9 +189,11 @@ RDMA_DoFixup("${HAVE_RDMA_USER_RXE}" "rdma/rdma_user_rxe.h") #------------------------- # Apply fixups -# FIXME: We should probably always enable memcheck.h, and only selectively -# turn it off in the real high performance paths. There is no reason umad -# should ever have memcheck disabled for instance. +# We prefer to build with valgrind memcheck.h present, but if not, or the user +# requested valgrind disabled, then replace it with our dummy stub. +if (NOT DEFINED ENABLE_VALGRIND) + set(ENABLE_VALGRIND "ON" CACHE BOOL "Enable use of valgrind annotations") +endif() if (ENABLE_VALGRIND) CHECK_INCLUDE_FILE("valgrind/memcheck.h" HAVE_VALGRIND_MEMCHECK) CHECK_INCLUDE_FILE("valgrind/drd.h" HAVE_VALGRIND_DRD) From b2d1bd625e12f3cf478c1979e3ae908618825eee Mon Sep 17 00:00:00 2001 From: Jason Gunthorpe Date: Sat, 27 Aug 2016 15:57:36 -0600 Subject: [PATCH 03/28] Do not produce libtool .la files These were preserved as part of the cmake transition, but no distributor uses them and we don't need them internally, so time for them to go. Signed-off-by: Jason Gunthorpe --- buildlib/rdma_functions.cmake | 99 ----------------------------------- 1 file changed, 99 deletions(-) diff --git a/buildlib/rdma_functions.cmake b/buildlib/rdma_functions.cmake index ea53f3825..8fe8828c0 100644 --- a/buildlib/rdma_functions.cmake +++ b/buildlib/rdma_functions.cmake @@ -151,103 +151,6 @@ function(rdma_alias_man_pages) endforeach() endfunction() -# For compatability write out a libtool .la file. This is only meaningful if -# the end user is statically linking, and only if the library has dependent -# libraries. - -# FIXME: it isn't clear how this is actually useful for provider libraries and -# libibverbs itself, the user must do some trick to get the constructor to run -# in the provider, at least how to do that should be documented someplace.. -function(rdma_make_libtool_la SHARED STATIC LIBS) - get_property(LIB TARGET ${STATIC} PROPERTY OUTPUT_NAME SET) - if (LIB) - get_target_property(LIB ${STATIC} OUTPUT_NAME) - else() - set(LIB ${STATIC}) - endif() - - set(BARE_LAFN "${CMAKE_STATIC_LIBRARY_PREFIX}${LIB}.la") - set(BARE_LIBFN "${CMAKE_STATIC_LIBRARY_PREFIX}${LIB}${CMAKE_STATIC_LIBRARY_SUFFIX}") - - get_property(SOLIB TARGET ${SHARED} PROPERTY OUTPUT_NAME SET) - if (SOLIB) - get_target_property(SOLIB ${SHARED} OUTPUT_NAME) - else() - set(SOLIB ${SHARED}) - endif() - - set(DLNAME "${CMAKE_SHARED_LIBRARY_PREFIX}${SOLIB}${CMAKE_SHARED_LIBRARY_SUFFIX}") - get_property(TMP TARGET ${SHARED} PROPERTY SOVERSION SET) - if (TMP) - get_target_property(VERSION ${SHARED} VERSION) - get_target_property(SOVERSION ${SHARED} SOVERSION) - set(NAMES "${DLNAME}.${VERSION} ${DLNAME}.${SOVERSION} ${DLNAME}") - set(DLNAME "${DLNAME}.${SOVERSION}") - else() - set(NAMES "${DLNAME}") - set(DLNAME "${CMAKE_SHARED_LIBRARY_PREFIX}${SOLIB}${CMAKE_SHARED_LIBRARY_SUFFIX}") - endif() - - if (LIBS) - list(REMOVE_DUPLICATES LIBS) - foreach(I ${LIBS}) - if (I MATCHES "^-l") - list(APPEND DEPS "${I}") - else() - list(APPEND DEPS "-l${I}") - endif() - endforeach() - string(REPLACE ";" " " DEPS "${DEPS}") - endif() - - set(LAFN "${BUILD_LIB}/${BARE_LAFN}") - file(WRITE ${LAFN} - "# ${BARE_LAFN} - a libtool library file\n" - "# Generated by cmake\n" - "#\n" - "# Please DO NOT delete this file!\n" - "# It is necessary for linking the library.\n" - "\n" - "# The name that we can dlopen(3).\n" - "dlname='${DLNAME}'\n" - "\n" - "# Names of this library.\n" - "library_names='${NAMES}'\n" - "\n" - "# The name of the static archive.\n" - "old_library='${BARE_LIBFN}'\n" - "\n" - "# Linker flags that can not go in dependency_libs.\n" - "inherited_linker_flags=''\n" - "\n" - "# Libraries that this one depends upon.\n" - "dependency_libs='${DEPS}'\n" - "\n" - "# Names of additional weak libraries provided by this library\n" - "weak_library_names=''\n" - "\n" - "# Version information for ${CMAKE_STATIC_LIBRARY_PREFIX}${LIB}.\n" - # We don't try very hard to emulate this, it isn't used for static linking anyhow - "current=${SOVERSION}\n" - "age=0\n" - "revision=0\n" - "\n" - "# Is this an already installed library?\n" - "installed=yes\n" - "\n" - "# Should we warn about portability when linking against -modules?\n" - "shouldnotlink=no\n" - "\n" - "# Files to dlopen/dlpreopen\n" - "dlopen=''\n" - "dlpreopen=''\n" - "\n" - "# Directory that this library needs to be installed in:\n" - "libdir='${CMAKE_INSTALL_FULL_LIBDIR}'\n" - ) - install(FILES ${LAFN} DESTINATION "${CMAKE_INSTALL_LIBDIR}") -endfunction() - # Finalize the setup of the static libraries by copying the meta information # from the shared and setting up the libtool .la files. function(rdma_finalize_libs) @@ -274,7 +177,5 @@ function(rdma_finalize_libs) set_target_properties(${STATIC} PROPERTIES LINK_LIBRARIES "${TMP}") list(APPEND LIBS "${TMP}") endif() - - rdma_make_libtool_la(${SHARED} ${STATIC} "${LIBS}") endforeach() endfunction() From 87d0804d42ad07f8536b465a241bb3769d59ae0f Mon Sep 17 00:00:00 2001 From: Jason Gunthorpe Date: Sat, 27 Aug 2016 18:07:11 -0600 Subject: [PATCH 04/28] Do not produce static libraries by default We no longer recommend that static libraries are distributed, this never worked sanely for libibverbs. Use: cmake -DENABLE_STATIC=1 To restore the old behaviour Signed-off-by: Jason Gunthorpe --- CMakeLists.txt | 6 ++++++ buildlib/rdma_functions.cmake | 34 +++++++++++++++++++++------------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index be82c2896..9b9e34e5c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,8 @@ # -DENABLE_RESOLVE_NEIGH=0 (default enabled) # Do not link to libnl and do not resolve neighbours internally for Ethernet, # and do not build iwpmd. +# -DENABLE_STATIC=1 (default disabled) +# Produce static libraries along with the usual shared libraries. cmake_minimum_required(VERSION 2.8.11 FATAL_ERROR) project(RDMA C) @@ -66,6 +68,10 @@ include(RDMA_DoFixup) include(publish_headers) include(rdma_functions) +if (NOT DEFINED ENABLE_STATIC) + set(ENABLE_STATIC "OFF" CACHE BOOL "Produce static linking libraries as well as shared libraries.") +endif() + #------------------------- # Setup the basic C compiler RDMA_BuildType() diff --git a/buildlib/rdma_functions.cmake b/buildlib/rdma_functions.cmake index 8fe8828c0..a4ecd7d4f 100644 --- a/buildlib/rdma_functions.cmake +++ b/buildlib/rdma_functions.cmake @@ -47,14 +47,16 @@ endfunction() # Basic function to produce a standard libary with a GNU LD version script. function(rdma_library DEST VERSION_SCRIPT SOVERSION VERSION) # Create a static library - add_library(${DEST}-static STATIC ${ARGN}) - set_target_properties(${DEST}-static PROPERTIES - OUTPUT_NAME ${DEST} - LIBRARY_OUTPUT_DIRECTORY "${BUILD_LIB}") - install(TARGETS ${DEST}-static DESTINATION "${CMAKE_INSTALL_LIBDIR}") - - list(APPEND RDMA_STATIC_LIBS ${DEST} ${DEST}-static) - set(RDMA_STATIC_LIBS "${RDMA_STATIC_LIBS}" CACHE INTERNAL "") + if (ENABLE_STATIC) + add_library(${DEST}-static STATIC ${ARGN}) + set_target_properties(${DEST}-static PROPERTIES + OUTPUT_NAME ${DEST} + LIBRARY_OUTPUT_DIRECTORY "${BUILD_LIB}") + install(TARGETS ${DEST}-static DESTINATION "${CMAKE_INSTALL_LIBDIR}") + + list(APPEND RDMA_STATIC_LIBS ${DEST} ${DEST}-static) + set(RDMA_STATIC_LIBS "${RDMA_STATIC_LIBS}" CACHE INTERNAL "") + endif() # Create a shared library add_library(${DEST} SHARED ${ARGN}) @@ -85,12 +87,14 @@ function(rdma_provider DEST) # FIXME: This is probably pointless, the provider library has no symbols so # what good is it? Presumably it should be used with -Wl,--whole-archive, # but we don't have any directions on how to make static linking work.. - add_library(${DEST} STATIC ${ARGN}) - set_target_properties(${DEST} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${BUILD_LIB}") - install(TARGETS ${DEST} DESTINATION "${CMAKE_INSTALL_LIBDIR}") + if (ENABLE_STATIC) + add_library(${DEST} STATIC ${ARGN}) + set_target_properties(${DEST} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${BUILD_LIB}") + install(TARGETS ${DEST} DESTINATION "${CMAKE_INSTALL_LIBDIR}") - list(APPEND RDMA_STATIC_LIBS ${DEST}-rdmav2 ${DEST}) - set(RDMA_STATIC_LIBS "${RDMA_STATIC_LIBS}" CACHE INTERNAL "") + list(APPEND RDMA_STATIC_LIBS ${DEST}-rdmav2 ${DEST}) + set(RDMA_STATIC_LIBS "${RDMA_STATIC_LIBS}" CACHE INTERNAL "") + endif() # Create the plugin shared library set(DEST ${DEST}-rdmav2) @@ -155,6 +159,10 @@ endfunction() # from the shared and setting up the libtool .la files. function(rdma_finalize_libs) list(LENGTH RDMA_STATIC_LIBS LEN) + if (LEN LESS 2) + return() + endif() + math(EXPR LEN ${LEN}-1) foreach(I RANGE 0 ${LEN} 2) list(GET RDMA_STATIC_LIBS ${I} SHARED) From cbae6953fd86008f73c668ede39d01e73a04ed56 Mon Sep 17 00:00:00 2001 From: Jason Gunthorpe Date: Fri, 23 Sep 2016 13:21:39 -0600 Subject: [PATCH 05/28] Have cmake run man pages through text substitution rsocket.7 had an errant text substitution that never worked, it is a good idea to have the man pages use the correct paths, so let us have cmake run them through. Any man page ending in '.in' will be substituted automatically. Acked-by: Sean Hefty Signed-off-by: Jason Gunthorpe --- buildlib/rdma_functions.cmake | 13 +++++++++++-- librdmacm/man/CMakeLists.txt | 3 +-- librdmacm/man/{rsocket.7 => rsocket.7.in} | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-) rename librdmacm/man/{rsocket.7 => rsocket.7.in} (97%) diff --git a/buildlib/rdma_functions.cmake b/buildlib/rdma_functions.cmake index a4ecd7d4f..260dd18d7 100644 --- a/buildlib/rdma_functions.cmake +++ b/buildlib/rdma_functions.cmake @@ -135,8 +135,17 @@ endfunction() # filename function(rdma_man_pages) foreach(I ${ARGN}) - string(REGEX REPLACE "^.+[.](.+)$" "\\1" MAN_SECT ${I}) - install(FILES ${I} DESTINATION "${CMAKE_INSTALL_MANDIR}/man${MAN_SECT}/") + if ("${I}" MATCHES "\\.in$") + string(REGEX REPLACE "^.+[.](.+)\\.in$" "\\1" MAN_SECT "${I}") + string(REGEX REPLACE "^(.+)\\.in$" "\\1" BASE_NAME "${I}") + get_filename_component(BASE_NAME "${BASE_NAME}" NAME) + rdma_subst_install(FILES "${I}" + DESTINATION "${CMAKE_INSTALL_MANDIR}/man${MAN_SECT}/" + RENAME "${BASE_NAME}") + else() + string(REGEX REPLACE "^.+[.](.+)$" "\\1" MAN_SECT "${I}") + install(FILES "${I}" DESTINATION "${CMAKE_INSTALL_MANDIR}/man${MAN_SECT}/") + endif() endforeach() endfunction() diff --git a/librdmacm/man/CMakeLists.txt b/librdmacm/man/CMakeLists.txt index 791c98265..5052f96de 100644 --- a/librdmacm/man/CMakeLists.txt +++ b/librdmacm/man/CMakeLists.txt @@ -57,8 +57,7 @@ rdma_man_pages( rdma_xserver.1 riostream.1 rping.1 - # FIXME: rsocket has a text substitution but nothing ever filled it in. - rsocket.7 + rsocket.7.in rstream.1 ucmatose.1 udaddy.1 diff --git a/librdmacm/man/rsocket.7 b/librdmacm/man/rsocket.7.in similarity index 97% rename from librdmacm/man/rsocket.7 rename to librdmacm/man/rsocket.7.in index dfb9804d8..6adf156f4 100644 --- a/librdmacm/man/rsocket.7 +++ b/librdmacm/man/rsocket.7.in @@ -129,7 +129,7 @@ fork off a process to handle the new connection. .P rsockets uses configuration files that give an administrator control over the default settings used by rsockets. Use files under -%sysconfig%/rdma/rsocket as shown: +@CMAKE_INSTALL_FULL_SYSCONFDIR@/rdma/rsocket as shown: .P .P mem_default - default size of receive buffer(s) @@ -149,7 +149,7 @@ polling_time - default number of microseconds to poll for data before waiting All configuration files should contain a single integer value. Values may be set by issuing a command similar to the following example. .P -echo 1000000 > /etc/rdma/rsocket/mem_default +echo 1000000 > @CMAKE_INSTALL_FULL_SYSCONFDIR@/rdma/rsocket/mem_default .P If configuration files are not available, rsockets uses internal defaults. Applications can override default values programmatically through the From 5eebdb9baaaae420a4bb16e586a96807823916a0 Mon Sep 17 00:00:00 2001 From: Jason Gunthorpe Date: Fri, 23 Sep 2016 11:55:45 -0600 Subject: [PATCH 06/28] Consolidate definitions for paths into config.h config.h is the only place we pass through cmake substitution, so it is the only place that can define the various filesystem paths. This patch handles the C code portions that use paths. Acked-by: Sean Hefty Signed-off-by: Jason Gunthorpe --- CMakeLists.txt | 10 ++++++++++ buildlib/config.h.in | 13 +++++++++++-- ibacm/CMakeLists.txt | 5 ----- ibacm/linux/osd.h | 2 +- ibacm/src/acm.c | 6 +++--- ibacm/src/acme.c | 10 +++++----- ibacm/src/libacm.c | 2 +- iwpmd/src/iwarp_pm.h | 1 - iwpmd/src/iwarp_pm_server.c | 1 + librdmacm/src/acm.c | 2 +- librdmacm/src/cma.h | 9 --------- srp_daemon/srp_daemon/srp_daemon.c | 4 ++-- 12 files changed, 35 insertions(+), 30 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b9e34e5c..713788f18 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,6 +53,16 @@ set(CMAKE_INSTALL_SYSTEMD_SERVICEDIR "${CMAKE_INSTALL_PREFIX}/lib/systemd" set(ACM_PROVIDER_DIR "${CMAKE_INSTALL_FULL_LIBDIR}/ibacm" CACHE PATH "Location for ibacm provider plugin shared library files.") +# Allow the 'run' dir to be configurable, this historically has been /var/run, but +# some systems now use /run/ +set(CMAKE_INSTALL_RUNDIR "var/run" + CACHE PATH "Location for runtime information, typically /var/run, or /run") +if(NOT IS_ABSOLUTE ${CMAKE_INSTALL_RUNDIR}) + set(CMAKE_INSTALL_FULL_RUNDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_RUNDIR}") +else() + set(CMAKE_INSTALL_FULL_RUNDIR "${CMAKE_INSTALL_RUNDIR}") +endif() + #------------------------- # Load CMake components set(BUILDLIB "${CMAKE_SOURCE_DIR}/buildlib") diff --git a/buildlib/config.h.in b/buildlib/config.h.in index 984d51bfa..bbc279d3c 100644 --- a/buildlib/config.h.in +++ b/buildlib/config.h.in @@ -17,9 +17,18 @@ #define HAVE_VALGRIND_MEMCHECK_H 1 #define INCLUDE_VALGRIND 1 -#define SYSCONFDIR "@CMAKE_INSTALL_FULL_SYSCONFDIR@" - #define IBV_CONFIG_DIR "@CONFIG_DIR@" +#define RS_CONF_DIR "@CMAKE_INSTALL_FULL_SYSCONFDIR@/rdma/rsocket" +#define IWPM_CONFIG_FILE "@CMAKE_INSTALL_FULL_SYSCONFDIR@/iwpmd.conf" + +#define SRP_DEAMON_CONFIG_FILE "@CMAKE_INSTALL_FULL_SYSCONFDIR@/srp_daemon.conf" + +#define ACM_CONF_DIR "@CMAKE_INSTALL_FULL_SYSCONFDIR@/rdma" +#define IBACM_LIB_PATH "@ACM_PROVIDER_DIR@" +#define IBACM_BIN_PATH "@CMAKE_INSTALL_FULL_BINDIR@" +#define IBACM_PID_FILE "@CMAKE_INSTALL_FULL_RUNDIR@/ibacm.pid" +#define IBACM_PORT_FILE "@CMAKE_INSTALL_FULL_RUNDIR@/ibacm.port" +#define IBACM_LOG_FILE "@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/log/ibacm.log" // FIXME This has been supported in compilers forever, we should just fail to build on such old systems. #cmakedefine HAVE_FUNC_ATTRIBUTE_ALWAYS_INLINE 1 diff --git a/ibacm/CMakeLists.txt b/ibacm/CMakeLists.txt index 8887c13af..857a6e823 100644 --- a/ibacm/CMakeLists.txt +++ b/ibacm/CMakeLists.txt @@ -3,11 +3,6 @@ publish_headers(infiniband include/infiniband/acm_prov.h ) -# FIXME: To config.h -add_definitions("-DIBACM_CONFIG_PATH=\"${CMAKE_INSTALL_FULL_SYSCONFDIR}/rdma\"") -add_definitions("-DIBACM_LIB_PATH=\"${ACM_PROVIDER_DIR}\"") -add_definitions("-DIBACM_BIN_PATH=\"${CMAKE_INSTALL_FULL_BINDIR}\"") - # FIXME: Fixup the include scheme to not require all these -Is include_directories("include") include_directories("src") diff --git a/ibacm/linux/osd.h b/ibacm/linux/osd.h index 5ca4c6f55..83d31b358 100644 --- a/ibacm/linux/osd.h +++ b/ibacm/linux/osd.h @@ -31,6 +31,7 @@ #if !defined(OSD_H) #define OSD_H +#include #include #include #include @@ -46,7 +47,6 @@ #include #include -#define ACM_CONF_DIR IBACM_CONFIG_PATH #define ACM_ADDR_FILE "ibacm_addr.cfg" #define ACM_OPTS_FILE "ibacm_opts.cfg" diff --git a/ibacm/src/acm.c b/ibacm/src/acm.c index ab1269f71..4650421b8 100644 --- a/ibacm/src/acm.c +++ b/ibacm/src/acm.c @@ -226,9 +226,9 @@ static struct sa_data { static char *acme = IBACM_BIN_PATH "/ib_acme -A"; static char *opts_file = ACM_CONF_DIR "/" ACM_OPTS_FILE; static char *addr_file = ACM_CONF_DIR "/" ACM_ADDR_FILE; -static char log_file[128] = "/var/log/ibacm.log"; +static char log_file[128] = IBACM_LOG_FILE; static int log_level = 0; -static char lock_file[128] = "/var/run/ibacm.pid"; +static char lock_file[128] = IBACM_PID_FILE; static short server_port = 6125; static int support_ips_in_addr_cfg = 0; static char prov_lib_path[256] = IBACM_LIB_PATH; @@ -578,7 +578,7 @@ static void acm_init_server(void) atomic_init(&client_array[i].refcnt); } - if (!(f = fopen("/var/run/ibacm.port", "w"))) { + if (!(f = fopen(IBACM_PORT_FILE, "w"))) { acm_log(0, "notice - cannot publish ibacm port number\n"); return; } diff --git a/ibacm/src/acme.c b/ibacm/src/acme.c index f1b0d0106..4d9003047 100644 --- a/ibacm/src/acme.c +++ b/ibacm/src/acme.c @@ -130,9 +130,9 @@ static void gen_opts_temp(FILE *f) fprintf(f, "# Examples:\n"); fprintf(f, "# log_file stdout\n"); fprintf(f, "# log_file stderr\n"); - fprintf(f, "# log_file /var/log/ibacm.log\n"); + fprintf(f, "# log_file %s\n", IBACM_LOG_FILE); fprintf(f, "\n"); - fprintf(f, "log_file /var/log/ibacm.log\n"); + fprintf(f, "log_file %s\n", IBACM_LOG_FILE); fprintf(f, "\n"); fprintf(f, "# log_level:\n"); fprintf(f, "# Indicates the amount of detailed data written to the log file. Log levels\n"); @@ -147,7 +147,7 @@ static void gen_opts_temp(FILE *f) fprintf(f, "# Specifies the location of the ACM lock file used to ensure that only a\n"); fprintf(f, "# single instance of ACM is running.\n"); fprintf(f, "\n"); - fprintf(f, "lock_file /var/run/ibacm.pid\n"); + fprintf(f, "lock_file %s\n", IBACM_PID_FILE); fprintf(f, "\n"); fprintf(f, "# addr_prot:\n"); fprintf(f, "# Default resolution protocol to resolve IP addresses into IB GIDs.\n"); @@ -276,7 +276,7 @@ static void gen_opts_temp(FILE *f) fprintf(f, "# the ACM cache. This option is only valid if route_preload\n"); fprintf(f, "# indicates that routing data should be read from a file.\n"); fprintf(f, "# Default is %s/ibacm_route.data\n", ACM_CONF_DIR); - fprintf(f, "# route_data_file /etc/rdma/ibacm_route.data\n"); + fprintf(f, "# route_data_file %s/ibacm_route.data\n", ACM_CONF_DIR); fprintf(f, "\n"); fprintf(f, "# addr_preload:\n"); fprintf(f, "# Specifies if the ACM address cache should be preloaded, or built on demand.\n"); @@ -292,7 +292,7 @@ static void gen_opts_temp(FILE *f) fprintf(f, "# the ACM cache. This option is only valid if addr_preload\n"); fprintf(f, "# indicates that address data should be read from a file.\n"); fprintf(f, "# Default is %s/ibacm_hosts.data\n", ACM_CONF_DIR); - fprintf(f, "# addr_data_file /etc/rdma/ibacm_hosts.data\n"); + fprintf(f, "# addr_data_file %s/ibacm_hosts.data\n", ACM_CONF_DIR); fprintf(f, "\n"); fprintf(f, "# support_ips_in_addr_cfg:\n"); fprintf(f, "# If 1 continue to read IP addresses from ibacm_addr.cfg\n"); diff --git a/ibacm/src/libacm.c b/ibacm/src/libacm.c index 95e562deb..3ad1db1d3 100644 --- a/ibacm/src/libacm.c +++ b/ibacm/src/libacm.c @@ -48,7 +48,7 @@ static void acm_set_server_port(void) { FILE *f; - if ((f = fopen("/var/run/ibacm.port", "r"))) { + if ((f = fopen(IBACM_PORT_FILE, "r"))) { if (fscanf(f, "%hu", (unsigned short *) &server_port) != 1) printf("Failed to read server port\n"); fclose(f); diff --git a/iwpmd/src/iwarp_pm.h b/iwpmd/src/iwarp_pm.h index bcf88ca30..5b7c6136f 100644 --- a/iwpmd/src/iwarp_pm.h +++ b/iwpmd/src/iwarp_pm.h @@ -85,7 +85,6 @@ #define IWPM_IFNAME_SIZE 16 #define IWPM_IPADDR_SIZE 16 -#define IWPM_CONFIG_FILE "/etc/iwpmd.conf" #define IWPM_PARAM_NUM 1 #define IWPM_PARAM_NAME_LEN 64 diff --git a/iwpmd/src/iwarp_pm_server.c b/iwpmd/src/iwarp_pm_server.c index e1c2a9c66..39e0aa2c3 100644 --- a/iwpmd/src/iwarp_pm_server.c +++ b/iwpmd/src/iwarp_pm_server.c @@ -31,6 +31,7 @@ * */ +#include "config.h" #include "iwarp_pm.h" const char iwpm_ulib_name [] = "iWarpPortMapperUser"; diff --git a/librdmacm/src/acm.c b/librdmacm/src/acm.c index f0da01e6d..75d9d8cf4 100644 --- a/librdmacm/src/acm.c +++ b/librdmacm/src/acm.c @@ -120,7 +120,7 @@ static int ucma_set_server_port(void) { FILE *f; - if ((f = fopen("/var/run/ibacm.port", "r" STREAM_CLOEXEC))) { + if ((f = fopen(IBACM_PORT_FILE, "r" STREAM_CLOEXEC))) { fscanf(f, "%" SCNu16, &server_port); fclose(f); } diff --git a/librdmacm/src/cma.h b/librdmacm/src/cma.h index 98eba8dc2..091d10465 100644 --- a/librdmacm/src/cma.h +++ b/librdmacm/src/cma.h @@ -179,13 +179,4 @@ struct ib_connect_hdr { #define cma_dst_ip6 dst_addr[0] }; -#ifndef SYSCONFDIR -#define SYSCONFDIR "/etc" -#endif -#ifndef RDMADIR -#define RDMADIR "rdma" -#endif -#define RDMA_CONF_DIR SYSCONFDIR "/" RDMADIR -#define RS_CONF_DIR RDMA_CONF_DIR "/rsocket" - #endif /* CMA_H */ diff --git a/srp_daemon/srp_daemon/srp_daemon.c b/srp_daemon/srp_daemon/srp_daemon.c index dfc976b8f..70764e00f 100644 --- a/srp_daemon/srp_daemon/srp_daemon.c +++ b/srp_daemon/srp_daemon/srp_daemon.c @@ -226,7 +226,7 @@ static void usage(const char *argv0) fprintf(stderr, "-R perform complete Rescan every seconds\n"); fprintf(stderr, "-T Retries to connect to existing target after Timeout of seconds\n"); fprintf(stderr, "-l Transport retry count before failing IO. should be in range [2..7], (default 2)\n"); - fprintf(stderr, "-f use rules File to set to which target(s) to connect (default: /etc/srp_daemon.conf\n"); + fprintf(stderr, "-f use rules File to set to which target(s) to connect (default: " SRP_DEAMON_CONFIG_FILE ")\n"); fprintf(stderr, "-t Timeout for mad response in milliseconds\n"); fprintf(stderr, "-r number of send Retries for each mad\n"); fprintf(stderr, "-n New connection command format - use also initiator extension\n"); @@ -1622,7 +1622,7 @@ static int get_config(struct config_t *conf, int argc, char *argv[]) conf->retry_timeout = 20; conf->add_target_file = NULL; conf->print_initiator_ext = 0; - conf->rules_file = "/etc/srp_daemon.conf"; + conf->rules_file = SRP_DEAMON_CONFIG_FILE; conf->rules = NULL; conf->tl_retry_count = 0; From 550d1603efa4d93bf9ae33b4ad1247e66597c10e Mon Sep 17 00:00:00 2001 From: Jason Gunthorpe Date: Fri, 23 Sep 2016 12:26:58 -0600 Subject: [PATCH 07/28] Pass ancillary files that use paths through cmake substitution This removes hardwired paths from the documentation and broadly makes the documentation and scripts match what the C code is now doing. Signed-off-by: Jason Gunthorpe --- ibacm/CMakeLists.txt | 2 +- ibacm/ibacm.init.in | 2 +- ibacm/man/{ibacm_prov.7 => ibacm_prov.7.in} | 4 ++-- iwpmd/CMakeLists.txt | 4 ++-- iwpmd/{iwpmd.1 => iwpmd.1.in} | 2 +- iwpmd/{iwpmd.conf.5 => iwpmd.conf.5.in} | 2 +- srp_daemon/man/CMakeLists.txt | 2 +- srp_daemon/man/{srp_daemon.1 => srp_daemon.1.in} | 8 ++++---- srp_daemon/srp_daemon/CMakeLists.txt | 4 +++- srp_daemon/srp_daemon/{srp_daemon.sh => srp_daemon.sh.in} | 4 ++-- srp_daemon/srp_daemon/srpd.in | 6 +++--- 11 files changed, 21 insertions(+), 19 deletions(-) rename ibacm/man/{ibacm_prov.7 => ibacm_prov.7.in} (95%) rename iwpmd/{iwpmd.1 => iwpmd.1.in} (98%) rename iwpmd/{iwpmd.conf.5 => iwpmd.conf.5.in} (92%) rename srp_daemon/man/{srp_daemon.1 => srp_daemon.1.in} (90%) rename srp_daemon/srp_daemon/{srp_daemon.sh => srp_daemon.sh.in} (95%) diff --git a/ibacm/CMakeLists.txt b/ibacm/CMakeLists.txt index 857a6e823..376a3a89d 100644 --- a/ibacm/CMakeLists.txt +++ b/ibacm/CMakeLists.txt @@ -52,7 +52,7 @@ rdma_man_pages( man/ib_acme.1 man/ibacm.1 man/ibacm.7 - man/ibacm_prov.7 + man/ibacm_prov.7.in ) # FIXME: update the .init.in diff --git a/ibacm/ibacm.init.in b/ibacm/ibacm.init.in index aea262b67..0fb0011f3 100644 --- a/ibacm/ibacm.init.in +++ b/ibacm/ibacm.init.in @@ -19,7 +19,7 @@ # host route lookups. ### END INIT INFO -pidfile=/var/run/ibacm.pid +pidfile=@CMAKE_INSTALL_FULL_RUNDIR@/ibacm.pid subsys=/var/lock/subsys/ibacm daemon() { /sbin/daemon ${1+"$@"}; } diff --git a/ibacm/man/ibacm_prov.7 b/ibacm/man/ibacm_prov.7.in similarity index 95% rename from ibacm/man/ibacm_prov.7 rename to ibacm/man/ibacm_prov.7.in index d04617e83..9e79d58f6 100644 --- a/ibacm/man/ibacm_prov.7 +++ b/ibacm/man/ibacm_prov.7.in @@ -12,7 +12,7 @@ To add a provider to the ibacm core service, the provider must .TP 1. be implemented as a shared library; .TP -2. be installed under a configured directory, eg., /usr/lib64/ibacm/; +2. be installed under a configured directory, eg., @ACM_PROVIDER_DIR@; .TP 3 export a function provider_query() that returns a pointer to its provider info and version info. @@ -66,7 +66,7 @@ Non-related sections should be ignored. .P Some helper functions are also exported by the ibacm core. For example, the acm_log define (or the acm_write() function) can be used to log messages into -ibacm's log file (default /var/log/ibacm.log). For details, refer to +ibacm's log file (default @CMAKE_INSTALL_FULL_LOCALSTATEDIR@/log/ibacm.log). For details, refer to the acm_prov.h file. .SH "NOTES" A provider should always set the version in its provider info structure as the diff --git a/iwpmd/CMakeLists.txt b/iwpmd/CMakeLists.txt index 21208dd5b..89a715128 100644 --- a/iwpmd/CMakeLists.txt +++ b/iwpmd/CMakeLists.txt @@ -1,4 +1,4 @@ rdma_man_pages( - iwpmd.1 - iwpmd.conf.5 + iwpmd.1.in + iwpmd.conf.5.in ) diff --git a/iwpmd/iwpmd.1 b/iwpmd/iwpmd.1.in similarity index 98% rename from iwpmd/iwpmd.1 rename to iwpmd/iwpmd.1.in index a4948c509..88eece7f6 100644 --- a/iwpmd/iwpmd.1 +++ b/iwpmd/iwpmd.1.in @@ -51,6 +51,6 @@ to the system message log. .P SIGTERM/SIGHUP will force iwpmd to exit. .SH "FILES" -/etc/iwpmd.conf +@CMAKE_INSTALL_FULL_SYSCONFDIR@/iwpmd.conf .SH "SEE ALSO" rdma_cm(7) diff --git a/iwpmd/iwpmd.conf.5 b/iwpmd/iwpmd.conf.5.in similarity index 92% rename from iwpmd/iwpmd.conf.5 rename to iwpmd/iwpmd.conf.5.in index 9dfe137d3..1baae82b7 100644 --- a/iwpmd/iwpmd.conf.5 +++ b/iwpmd/iwpmd.conf.5.in @@ -15,6 +15,6 @@ to communicate with the kernel port map client. The default is 400MB. .SH "EXAMPLES" nl_sock_rbuf_size=419430400 .SH "FILES" -/etc/iwpmd.conf +@CMAKE_INSTALL_FULL_SYSCONFDIR@/iwpmd.conf .SH "SEE ALSO" iwpmd(1) diff --git a/srp_daemon/man/CMakeLists.txt b/srp_daemon/man/CMakeLists.txt index f05de60b9..cd644a6bd 100644 --- a/srp_daemon/man/CMakeLists.txt +++ b/srp_daemon/man/CMakeLists.txt @@ -1,4 +1,4 @@ rdma_man_pages( ibsrpdm.1 - srp_daemon.1 + srp_daemon.1.in ) diff --git a/srp_daemon/man/srp_daemon.1 b/srp_daemon/man/srp_daemon.1.in similarity index 90% rename from srp_daemon/man/srp_daemon.1 rename to srp_daemon/man/srp_daemon.1.in index 6117e3679..6ee114284 100644 --- a/srp_daemon/man/srp_daemon.1 +++ b/srp_daemon/man/srp_daemon.1.in @@ -15,7 +15,7 @@ Each srp_daemon instance operates on one local port. Upon boot it performs a ful When a new machine joins the fabric, srp_daemon checks if it is a target. When there is a change of capabilities, srp_daemon checks if the machine has turned into a target. When there is an SA change or a timeout expiration, srp_daemon performs a full rescan of the fabric. -For each target srp_daemon finds, it checks if it should connect to this target according to its rules (default rules file is /etc/srp_daemon.conf) and if it is already connected to the local port. If it should connect to this target and if it is not connected yet, srp_daemon can either print the target details or connect to it. +For each target srp_daemon finds, it checks if it should connect to this target according to its rules (default rules file is @CMAKE_INSTALL_FULL_SYSCONFDIR@/srp_daemon.conf) and if it is already connected to the local port. If it should connect to this target and if it is not connected yet, srp_daemon can either print the target details or connect to it. .SH OPTIONS @@ -57,7 +57,7 @@ Retries to connect to existing target after \fIretry-Timeout\fR seconds. If -R i .TP \fB\-f\fR \fIrules-File\fR Decide to which targets to connect according to the rules in \fIrules-File\fR. -If \fB\-f\fR is not specified, uses the default rules file /etc/srp_daemon.conf. +If \fB\-f\fR is not specified, uses the default rules file @CMAKE_INSTALL_FULL_SYSCONFDIR@/srp_daemon.conf. Each line in the \fIrules-File\fR is a rule which can be either an allow connection or a disallow connection according to the first character in the line (a or d accordingly). The rest of the line is values for id_ext, ioc_guid, dgid, service_id. Please take a look at the example section for an example of the file. srp_daemon decide whether to allow or disallow each target according to first rule that match the target. If no rule matches the target, the target is allowed and will be connected. In an allow rule it is possible to set attributes for the connection to the target. Supported attributes are max_cmd_per_lun and max_sect. @@ -72,7 +72,7 @@ Perform \fIretries\fR retries on each send to MAD (default: 3 retries). New format - use also initiator_ext in the connection command. .SH FILES -/etc/srp_daemon.conf - +@CMAKE_INSTALL_FULL_SYSCONFDIR@/srp_daemon.conf - Default rules configuration file that indicates to which targets to connect. Can be overridden using the \fB\-f\fR \fIrules-File\fR option. Each line in this file is a rule which can be either an allow connection or a disallow connection according to the first character in the line (a or d accordingly). The rest of the line is values for id_ext, ioc_guid, dgid, @@ -86,7 +86,7 @@ srp_daemon -o -c -a (Prints the connection commands for the targets in the srp_daemon -e -f rules.txt (Connects to the targets allowed in the rules file rules.txt) .nf -An example for a rules configuration file (such as /etc/srp_daemon.conf) +An example for a rules configuration file (such as @CMAKE_INSTALL_FULL_SYSCONFDIR@/srp_daemon.conf) ------------------------------------------------------------------------ # Rules file example # This is a comment diff --git a/srp_daemon/srp_daemon/CMakeLists.txt b/srp_daemon/srp_daemon/CMakeLists.txt index 84d740441..fe6b41811 100644 --- a/srp_daemon/srp_daemon/CMakeLists.txt +++ b/srp_daemon/srp_daemon/CMakeLists.txt @@ -15,7 +15,9 @@ target_link_libraries(srp_daemon rdma_install_symlink(srp_daemon "${CMAKE_INSTALL_SBINDIR}/ibsrpdm") # FIXME: Why? rdma_install_symlink(srp_daemon "${CMAKE_INSTALL_SBINDIR}/run_srp_daemon") -install(FILES srp_daemon.sh DESTINATION "${CMAKE_INSTALL_SBINDIR}") +rdma_subst_install(FILES "srp_daemon.sh.in" + DESTINATION "${CMAKE_INSTALL_SBINDIR}" + RENAME "srp_daemon.sh") install(FILES logrotate-srp_daemon DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/logrotate.d" RENAME "srp_daemon") install(FILES rsyslog-srp_daemon.conf DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/rsyslog.d" RENAME "srp_daemon.conf") diff --git a/srp_daemon/srp_daemon/srp_daemon.sh b/srp_daemon/srp_daemon/srp_daemon.sh.in similarity index 95% rename from srp_daemon/srp_daemon/srp_daemon.sh rename to srp_daemon/srp_daemon/srp_daemon.sh.in index 3981a0d4b..cb0b81efe 100755 --- a/srp_daemon/srp_daemon/srp_daemon.sh +++ b/srp_daemon/srp_daemon/srp_daemon.sh.in @@ -30,12 +30,12 @@ shopt -s nullglob -prog=/usr/sbin/srp_daemon +prog=@CMAKE_INSTALL_FULL_SBINDIR@/srp_daemon params=$@ ibdir="/sys/class/infiniband" rescan_interval=60 pids="" -pidfile=/var/run/srp_daemon.sh.pid +pidfile=@CMAKE_INSTALL_FULL_RUNDIR@/srp_daemon.sh.pid mypid=$$ trap_handler() diff --git a/srp_daemon/srp_daemon/srpd.in b/srp_daemon/srp_daemon/srpd.in index 10692e7e0..d77579170 100755 --- a/srp_daemon/srp_daemon/srpd.in +++ b/srp_daemon/srp_daemon/srpd.in @@ -4,7 +4,7 @@ # # chkconfig: - 25 75 # description: Starts/Stops InfiniBand SRP client service -# config: /etc/srp_daemon.conf +# config: @CMAKE_INSTALL_FULL_SYSCONFDIR@/srp_daemon.conf # ### BEGIN INIT INFO # Provides: srpd @@ -32,8 +32,8 @@ fi if [ -f $RDMA_CONFIG ]; then . $RDMA_CONFIG fi -pidfile=/var/run/srp_daemon.sh.pid -prog=/usr/sbin/srp_daemon.sh +pidfile=@CMAKE_INSTALL_FULL_RUNDIR@/srp_daemon.sh.pid +prog=@CMAKE_INSTALL_FULL_SBINDIR@/srp_daemon.sh checkpid() { [ -e "/proc/$1" ] From 8bef8370f48fc6a9af16e9318a3948a8e20753ae Mon Sep 17 00:00:00 2001 From: Jason Gunthorpe Date: Fri, 23 Sep 2016 12:16:01 -0600 Subject: [PATCH 08/28] srp_daemon: Move lock file into /var/run/ '/var/tmp' is an inappropriate places for lock files of this nature, they belong in /var/run. /var/lock does not seem suitable because this lock is not against a basic device node. Signed-off-by: Jason Gunthorpe --- buildlib/config.h.in | 1 + srp_daemon/srp_daemon/srp_daemon.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/buildlib/config.h.in b/buildlib/config.h.in index bbc279d3c..78994a39d 100644 --- a/buildlib/config.h.in +++ b/buildlib/config.h.in @@ -22,6 +22,7 @@ #define IWPM_CONFIG_FILE "@CMAKE_INSTALL_FULL_SYSCONFDIR@/iwpmd.conf" #define SRP_DEAMON_CONFIG_FILE "@CMAKE_INSTALL_FULL_SYSCONFDIR@/srp_daemon.conf" +#define SRP_DEAMON_LOCK_PREFIX "@CMAKE_INSTALL_FULL_RUNDIR@/srp_daemon" #define ACM_CONF_DIR "@CMAKE_INSTALL_FULL_SYSCONFDIR@/rdma" #define IBACM_LIB_PATH "@ACM_PROVIDER_DIR@" diff --git a/srp_daemon/srp_daemon/srp_daemon.c b/srp_daemon/srp_daemon/srp_daemon.c index 70764e00f..f16674dbf 100644 --- a/srp_daemon/srp_daemon/srp_daemon.c +++ b/srp_daemon/srp_daemon/srp_daemon.c @@ -131,7 +131,7 @@ static int check_process_uniqueness(struct config_t *conf) char path[256]; int fd; - snprintf(path, sizeof(path), "/var/tmp/srp_daemon_%s_%d", + snprintf(path, sizeof(path), SRP_DEAMON_LOCK_PREFIX "_%s_%d", conf->dev_name, conf->port_num); if ((fd = open(path, O_CREAT|O_RDWR, From 6966d5d3d5a6d4f2891fab6d2221bb881642fbc8 Mon Sep 17 00:00:00 2001 From: Jason Gunthorpe Date: Mon, 12 Sep 2016 14:54:08 -0600 Subject: [PATCH 09/28] verbs: Move the providers into /usr/lib.../libibverbs by default The Debian packaging has always used this path, provide official support for this configuration so Debian does not rely on the absolute path in the .driver file, which breaks biarch. Since there is no reason for the providers to be in the system library search path (they export no symbols, and have no soname) make this the default configuration. The old behaviour can be restored by using: cmake -DVERBS_PROVIDER_DIR='' This continues to support out-of-tree drivers by searching both the provider path and the system library path if an unqualified name is given in the .driver file. Signed-off-by: Jason Gunthorpe --- CMakeLists.txt | 6 ++++ buildlib/config.h.in | 2 ++ buildlib/rdma_functions.cmake | 16 ++++++---- libibverbs/src/init.c | 55 +++++++++++++++++++++++++---------- 4 files changed, 57 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 713788f18..7ae236f88 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,8 @@ # and do not build iwpmd. # -DENABLE_STATIC=1 (default disabled) # Produce static libraries along with the usual shared libraries. +# -DVERBS_PROVIDER_DIR='' (default /usr/lib.../libibverbs) +# Use the historical search path for providers, in the standard system library. cmake_minimum_required(VERSION 2.8.11 FATAL_ERROR) project(RDMA C) @@ -53,6 +55,10 @@ set(CMAKE_INSTALL_SYSTEMD_SERVICEDIR "${CMAKE_INSTALL_PREFIX}/lib/systemd" set(ACM_PROVIDER_DIR "${CMAKE_INSTALL_FULL_LIBDIR}/ibacm" CACHE PATH "Location for ibacm provider plugin shared library files.") +# Location to find the provider plugin shared library files +set(VERBS_PROVIDER_DIR "${CMAKE_INSTALL_FULL_LIBDIR}/libibverbs" + CACHE PATH "Location for provider plugin shared library files. If set to empty the system search path is used.") + # Allow the 'run' dir to be configurable, this historically has been /var/run, but # some systems now use /run/ set(CMAKE_INSTALL_RUNDIR "var/run" diff --git a/buildlib/config.h.in b/buildlib/config.h.in index 78994a39d..8ae2a4e53 100644 --- a/buildlib/config.h.in +++ b/buildlib/config.h.in @@ -31,6 +31,8 @@ #define IBACM_PORT_FILE "@CMAKE_INSTALL_FULL_RUNDIR@/ibacm.port" #define IBACM_LOG_FILE "@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/log/ibacm.log" +#define VERBS_PROVIDER_DIR "@VERBS_PROVIDER_DIR@" + // FIXME This has been supported in compilers forever, we should just fail to build on such old systems. #cmakedefine HAVE_FUNC_ATTRIBUTE_ALWAYS_INLINE 1 diff --git a/buildlib/rdma_functions.cmake b/buildlib/rdma_functions.cmake index 260dd18d7..06ccd518c 100644 --- a/buildlib/rdma_functions.cmake +++ b/buildlib/rdma_functions.cmake @@ -78,11 +78,6 @@ function(rdma_provider DEST) file(MAKE_DIRECTORY "${BUILD_LIB}/libibverbs.d/") file(WRITE "${BUILD_LIB}/libibverbs.d/${DEST}.driver" "driver ${BUILD_LIB}/${DEST}\n") - # FIXME: This symlink is provided for compat with the old build, but it - # never should have existed in the first place, nothing should use this - # name, we can probably remove it. - rdma_install_symlink("lib${DEST}-rdmav2.so" "${CMAKE_INSTALL_LIBDIR}/lib${DEST}.so") - # Create a static provider library # FIXME: This is probably pointless, the provider library has no symbols so # what good is it? Presumably it should be used with -Wl,--whole-archive, @@ -108,7 +103,16 @@ function(rdma_provider DEST) # Provider Plugins do not use SONAME versioning, there is no reason to # create the usual symlinks. - install(TARGETS ${DEST} DESTINATION "${CMAKE_INSTALL_LIBDIR}") + if (VERBS_PROVIDER_DIR) + install(TARGETS ${DEST} DESTINATION "${VERBS_PROVIDER_DIR}") + else() + install(TARGETS ${DEST} DESTINATION "${CMAKE_INSTALL_LIBDIR}") + + # FIXME: This symlink is provided for compat with the old build, but it + # never should have existed in the first place, nothing should use this + # name, we can probably remove it. + rdma_install_symlink("lib${DEST}-rdmav2.so" "${CMAKE_INSTALL_LIBDIR}/lib${DEST}.so") + endif() endfunction() # Create an installed executable diff --git a/libibverbs/src/init.c b/libibverbs/src/init.c index bca0e02d1..7ae0fc87d 100644 --- a/libibverbs/src/init.c +++ b/libibverbs/src/init.c @@ -190,33 +190,56 @@ void verbs_register_driver(const char *name, verbs_driver_init_func init_func) register_driver(name, NULL, init_func); } +#define __IBV_QUOTE(x) #x +#define IBV_QUOTE(x) __IBV_QUOTE(x) +#define DLOPEN_TRAILER "-" IBV_QUOTE(IBV_DEVICE_LIBRARY_EXTENSION) ".so" + static void load_driver(const char *name) { char *so_name; void *dlhandle; -#define __IBV_QUOTE(x) #x -#define IBV_QUOTE(x) __IBV_QUOTE(x) - - if (asprintf(&so_name, - name[0] == '/' ? - "%s-" IBV_QUOTE(IBV_DEVICE_LIBRARY_EXTENSION) ".so" : - "lib%s-" IBV_QUOTE(IBV_DEVICE_LIBRARY_EXTENSION) ".so", - name) < 0) { - fprintf(stderr, PFX "Warning: couldn't load driver '%s'.\n", - name); + /* If the name is an absolute path then open that path after appending + the trailer suffix */ + if (name[0] == '/') { + if (asprintf(&so_name, "%s" DLOPEN_TRAILER, name) < 0) + goto out_asprintf; + dlhandle = dlopen(so_name, RTLD_NOW); + if (!dlhandle) + goto out_dlopen; + free(so_name); return; } - dlhandle = dlopen(so_name, RTLD_NOW); - if (!dlhandle) { - fprintf(stderr, PFX "Warning: couldn't load driver '%s': %s\n", - name, dlerror()); - goto out; + /* If configured with a provider plugin path then try that next */ + if (sizeof(VERBS_PROVIDER_DIR) >= 1) { + if (asprintf(&so_name, VERBS_PROVIDER_DIR "/lib%s" DLOPEN_TRAILER, name) < + 0) + goto out_asprintf; + dlhandle = dlopen(so_name, RTLD_NOW); + free(so_name); + if (dlhandle) + return; } -out: + /* Otherwise use the system libary search path. This is the historical + behavior of libibverbs */ + if (asprintf(&so_name, "lib%s" DLOPEN_TRAILER, name) < 0) + goto out_asprintf; + dlhandle = dlopen(so_name, RTLD_NOW); + if (!dlhandle) + goto out_dlopen; + free(so_name); + return; + +out_asprintf: + fprintf(stderr, PFX "Warning: couldn't load driver '%s'.\n", name); + return; +out_dlopen: + fprintf(stderr, PFX "Warning: couldn't load driver '%s': %s\n", so_name, + dlerror()); free(so_name); + return; } static void load_drivers(void) From 10d6b39e7644de1c035f00fde93459b6e135d120 Mon Sep 17 00:00:00 2001 From: Jason Gunthorpe Date: Mon, 12 Sep 2016 15:43:44 -0600 Subject: [PATCH 10/28] ipathverbs: Move truescale-serdes.cmds to /usr/libexec/ This is the FHS defined place for non-user runnable helper programs. Debian forbids the use of /usr/libexec/ so we provide substitution support to let cmake customize this. Signed-off-by: Jason Gunthorpe --- libipathverbs/CMakeLists.txt | 6 ++++-- libipathverbs/dracut_install | 2 +- libipathverbs/truescale.conf | 1 - libipathverbs/truescale.conf.in | 1 + 4 files changed, 6 insertions(+), 4 deletions(-) delete mode 100644 libipathverbs/truescale.conf create mode 100644 libipathverbs/truescale.conf.in diff --git a/libipathverbs/CMakeLists.txt b/libipathverbs/CMakeLists.txt index 359438ef0..bde405d0d 100644 --- a/libipathverbs/CMakeLists.txt +++ b/libipathverbs/CMakeLists.txt @@ -1,4 +1,6 @@ -install(FILES truescale.conf DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/modprobe.d/") +rdma_subst_install(FILES "truescale.conf.in" + DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/modprobe.d/" + RENAME "truescale.conf") install(FILES truescale-serdes.cmds - DESTINATION "${CMAKE_INSTALL_SBINDIR}" + DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}" PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE) diff --git a/libipathverbs/dracut_install b/libipathverbs/dracut_install index 131adfa03..a7ef490ea 100644 --- a/libipathverbs/dracut_install +++ b/libipathverbs/dracut_install @@ -1,7 +1,7 @@ #!/bin/bash inst /etc/modprobe.d/truescale.conf -inst /usr/sbin/truescale-serdes.cmds +inst /usr/libexec/truescale-serdes.cmds # All files needed by truescale-serdes.cmds need to be present here inst /sbin/lspci diff --git a/libipathverbs/truescale.conf b/libipathverbs/truescale.conf deleted file mode 100644 index 8ed227c91..000000000 --- a/libipathverbs/truescale.conf +++ /dev/null @@ -1 +0,0 @@ -install ib_qib modprobe -i ib_qib $CMDLINE_OPTS && /usr/sbin/truescale-serdes.cmds start diff --git a/libipathverbs/truescale.conf.in b/libipathverbs/truescale.conf.in new file mode 100644 index 000000000..e2827d956 --- /dev/null +++ b/libipathverbs/truescale.conf.in @@ -0,0 +1 @@ +install ib_qib modprobe -i ib_qib $CMDLINE_OPTS && @CMAKE_INSTALL_FULL_LIBEXECDIR@/truescale-serdes.cmds start From d99f1152805e6d66846bc48943756de366531178 Mon Sep 17 00:00:00 2001 From: Jason Gunthorpe Date: Fri, 23 Sep 2016 12:53:20 -0600 Subject: [PATCH 11/28] Document a versioning strategy and use it This is particularly important for the three shared libraries, and we haven't been doing it right historically, perhaps due to libtool braindamage. The names of the shlibs are updated to: libibcm 1.0.11 libibumad 3.1.11 libibverbs 1.3.11 librdmacm 1.1.11 The SONAME remains the same. The overall package release is set to 11 due to libibumad having got up to a .10 release. Signed-off-by: Jason Gunthorpe --- CMakeLists.txt | 5 +- Documentation/versioning.md | 108 ++++++++++++++++++++++++++++++++++ libibcm/src/CMakeLists.txt | 4 +- libibcm/src/libibcm.map | 1 + libibumad/src/CMakeLists.txt | 4 +- libibumad/src/libibumad.map | 1 + libibverbs/src/CMakeLists.txt | 4 +- libibverbs/src/libibverbs.map | 1 + librdmacm/src/CMakeLists.txt | 4 +- librdmacm/src/librdmacm.map | 1 + 10 files changed, 127 insertions(+), 6 deletions(-) create mode 100644 Documentation/versioning.md diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ae236f88..9a88451a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,8 +32,9 @@ else() endif() set(PACKAGE_NAME "RDMA") -# FIXME versioning strategy? -set(PACKAGE_VERSION "1") + +# See Documentation/versioning.md +set(PACKAGE_VERSION "11") #------------------------- # Basic standard paths diff --git a/Documentation/versioning.md b/Documentation/versioning.md new file mode 100644 index 000000000..0cc542aa6 --- /dev/null +++ b/Documentation/versioning.md @@ -0,0 +1,108 @@ +# Overall Package Version + +This version number is set in the top level CMakeLists.txt: + +```sh +set(PACKAGE_VERSION "11") +```` + +For upstream releases this is a single integer showing the release +ordering. We do not attempt to encode any 'ABI' information in this version. + +Branched stabled releases can append an additional counter eg `11.2`. + +Unofficial releases should include a distributor tag, eg '11.vendor2'. + +When the PACKAGE_VERSION is changed, the packaging files should be updated: + +```diff +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 389feee1e0f9..63854fe8f07f 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -26,7 +26,7 @@ project(RDMA C) + set(PACKAGE_NAME "RDMA") + + # See Documentation/versioning.md +-set(PACKAGE_VERSION "11") ++set(PACKAGE_VERSION "12") + + #------------------------- + # Basic standard paths +``` + +# Shared Library Versions + +The shared libraries use the typical semantic versioning scheme, eg +*libibumad* has a version like `3.1.11`. + +The version number is broken up into three fields: +- '3' is called the SONAME and is embedded into the ELF: + ```sh + $ readelf -ds build/lib/libibumad.so.3.1.11 + 0x000000000000000e (SONAME) Library soname: [libibumad.so.3] + ``` + + We do not expect this value to ever change for our libraries. It indicates + the overall ABI, changing it means the library will not dynamically to old + programs link anymore. + +- '1' is called the ABI level and is used within the ELF as the last component + symbol version tag. This version must be changed every time a new symbol + is introduced. It allows the user to see what version of the ABI the + library provides. + +- '11' is the overall release number and is copied from `PACKAGE_VERSION` This + version increases with every package release, even if the library code did + not change. It allows the user to see what upstream source was used to build + the library. + +This version is encoded into the filename `build/lib/libibumad.so.3.1.11` and +a symlink from `libibumad.so.3` to `build/lib/libibumad.so.3.1.11` is created. + +## Shared Library Symbol Versions + +Symbol versions are a linker technique that lets the library author provide +two symbols with different ABIs that have the same API name. The linker +differentiates the two cases internally. This allows the library author to +change the ABI that the API uses. This project typically does not make use of +this feature. + +As a secondary feature, the symbol version is also used by package managers +like RPM to manage the ABI level. To make this work properly the ABI level +must be correctly encoded into the symbol version. + +## Adding a new symbol + +First, increase the ABI level of the library. It is safe to re-use the ABI +level for multiple new functions within a single release, but once a release +is tagged the ABI level becomes *immutable*. The maintainer can provide +guidence on what ABI level to use for each series. + +```diff + rdma_library(ibumad libibumad.map + # See Documentation/versioning.md +- 3 3.1.${PACKAGE_VERSION} ++ 3 3.2.${PACKAGE_VERSION} +``` + +Next, add your new symbol to the symbol version file: + +```diff ++ IBUMAD_3.2 { ++ global: ++ umad_new_symbol; ++ } IBUMAD_1.0; +``` + +NOTE: Once a release is made the stanzas in the map file are *immutable* and +cannot be changed. Do not add your new symbol to old stanzas. + +The new symbol should appear in the ELF: + +```sh +$ readelf -s build/lib/libibumad.so.3.1.11 + 35: 00000000000031e0 450 FUNC GLOBAL DEFAULT 12 umad_new_symbol@@IBUMAD_3.2 +``` + +Finally update the `debian/libibumad3.symbols` file. diff --git a/libibcm/src/CMakeLists.txt b/libibcm/src/CMakeLists.txt index 2479886c6..66b3362ec 100644 --- a/libibcm/src/CMakeLists.txt +++ b/libibcm/src/CMakeLists.txt @@ -3,7 +3,9 @@ publish_headers(infiniband ../include/infiniband/cm_abi.h ) -rdma_library(ibcm libibcm.map 1 1.0.0 +rdma_library(ibcm libibcm.map + # See Documentation/versioning.md + 1 1.0.${PACKAGE_VERSION} cm.c ) target_link_libraries(ibcm LINK_PUBLIC ibverbs) diff --git a/libibcm/src/libibcm.map b/libibcm/src/libibcm.map index 3d83e481a..c94e420a6 100644 --- a/libibcm/src/libibcm.map +++ b/libibcm/src/libibcm.map @@ -1,3 +1,4 @@ +/* Do not change this file without reading Documentation/versioning.md */ IBCM_1.0 { global: ib_cm_open_device; diff --git a/libibumad/src/CMakeLists.txt b/libibumad/src/CMakeLists.txt index b7b5d03bc..fbd15893d 100644 --- a/libibumad/src/CMakeLists.txt +++ b/libibumad/src/CMakeLists.txt @@ -7,7 +7,9 @@ publish_headers(infiniband ../include/infiniband/umad_types.h ) -rdma_library(ibumad libibumad.map 3 3.1.0 +rdma_library(ibumad libibumad.map + # See Documentation/versioning.md + 3 3.1.${PACKAGE_VERSION} sysfs.c umad.c umad_str.c diff --git a/libibumad/src/libibumad.map b/libibumad/src/libibumad.map index e42dc799d..8bf474e26 100644 --- a/libibumad/src/libibumad.map +++ b/libibumad/src/libibumad.map @@ -1,3 +1,4 @@ +/* Do not change this file without reading Documentation/versioning.md */ IBUMAD_1.0 { global: umad_init; diff --git a/libibverbs/src/CMakeLists.txt b/libibverbs/src/CMakeLists.txt index e1a54345c..6989f7730 100644 --- a/libibverbs/src/CMakeLists.txt +++ b/libibverbs/src/CMakeLists.txt @@ -17,7 +17,9 @@ else() set(NEIGH "") endif() -rdma_library(ibverbs libibverbs.map 1 1.0.0 +rdma_library(ibverbs libibverbs.map + # See Documentation/versioning.md + 1 1.3.${PACKAGE_VERSION} cmd.c compat-1_0.c device.c diff --git a/libibverbs/src/libibverbs.map b/libibverbs/src/libibverbs.map index 46744e551..33cd6b639 100644 --- a/libibverbs/src/libibverbs.map +++ b/libibverbs/src/libibverbs.map @@ -1,3 +1,4 @@ +/* Do not change this file without reading Documentation/versioning.md */ IBVERBS_1.0 { global: ibv_get_device_list; diff --git a/librdmacm/src/CMakeLists.txt b/librdmacm/src/CMakeLists.txt index 5324f6256..0a60786c5 100644 --- a/librdmacm/src/CMakeLists.txt +++ b/librdmacm/src/CMakeLists.txt @@ -8,7 +8,9 @@ publish_headers(infiniband ../include/infiniband/ib.h ) -rdma_library(rdmacm librdmacm.map 1 1.0.0 +rdma_library(rdmacm librdmacm.map + # See Documentation/versioning.md + 1 1.1.${PACKAGE_VERSION} acm.c addrinfo.c cma.c diff --git a/librdmacm/src/librdmacm.map b/librdmacm/src/librdmacm.map index ffbd199d3..65c049211 100644 --- a/librdmacm/src/librdmacm.map +++ b/librdmacm/src/librdmacm.map @@ -1,3 +1,4 @@ +/* Do not change this file without reading Documentation/versioning.md */ RDMACM_1.0 { global: rdma_create_event_channel; From 060b4c8c5f2927a97358cbee9bf7c74c1d174494 Mon Sep 17 00:00:00 2001 From: Jason Gunthorpe Date: Mon, 26 Sep 2016 12:07:41 -0600 Subject: [PATCH 12/28] Remove ibsupport@intel.com from MAINTAINERS Turns out this is not a mailing list. Signed-off-by: Jason Gunthorpe --- MAINTAINERS | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index b39529fee..9048311af 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -52,6 +52,7 @@ F: libcxgb4/ HF1 USERSPACE PROVIDER (for hf1.ko) M: Mike Marciniszyn +M: Dennis Dalessandro S: Supported L: intel-opa@lists.01.org F: libhfi1verbs/ @@ -68,8 +69,9 @@ F: ibacm/* IPATH/QIB USERSPACE PROVIDER (for ib_qib.ko) M: Mike Marciniszyn +M: Dennis Dalessandro +L: infinipath S: Supported -L: ibsupport@intel.com F: libipathverbs/ IWARP PORT MAPPER DAEMON (for iwarp kernel providers) From 6f2c2b0021cc35e991808aeb825b7221f9e031b4 Mon Sep 17 00:00:00 2001 From: Jason Gunthorpe Date: Wed, 28 Sep 2016 17:19:25 -0600 Subject: [PATCH 13/28] Add a .travis.yml file Necessary to use the Travis CI service. Signed-off-by: Jason Gunthorpe --- .travis.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..e09dd32ff --- /dev/null +++ b/.travis.yml @@ -0,0 +1,28 @@ +language: c +# We need at least cmake 2.12, this means we need to use trusty. +# Precise's glibc, etc predates what we are willing to support. +# No reason for sudo. +sudo: required +dist: trusty +addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - build-essential + - cmake + - debhelper + - gcc + - gcc-6 + - libnl-3-dev + - libnl-route-3-dev + - make + - ninja-build + - pkg-config + - python + - valgrind +script: + - mkdir build + - cd build + - CC=gcc-6 cmake -GNinja .. + - ninja From ced0f452803bea783d7978c9ff133df411d685b9 Mon Sep 17 00:00:00 2001 From: Jason Gunthorpe Date: Mon, 5 Sep 2016 12:29:51 -0600 Subject: [PATCH 14/28] Avoid gcc warning -Wpointer-to-int-cast In C99 casting a pointer to an integer should always be done via uintptr_t. When compiling on 32 bit all these sites produce warnings. Signed-off-by: Jason Gunthorpe --- ibacm/src/acm.c | 4 ++-- iwpmd/src/iwarp_pm_helper.c | 2 +- libhfi1verbs/src/verbs.c | 2 +- libi40iw/src/i40iw_uverbs.c | 2 +- libipathverbs/src/verbs.c | 2 +- librdmacm/src/rsocket.c | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ibacm/src/acm.c b/ibacm/src/acm.c index 4650421b8..74b6de3ff 100644 --- a/ibacm/src/acm.c +++ b/ibacm/src/acm.c @@ -1562,7 +1562,7 @@ static void acm_nl_process_invalid_request(struct acmc_client *client, msg.hdr.version = ACM_VERSION; msg.hdr.length = ACM_MSG_HDR_LENGTH; msg.hdr.status = ACM_STATUS_EINVAL; - msg.hdr.tid = (uint64_t) acmnlmsg; + msg.hdr.tid = (uintptr_t) acmnlmsg; acm_nl_send(client->sock, &msg); } @@ -1584,7 +1584,7 @@ static void acm_nl_process_resolve(struct acmc_client *client, msg.hdr.version = ACM_VERSION; msg.hdr.length = ACM_MSG_HDR_LENGTH + ACM_MSG_EP_LENGTH; msg.hdr.status = ACM_STATUS_SUCCESS; - msg.hdr.tid = (uint64_t) acmnlmsg; + msg.hdr.tid = (uintptr_t) acmnlmsg; msg.resolve_data[0].type = ACM_EP_INFO_PATH; /* We support only one pathrecord */ diff --git a/iwpmd/src/iwarp_pm_helper.c b/iwpmd/src/iwarp_pm_helper.c index f5c7b96a2..89d2b6cef 100644 --- a/iwpmd/src/iwarp_pm_helper.c +++ b/iwpmd/src/iwarp_pm_helper.c @@ -82,7 +82,7 @@ iwpm_mapping_request *create_iwpm_map_request(struct nlmsghdr *req_nlh, /* assochandle helps match iwpm request sent to remote peer with future iwpm accept/reject */ iwpm_map_req->assochandle = assochandle; if (!assochandle) - iwpm_map_req->assochandle = (__u64)iwpm_map_req; + iwpm_map_req->assochandle = (uintptr_t)iwpm_map_req; memcpy(&iwpm_map_req->src_addr, src_addr, sizeof(struct sockaddr_storage)); /* keep record of remote IP address and port */ diff --git a/libhfi1verbs/src/verbs.c b/libhfi1verbs/src/verbs.c index 854c56769..e245ad9e5 100644 --- a/libhfi1verbs/src/verbs.c +++ b/libhfi1verbs/src/verbs.c @@ -607,7 +607,7 @@ int hfi1_modify_srq(struct ibv_srq *ibsrq, (sizeof(struct ibv_sge) * srq->rq.max_sge)) * srq->rq.size; } - cmd.offset_addr = (__u64) &offset; + cmd.offset_addr = (uintptr_t) &offset; ret = ibv_cmd_modify_srq(ibsrq, attr, attr_mask, &cmd.ibv_cmd, sizeof cmd); if (ret) { diff --git a/libi40iw/src/i40iw_uverbs.c b/libi40iw/src/i40iw_uverbs.c index da23e4c9f..bdc201ab2 100644 --- a/libi40iw/src/i40iw_uverbs.c +++ b/libi40iw/src/i40iw_uverbs.c @@ -557,7 +557,7 @@ static int i40iw_vmapped_qp(struct i40iw_uqp *iwuqp, struct ibv_pd *pd, return 0; } cmd.user_wqe_buffers = (__u64)((uintptr_t)info->sq); - cmd.user_compl_ctx = (u64)&iwuqp->qp; + cmd.user_compl_ctx = (uintptr_t)&iwuqp->qp; ret = ibv_cmd_create_qp(pd, &iwuqp->ibv_qp, attr, &cmd.ibv_cmd, sizeof(cmd), &resp->ibv_resp, sizeof(struct i40iw_ucreate_qp_resp)); diff --git a/libipathverbs/src/verbs.c b/libipathverbs/src/verbs.c index 17d54cd40..578a38af3 100644 --- a/libipathverbs/src/verbs.c +++ b/libipathverbs/src/verbs.c @@ -583,7 +583,7 @@ int ipath_modify_srq(struct ibv_srq *ibsrq, (sizeof(struct ibv_sge) * srq->rq.max_sge)) * srq->rq.size; } - cmd.offset_addr = (__u64) &offset; + cmd.offset_addr = (uintptr_t) &offset; ret = ibv_cmd_modify_srq(ibsrq, attr, attr_mask, &cmd.ibv_cmd, sizeof cmd); if (ret) { diff --git a/librdmacm/src/rsocket.c b/librdmacm/src/rsocket.c index 818505fbe..051dd89bf 100644 --- a/librdmacm/src/rsocket.c +++ b/librdmacm/src/rsocket.c @@ -4266,7 +4266,7 @@ static void tcp_svc_send_keepalive(struct rsocket *rs) if (rs_ctrl_avail(rs) && (rs->state & rs_connected)) { rs->ctrl_seqno++; rs_post_write(rs, NULL, 0, rs_msg_set(RS_OP_CTRL, RS_CTRL_KEEPALIVE), - 0, (uint64_t) NULL, (uint64_t) NULL); + 0, (uintptr_t) NULL, (uintptr_t) NULL); } fastlock_release(&rs->cq_lock); } From ae66cd1386f77a8a09bdc053c54fcb3d452f4ec2 Mon Sep 17 00:00:00 2001 From: Jason Gunthorpe Date: Mon, 5 Sep 2016 12:35:04 -0600 Subject: [PATCH 15/28] Avoid gcc warning -Wint-to-pointer-cast A u64 value needs to be casted to uintptr_t before being converted back into a pointer, otherwise gcc produces warning on a 32 bit build. Signed-off-by: Jason Gunthorpe --- ibacm/src/acm.c | 2 +- libi40iw/src/i40iw_uverbs.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ibacm/src/acm.c b/ibacm/src/acm.c index 74b6de3ff..ac0c32426 100644 --- a/ibacm/src/acm.c +++ b/ibacm/src/acm.c @@ -1402,7 +1402,7 @@ static int acm_nl_send(SOCKET sock, struct acm_msg *msg) int ret; int datalen; - orig = (struct acm_nl_msg *) msg->hdr.tid; + orig = (struct acm_nl_msg *)(uintptr_t)msg->hdr.tid; memset(&dst_addr, 0, sizeof(dst_addr)); dst_addr.nl_family = AF_NETLINK; diff --git a/libi40iw/src/i40iw_uverbs.c b/libi40iw/src/i40iw_uverbs.c index bdc201ab2..8369e10f6 100644 --- a/libi40iw/src/i40iw_uverbs.c +++ b/libi40iw/src/i40iw_uverbs.c @@ -858,7 +858,7 @@ int i40iw_upost_send(struct ibv_qp *ib_qp, struct ibv_send_wr *ib_wr, struct ibv info.op_type = I40IW_OP_TYPE_SEND; if (ib_wr->send_flags & IBV_SEND_INLINE) { - info.op.inline_send.data = (void *)ib_wr->sg_list[0].addr; + info.op.inline_send.data = (void *)(uintptr_t)ib_wr->sg_list[0].addr; info.op.inline_send.len = ib_wr->sg_list[0].length; ret = iwuqp->qp.ops.iw_inline_send(&iwuqp->qp, &info, ib_wr->wr.rdma.rkey, false); @@ -881,7 +881,7 @@ int i40iw_upost_send(struct ibv_qp *ib_qp, struct ibv_send_wr *ib_wr, struct ibv info.op_type = I40IW_OP_TYPE_RDMA_WRITE; if (ib_wr->send_flags & IBV_SEND_INLINE) { - info.op.inline_rdma_write.data = (void *)ib_wr->sg_list[0].addr; + info.op.inline_rdma_write.data = (void *)(uintptr_t)ib_wr->sg_list[0].addr; info.op.inline_rdma_write.len = ib_wr->sg_list[0].length; info.op.inline_rdma_write.rem_addr.tag_off = ib_wr->wr.rdma.remote_addr; info.op.inline_rdma_write.rem_addr.len = ib_wr->sg_list->length; From c9614048089c2e85780e669358d0814f93535d40 Mon Sep 17 00:00:00 2001 From: Jason Gunthorpe Date: Mon, 19 Sep 2016 15:39:20 -0600 Subject: [PATCH 16/28] ibacm: Fix incomplete struct initialization It appears the original intent was to zero the reaminder of the struct. Signed-off-by: Jason Gunthorpe --- ibacm/src/acm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ibacm/src/acm.c b/ibacm/src/acm.c index ac0c32426..cd1d851d9 100644 --- a/ibacm/src/acm.c +++ b/ibacm/src/acm.c @@ -218,7 +218,7 @@ static struct sa_data { struct pollfd *fds; struct acmc_port **ports; int nfds; -} sa = { 2000, 2, 1}; +} sa = { 2000, 2, 1, 0, NULL, NULL, 0}; /* * Service options - may be set through ibacm_opts.cfg file. From 4e0587030849583ea031418781678ad43ccdf96a Mon Sep 17 00:00:00 2001 From: Jason Gunthorpe Date: Mon, 19 Sep 2016 15:49:52 -0600 Subject: [PATCH 17/28] ibacm: Avoid warning on use of uninitialized ret gcc 6.1 remarks: ../ibacm/src/acme.c:1069:6: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized] if (!ret && make_addr) This is because query_svcs() can return without setting ret if svc_list is empty. It looks like parse() probably cannot return an empty list, so avoid the compiler warning by initing to -1. Signed-off-by: Jason Gunthorpe --- ibacm/src/acme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ibacm/src/acme.c b/ibacm/src/acme.c index 4d9003047..09c56ba75 100644 --- a/ibacm/src/acme.c +++ b/ibacm/src/acme.c @@ -927,7 +927,7 @@ static void enumerate_eps(char *svc) static int query_svcs(void) { char **svc_list; - int ret, i; + int ret = -1, i; svc_list = parse(svc_arg, NULL); if (!svc_list) { From d38b556ef6365b16bddbb306b487c49f2386cb6c Mon Sep 17 00:00:00 2001 From: Jason Gunthorpe Date: Wed, 28 Sep 2016 21:25:03 -0600 Subject: [PATCH 18/28] ibacm: Avoid gcc warning -Wunused-result gcc observes: ../ibacm/src/acm.c:3007:3: error: ignoring return value of 'lockf', declared with attribute warn_unused_result [-Werror=unused-result] lockf(lock_fd, F_ULOCK, 0); lockf locks are only held so long as the FD is open, so there is no reason to unlock it before calling close. Signed-off-by: Jason Gunthorpe --- ibacm/src/acm.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ibacm/src/acm.c b/ibacm/src/acm.c index cd1d851d9..41429e1db 100644 --- a/ibacm/src/acm.c +++ b/ibacm/src/acm.c @@ -3031,7 +3031,6 @@ static int acm_open_lock_file(void) snprintf(pid, sizeof pid, "%d\n", getpid()); if (write(lock_fd, pid, strlen(pid)) != strlen(pid)){ - lockf(lock_fd, F_ULOCK, 0); close(lock_fd); return -1; } From 842d223e282cbdd0fd1494aa6b271943a20e84ef Mon Sep 17 00:00:00 2001 From: Jason Gunthorpe Date: Fri, 23 Sep 2016 21:11:52 -0600 Subject: [PATCH 19/28] ibacm: Use inttypes.h format string macros Otherwise a 32bit compile will print garbage for the GUID. igned-off-by: Jason Gunthorpe --- ibacm/src/acme.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ibacm/src/acme.c b/ibacm/src/acme.c index 09c56ba75..4b5fe684c 100644 --- a/ibacm/src/acme.c +++ b/ibacm/src/acme.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -902,7 +903,7 @@ static int enumerate_ep(char *svc, int index) labels = 1; } - printf("%s,0x%016lx,%d,0x%04x,%d,%s", svc, ep_data->dev_guid, + printf("%s,0x%016" PRIx64 ",%d,0x%04x,%d,%s", svc, ep_data->dev_guid, ep_data->port_num, ep_data->pkey, index, ep_data->prov_name); for (i = 0; i < ep_data->addr_cnt; i++) printf(",%s", ep_data->addrs[i].name); From 3adc8103f42dfb84e3d12a9a2355b097d6e77180 Mon Sep 17 00:00:00 2001 From: Jason Gunthorpe Date: Fri, 2 Sep 2016 12:38:46 -0600 Subject: [PATCH 20/28] verbs: Fix clang 3.6 warning -Wtautological-compare The signededness of a 'enum X' is undefined in the C standard, compilers are free to use any type they like. So, coercing -1 into an enum and expecting '< 0' to work is undefined behaviour, and as the warning shows at least clang miscompiles this code. Instead use 0 to indicate undefined MTU from pp_mtu_to_enum, 0 is unused in the mtu enum. Signed-off-by: Jason Gunthorpe --- libibverbs/examples/pingpong.c | 2 +- libibverbs/examples/rc_pingpong.c | 2 +- libibverbs/examples/srq_pingpong.c | 2 +- libibverbs/examples/uc_pingpong.c | 2 +- libibverbs/examples/xsrq_pingpong.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libibverbs/examples/pingpong.c b/libibverbs/examples/pingpong.c index 2fe4a0411..f6a50e9c6 100644 --- a/libibverbs/examples/pingpong.c +++ b/libibverbs/examples/pingpong.c @@ -44,7 +44,7 @@ enum ibv_mtu pp_mtu_to_enum(int mtu) case 1024: return IBV_MTU_1024; case 2048: return IBV_MTU_2048; case 4096: return IBV_MTU_4096; - default: return -1; + default: return 0; } } diff --git a/libibverbs/examples/rc_pingpong.c b/libibverbs/examples/rc_pingpong.c index 967678362..1fad16a0b 100644 --- a/libibverbs/examples/rc_pingpong.c +++ b/libibverbs/examples/rc_pingpong.c @@ -768,7 +768,7 @@ int main(int argc, char *argv[]) case 'm': mtu = pp_mtu_to_enum(strtol(optarg, NULL, 0)); - if (mtu < 0) { + if (mtu == 0) { usage(argv[0]); return 1; } diff --git a/libibverbs/examples/srq_pingpong.c b/libibverbs/examples/srq_pingpong.c index a1061c319..929b73654 100644 --- a/libibverbs/examples/srq_pingpong.c +++ b/libibverbs/examples/srq_pingpong.c @@ -697,7 +697,7 @@ int main(int argc, char *argv[]) case 'm': mtu = pp_mtu_to_enum(strtol(optarg, NULL, 0)); - if (mtu < 0) { + if (mtu == 0) { usage(argv[0]); return 1; } diff --git a/libibverbs/examples/uc_pingpong.c b/libibverbs/examples/uc_pingpong.c index b25d16c79..3802e3821 100644 --- a/libibverbs/examples/uc_pingpong.c +++ b/libibverbs/examples/uc_pingpong.c @@ -604,7 +604,7 @@ int main(int argc, char *argv[]) case 'm': mtu = pp_mtu_to_enum(strtol(optarg, NULL, 0)); - if (mtu < 0) { + if (mtu == 0) { usage(argv[0]); return 1; } diff --git a/libibverbs/examples/xsrq_pingpong.c b/libibverbs/examples/xsrq_pingpong.c index ff00180f2..a7e345f38 100644 --- a/libibverbs/examples/xsrq_pingpong.c +++ b/libibverbs/examples/xsrq_pingpong.c @@ -906,7 +906,7 @@ int main(int argc, char *argv[]) break; case 'm': ctx.mtu = pp_mtu_to_enum(strtol(optarg, NULL, 0)); - if (ctx.mtu < 0) { + if (ctx.mtu == 0) { usage(argv[0]); return 1; } From f3007e3e657332c194a8816dce38c0e0f7990148 Mon Sep 17 00:00:00 2001 From: Jason Gunthorpe Date: Thu, 1 Sep 2016 22:52:48 -0600 Subject: [PATCH 21/28] verbs: Avoid gcc 6.1 warning -Wunused-variable gcc remarks: ../libibverbs/src/neigh.c:339:6: warning: 'sock_fd' may be used uninitialized in this function [-Wmaybe-uninitialized] err = try_send_to(sock_fd, buff, sizeof(buff), &addr_dst); But this is bogus because create_socket will always return an error if it does not set psock_fd. It looks like the insane if logic is just a tish too much for gcc to handle. Since the result of create_socket is discarded anyhow, simplify the tortured logic. Signed-off-by: Jason Gunthorpe --- libibverbs/src/neigh.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/libibverbs/src/neigh.c b/libibverbs/src/neigh.c index 799b810a9..dc8c2bc99 100644 --- a/libibverbs/src/neigh.c +++ b/libibverbs/src/neigh.c @@ -207,7 +207,7 @@ static int create_socket(struct get_neigh_handler *neigh_handler, &addr_src.len); if (err) { errno = EADDRNOTAVAIL; - return err; + return -1; } addr_dst->len = sizeof(addr_dst->sktaddr); @@ -216,24 +216,22 @@ static int create_socket(struct get_neigh_handler *neigh_handler, &addr_dst->len); if (err) { errno = EADDRNOTAVAIL; - return err; + return -1; } err = set_link_port(&addr_dst->sktaddr, PORT_DISCARD, neigh_handler->oif); if (err) - return err; + return -1; sock_fd = socket(addr_dst->sktaddr.s.sa_family, SOCK_DGRAM | SOCK_CLOEXEC, 0); if (sock_fd == -1) - return errno ? -errno : -1; + return -1; err = bind(sock_fd, &addr_src.sktaddr.s, addr_src.len); if (err) { - int bind_err = -errno; - close(sock_fd); - return bind_err ?: EADDRNOTAVAIL; + return -1; } *psock_fd = sock_fd; From 560a912eb7c9790cbc2e7a00863f1f465a371059 Mon Sep 17 00:00:00 2001 From: Jason Gunthorpe Date: Thu, 1 Sep 2016 22:41:50 -0600 Subject: [PATCH 22/28] nes: Avoid gcc 6.1 warning -Wmisleading-indentation ../providers/nes/nes_uverbs.c:489:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation] if (++nesuqp->rq_tail >= nesuqp->rq_size) ^~ ../providers/nes/nes_uverbs.c:491:6: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if' if (entry->status == NES_CQ_BUF_OV_ERR) ^~ Presumably this has been tested as is, so I've opted to preserve the behaviour, but I can't tell if that is right or not. Signed-off-by: Jason Gunthorpe --- libnes/src/nes_uverbs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libnes/src/nes_uverbs.c b/libnes/src/nes_uverbs.c index 80891d624..6458c51c3 100644 --- a/libnes/src/nes_uverbs.c +++ b/libnes/src/nes_uverbs.c @@ -518,8 +518,8 @@ int nes_ima_upoll_cq(struct ibv_cq *cq, int num_entries, struct ibv_wc *entry) /* Working on a RQ Completion*/ if (++nesuqp->rq_tail >= nesuqp->rq_size) nesuqp->rq_tail = 0; - if (entry->status == NES_CQ_BUF_OV_ERR) - entry->status = IBV_WC_LOC_LEN_ERR; + if (entry->status == NES_CQ_BUF_OV_ERR) + entry->status = IBV_WC_LOC_LEN_ERR; } if (++head >= cq_size) From 985f0400d60ab7db20dc724a56c5236dcb52831a Mon Sep 17 00:00:00 2001 From: Jason Gunthorpe Date: Thu, 1 Sep 2016 22:36:36 -0600 Subject: [PATCH 23/28] rxe: Avoid gcc 5.4 warning -Wswitch convert_send_wr switches incompletely on an enum. Assume the intent was to not do any copies for other enum members and dummy them in. Signed-off-by: Jason Gunthorpe --- librxe/src/rxe.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/librxe/src/rxe.c b/librxe/src/rxe.c index 94d0de51f..7164f6627 100644 --- a/librxe/src/rxe.c +++ b/librxe/src/rxe.c @@ -596,6 +596,12 @@ void convert_send_wr(struct rxe_send_wr *kwr, struct ibv_send_wr *uwr) kwr->wr.atomic.swap = uwr->wr.atomic.swap; kwr->wr.atomic.rkey = uwr->wr.atomic.rkey; break; + + case IBV_WR_LOCAL_INV: + case IBV_WR_BIND_MW: + case IBV_WR_SEND_WITH_INV: + case IBV_WR_TSO: + break; } } From e99e7bb91fe69e6ebd35ef06e65a0f0bfb95a67b Mon Sep 17 00:00:00 2001 From: Jason Gunthorpe Date: Thu, 1 Sep 2016 22:30:57 -0600 Subject: [PATCH 24/28] Fix gcc 5.4, clang 3.6 warnings about unused objects Mostly just delete cruft. nes has a number of unused related to HAVE_DECL_IBV_QPT_RAW_ETH, perhaps this code should be deleted entirely because whatever QPT_RAW_ETH is, it is not part of this repository. Signed-off-by: Jason Gunthorpe --- libibumad/tests/umad_reg2_compat.c | 1 - libnes/src/nes_uverbs.c | 17 ++++++++++------- libocrdma/src/ocrdma_verbs.c | 3 ++- librdmacm/examples/cmtime.c | 16 ---------------- 4 files changed, 12 insertions(+), 25 deletions(-) diff --git a/libibumad/tests/umad_reg2_compat.c b/libibumad/tests/umad_reg2_compat.c index 6dd4a48a5..9c239ee4b 100644 --- a/libibumad/tests/umad_reg2_compat.c +++ b/libibumad/tests/umad_reg2_compat.c @@ -100,7 +100,6 @@ int open_test_device(void) void test_register(void) { - int rc = 0; int agent_id; long method_mask[16 / sizeof(long)]; uint32_t class_oui = 0x001405; /* OPENIB_OUI */ diff --git a/libnes/src/nes_uverbs.c b/libnes/src/nes_uverbs.c index 6458c51c3..983d87a80 100644 --- a/libnes/src/nes_uverbs.c +++ b/libnes/src/nes_uverbs.c @@ -215,6 +215,7 @@ int nes_udereg_mr(struct ibv_mr *mr) return 0; } +#if HAVE_DECL_IBV_QPT_RAW_ETH static int nes_ima_ureplace_cq(struct ibv_cq *cq, int mcrqf, @@ -296,6 +297,7 @@ int nes_ima_ureplace_cq(struct ibv_cq *cq, err: return ret; } +#endif /** * nes_ucreate_cq @@ -425,7 +427,6 @@ int nes_ima_upoll_cq(struct ibv_cq *cq, int num_entries, struct ibv_wc *entry) int cqe_count = 0; uint32_t head; uint32_t cq_size; - uint16_t qp_size; volatile struct nes_hw_nic_cqe *cqe = 0; volatile struct nes_hw_nic_cqe *cqes; @@ -487,7 +488,6 @@ int nes_ima_upoll_cq(struct ibv_cq *cq, int num_entries, struct ibv_wc *entry) entry->src_qp = nesuqp->qp_id; if (cqe_misc & NES_NIC_CQE_SQ) { entry->opcode = IBV_WC_SEND; - qp_size = nesuqp->sq_size; entry->wr_id = nesuqp->send_wr_id[nesuqp->sq_tail]; @@ -557,7 +557,6 @@ int nes_upoll_cq(struct ibv_cq *cq, int num_entries, struct ibv_wc *entry) uint32_t wqe_index; uint32_t wq_tail = 0; struct nes_hw_cqe cqe; - uint32_t tmp; uint64_t u64temp; int move_cq_head = 1; uint32_t err_code; @@ -679,7 +678,6 @@ int nes_upoll_cq(struct ibv_cq *cq, int num_entries, struct ibv_wc *entry) nesvctx = to_nes_uctx(cq->context); nesvctx->nesupd->udoorbell->cqe_alloc = cpu_to_le32(nesucq->cq_id | (nesucq->polled_completions << 16)); - tmp = nesvctx->nesupd->udoorbell->cqe_alloc; nesucq->polled_completions = 0; } } else { @@ -699,7 +697,6 @@ int nes_upoll_cq(struct ibv_cq *cq, int num_entries, struct ibv_wc *entry) nesvctx = to_nes_uctx(cq->context); nesvctx->nesupd->udoorbell->cqe_alloc = cpu_to_le32(nesucq->cq_id | (nesucq->polled_completions << 16)); - tmp = nesvctx->nesupd->udoorbell->cqe_alloc; nesucq->polled_completions = 0; } nesucq->head = head; @@ -1140,7 +1137,6 @@ struct ibv_qp *nes_ucreate_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *attr) struct nes_uqp *nesuqp; int sqdepth, rqdepth; int status = 1; - int i = 0; /* fprintf(stderr, PFX "%s\n", __FUNCTION__); */ @@ -1211,6 +1207,8 @@ struct ibv_qp *nes_ucreate_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *attr) #if HAVE_DECL_IBV_QPT_RAW_ETH if (attr->qp_type == IBV_QPT_RAW_ETH) { + int i = 0; + nesuqp->nes_ud_sksq_fd = open("/dev/infiniband/nes_ud_sksq", O_RDWR); if (nesuqp->nes_ud_sksq_fd <= 0) @@ -1327,7 +1325,6 @@ int nes_udestroy_qp(struct ibv_qp *qp) { struct nes_uqp *nesuqp = to_nes_uqp(qp); int ret = 0; - int i = 0; // fprintf(stderr, PFX "%s addr&mr= %p \n", __FUNCTION__, &nesuqp->mr ); @@ -1353,6 +1350,8 @@ int nes_udestroy_qp(struct ibv_qp *qp) #if HAVE_DECL_IBV_QPT_RAW_ETH if (qp->qp_type == IBV_QPT_RAW_ETH) { + int i = 0; + if (nesuqp->pend_rx_wr) { for (i = 0; i < NES_UD_RX_BATCH_SZ; i++) if (nesuqp->pend_rx_wr[i].sg_list) { @@ -1381,6 +1380,7 @@ int nes_udestroy_qp(struct ibv_qp *qp) return 0; } +#if HAVE_DECL_IBV_QPT_RAW_ETH static inline int nes_ima_upost_send(struct ibv_qp *ib_qp, struct ibv_send_wr *ib_wr, struct ibv_send_wr **bad_wr) @@ -1457,6 +1457,7 @@ int nes_ima_upost_send(struct ibv_qp *ib_qp, struct ibv_send_wr *ib_wr, out: return ret; } +#endif /** * nes_upost_send @@ -1653,6 +1654,7 @@ int nes_upost_send(struct ibv_qp *ib_qp, struct ibv_send_wr *ib_wr, return err; } +#if HAVE_DECL_IBV_QPT_RAW_ETH static inline int nes_ima_upost_recv(struct ibv_qp *ib_qp, struct ibv_recv_wr *ib_wr, struct ibv_recv_wr **bad_wr) @@ -1727,6 +1729,7 @@ int nes_ima_upost_recv(struct ibv_qp *ib_qp, struct ibv_recv_wr *ib_wr, out: return ret; } +#endif /** * nes_upost_recv diff --git a/libocrdma/src/ocrdma_verbs.c b/libocrdma/src/ocrdma_verbs.c index 606262606..8eb70db26 100644 --- a/libocrdma/src/ocrdma_verbs.c +++ b/libocrdma/src/ocrdma_verbs.c @@ -945,10 +945,11 @@ static inline void *ocrdma_hwq_head(struct ocrdma_qp_hwq_info *q) return q->va + (q->head * q->entry_size); } -static inline void *ocrdma_wq_tail(struct ocrdma_qp_hwq_info *q) +/*static inline void *ocrdma_wq_tail(struct ocrdma_qp_hwq_info *q) { return q->va + (q->tail * q->entry_size); } +*/ static inline void *ocrdma_hwq_head_from_idx(struct ocrdma_qp_hwq_info *q, uint32_t idx) diff --git a/librdmacm/examples/cmtime.c b/librdmacm/examples/cmtime.c index e45980b9b..f0b4d0276 100644 --- a/librdmacm/examples/cmtime.c +++ b/librdmacm/examples/cmtime.c @@ -128,13 +128,6 @@ static inline int __list_empty(struct work_list *list) return list->list.next == &list->list; } -static inline int list_empty(struct work_list *work_list) -{ - pthread_mutex_lock(&work_list->lock); - return work_list->list.next == &work_list->list; - pthread_mutex_unlock(&work_list->lock); -} - static inline struct list_head *__list_remove_head(struct work_list *work_list) { struct list_head *list_item; @@ -144,15 +137,6 @@ static inline struct list_head *__list_remove_head(struct work_list *work_list) return list_item; } -static inline struct list_head *list_remove_head(struct work_list *work_list) -{ - struct list_head *list_item; - pthread_mutex_lock(&work_list->lock); - list_item = __list_remove_head(work_list); - pthread_mutex_unlock(&work_list->lock); - return list_item; -} - static inline void list_add_tail(struct work_list *work_list, struct list_head *req) { int empty; From dbc9457e34f488359437b9727099f0cb0a1454a0 Mon Sep 17 00:00:00 2001 From: Jason Gunthorpe Date: Thu, 1 Sep 2016 21:55:28 -0600 Subject: [PATCH 25/28] Avoid gcc 5.4 warning -Wtype-limits Eg: comparison of unsigned expression < 0 is always false These are all harmless cases where some simple adjustments will supress the warning. Signed-off-by: Jason Gunthorpe --- libibverbs/src/neigh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libibverbs/src/neigh.c b/libibverbs/src/neigh.c index dc8c2bc99..6b6e58cd5 100644 --- a/libibverbs/src/neigh.c +++ b/libibverbs/src/neigh.c @@ -727,7 +727,7 @@ uint16_t neigh_get_vlan_id_from_dev(struct get_neigh_handler *neigh_handler) void neigh_set_vlan_id(struct get_neigh_handler *neigh_handler, uint16_t vid) { - if (vid >= 0 && vid <= 0xfff) + if (vid <= 0xfff) neigh_handler->vid = vid; } From f3912df771db1f1266cbc516d2c210642144ace0 Mon Sep 17 00:00:00 2001 From: Jason Gunthorpe Date: Thu, 1 Sep 2016 22:22:03 -0600 Subject: [PATCH 26/28] Avoid gcc 5.4 warning -Wunused-result It used to be you could suppress this with (void), however the gcc developers have decided to get rid of that. So, look closely at each occurrence and decide what to do: - *pingpong: Join the error handling with the if statement directly above - niegh: read on a timer_fd should never fail, so just use assert. The assert is compiled out for Release builds so this is no-change - acm: Failure of ucma_set_server_port is detected by a 0 return so check fscanf and return appropriately. This is no change since fscanf failure was assumed to have left server_port as 0 (though I doubt the standard supports that usage) - rsocket: This looks super sketchy. At least lets make the intent clear with a read_all/write_all wrapper that calls assert. Most likely this code is wrong.. Mangle the code with failable_fscanf to make it clear, but as with acm, I don't think the standard supports this usage. Acked-by: Sean Hefty (rdmacm) Signed-off-by: Jason Gunthorpe --- libibverbs/examples/rc_pingpong.c | 15 ++++---- libibverbs/examples/srq_pingpong.c | 13 +++++-- libibverbs/examples/uc_pingpong.c | 15 ++++---- libibverbs/examples/ud_pingpong.c | 17 ++++----- libibverbs/src/neigh.c | 7 ++-- librdmacm/src/acm.c | 3 +- librdmacm/src/rsocket.c | 56 +++++++++++++++++++++--------- 7 files changed, 78 insertions(+), 48 deletions(-) diff --git a/libibverbs/examples/rc_pingpong.c b/libibverbs/examples/rc_pingpong.c index 1fad16a0b..7bcc413a0 100644 --- a/libibverbs/examples/rc_pingpong.c +++ b/libibverbs/examples/rc_pingpong.c @@ -208,14 +208,13 @@ static struct pingpong_dest *pp_client_exch_dest(const char *servername, int por goto out; } - if (read(sockfd, msg, sizeof msg) != sizeof msg) { - perror("client read"); - fprintf(stderr, "Couldn't read remote address\n"); + if (read(sockfd, msg, sizeof msg) != sizeof msg || + write(sockfd, "done", sizeof "done") != sizeof "done") { + perror("client read/write"); + fprintf(stderr, "Couldn't read/write remote address\n"); goto out; } - write(sockfd, "done", sizeof "done"); - rem_dest = malloc(sizeof *rem_dest); if (!rem_dest) goto out; @@ -316,14 +315,14 @@ static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx, gid_to_wire_gid(&my_dest->gid, gid); sprintf(msg, "%04x:%06x:%06x:%s", my_dest->lid, my_dest->qpn, my_dest->psn, gid); - if (write(connfd, msg, sizeof msg) != sizeof msg) { - fprintf(stderr, "Couldn't send local address\n"); + if (write(connfd, msg, sizeof msg) != sizeof msg || + read(connfd, msg, sizeof msg) != sizeof msg) { + fprintf(stderr, "Couldn't send/recv local address\n"); free(rem_dest); rem_dest = NULL; goto out; } - read(connfd, msg, sizeof msg); out: close(connfd); diff --git a/libibverbs/examples/srq_pingpong.c b/libibverbs/examples/srq_pingpong.c index 929b73654..e6492dc55 100644 --- a/libibverbs/examples/srq_pingpong.c +++ b/libibverbs/examples/srq_pingpong.c @@ -222,8 +222,10 @@ static struct pingpong_dest *pp_client_exch_dest(const char *servername, int por wire_gid_to_gid(gid, &rem_dest[i].gid); } - write(sockfd, "done", sizeof "done"); - + if (write(sockfd, "done", sizeof "done") != sizeof "done") { + perror("client write"); + goto out; + } out: close(sockfd); return rem_dest; @@ -333,7 +335,12 @@ static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx, } } - read(connfd, msg, sizeof msg); + if (read(connfd, msg, sizeof msg) != sizeof msg) { + perror("client write"); + free(rem_dest); + rem_dest = NULL; + goto out; + } out: close(connfd); diff --git a/libibverbs/examples/uc_pingpong.c b/libibverbs/examples/uc_pingpong.c index 3802e3821..d132de986 100644 --- a/libibverbs/examples/uc_pingpong.c +++ b/libibverbs/examples/uc_pingpong.c @@ -176,13 +176,13 @@ static struct pingpong_dest *pp_client_exch_dest(const char *servername, int por goto out; } - if (read(sockfd, msg, sizeof msg) != sizeof msg) { - perror("client read"); - fprintf(stderr, "Couldn't read remote address\n"); + if (read(sockfd, msg, sizeof msg) != sizeof msg || + write(sockfd, "done", sizeof "done") != sizeof "done") { + perror("client read/write"); + fprintf(stderr, "Couldn't read/write remote address\n"); goto out; } - write(sockfd, "done", sizeof "done"); rem_dest = malloc(sizeof *rem_dest); if (!rem_dest) @@ -284,15 +284,14 @@ static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx, gid_to_wire_gid(&my_dest->gid, gid); sprintf(msg, "%04x:%06x:%06x:%s", my_dest->lid, my_dest->qpn, my_dest->psn, gid); - if (write(connfd, msg, sizeof msg) != sizeof msg) { - fprintf(stderr, "Couldn't send local address\n"); + if (write(connfd, msg, sizeof msg) != sizeof msg || + read(connfd, msg, sizeof msg) != sizeof msg) { + fprintf(stderr, "Couldn't send/recv local address\n"); free(rem_dest); rem_dest = NULL; goto out; } - read(connfd, msg, sizeof msg); - out: close(connfd); return rem_dest; diff --git a/libibverbs/examples/ud_pingpong.c b/libibverbs/examples/ud_pingpong.c index fa99b9e51..67da4bd90 100644 --- a/libibverbs/examples/ud_pingpong.c +++ b/libibverbs/examples/ud_pingpong.c @@ -176,14 +176,13 @@ static struct pingpong_dest *pp_client_exch_dest(const char *servername, int por goto out; } - if (read(sockfd, msg, sizeof msg) != sizeof msg) { - perror("client read"); - fprintf(stderr, "Couldn't read remote address\n"); + if (read(sockfd, msg, sizeof msg) != sizeof msg || + write(sockfd, "done", sizeof "done") != sizeof "done") { + perror("client read/write"); + fprintf(stderr, "Couldn't read/write remote address\n"); goto out; } - write(sockfd, "done", sizeof "done"); - rem_dest = malloc(sizeof *rem_dest); if (!rem_dest) goto out; @@ -282,15 +281,13 @@ static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx, gid_to_wire_gid(&my_dest->gid, gid); sprintf(msg, "%04x:%06x:%06x:%s", my_dest->lid, my_dest->qpn, my_dest->psn, gid); - if (write(connfd, msg, sizeof msg) != sizeof msg) { - fprintf(stderr, "Couldn't send local address\n"); + if (write(connfd, msg, sizeof msg) != sizeof msg || + read(connfd, msg, sizeof msg) != sizeof msg) { + fprintf(stderr, "Couldn't send/recv local address\n"); free(rem_dest); rem_dest = NULL; goto out; } - - read(connfd, msg, sizeof msg); - out: close(connfd); return rem_dest; diff --git a/libibverbs/src/neigh.c b/libibverbs/src/neigh.c index 6b6e58cd5..5acfcf06f 100644 --- a/libibverbs/src/neigh.c +++ b/libibverbs/src/neigh.c @@ -19,6 +19,7 @@ #include #include #include +#include #ifndef _LINUX_IF_H #include #else @@ -372,9 +373,11 @@ static struct nl_addr *process_get_neigh_mac( if (FD_ISSET(timer_fd, &fdset)) { uint64_t read_val; + ssize_t rc; - (void)read(timer_fd, &read_val, - sizeof(read_val)); + rc = + read(timer_fd, &read_val, sizeof(read_val)); + assert(rc == sizeof(read_val)); if (++retries >= NUM_OF_TRIES) { if (!errno) errno = EDESTADDRREQ; diff --git a/librdmacm/src/acm.c b/librdmacm/src/acm.c index 75d9d8cf4..823381aac 100644 --- a/librdmacm/src/acm.c +++ b/librdmacm/src/acm.c @@ -121,7 +121,8 @@ static int ucma_set_server_port(void) FILE *f; if ((f = fopen(IBACM_PORT_FILE, "r" STREAM_CLOEXEC))) { - fscanf(f, "%" SCNu16, &server_port); + if (fscanf(f, "%" SCNu16, &server_port) != 1) + server_port = 0; fclose(f); } return server_port; diff --git a/librdmacm/src/rsocket.c b/librdmacm/src/rsocket.c index 051dd89bf..205101f17 100644 --- a/librdmacm/src/rsocket.c +++ b/librdmacm/src/rsocket.c @@ -404,6 +404,20 @@ struct ds_udp_header { #define ds_next_qp(qp) container_of((qp)->list.next, struct ds_qp, list) +static void write_all(int fd, const void *msg, size_t len) +{ + // FIXME: if fd is a socket this really needs to handle EINTR and other conditions. + ssize_t rc = write(fd, msg, len); + assert(rc == len); +} + +static void read_all(int fd, void *msg, size_t len) +{ + // FIXME: if fd is a socket this really needs to handle EINTR and other conditions. + ssize_t rc = read(fd, msg, len); + assert(rc == len); +} + static void ds_insert_qp(struct rsocket *rs, struct ds_qp *qp) { if (!rs->qp_list) @@ -444,8 +458,8 @@ static int rs_notify_svc(struct rs_svc *svc, struct rsocket *rs, int cmd) msg.cmd = cmd; msg.status = EINVAL; msg.rs = rs; - write(svc->sock[0], &msg, sizeof msg); - read(svc->sock[0], &msg, sizeof msg); + write_all(svc->sock[0], &msg, sizeof msg); + read_all(svc->sock[0], &msg, sizeof msg); ret = rdma_seterrno(msg.status); if (svc->cnt) goto unlock; @@ -484,6 +498,15 @@ static int rs_scale_to_value(int value, int bits) value : (value & ~(1 << (bits - 1))) << bits; } +/* gcc > ~5 will not allow (void)fscanf to suppress -Wunused-result, but this + will do it. In this case ignoring the result is OK (but horribly + unfriendly to user) since the library has a sane default. */ +#define failable_fscanf(f, fmt, ...) \ + { \ + int rc = fscanf(f, fmt, __VA_ARGS__); \ + (void) rc; \ + } + void rs_configure(void) { FILE *f; @@ -501,27 +524,27 @@ void rs_configure(void) ucma_ib_init(); if ((f = fopen(RS_CONF_DIR "/polling_time", "r"))) { - (void) fscanf(f, "%u", &polling_time); + failable_fscanf(f, "%u", &polling_time); fclose(f); } if ((f = fopen(RS_CONF_DIR "/inline_default", "r"))) { - (void) fscanf(f, "%hu", &def_inline); + failable_fscanf(f, "%hu", &def_inline); fclose(f); } if ((f = fopen(RS_CONF_DIR "/sqsize_default", "r"))) { - (void) fscanf(f, "%hu", &def_sqsize); + failable_fscanf(f, "%hu", &def_sqsize); fclose(f); } if ((f = fopen(RS_CONF_DIR "/rqsize_default", "r"))) { - (void) fscanf(f, "%hu", &def_rqsize); + failable_fscanf(f, "%hu", &def_rqsize); fclose(f); } if ((f = fopen(RS_CONF_DIR "/mem_default", "r"))) { - (void) fscanf(f, "%u", &def_mem); + failable_fscanf(f, "%u", &def_mem); fclose(f); if (def_mem < 1) @@ -529,14 +552,14 @@ void rs_configure(void) } if ((f = fopen(RS_CONF_DIR "/wmem_default", "r"))) { - (void) fscanf(f, "%u", &def_wmem); + failable_fscanf(f, "%u", &def_wmem); fclose(f); if (def_wmem < RS_SNDLOWAT) def_wmem = RS_SNDLOWAT << 1; } if ((f = fopen(RS_CONF_DIR "/iomap_size", "r"))) { - (void) fscanf(f, "%hu", &def_iomap_size); + failable_fscanf(f, "%hu", &def_iomap_size); fclose(f); /* round to supported values */ @@ -3345,7 +3368,8 @@ static int rs_set_keepalive(struct rsocket *rs, int on) if (on) { if (!rs->keepalive_time) { if ((f = fopen("/proc/sys/net/ipv4/tcp_keepalive_time", "r"))) { - (void) fscanf(f, "%u", &rs->keepalive_time); + if (fscanf(f, "%u", &rs->keepalive_time) != 1) + rs->keepalive_time = 7200; fclose(f); } else { rs->keepalive_time = 7200; @@ -3985,7 +4009,7 @@ static void udp_svc_process_sock(struct rs_svc *svc) { struct rs_svc_msg msg; - read(svc->sock[1], &msg, sizeof msg); + read_all(svc->sock[1], &msg, sizeof msg); switch (msg.cmd) { case RS_SVC_ADD_DGRAM: msg.status = rs_svc_add_rs(svc, msg.rs); @@ -4009,7 +4033,7 @@ static void udp_svc_process_sock(struct rs_svc *svc) break; } - write(svc->sock[1], &msg, sizeof msg); + write_all(svc->sock[1], &msg, sizeof msg); } static uint8_t udp_svc_sgid_index(struct ds_dest *dest, union ibv_gid *sgid) @@ -4184,7 +4208,7 @@ static void *udp_svc_run(void *arg) ret = rs_svc_grow_sets(svc, 4); if (ret) { msg.status = ret; - write(svc->sock[1], &msg, sizeof msg); + write_all(svc->sock[1], &msg, sizeof msg); return (void *) (uintptr_t) ret; } @@ -4222,7 +4246,7 @@ static void tcp_svc_process_sock(struct rs_svc *svc) struct rs_svc_msg msg; int i; - read(svc->sock[1], &msg, sizeof msg); + read_all(svc->sock[1], &msg, sizeof msg); switch (msg.cmd) { case RS_SVC_ADD_KEEPALIVE: msg.status = rs_svc_add_rs(svc, msg.rs); @@ -4253,7 +4277,7 @@ static void tcp_svc_process_sock(struct rs_svc *svc) default: break; } - write(svc->sock[1], &msg, sizeof msg); + write_all(svc->sock[1], &msg, sizeof msg); } /* @@ -4282,7 +4306,7 @@ static void *tcp_svc_run(void *arg) ret = rs_svc_grow_sets(svc, 16); if (ret) { msg.status = ret; - write(svc->sock[1], &msg, sizeof msg); + write_all(svc->sock[1], &msg, sizeof msg); return (void *) (uintptr_t) ret; } From 0db49b8b3e8f78e174b5873bc747fa6ab7745fff Mon Sep 17 00:00:00 2001 From: Jason Gunthorpe Date: Fri, 2 Sep 2016 12:17:47 -0600 Subject: [PATCH 27/28] Avoid clang 3.6 warning -Wmissing-field-initializers The canonical way to zero fill a struct is {}. Sometimes people will write this as {0} which does the same thing if the first struct member is integral. However the preference for {} is because it allows the compiler to see that the intent is for every member to be zero, and this is not an inadvertent incomplete initialization of an array or struct. We have a random jumble of both styles, so lets prefer {} since it avoids a useful warning. Signed-off-by: Jason Gunthorpe --- libibverbs/examples/asyncwatch.c | 2 +- libibverbs/examples/rc_pingpong.c | 2 +- libibverbs/examples/srq_pingpong.c | 2 +- libibverbs/examples/uc_pingpong.c | 2 +- libibverbs/examples/ud_pingpong.c | 4 ++-- libibverbs/examples/xsrq_pingpong.c | 2 +- libmlx5/src/verbs.c | 4 ++-- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libibverbs/examples/asyncwatch.c b/libibverbs/examples/asyncwatch.c index df1261503..c78994d24 100644 --- a/libibverbs/examples/asyncwatch.c +++ b/libibverbs/examples/asyncwatch.c @@ -105,7 +105,7 @@ int main(int argc, char *argv[]) static struct option long_options[] = { { .name = "ib-dev", .has_arg = 1, .val = 'd' }, { .name = "help", .has_arg = 0, .val = 'h' }, - { 0 } + {} }; c = getopt_long(argc, argv, "d:h", long_options, NULL); diff --git a/libibverbs/examples/rc_pingpong.c b/libibverbs/examples/rc_pingpong.c index 7bcc413a0..9054a68b7 100644 --- a/libibverbs/examples/rc_pingpong.c +++ b/libibverbs/examples/rc_pingpong.c @@ -731,7 +731,7 @@ int main(int argc, char *argv[]) { .name = "gid-idx", .has_arg = 1, .val = 'g' }, { .name = "odp", .has_arg = 0, .val = 'o' }, { .name = "ts", .has_arg = 0, .val = 't' }, - { 0 } + {} }; c = getopt_long(argc, argv, "p:d:i:s:m:r:n:l:eg:ot", diff --git a/libibverbs/examples/srq_pingpong.c b/libibverbs/examples/srq_pingpong.c index e6492dc55..f17972580 100644 --- a/libibverbs/examples/srq_pingpong.c +++ b/libibverbs/examples/srq_pingpong.c @@ -665,7 +665,7 @@ int main(int argc, char *argv[]) { .name = "sl", .has_arg = 1, .val = 'l' }, { .name = "events", .has_arg = 0, .val = 'e' }, { .name = "gid-idx", .has_arg = 1, .val = 'g' }, - { 0 } + {} }; c = getopt_long(argc, argv, "p:d:i:s:m:q:r:n:l:eg:", diff --git a/libibverbs/examples/uc_pingpong.c b/libibverbs/examples/uc_pingpong.c index d132de986..7d982d36a 100644 --- a/libibverbs/examples/uc_pingpong.c +++ b/libibverbs/examples/uc_pingpong.c @@ -568,7 +568,7 @@ int main(int argc, char *argv[]) { .name = "sl", .has_arg = 1, .val = 'l' }, { .name = "events", .has_arg = 0, .val = 'e' }, { .name = "gid-idx", .has_arg = 1, .val = 'g' }, - { 0 } + {} }; c = getopt_long(argc, argv, "p:d:i:s:m:r:n:l:eg:", diff --git a/libibverbs/examples/ud_pingpong.c b/libibverbs/examples/ud_pingpong.c index 67da4bd90..deefb9b81 100644 --- a/libibverbs/examples/ud_pingpong.c +++ b/libibverbs/examples/ud_pingpong.c @@ -324,7 +324,7 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size, } { - struct ibv_port_attr port_info = { 0 }; + struct ibv_port_attr port_info = {}; int mtu; if (ibv_query_port(ctx->context, port, &port_info)) { @@ -588,7 +588,7 @@ int main(int argc, char *argv[]) { .name = "sl", .has_arg = 1, .val = 'l' }, { .name = "events", .has_arg = 0, .val = 'e' }, { .name = "gid-idx", .has_arg = 1, .val = 'g' }, - { 0 } + {} }; c = getopt_long(argc, argv, "p:d:i:s:r:n:l:eg:", diff --git a/libibverbs/examples/xsrq_pingpong.c b/libibverbs/examples/xsrq_pingpong.c index a7e345f38..903548ed6 100644 --- a/libibverbs/examples/xsrq_pingpong.c +++ b/libibverbs/examples/xsrq_pingpong.c @@ -875,7 +875,7 @@ int main(int argc, char *argv[]) { .name = "sl", .has_arg = 1, .val = 'l' }, { .name = "events", .has_arg = 0, .val = 'e' }, { .name = "gid-idx", .has_arg = 1, .val = 'g' }, - { 0 } + {} }; c = getopt_long(argc, argv, "p:d:i:s:m:c:n:l:eg:", long_options, diff --git a/libmlx5/src/verbs.c b/libmlx5/src/verbs.c index 52289acc3..75cbae35e 100644 --- a/libmlx5/src/verbs.c +++ b/libmlx5/src/verbs.c @@ -1700,8 +1700,8 @@ mlx5_open_xrcd(struct ibv_context *context, { int err; struct verbs_xrcd *xrcd; - struct ibv_open_xrcd cmd = {0}; - struct ibv_open_xrcd_resp resp = {0}; + struct ibv_open_xrcd cmd = {}; + struct ibv_open_xrcd_resp resp = {}; xrcd = calloc(1, sizeof(*xrcd)); if (!xrcd) From ad48f384594facfc73f9b9467c9a4bd33500ba02 Mon Sep 17 00:00:00 2001 From: Jason Gunthorpe Date: Wed, 28 Sep 2016 21:13:07 -0600 Subject: [PATCH 28/28] Add -Werror and 32 bit to TravisCI Now that the build is warning free, try to keep it that way. Signed-off-by: Jason Gunthorpe --- .travis.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index e09dd32ff..a2b9e3b8c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,8 +21,20 @@ addons: - pkg-config - python - valgrind + + # 32 bit support packages + - gcc-multilib + - lib32gcc-6-dev script: - - mkdir build + - mkdir build build32 - cd build - - CC=gcc-6 cmake -GNinja .. + # The goal is warning free compile on latest gcc. + - CC=gcc-6 CFLAGS=-Werror cmake -GNinja .. + - ninja + + # 32 bit build + - cd ../build32 + # travis's trusty is not configured in a way that enables all32 bit + # packages. We could fix this with some sudo stuff.. For now turn off libnl + - CC=gcc-6 CFLAGS="-Werror -m32" cmake -GNinja .. -DENABLE_RESOLVE_NEIGH=0 - ninja