]> git.openfabrics.org - ~shefty/librdmacm.git/commitdiff
r6135: If the user calls rdma_bind_addr(), but specifies either a zero IP address
authorSean Hefty <sean.hefty@intel.com>
Fri, 31 Mar 2006 20:07:25 +0000 (20:07 +0000)
committerSean Hefty <sean.hefty@intel.com>
Fri, 31 Mar 2006 20:07:25 +0000 (20:07 +0000)
or the loopback address, bind will succeed, but the cm_id will not be
attached to an RDMA device.  This will result in a failure if rdma_resolve_addr
is called.  Fix rdma_resolve_addr(), so that it handles this condition
properly.

Also fix the userspace interface to allow querying for address information
after binding to the zero or loopback address.  This breaks the behavior of
the current ABI, so bump the ABI version, and add the proper support to
allow checking the kernel ABI version from the userspace library.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
include/rdma/rdma_cma_abi.h
src/cma.c

index db96894d0c1391d13d6bdf24959ed8b862bab95d..5837a4d087c4cb3dc2c891ab4e4d43046a133d8c 100644 (file)
@@ -40,7 +40,7 @@
  */
 
 #define RDMA_USER_CM_MIN_ABI_VERSION   1
-#define RDMA_USER_CM_MAX_ABI_VERSION   1
+#define RDMA_USER_CM_MAX_ABI_VERSION   2
 
 #define RDMA_MAX_PRIVATE_DATA          256
 
index 497f64b2a0d46e53abeec2b379cb72afd598821e..39cf21c3cca4604675c382542afd0d20462e8a16 100644 (file)
--- a/src/cma.c
+++ b/src/cma.c
@@ -118,6 +118,7 @@ static struct ibv_device **dev_list;
 static struct dlist *cma_dev_list;
 static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
 static int ucma_initialized;
+static int abi_ver;
 int cma_fd;
 
 #define container_of(ptr, type, field) \
@@ -139,6 +140,32 @@ static void ucma_cleanup(void)
                close(cma_fd);
 }
 
+static int check_abi_version(void)
+{
+       char path[256];
+       char val[16];
+
+       if (sysfs_get_mnt_path(path, sizeof path)) {
+               fprintf(stderr, "librdmacm: couldn't find sysfs mount.\n");
+               return -ENODEV;
+       }
+
+       strncat(path, "/class/misc/rdma_cm/abi_version", sizeof path);
+       if (sysfs_read_attribute_value(path, val, sizeof val))
+               abi_ver = 1; /* ABI version wasn't available until version 2 */
+       else
+               abi_ver = strtol(val, NULL, 10);
+
+       if (abi_ver < RDMA_USER_CM_MIN_ABI_VERSION ||
+           abi_ver > RDMA_USER_CM_MAX_ABI_VERSION) {
+               fprintf(stderr, "librdmacm: kernel ABI version %d "
+                               "doesn't match library version %d.\n",
+                               abi_ver, RDMA_USER_CM_MAX_ABI_VERSION);
+               return -ENOSYS;
+       }
+       return 0;
+}
+
 static int ucma_init(void)
 {
        int i;
@@ -157,6 +184,10 @@ static int ucma_init(void)
                goto err;
        }
 
+       ret = check_abi_version();
+       if (ret)
+               goto err;
+
        cma_dev_list = dlist_new(sizeof *cma_dev);
        if (!cma_dev_list) {
                ret = -ENOMEM;
@@ -404,7 +435,7 @@ int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr)
        if (ret != size)
                return (ret > 0) ? -ENODATA : ret;
 
-       if (((struct sockaddr_in *) addr)->sin_addr.s_addr != 0) {
+       if (abi_ver > 1) {
                ret = ucma_query_route(id);
                if (ret)
                        return ret;