diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..a2b9e3b8c --- /dev/null +++ b/.travis.yml @@ -0,0 +1,40 @@ +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 + + # 32 bit support packages + - gcc-multilib + - lib32gcc-6-dev +script: + - mkdir build build32 + - cd build + # 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 diff --git a/CMakeLists.txt b/CMakeLists.txt index a829cd477..9a88451a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,11 +7,18 @@ # Common options passed to cmake are: # -DCMAKE_EXPORT_COMPILE_COMMANDS=1 # Write a compile_commands.json file for clang tooling -# -DENABLE_VALGRIND=1 (default disabled) -# Embed valgrind notations, this has a tiny negative performance impact +# -DCMAKE_BUILD_TYPE=RelWithDebInfo +# Change the optimization level, Debug disables optimization, +# Release is for packagers +# -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. +# -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) @@ -25,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 @@ -48,6 +56,20 @@ 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" + 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") @@ -58,12 +80,18 @@ include(CheckCCompilerFlag) include(CheckIncludeFile) include(CheckTypeSize) include(RDMA_EnableCStd) +include(RDMA_BuildType) 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() include_directories(${BUILD_INCLUDE}) # FIXME: Eliminate HAVE_CONFIG_H, we always have it. add_definitions(-DHAVE_CONFIG_H) @@ -184,9 +212,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) 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/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) 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() diff --git a/buildlib/config.h.in b/buildlib/config.h.in index 984d51bfa..8ae2a4e53 100644 --- a/buildlib/config.h.in +++ b/buildlib/config.h.in @@ -17,9 +17,21 @@ #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 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@" +#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" + +#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 ea53f3825..06ccd518c 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}) @@ -76,21 +78,18 @@ 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, # 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) @@ -104,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 @@ -131,8 +139,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() @@ -151,107 +168,14 @@ 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) 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) @@ -274,7 +198,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() diff --git a/ibacm/CMakeLists.txt b/ibacm/CMakeLists.txt index 8887c13af..376a3a89d 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") @@ -57,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/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/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/ibacm/src/acm.c b/ibacm/src/acm.c index ab1269f71..41429e1db 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. @@ -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; } @@ -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; @@ -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 */ @@ -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; } diff --git a/ibacm/src/acme.c b/ibacm/src/acme.c index f1b0d0106..4b5fe684c 100644 --- a/ibacm/src/acme.c +++ b/ibacm/src/acme.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -130,9 +131,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 +148,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 +277,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 +293,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"); @@ -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); @@ -927,7 +928,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) { 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/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/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_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/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/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..8369e10f6 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)); @@ -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; 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/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/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/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..9054a68b7 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); @@ -732,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", @@ -768,7 +767,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..f17972580 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); @@ -658,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:", @@ -697,7 +704,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..7d982d36a 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; @@ -569,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:", @@ -604,7 +603,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/ud_pingpong.c b/libibverbs/examples/ud_pingpong.c index fa99b9e51..deefb9b81 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; @@ -327,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)) { @@ -591,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 ff00180f2..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, @@ -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; } 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/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) 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/libibverbs/src/neigh.c b/libibverbs/src/neigh.c index 799b810a9..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 @@ -207,7 +208,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 +217,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; @@ -374,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; @@ -729,7 +730,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; } 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/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/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 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) diff --git a/libnes/src/nes_uverbs.c b/libnes/src/nes_uverbs.c index 80891d624..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]; @@ -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) @@ -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; 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 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/acm.c b/librdmacm/src/acm.c index f0da01e6d..823381aac 100644 --- a/librdmacm/src/acm.c +++ b/librdmacm/src/acm.c @@ -120,8 +120,9 @@ static int ucma_set_server_port(void) { FILE *f; - if ((f = fopen("/var/run/ibacm.port", "r" STREAM_CLOEXEC))) { - fscanf(f, "%" SCNu16, &server_port); + if ((f = fopen(IBACM_PORT_FILE, "r" STREAM_CLOEXEC))) { + if (fscanf(f, "%" SCNu16, &server_port) != 1) + server_port = 0; fclose(f); } return server_port; 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/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; diff --git a/librdmacm/src/rsocket.c b/librdmacm/src/rsocket.c index 818505fbe..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); } /* @@ -4266,7 +4290,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); } @@ -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; } 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; } } 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.c b/srp_daemon/srp_daemon/srp_daemon.c index dfc976b8f..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, @@ -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; 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" ]