Hello community,

here is the log from the commit of package librdmacm for openSUSE:Factory 
checked in at 2016-07-21 07:54:17
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/librdmacm (Old)
 and      /work/SRC/openSUSE:Factory/.librdmacm.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "librdmacm"

Changes:
--------
--- /work/SRC/openSUSE:Factory/librdmacm/librdmacm.changes      2015-03-05 
18:15:50.000000000 +0100
+++ /work/SRC/openSUSE:Factory/.librdmacm.new/librdmacm.changes 2016-07-21 
07:54:19.000000000 +0200
@@ -1,0 +2,6 @@
+Mon Apr 25 09:16:56 UTC 2016 - [email protected]
+
+- Update to version 1.1.0
+  * No changelog available
+
+-------------------------------------------------------------------

Old:
----
  librdmacm-1.0.19.1.tar.gz

New:
----
  librdmacm-1.1.0.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ librdmacm.spec ++++++
--- /var/tmp/diff_new_pack.XjBQFq/_old  2016-07-21 07:54:20.000000000 +0200
+++ /var/tmp/diff_new_pack.XjBQFq/_new  2016-07-21 07:54:20.000000000 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package librdmacm
 #
-# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -18,7 +18,7 @@
 
 %define so_version 1
 Name:           librdmacm
-Version:        1.0.19.1
+Version:        1.1.0
 Release:        0
 Summary:        RDMA cm library
 License:        BSD-2-Clause or GPL-2.0

++++++ librdmacm-1.0.19.1.tar.gz -> librdmacm-1.1.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/librdmacm-1.0.19.1/configure 
new/librdmacm-1.1.0/configure
--- old/librdmacm-1.0.19.1/configure    2014-08-18 22:34:44.000000000 +0200
+++ new/librdmacm-1.1.0/configure       2016-03-18 23:55:00.000000000 +0100
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.67 for librdmacm 1.0.19.1.
+# Generated by GNU Autoconf 2.67 for librdmacm 1.1.0.
 #
 # Report bugs to <[email protected]>.
 #
@@ -701,8 +701,8 @@
 # Identity of this package.
 PACKAGE_NAME='librdmacm'
 PACKAGE_TARNAME='librdmacm'
-PACKAGE_VERSION='1.0.19.1'
-PACKAGE_STRING='librdmacm 1.0.19.1'
+PACKAGE_VERSION='1.1.0'
+PACKAGE_STRING='librdmacm 1.1.0'
 PACKAGE_BUGREPORT='[email protected]'
 PACKAGE_URL=''
 
@@ -1423,7 +1423,7 @@
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures librdmacm 1.0.19.1 to adapt to many kinds of systems.
+\`configure' configures librdmacm 1.1.0 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1493,7 +1493,7 @@
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of librdmacm 1.0.19.1:";;
+     short | recursive ) echo "Configuration of librdmacm 1.1.0:";;
    esac
   cat <<\_ACEOF
 
@@ -1597,7 +1597,7 @@
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-librdmacm configure 1.0.19.1
+librdmacm configure 1.1.0
 generated by GNU Autoconf 2.67
 
 Copyright (C) 2010 Free Software Foundation, Inc.
@@ -2190,7 +2190,7 @@
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by librdmacm $as_me 1.0.19.1, which was
+It was created by librdmacm $as_me 1.1.0, which was
 generated by GNU Autoconf 2.67.  Invocation command line was
 
   $ $0 $@
@@ -3009,7 +3009,7 @@
 
 # Define the identity of the package.
  PACKAGE='librdmacm'
- VERSION='1.0.19.1'
+ VERSION='1.1.0'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -12362,7 +12362,7 @@
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by librdmacm $as_me 1.0.19.1, which was
+This file was extended by librdmacm $as_me 1.1.0, which was
 generated by GNU Autoconf 2.67.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -12428,7 +12428,7 @@
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; 
s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-librdmacm config.status 1.0.19.1
+librdmacm config.status 1.1.0
 configured by $0, generated by GNU Autoconf 2.67,
   with options \\"\$ac_cs_config\\"
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/librdmacm-1.0.19.1/configure.ac 
new/librdmacm-1.1.0/configure.ac
--- old/librdmacm-1.0.19.1/configure.ac 2014-08-18 22:31:49.000000000 +0200
+++ new/librdmacm-1.1.0/configure.ac    2016-03-18 23:53:43.000000000 +0100
@@ -1,7 +1,7 @@
 dnl Process this file with autoconf to produce a configure script.
 
 AC_PREREQ([2.63])
-AC_INIT([librdmacm],[1.0.19.1],[[email protected]])
+AC_INIT([librdmacm],[1.1.0],[[email protected]])
 AC_CONFIG_SRCDIR([src/cma.c])
 AC_CONFIG_AUX_DIR(config)
 AC_CONFIG_MACRO_DIR(config)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/librdmacm-1.0.19.1/examples/cmatose.c 
new/librdmacm-1.1.0/examples/cmatose.c
--- old/librdmacm-1.0.19.1/examples/cmatose.c   2014-08-18 22:31:49.000000000 
+0200
+++ new/librdmacm-1.1.0/examples/cmatose.c      2016-03-18 23:53:43.000000000 
+0100
@@ -509,7 +509,7 @@
 
        ret = get_rdma_addr(src_addr, dst_addr, port, &hints, &test.rai);
        if (ret) {
-               perror("cmatose: getrdmaaddr error");
+               printf("cmatose: getrdmaaddr error: %s\n", gai_strerror(ret));
                goto out;
        }
 
@@ -582,7 +582,7 @@
 
        ret = get_rdma_addr(src_addr, dst_addr, port, &hints, &test.rai);
        if (ret) {
-               perror("cmatose: getaddrinfo error");
+               printf("cmatose: getaddrinfo error: %s\n", gai_strerror(ret));
                return ret;
        }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/librdmacm-1.0.19.1/examples/cmtime.c 
new/librdmacm-1.1.0/examples/cmtime.c
--- old/librdmacm-1.0.19.1/examples/cmtime.c    2014-08-18 22:31:49.000000000 
+0200
+++ new/librdmacm-1.1.0/examples/cmtime.c       2016-03-18 23:53:43.000000000 
+0100
@@ -479,7 +479,7 @@
 
        ret = get_rdma_addr(src_addr, dst_addr, port, &hints, &rai);
        if (ret) {
-               perror("getrdmaaddr error");
+               printf("getrdmaaddr error: %s\n", gai_strerror(ret));
                goto out;
        }
 
@@ -508,7 +508,7 @@
 
        ret = get_rdma_addr(src_addr, dst_addr, port, &hints, &rai);
        if (ret) {
-               perror("getaddrinfo error");
+               printf("getaddrinfo error: %s\n", gai_strerror(ret));
                return ret;
        }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/librdmacm-1.0.19.1/examples/mckey.c 
new/librdmacm-1.1.0/examples/mckey.c
--- old/librdmacm-1.0.19.1/examples/mckey.c     2014-08-18 22:31:49.000000000 
+0200
+++ new/librdmacm-1.1.0/examples/mckey.c        2016-03-18 23:53:43.000000000 
+0100
@@ -452,7 +452,7 @@
 
        ret = getaddrinfo(dst, NULL, NULL, &res);
        if (ret) {
-               printf("getaddrinfo failed - invalid hostname or IP address\n");
+               printf("getaddrinfo failed (%s) - invalid hostname or IP 
address\n", gai_strerror(ret));
                return ret;
        }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/librdmacm-1.0.19.1/examples/rcopy.c 
new/librdmacm-1.1.0/examples/rcopy.c
--- old/librdmacm-1.0.19.1/examples/rcopy.c     2014-08-18 22:31:49.000000000 
+0200
+++ new/librdmacm-1.1.0/examples/rcopy.c        2016-03-18 23:53:43.000000000 
+0100
@@ -186,7 +186,7 @@
        hints.ai_flags = RAI_PASSIVE;
        ret = getaddrinfo(NULL, port, &hints, &res);
        if (ret) {
-               perror("getaddrinfo failed\n");
+               printf("getaddrinfo failed: %s\n", gai_strerror(ret));
                return ret;
        }
 
@@ -396,7 +396,7 @@
 
        ret = getaddrinfo(dst_addr, port, NULL, &res);
        if (ret) {
-               perror("getaddrinfo failed\n");
+               printf("getaddrinfo failed: %s\n", gai_strerror(ret));
                return ret;
        }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/librdmacm-1.0.19.1/examples/rdma_client.c 
new/librdmacm-1.1.0/examples/rdma_client.c
--- old/librdmacm-1.0.19.1/examples/rdma_client.c       2014-08-18 
22:31:49.000000000 +0200
+++ new/librdmacm-1.1.0/examples/rdma_client.c  2016-03-18 23:53:43.000000000 
+0100
@@ -30,6 +30,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <netdb.h>
 #include <errno.h>
 #include <getopt.h>
 #include <rdma/rdma_cma.h>
@@ -55,7 +56,7 @@
        hints.ai_port_space = RDMA_PS_TCP;
        ret = rdma_getaddrinfo(server, port, &hints, &res);
        if (ret) {
-               perror("rdma_getaddrinfo");
+               printf("rdma_getaddrinfo: %s\n", gai_strerror(ret));
                goto out;
        }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/librdmacm-1.0.19.1/examples/rdma_server.c 
new/librdmacm-1.1.0/examples/rdma_server.c
--- old/librdmacm-1.0.19.1/examples/rdma_server.c       2014-08-18 
22:31:49.000000000 +0200
+++ new/librdmacm-1.1.0/examples/rdma_server.c  2016-03-18 23:53:43.000000000 
+0100
@@ -57,7 +57,7 @@
        hints.ai_port_space = RDMA_PS_TCP;
        ret = rdma_getaddrinfo(NULL, port, &hints, &res);
        if (ret) {
-               perror("rdma_getaddrinfo");
+               printf("rdma_getaddrinfo: %s\n", gai_strerror(ret));
                return ret;
        }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/librdmacm-1.0.19.1/examples/rdma_xclient.c 
new/librdmacm-1.1.0/examples/rdma_xclient.c
--- old/librdmacm-1.0.19.1/examples/rdma_xclient.c      2014-08-18 
22:31:49.000000000 +0200
+++ new/librdmacm-1.1.0/examples/rdma_xclient.c 2016-03-18 23:53:43.000000000 
+0100
@@ -30,6 +30,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <netdb.h>
 #include <errno.h>
 #include <getopt.h>
 #include <ctype.h>
@@ -80,7 +81,7 @@
 
        ret = rdma_getaddrinfo(server, port, &hints, &res);
        if (ret) {
-               perror("rdma_getaddrinfo");
+               printf("rdma_getaddrinfo: %s\n", gai_strerror(ret));
                return ret;
        }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/librdmacm-1.0.19.1/examples/rdma_xserver.c 
new/librdmacm-1.1.0/examples/rdma_xserver.c
--- old/librdmacm-1.0.19.1/examples/rdma_xserver.c      2014-08-18 
22:31:49.000000000 +0200
+++ new/librdmacm-1.1.0/examples/rdma_xserver.c 2016-03-18 23:53:43.000000000 
+0100
@@ -78,7 +78,7 @@
 
        ret = rdma_getaddrinfo(NULL, port, &hints, &res);
        if (ret) {
-               perror("rdma_getaddrinfo");
+               printf("rdma_getaddrinfo: %s\n", gai_strerror(ret));
                return ret;
        }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/librdmacm-1.0.19.1/examples/riostream.c 
new/librdmacm-1.1.0/examples/riostream.c
--- old/librdmacm-1.0.19.1/examples/riostream.c 2014-08-18 22:31:49.000000000 
+0200
+++ new/librdmacm-1.1.0/examples/riostream.c    2016-03-18 23:53:43.000000000 
+0100
@@ -86,7 +86,7 @@
 static int iterations = 1;
 static int transfer_size = 1000;
 static int transfer_count = 1000;
-static int buffer_size;
+static int buffer_size, inline_size = 64;
 static char test_name[10] = "custom";
 static char *port = "7471";
 static char *dst_addr;
@@ -341,8 +341,8 @@
 
        /* Inline size based on experimental data */
        if (optimization == opt_latency) {
-               val = 384;
-               rsetsockopt(rs, SOL_RDMA, RDMA_INLINE, &val, sizeof val);
+               rsetsockopt(rs, SOL_RDMA, RDMA_INLINE, &inline_size,
+                           sizeof inline_size);
        } else if (optimization == opt_bandwidth) {
                val = 0;
                rsetsockopt(rs, SOL_RDMA, RDMA_INLINE, &val, sizeof val);
@@ -363,7 +363,7 @@
                ret = getaddrinfo(src_addr, port, &ai_hints, &ai);
        }
        if (ret) {
-               perror("getaddrinfo");
+               printf("getaddrinfo: %s\n", gai_strerror(ret));
                return ret;
        }
 
@@ -444,7 +444,7 @@
        ret = use_rgai ? rdma_getaddrinfo(dst_addr, port, &rai_hints, &rai) :
                         getaddrinfo(dst_addr, port, &ai_hints, &ai);
        if (ret) {
-               perror("getaddrinfo");
+               printf("getaddrinfo: %s\n", gai_strerror(ret));
                return ret;
        }
 
@@ -470,8 +470,10 @@
                fds.fd = rs;
                fds.events = POLLOUT;
                ret = do_poll(&fds, poll_timeout);
-               if (ret)
+               if (ret) {
+                       perror("rpoll");
                        goto close;
+               }
 
                len = sizeof err;
                ret = rgetsockopt(rs, SOL_SOCKET, SO_ERROR, &err, &len);
@@ -594,7 +596,7 @@
 
        ai_hints.ai_socktype = SOCK_STREAM;
        rai_hints.ai_port_space = RDMA_PS_TCP;
-       while ((op = getopt(argc, argv, "s:b:f:B:I:C:S:p:T:")) != -1) {
+       while ((op = getopt(argc, argv, "s:b:f:B:i:I:C:S:p:T:")) != -1) {
                switch (op) {
                case 's':
                        dst_addr = optarg;
@@ -616,6 +618,9 @@
                case 'B':
                        buffer_size = atoi(optarg);
                        break;
+               case 'i':
+                       inline_size = atoi(optarg);
+                       break;
                case 'I':
                        custom = 1;
                        iterations = atoi(optarg);
@@ -646,6 +651,7 @@
                        printf("\t[-f address_format]\n");
                        printf("\t    name, ip, ipv6, or gid\n");
                        printf("\t[-B buffer_size]\n");
+                       printf("\t[-i inline_size]\n");
                        printf("\t[-I iterations]\n");
                        printf("\t[-C transfer_count]\n");
                        printf("\t[-S transfer_size or all]\n");
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/librdmacm-1.0.19.1/examples/rping.c 
new/librdmacm-1.1.0/examples/rping.c
--- old/librdmacm-1.0.19.1/examples/rping.c     2014-08-18 22:31:49.000000000 
+0200
+++ new/librdmacm-1.1.0/examples/rping.c        2016-03-18 23:53:43.000000000 
+0100
@@ -277,15 +277,20 @@
        struct ibv_wc wc;
        struct ibv_recv_wr *bad_wr;
        int ret;
+       int flushed = 0;
 
        while ((ret = ibv_poll_cq(cb->cq, 1, &wc)) == 1) {
                ret = 0;
 
                if (wc.status) {
-                       if (wc.status != IBV_WC_WR_FLUSH_ERR)
-                               fprintf(stderr,
-                                       "cq completion failed status %d\n",
-                                       wc.status);
+                       if (wc.status == IBV_WC_WR_FLUSH_ERR) {
+                               flushed = 1;
+                               continue;
+
+                       }
+                       fprintf(stderr,
+                               "cq completion failed status %d\n",
+                               wc.status);
                        ret = -1;
                        goto error;
                }
@@ -334,7 +339,7 @@
                fprintf(stderr, "poll error %d\n", ret);
                goto error;
        }
-       return 0;
+       return flushed;
 
 error:
        cb->state = ERROR;
@@ -788,7 +793,11 @@
                goto err2;
        }
 
-       pthread_create(&cb->cqthread, NULL, cq_thread, cb);
+       ret = pthread_create(&cb->cqthread, NULL, cq_thread, cb);
+       if (ret) {
+               perror("pthread_create");
+               goto err2;
+       }
 
        ret = rping_accept(cb);
        if (ret) {
@@ -820,11 +829,27 @@
 {
        int ret;
        struct rping_cb *cb;
+       pthread_attr_t attr;
 
        ret = rping_bind_server(listening_cb);
        if (ret)
                return ret;
 
+       /*
+        * Set persistent server threads to DEATCHED state so
+        * they release all their resources when they exit.
+        */
+       ret = pthread_attr_init(&attr);
+       if (ret) {
+               perror("pthread_attr_init");
+               return ret;
+       }
+       ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+       if (ret) {
+               perror("pthread_attr_setdetachstate");
+               return ret;
+       }
+
        while (1) {
                sem_wait(&listening_cb->sem);
                if (listening_cb->state != CONNECT_REQUEST) {
@@ -836,7 +861,12 @@
                cb = clone_cb(listening_cb);
                if (!cb)
                        return -1;
-               pthread_create(&cb->persistent_server_thread, NULL, 
rping_persistent_server_thread, cb);
+
+               ret = pthread_create(&cb->persistent_server_thread, &attr, 
rping_persistent_server_thread, cb);
+               if (ret) {
+                       perror("pthread_create");
+                       return ret;
+               }
        }
        return 0;
 }
@@ -875,7 +905,11 @@
                goto err2;
        }
 
-       pthread_create(&cb->cqthread, NULL, cq_thread, cb);
+       ret = pthread_create(&cb->cqthread, NULL, cq_thread, cb);
+       if (ret) {
+               perror("pthread_create");
+               goto err2;
+       }
 
        ret = rping_accept(cb);
        if (ret) {
@@ -1050,23 +1084,28 @@
                goto err2;
        }
 
-       pthread_create(&cb->cqthread, NULL, cq_thread, cb);
+       ret = pthread_create(&cb->cqthread, NULL, cq_thread, cb);
+       if (ret) {
+               perror("pthread_create");
+               goto err2;
+       }
 
        ret = rping_connect_client(cb);
        if (ret) {
                fprintf(stderr, "connect error %d\n", ret);
-               goto err2;
+               goto err3;
        }
 
        ret = rping_test_client(cb);
        if (ret) {
                fprintf(stderr, "rping client failed: %d\n", ret);
-               goto err3;
+               goto err4;
        }
 
        ret = 0;
-err3:
+err4:
        rdma_disconnect(cb->cm_id);
+err3:
        pthread_join(cb->cqthread, NULL);
 err2:
        rping_free_buffers(cb);
@@ -1083,7 +1122,7 @@
 
        ret = getaddrinfo(dst, NULL, NULL, &res);
        if (ret) {
-               printf("getaddrinfo failed - invalid hostname or IP address\n");
+               printf("getaddrinfo failed (%s) - invalid hostname or IP 
address\n", gai_strerror(ret));
                return ret;
        }
 
@@ -1216,7 +1255,11 @@
        }
        DEBUG_LOG("created cm_id %p\n", cb->cm_id);
 
-       pthread_create(&cb->cmthread, NULL, cm_thread, cb);
+       ret = pthread_create(&cb->cmthread, NULL, cm_thread, cb);
+       if (ret) {
+               perror("pthread_create");
+               goto out2;
+       }
 
        if (cb->server) {
                if (persistent_server)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/librdmacm-1.0.19.1/examples/rstream.c 
new/librdmacm-1.1.0/examples/rstream.c
--- old/librdmacm-1.0.19.1/examples/rstream.c   2014-08-18 22:31:49.000000000 
+0200
+++ new/librdmacm-1.1.0/examples/rstream.c      2016-03-18 23:53:43.000000000 
+0100
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2011-2012 Intel Corporation.  All rights reserved.
+ * Copyright (c) 2014-2015 Mellanox Technologies LTD. All rights reserved.
  *
  * This software is available to you under the OpenIB.org BSD license
  * below:
@@ -87,7 +88,7 @@
 static int iterations = 1;
 static int transfer_size = 1000;
 static int transfer_count = 1000;
-static int buffer_size;
+static int buffer_size, inline_size = 64;
 static char test_name[10] = "custom";
 static char *port = "7471";
 static int keepalive;
@@ -300,8 +301,8 @@
        if (use_rs) {
                /* Inline size based on experimental data */
                if (optimization == opt_latency) {
-                       val = 384;
-                       rs_setsockopt(rs, SOL_RDMA, RDMA_INLINE, &val, sizeof 
val);
+                       rs_setsockopt(rs, SOL_RDMA, RDMA_INLINE, &inline_size,
+                                     sizeof inline_size);
                } else if (optimization == opt_bandwidth) {
                        val = 0;
                        rs_setsockopt(rs, SOL_RDMA, RDMA_INLINE, &val, sizeof 
val);
@@ -326,7 +327,7 @@
                ret = getaddrinfo(src_addr, port, &ai_hints, &ai);
        }
        if (ret) {
-               perror("getaddrinfo");
+               printf("getaddrinfo: %s\n", gai_strerror(ret));
                return ret;
        }
 
@@ -401,8 +402,8 @@
 
 static int client_connect(void)
 {
-       struct rdma_addrinfo *rai = NULL;
-       struct addrinfo *ai;
+       struct rdma_addrinfo *rai = NULL, *rai_src = NULL;
+       struct addrinfo *ai, *ai_src;
        struct pollfd fds;
        int ret, err;
        socklen_t len;
@@ -411,10 +412,24 @@
                         getaddrinfo(dst_addr, port, &ai_hints, &ai);
 
        if (ret) {
-               perror("getaddrinfo");
+               printf("getaddrinfo: %s\n", gai_strerror(ret));
                return ret;
        }
 
+       if (src_addr) {
+               if (use_rgai) {
+                       rai_hints.ai_flags |= RAI_PASSIVE;
+                       ret = rdma_getaddrinfo(src_addr, port, &rai_hints, 
&rai_src);
+               } else {
+                       ai_hints.ai_flags |= AI_PASSIVE;
+                       ret = getaddrinfo(src_addr, port, &ai_hints, &ai_src);
+               }
+               if (ret) {
+                       printf("getaddrinfo src_addr: %s\n", gai_strerror(ret));
+                       return ret;
+               }
+       }
+
        rs = rai ? rs_socket(rai->ai_family, SOCK_STREAM, 0) :
                   rs_socket(ai->ai_family, SOCK_STREAM, 0);
        if (rs < 0) {
@@ -424,7 +439,15 @@
        }
 
        set_options(rs);
-       /* TODO: bind client to src_addr */
+
+       if (src_addr) {
+               ret = rai ? rs_bind(rs, rai_src->ai_src_addr, 
rai_src->ai_src_len) :
+                           rs_bind(rs, ai_src->ai_addr, ai_src->ai_addrlen);
+               if (ret) {
+                       perror("rbind");
+                       goto close;
+               }
+       }
 
        if (rai && rai->ai_route) {
                ret = rs_setsockopt(rs, SOL_RDMA, RDMA_ROUTE, rai->ai_route,
@@ -446,8 +469,10 @@
                fds.fd = rs;
                fds.events = POLLOUT;
                ret = do_poll(&fds, poll_timeout);
-               if (ret)
+               if (ret) {
+                       perror("rpoll");
                        goto close;
+               }
 
                len = sizeof err;
                ret = rs_getsockopt(rs, SOL_SOCKET, SO_ERROR, &err, &len);
@@ -597,7 +622,7 @@
 
        ai_hints.ai_socktype = SOCK_STREAM;
        rai_hints.ai_port_space = RDMA_PS_TCP;
-       while ((op = getopt(argc, argv, "s:b:f:B:I:C:S:p:k:T:")) != -1) {
+       while ((op = getopt(argc, argv, "s:b:f:B:i:I:C:S:p:k:T:")) != -1) {
                switch (op) {
                case 's':
                        dst_addr = optarg;
@@ -619,6 +644,9 @@
                case 'B':
                        buffer_size = atoi(optarg);
                        break;
+               case 'i':
+                       inline_size = atoi(optarg);
+                       break;
                case 'I':
                        custom = 1;
                        iterations = atoi(optarg);
@@ -652,6 +680,7 @@
                        printf("\t[-f address_format]\n");
                        printf("\t    name, ip, ipv6, or gid\n");
                        printf("\t[-B buffer_size]\n");
+                       printf("\t[-i inline_size]\n");
                        printf("\t[-I iterations]\n");
                        printf("\t[-C transfer_count]\n");
                        printf("\t[-S transfer_size or all]\n");
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/librdmacm-1.0.19.1/examples/udaddy.c 
new/librdmacm-1.1.0/examples/udaddy.c
--- old/librdmacm-1.0.19.1/examples/udaddy.c    2014-08-18 22:31:49.000000000 
+0200
+++ new/librdmacm-1.1.0/examples/udaddy.c       2016-03-18 23:53:43.000000000 
+0100
@@ -516,7 +516,7 @@
 
        ret = get_rdma_addr(src_addr, dst_addr, port, &hints, &test.rai);
        if (ret) {
-               perror("cmatose: getrdmaaddr error");
+               printf("udaddy: getrdmaaddr error: %s\n", gai_strerror(ret));
                goto out;
        }
 
@@ -565,7 +565,7 @@
 
        ret = get_rdma_addr(src_addr, dst_addr, port, &hints, &test.rai);
        if (ret) {
-               perror("udaddy: getaddrinfo error");
+               printf("udaddy: getaddrinfo error: %s\n", gai_strerror(ret));
                return ret;
        }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/librdmacm-1.0.19.1/examples/udpong.c 
new/librdmacm-1.1.0/examples/udpong.c
--- old/librdmacm-1.0.19.1/examples/udpong.c    2014-08-18 22:31:49.000000000 
+0200
+++ new/librdmacm-1.1.0/examples/udpong.c       2016-03-18 23:53:43.000000000 
+0100
@@ -266,7 +266,7 @@
        hints.ai_socktype = SOCK_DGRAM;
        ret = getaddrinfo(src_addr, port, &hints, &res);
        if (ret) {
-               perror("getaddrinfo");
+               printf("getaddrinfo: %s\n", gai_strerror(ret));
                return ret;
        }
 
@@ -411,7 +411,7 @@
        hints.ai_socktype = SOCK_DGRAM;
        ret = getaddrinfo(dst_addr, port, &hints, &res);
        if (ret) {
-               perror("getaddrinfo");
+               printf("getaddrinfo: %s\n", gai_strerror(ret));
                return ret;
        }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/librdmacm-1.0.19.1/librdmacm.spec 
new/librdmacm-1.1.0/librdmacm.spec
--- old/librdmacm-1.0.19.1/librdmacm.spec       2014-08-18 22:35:55.000000000 
+0200
+++ new/librdmacm-1.1.0/librdmacm.spec  2016-03-18 23:55:35.000000000 +0100
@@ -1,7 +1,7 @@
-%define ver 1.0.19.1
+%define ver 1.1.0
 
 Name: librdmacm
-Version: 1.0.19.1
+Version: 1.1.0
 Release: 1%{?dist}
 Summary: Userspace RDMA Connection Manager
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/librdmacm-1.0.19.1/librdmacm.spec.in 
new/librdmacm-1.1.0/librdmacm.spec.in
--- old/librdmacm-1.0.19.1/librdmacm.spec.in    2014-08-18 22:31:49.000000000 
+0200
+++ new/librdmacm-1.1.0/librdmacm.spec.in       2016-03-18 23:53:43.000000000 
+0100
@@ -1,7 +1,7 @@
 %define ver @VERSION@
 
 Name: librdmacm
-Version: 1.0.19.1
+Version: 1.1.0
 Release: 1%{?dist}
 Summary: Userspace RDMA Connection Manager
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/librdmacm-1.0.19.1/src/acm.c 
new/librdmacm-1.1.0/src/acm.c
--- old/librdmacm-1.0.19.1/src/acm.c    2014-08-18 22:31:49.000000000 +0200
+++ new/librdmacm-1.1.0/src/acm.c       2016-03-18 23:53:54.000000000 +0100
@@ -176,11 +176,11 @@
        struct sockaddr_ib *src, *dst;
        struct ibv_path_record *path;
 
-       src = calloc(1, sizeof *src);
+       src = calloc(1, sizeof(*src));
        if (!src)
                return ERR(ENOMEM);
 
-       dst = calloc(1, sizeof *dst);
+       dst = calloc(1, sizeof(*dst));
        if (!dst) {
                free(src);
                return ERR(ENOMEM);
@@ -217,7 +217,7 @@
        if (rai->ai_family == AF_IB)
                return 0;
 
-       hdr = calloc(1, sizeof *hdr);
+       hdr = calloc(1, sizeof(*hdr));
        if (!hdr)
                return ERR(ENOMEM);
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/librdmacm-1.0.19.1/src/addrinfo.c 
new/librdmacm-1.1.0/src/addrinfo.c
--- old/librdmacm-1.0.19.1/src/addrinfo.c       2014-08-18 22:31:49.000000000 
+0200
+++ new/librdmacm-1.1.0/src/addrinfo.c  2016-03-18 23:53:54.000000000 +0100
@@ -49,7 +49,7 @@
 
 static void ucma_convert_to_ai(struct addrinfo *ai, struct rdma_addrinfo *rai)
 {
-       memset(ai, 0, sizeof *ai);
+       memset(ai, 0, sizeof(*ai));
        if (rai->ai_flags & RAI_PASSIVE)
                ai->ai_flags = AI_PASSIVE;
        if (rai->ai_flags & RAI_NUMERICHOST)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/librdmacm-1.0.19.1/src/cma.c 
new/librdmacm-1.1.0/src/cma.c
--- old/librdmacm-1.0.19.1/src/cma.c    2014-08-18 22:31:49.000000000 +0200
+++ new/librdmacm-1.1.0/src/cma.c       2016-03-18 23:53:54.000000000 +0100
@@ -49,6 +49,7 @@
 #include <stddef.h>
 #include <netdb.h>
 #include <syslog.h>
+#include <limits.h>
 
 #include "cma.h"
 #include "indexer.h"
@@ -73,10 +74,15 @@
        (req)->response = (uintptr_t) (resp);   \
 } while (0)
 
+struct cma_port {
+       uint8_t                 link_layer;
+};
+
 struct cma_device {
        struct ibv_context *verbs;
        struct ibv_pd      *pd;
        struct ibv_xrcd    *xrcd;
+       struct cma_port    *port;
        uint64_t            guid;
        int                 port_cnt;
        int                 refcnt;
@@ -142,6 +148,7 @@
                        if (cma_dev_array[cma_dev_cnt].refcnt)
                                ibv_dealloc_pd(cma_dev_array[cma_dev_cnt].pd);
                        ibv_close_device(cma_dev_array[cma_dev_cnt].verbs);
+                       free(cma_dev_array[cma_dev_cnt].port);
                        cma_init_cnt--;
                }
 
@@ -166,17 +173,12 @@
                 * backports, assume the most recent version of the ABI.  If
                 * we're wrong, we'll simply fail later when calling the ABI.
                 */
-               fprintf(stderr, PFX "Warning: couldn't read ABI version.\n");
-               fprintf(stderr, PFX "Warning: assuming: %d\n", abi_ver);
                return 0;
        }
 
        abi_ver = strtol(value, NULL, 10);
        if (abi_ver < RDMA_USER_CM_MIN_ABI_VERSION ||
            abi_ver > RDMA_USER_CM_MAX_ABI_VERSION) {
-               fprintf(stderr, PFX "Fatal: kernel ABI version %d "
-                               "doesn't match library version %d.\n",
-                               abi_ver, RDMA_USER_CM_MAX_ABI_VERSION);
                return -1;
        }
        return 0;
@@ -230,18 +232,16 @@
 
        dev_list = ibv_get_device_list(&dev_cnt);
        if (!dev_list) {
-               fprintf(stderr, PFX "Fatal: unable to get RDMA device list\n");
                ret = ERR(ENODEV);
                goto err1;
        }
 
        if (!dev_cnt) {
-               fprintf(stderr, PFX "Fatal: no RDMA devices found\n");
                ret = ERR(ENODEV);
                goto err2;
        }
 
-       cma_dev_array = calloc(dev_cnt, sizeof *cma_dev_array);
+       cma_dev_array = calloc(dev_cnt, sizeof(*cma_dev_array));
        if (!cma_dev_array) {
                ret = ERR(ENOMEM);
                goto err2;
@@ -272,7 +272,6 @@
 
        dev_list = ibv_get_device_list(NULL);
        if (!dev_list) {
-               fprintf(stderr, PFX "Fatal: unable to get RDMA device list\n");
                return NULL;
        }
 
@@ -283,17 +282,15 @@
                }
        }
 
-       if (!verbs)
-               fprintf(stderr, PFX "Fatal: unable to open RDMA device\n");
-
        ibv_free_device_list(dev_list);
        return verbs;
 }
 
 static int ucma_init_device(struct cma_device *cma_dev)
 {
+       struct ibv_port_attr port_attr;
        struct ibv_device_attr attr;
-       int ret;
+       int i, ret;
 
        if (cma_dev->verbs)
                return 0;
@@ -304,11 +301,23 @@
 
        ret = ibv_query_device(cma_dev->verbs, &attr);
        if (ret) {
-               fprintf(stderr, PFX "Fatal: unable to query RDMA device\n");
                ret = ERR(ret);
                goto err;
        }
 
+       cma_dev->port = malloc(sizeof(*cma_dev->port) * attr.phys_port_cnt);
+       if (!cma_dev->port) {
+               ret = ERR(ENOMEM);
+               goto err;
+       }
+
+       for (i = 1; i <= attr.phys_port_cnt; i++) {
+               if (ibv_query_port(cma_dev->verbs, i, &port_attr))
+                       cma_dev->port[i - 1].link_layer = 
IBV_LINK_LAYER_UNSPECIFIED;
+               else
+                       cma_dev->port[i - 1].link_layer = port_attr.link_layer;
+       }
+
        cma_dev->port_cnt = attr.phys_port_cnt;
        cma_dev->max_qpsize = attr.max_qp_wr;
        cma_dev->max_initiator_depth = (uint8_t) attr.max_qp_init_rd_atom;
@@ -353,7 +362,7 @@
        if (ucma_init_all())
                goto out;
 
-       devs = malloc(sizeof *devs * (cma_dev_cnt + 1));
+       devs = malloc(sizeof(*devs) * (cma_dev_cnt + 1));
        if (!devs)
                goto out;
 
@@ -383,13 +392,12 @@
        if (ucma_init())
                return NULL;
 
-       channel = malloc(sizeof *channel);
+       channel = malloc(sizeof(*channel));
        if (!channel)
                return NULL;
 
        channel->fd = open("/dev/infiniband/rdma_cm", O_RDWR | O_CLOEXEC);
        if (channel->fd < 0) {
-               fprintf(stderr, PFX "Fatal: unable to open 
/dev/infiniband/rdma_cm\n");
                goto err;
        }
        return channel;
@@ -506,7 +514,7 @@
 {
        struct cma_id_private *id_priv;
 
-       id_priv = calloc(1, sizeof *id_priv);
+       id_priv = calloc(1, sizeof(*id_priv));
        if (!id_priv)
                return NULL;
 
@@ -783,7 +791,7 @@
        VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
 
        if (resp.num_paths) {
-               id->route.path_rec = malloc(sizeof *id->route.path_rec *
+               id->route.path_rec = malloc(sizeof(*id->route.path_rec) *
                                            resp.num_paths);
                if (!id->route.path_rec)
                        return ERR(ENOMEM);
@@ -1034,8 +1042,10 @@
 
 static int ucma_modify_qp_rtr(struct rdma_cm_id *id, uint8_t resp_res)
 {
+       struct cma_id_private *id_priv;
        struct ibv_qp_attr qp_attr;
        int qp_attr_mask, ret;
+       uint8_t link_layer;
 
        if (!id->qp)
                return ERR(EINVAL);
@@ -1055,6 +1065,16 @@
        if (ret)
                return ret;
 
+       /*
+        * Workaround for rdma_ucm kernel bug:
+        * mask off qp_attr_mask bits 21-24 which are used for RoCE
+        */
+       id_priv = container_of(id, struct cma_id_private, id);
+       link_layer = id_priv->cma_dev->port[id->port_num - 1].link_layer;
+
+       if (link_layer == IBV_LINK_LAYER_INFINIBAND)
+               qp_attr_mask &= UINT_MAX ^ 0xe00000;
+
        if (resp_res != RDMA_MAX_RESP_RES)
                qp_attr.max_dest_rd_atomic = resp_res;
        return rdma_seterrno(ibv_modify_qp(id->qp, &qp_attr, qp_attr_mask));
@@ -1313,7 +1333,7 @@
        struct ibv_srq_init_attr_ex attr_ex;
        int ret;
 
-       memcpy(&attr_ex, attr, sizeof *attr);
+       memcpy(&attr_ex, attr, sizeof(*attr));
        attr_ex.comp_mask = IBV_SRQ_INIT_ATTR_TYPE | IBV_SRQ_INIT_ATTR_PD;
        if (id->qp_type == IBV_QPT_XRC_RECV) {
                attr_ex.srq_type = IBV_SRQT_XRC;
@@ -1322,7 +1342,7 @@
        }
        attr_ex.pd = pd;
        ret = rdma_create_srq_ex(id, &attr_ex);
-       memcpy(attr, &attr_ex, sizeof *attr);
+       memcpy(attr, &attr_ex, sizeof(*attr));
        return ret;
 }
 
@@ -1403,11 +1423,11 @@
        struct ibv_qp_init_attr_ex attr_ex;
        int ret;
 
-       memcpy(&attr_ex, qp_init_attr, sizeof *qp_init_attr);
+       memcpy(&attr_ex, qp_init_attr, sizeof(*qp_init_attr));
        attr_ex.comp_mask = IBV_QP_INIT_ATTR_PD;
        attr_ex.pd = pd ? pd : id->pd;
        ret = rdma_create_qp_ex(id, &attr_ex);
-       memcpy(qp_init_attr, &attr_ex, sizeof *qp_init_attr);
+       memcpy(qp_init_attr, &attr_ex, sizeof(*qp_init_attr));
        return ret;
 }
 
@@ -1731,7 +1751,7 @@
        int ret;
        
        id_priv = container_of(id, struct cma_id_private, id);
-       mc = calloc(1, sizeof *mc);
+       mc = calloc(1, sizeof(*mc));
        if (!mc)
                return ERR(ENOMEM);
 
@@ -2076,12 +2096,12 @@
        if (!event)
                return ERR(EINVAL);
 
-       evt = malloc(sizeof *evt);
+       evt = malloc(sizeof(*evt));
        if (!evt)
                return ERR(ENOMEM);
 
 retry:
-       memset(evt, 0, sizeof *evt);
+       memset(evt, 0, sizeof(*evt));
        CMA_INIT_CMD_RESP(&cmd, sizeof cmd, GET_EVENT, &resp, sizeof resp);
        ret = write(channel->fd, &cmd, sizeof cmd);
        if (ret != sizeof cmd) {
@@ -2334,7 +2354,7 @@
                id->pd = pd;
 
        if (qp_init_attr) {
-               id_priv->qp_init_attr = malloc(sizeof *qp_init_attr);
+               id_priv->qp_init_attr = malloc(sizeof(*qp_init_attr));
                if (!id_priv->qp_init_attr)
                        return ERR(ENOMEM);
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/librdmacm-1.0.19.1/src/indexer.c 
new/librdmacm-1.1.0/src/indexer.c
--- old/librdmacm-1.0.19.1/src/indexer.c        2014-08-18 22:31:49.000000000 
+0200
+++ new/librdmacm-1.1.0/src/indexer.c   2016-03-18 23:53:54.000000000 +0100
@@ -151,7 +151,6 @@
 
        entry = idm->array[idx_array_index(index)];
        entry[idx_entry_index(index)] = item;
-       idm->count[idx_array_index(index)]++;
        return index;
 }
 
@@ -163,9 +162,5 @@
        entry = idm->array[idx_array_index(index)];
        item = entry[idx_entry_index(index)];
        entry[idx_entry_index(index)] = NULL;
-       if (--idm->count[idx_array_index(index)] == 0) {
-               free(idm->array[idx_array_index(index)]);
-               idm->array[idx_array_index(index)] = NULL;
-       }
        return item;
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/librdmacm-1.0.19.1/src/indexer.h 
new/librdmacm-1.1.0/src/indexer.h
--- old/librdmacm-1.0.19.1/src/indexer.h        2014-08-18 22:31:49.000000000 
+0200
+++ new/librdmacm-1.1.0/src/indexer.h   2016-03-18 23:53:54.000000000 +0100
@@ -85,7 +85,6 @@
 struct index_map
 {
        void **array[IDX_ARRAY_SIZE];
-       int count[IDX_ARRAY_SIZE];
 };
 
 int idm_set(struct index_map *idm, int index, void *item);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/librdmacm-1.0.19.1/src/preload.c 
new/librdmacm-1.1.0/src/preload.c
--- old/librdmacm-1.0.19.1/src/preload.c        2014-08-18 22:31:49.000000000 
+0200
+++ new/librdmacm-1.1.0/src/preload.c   2016-03-18 23:53:54.000000000 +0100
@@ -50,6 +50,9 @@
 #include <netinet/tcp.h>
 #include <unistd.h>
 #include <semaphore.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <stdio.h>
 
 #include <rdma/rdma_cma.h>
 #include <rdma/rdma_verbs.h>
@@ -122,12 +125,142 @@
        atomic_t refcnt;
 };
 
+struct config_entry {
+       char *name;
+       int domain;
+       int type;
+       int protocol;
+};
+
+static struct config_entry *config;
+static int config_cnt;
+extern char *program_invocation_short_name;
+
+
+static void free_config(void)
+{
+       while (config_cnt)
+               free(config[--config_cnt].name);
+
+       free(config);
+}
+
+/*
+ * Config file format:
+ * # Starting '#' indicates comment
+ * # wild card values are supported using '*'
+ * # domain - *, INET, INET6, IB
+ * # type - *, STREAM, DGRAM
+ * # protocol - *, TCP, UDP
+ * program_name domain type protocol
+ */
+static void scan_config(void)
+{
+       struct config_entry *new_config;
+       FILE *fp;
+       char line[120], prog[64], dom[16], type[16], proto[16];
+
+       fp = fopen(RS_CONF_DIR "/preload_config", "r");
+       if (!fp)
+               return;
+
+       while (fgets(line, sizeof(line), fp)) {
+               if (line[0] == '#')
+                       continue;
+
+               if (sscanf(line, "%64s%16s%16s%16s", prog, dom, type, proto) != 
4)
+                       continue;
+
+               new_config = realloc(config, (config_cnt + 1) *
+                                            sizeof(struct config_entry));
+               if (!new_config)
+                       break;
+
+               config = new_config;
+               memset(&config[config_cnt], 0, sizeof(struct config_entry));
+
+               if (!strcasecmp(dom, "INET") ||
+                   !strcasecmp(dom, "AF_INET") ||
+                   !strcasecmp(dom, "PF_INET")) {
+                       config[config_cnt].domain = AF_INET;
+               } else if (!strcasecmp(dom, "INET6") ||
+                          !strcasecmp(dom, "AF_INET6") ||
+                          !strcasecmp(dom, "PF_INET6")) {
+                       config[config_cnt].domain = AF_INET6;
+               } else if (!strcasecmp(dom, "IB") ||
+                          !strcasecmp(dom, "AF_IB") ||
+                          !strcasecmp(dom, "PF_IB")) {
+                       config[config_cnt].domain = AF_IB;
+               } else if (strcmp(dom, "*")) {
+                       continue;
+               }
+
+               if (!strcasecmp(type, "STREAM") ||
+                   !strcasecmp(type, "SOCK_STREAM")) {
+                       config[config_cnt].type = SOCK_STREAM;
+               } else if (!strcasecmp(type, "DGRAM") ||
+                          !strcasecmp(type, "SOCK_DGRAM")) {
+                       config[config_cnt].type = SOCK_DGRAM;
+               } else if (strcmp(type, "*")) {
+                       continue;
+               }
+
+               if (!strcasecmp(proto, "TCP") ||
+                   !strcasecmp(proto, "IPPROTO_TCP")) {
+                       config[config_cnt].protocol = IPPROTO_TCP;
+               } else if (!strcasecmp(proto, "UDP") ||
+                          !strcasecmp(proto, "IPPROTO_UDP")) {
+                       config[config_cnt].protocol = IPPROTO_UDP;
+               } else if (strcmp(proto, "*")) {
+                       continue;
+               }
+
+               if (strcmp(prog, "*")) {
+                   if (!(config[config_cnt].name = strdup(prog)))
+                           continue;
+               }
+
+               config_cnt++;
+       }
+
+       fclose(fp);
+       if (config_cnt)
+               atexit(free_config);
+}
+
+static int intercept_socket(int domain, int type, int protocol)
+{
+       int i;
+
+       if (!config_cnt)
+               return 1;
+
+       if (!protocol) {
+               if (type == SOCK_STREAM)
+                       protocol = IPPROTO_TCP;
+               else if (type == SOCK_DGRAM)
+                       protocol = IPPROTO_UDP;
+       }
+
+       for (i = 0; i < config_cnt; i++) {
+               if ((!config[i].name ||
+                    !strncasecmp(config[i].name, program_invocation_short_name,
+                                 strlen(config[i].name))) &&
+                   (!config[i].domain || config[i].domain == domain) &&
+                   (!config[i].type || config[i].type == type) &&
+                   (!config[i].protocol || config[i].protocol == protocol))
+                       return 1;
+       }
+
+       return 0;
+}
+
 static int fd_open(void)
 {
        struct fd_info *fdi;
        int ret, index;
 
-       fdi = calloc(1, sizeof *fdi);
+       fdi = calloc(1, sizeof(*fdi));
        if (!fdi)
                return ERR(ENOMEM);
 
@@ -308,6 +441,7 @@
        rs.fcntl = dlsym(RTLD_DEFAULT, "rfcntl");
 
        getenv_options();
+       scan_config();
        init = 1;
 out:
        pthread_mutex_unlock(&mut);
@@ -404,10 +538,11 @@
        static __thread int recursive;
        int index, ret;
 
-       if (recursive)
+       init_preload();
+
+       if (recursive || !intercept_socket(domain, type, protocol))
                goto real;
 
-       init_preload();
        index = fd_open();
        if (index < 0)
                return index;
@@ -741,7 +876,7 @@
                if (rfds)
                        free(rfds);
 
-               rfds = malloc(sizeof *rfds * nfds);
+               rfds = malloc(sizeof(*rfds) * nfds);
                rnfds = rfds ? nfds : 0;
        }
 
@@ -997,7 +1132,7 @@
        if (!oldfdi || ret != newfd)
                return ret;
 
-       newfdi = calloc(1, sizeof *newfdi);
+       newfdi = calloc(1, sizeof(*newfdi));
        if (!newfdi) {
                close(newfd);
                return ERR(ENOMEM);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/librdmacm-1.0.19.1/src/rsocket.c 
new/librdmacm-1.1.0/src/rsocket.c
--- old/librdmacm-1.0.19.1/src/rsocket.c        2014-08-18 22:31:49.000000000 
+0200
+++ new/librdmacm-1.1.0/src/rsocket.c   2016-03-18 23:53:54.000000000 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008-2013 Intel Corporation.  All rights reserved.
+ * Copyright (c) 2008-2014 Intel Corporation.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -352,7 +352,7 @@
        };
 
        int               opts;
-       long              fd_flags;
+       int               fd_flags;
        uint64_t          so_opts;
        uint64_t          ipv6_opts;
        void              *optval;
@@ -381,6 +381,7 @@
        dlist_entry       iomap_list;
        dlist_entry       iomap_queue;
        int               iomap_pending;
+       int               unack_cqe;
 };
 
 #define DS_UDP_TAG 0x55555555
@@ -567,7 +568,7 @@
 {
        struct rsocket *rs;
 
-       rs = calloc(1, sizeof *rs);
+       rs = calloc(1, sizeof(*rs));
        if (!rs)
                return NULL;
 
@@ -609,7 +610,7 @@
        return rs;
 }
 
-static int rs_set_nonblocking(struct rsocket *rs, long arg)
+static int rs_set_nonblocking(struct rsocket *rs, int arg)
 {
        struct ds_qp *qp;
        int ret = 0;
@@ -838,10 +839,6 @@
        rs_set_qp_size(rs);
        if (rs->cm_id->verbs->device->transport_type == IBV_TRANSPORT_IWARP)
                rs->opts |= RS_OPT_MSG_SEND;
-       ret = rs_init_bufs(rs);
-       if (ret)
-               return ret;
-
        ret = rs_create_cq(rs, rs->cm_id);
        if (ret)
                return ret;
@@ -866,6 +863,10 @@
        if ((rs->opts & RS_OPT_MSG_SEND) && (rs->sq_inline < RS_MSG_SIZE))
                return ERR(ENOTSUP);
 
+       ret = rs_init_bufs(rs);
+       if (ret)
+               return ret;
+
        for (i = 0; i < rs->rq_size; i++) {
                ret = rs_post_recv(rs);
                if (ret)
@@ -967,9 +968,6 @@
                return;
        }
 
-       if (rs->index >= 0)
-               rs_remove(rs);
-
        if (rs->rmsg)
                free(rs->rmsg);
 
@@ -993,11 +991,16 @@
 
        if (rs->cm_id) {
                rs_free_iomappings(rs);
-               if (rs->cm_id->qp)
+               if (rs->cm_id->qp) {
+                       ibv_ack_cq_events(rs->cm_id->recv_cq, rs->unack_cqe);
                        rdma_destroy_qp(rs->cm_id);
+               }
                rdma_destroy_id(rs->cm_id);
        }
 
+       if (rs->index >= 0)
+               rs_remove(rs);
+
        fastlock_destroy(&rs->map_lock);
        fastlock_destroy(&rs->cq_wait_lock);
        fastlock_destroy(&rs->cq_lock);
@@ -1174,9 +1177,14 @@
        rs = idm_lookup(&idm, socket);
        if (!rs)
                return ERR(EBADF);
-       ret = rdma_listen(rs->cm_id, backlog);
-       if (!ret)
-               rs->state = rs_listening;
+
+       if (rs->state != rs_listening) {
+               ret = rdma_listen(rs->cm_id, backlog);
+               if (!ret)
+                       rs->state = rs_listening;
+       } else {
+               ret = 0;
+       }
        return ret;
 }
 
@@ -1388,7 +1396,7 @@
        int sock, ret;
        uint16_t port;
 
-       *src_len = sizeof *src_addr;
+       *src_len = sizeof(*src_addr);
        ret = getsockname(rs->udp_sock, &src_addr->sa, src_len);
        if (ret || !rs_any_addr(src_addr))
                return ret;
@@ -1402,7 +1410,7 @@
        if (ret)
                goto out;
 
-       *src_len = sizeof *src_addr;
+       *src_len = sizeof(*src_addr);
        ret = getsockname(sock, &src_addr->sa, src_len);
        src_addr->sin.sin_port = port;
 out:
@@ -1965,9 +1973,12 @@
 
        ret = ibv_get_cq_event(rs->cm_id->recv_cq_channel, &cq, &context);
        if (!ret) {
-               ibv_ack_cq_events(rs->cm_id->recv_cq, 1);
+               if (++rs->unack_cqe >= rs->sq_size + rs->rq_size) {
+                       ibv_ack_cq_events(rs->cm_id->recv_cq, rs->unack_cqe);
+                       rs->unack_cqe = 0;
+               }
                rs->cq_armed = 0;
-       } else if (errno != EAGAIN) {
+       } else if (!(errno == EAGAIN || errno == EINTR)) {
                rs->state = rs_error;
        }
 
@@ -2383,7 +2394,7 @@
        struct rsocket *rs;
        size_t left = len;
        uint32_t end_size, rsize;
-       int ret;
+       int ret = 0;
 
        rs = idm_at(&idm, socket);
        if (rs->type == SOCK_DGRAM) {
@@ -2410,7 +2421,6 @@
                                break;
                }
 
-               ret = 0;
                if (flags & MSG_PEEK) {
                        left = len - rs_peek(rs, buf, left);
                        break;
@@ -2445,7 +2455,7 @@
        } while (left && (flags & MSG_WAITALL) && (rs->state & rs_readable));
 
        fastlock_release(&rs->rlock);
-       return ret ? ret : len - left;
+       return (ret && left == len) ? ret : len - left;
 }
 
 ssize_t rrecvfrom(int socket, void *buf, size_t len, int flags,
@@ -2590,7 +2600,7 @@
        miov[0].iov_base = &hdr;
        miov[0].iov_len = hdr.length;
        if (iov && iovcnt)
-               memcpy(&miov[1], iov, sizeof *iov * iovcnt);
+               memcpy(&miov[1], iov, sizeof(*iov) * iovcnt);
 
        memset(&msg, 0, sizeof msg);
        msg.msg_name = &rs->conn_dest->addr;
@@ -2900,7 +2910,7 @@
                if (rfds)
                        free(rfds);
 
-               rfds = malloc(sizeof *rfds * nfds);
+               rfds = malloc(sizeof(*rfds) * nfds);
                rnfds = rfds ? nfds : 0;
        }
 
@@ -2954,19 +2964,22 @@
 
        if (rs->state & rs_opening) {
                ret = rs_do_connect(rs);
-               if (ret) {
-                       if (errno == EINPROGRESS) {
-                               errno = 0;
-                               return 0;
-                       } else {
-                               return POLLOUT;
-                       }
+               if (ret && (errno == EINPROGRESS)) {
+                       errno = 0;
+               } else {
+                       goto check_cq;
                }
-               goto check_cq;
        }
 
-       if (rs->state == rs_connect_error)
-               return (rs->err && events & POLLOUT) ? POLLOUT : 0;
+       if (rs->state == rs_connect_error) {
+               revents = 0;
+               if (events & POLLOUT)
+                       revents |= POLLOUT;
+               if (events & POLLIN)
+                       revents |= POLLIN;
+               revents |= POLLERR;
+               return revents;
+       }
 
        return 0;
 }
@@ -3097,7 +3110,7 @@
        struct pollfd *fds;
        int fd, i = 0;
 
-       fds = calloc(*nfds, sizeof *fds);
+       fds = calloc(*nfds, sizeof(*fds));
        if (!fds)
                return NULL;
 
@@ -3673,7 +3686,7 @@
 {
        struct rsocket *rs;
        va_list args;
-       long param;
+       int param;
        int ret = 0;
 
        rs = idm_lookup(&idm, socket);
@@ -3682,15 +3695,15 @@
        va_start(args, cmd);
        switch (cmd) {
        case F_GETFL:
-               ret = (int) rs->fd_flags;
+               ret = rs->fd_flags;
                break;
        case F_SETFL:
-               param = va_arg(args, long);
-               if (param & O_NONBLOCK)
-                       ret = rs_set_nonblocking(rs, O_NONBLOCK);
+               param = va_arg(args, int);
+               if ((rs->fd_flags & O_NONBLOCK) != (param & O_NONBLOCK))
+                       ret = rs_set_nonblocking(rs, param & O_NONBLOCK);
 
                if (!ret)
-                       rs->fd_flags |= param;
+                       rs->fd_flags = param;
                break;
        default:
                ret = ERR(ENOTSUP);
@@ -3741,7 +3754,7 @@
                iomr = rs_get_iomap_mr(rs);
                access |= IBV_ACCESS_REMOTE_WRITE;
        } else {
-               iomr = calloc(1, sizeof *iomr);
+               iomr = calloc(1, sizeof(*iomr));
                iomr->index = -1;
        }
        if (!iomr) {


Reply via email to