1 diff -Nur librdmacm-1.0.19/examples/rping.c librdmacm-1.0.19.ssa1/examples/rping.c
2 --- librdmacm-1.0.19/examples/rping.c 2014-07-17 00:30:15.000000000 +0200
3 +++ librdmacm-1.0.19.ssa1/examples/rping.c 2015-01-22 18:11:28.000000000 +0100
6 struct ibv_recv_wr *bad_wr;
10 while ((ret = ibv_poll_cq(cb->cq, 1, &wc)) == 1) {
14 - if (wc.status != IBV_WC_WR_FLUSH_ERR)
16 - "cq completion failed status %d\n",
18 + if (wc.status == IBV_WC_WR_FLUSH_ERR) {
24 + "cq completion failed status %d\n",
30 fprintf(stderr, "poll error %d\n", ret);
38 @@ -1055,18 +1060,19 @@
39 ret = rping_connect_client(cb);
41 fprintf(stderr, "connect error %d\n", ret);
46 ret = rping_test_client(cb);
48 fprintf(stderr, "rping client failed: %d\n", ret);
56 rdma_disconnect(cb->cm_id);
58 pthread_join(cb->cqthread, NULL);
60 rping_free_buffers(cb);
61 diff -Nur librdmacm-1.0.19/src/cma.c librdmacm-1.0.19.ssa1/src/cma.c
62 --- librdmacm-1.0.19/src/cma.c 2014-07-17 00:30:15.000000000 +0200
63 +++ librdmacm-1.0.19.ssa1/src/cma.c 2015-01-22 19:46:41.000000000 +0100
73 static int ucma_modify_qp_rtr(struct rdma_cm_id *id, uint8_t resp_res)
75 struct ibv_qp_attr qp_attr;
76 + struct ibv_port_attr port_attr;
77 int qp_attr_mask, ret;
82 @@ -1055,6 +1058,17 @@
86 + /* Workaround for rdma_ucm kernel bug */
87 + ret = ibv_query_port(id->verbs, id->port_num, &port_attr);
89 + link_layer = IBV_LINK_LAYER_UNSPECIFIED;
91 + link_layer = port_attr.link_layer;
93 + if (id->verbs->device->transport_type == IBV_TRANSPORT_IB &&
94 + link_layer == IBV_LINK_LAYER_INFINIBAND)
95 + qp_attr_mask &= UINT_MAX ^ 0xe00000; /* mask off bits 21-24 which are used for RoCE */
97 if (resp_res != RDMA_MAX_RESP_RES)
98 qp_attr.max_dest_rd_atomic = resp_res;
99 return rdma_seterrno(ibv_modify_qp(id->qp, &qp_attr, qp_attr_mask));
100 diff -Nur librdmacm-1.0.19/src/preload.c librdmacm-1.0.19.ssa1/src/preload.c
101 --- librdmacm-1.0.19/src/preload.c 2014-07-17 00:30:15.000000000 +0200
102 +++ librdmacm-1.0.19.ssa1/src/preload.c 2015-01-22 18:11:29.000000000 +0100
104 #include <netinet/tcp.h>
106 #include <semaphore.h>
111 #include <rdma/rdma_cma.h>
112 #include <rdma/rdma_verbs.h>
113 @@ -122,6 +125,136 @@
117 +struct config_entry {
124 +static struct config_entry *config;
125 +static int config_cnt;
126 +extern char *program_invocation_short_name;
129 +static void free_config(void)
132 + free(config[--config_cnt].name);
138 + * Config file format:
139 + * # Starting '#' indicates comment
140 + * # wild card values are supported using '*'
141 + * # domain - *, INET, INET6, IB
142 + * # type - *, STREAM, DGRAM
143 + * # protocol - *, TCP, UDP
144 + * program_name domain type protocol
146 +static void scan_config(void)
148 + struct config_entry *new_config;
150 + char line[120], prog[64], dom[16], type[16], proto[16];
152 + fp = fopen(RS_CONF_DIR "/preload_config", "r");
156 + while (fgets(line, sizeof(line), fp)) {
157 + if (line[0] == '#')
160 + if (sscanf(line, "%64s%16s%16s%16s", prog, dom, type, proto) != 4)
163 + new_config = realloc(config, (config_cnt + 1) *
164 + sizeof(struct config_entry));
168 + config = new_config;
169 + memset(&config[config_cnt], 0, sizeof(struct config_entry));
171 + if (!strcasecmp(dom, "INET") ||
172 + !strcasecmp(dom, "AF_INET") ||
173 + !strcasecmp(dom, "PF_INET")) {
174 + config[config_cnt].domain = AF_INET;
175 + } else if (!strcasecmp(dom, "INET6") ||
176 + !strcasecmp(dom, "AF_INET6") ||
177 + !strcasecmp(dom, "PF_INET6")) {
178 + config[config_cnt].domain = AF_INET6;
179 + } else if (!strcasecmp(dom, "IB") ||
180 + !strcasecmp(dom, "AF_IB") ||
181 + !strcasecmp(dom, "PF_IB")) {
182 + config[config_cnt].domain = AF_IB;
183 + } else if (strcmp(dom, "*")) {
187 + if (!strcasecmp(type, "STREAM") ||
188 + !strcasecmp(type, "SOCK_STREAM")) {
189 + config[config_cnt].type = SOCK_STREAM;
190 + } else if (!strcasecmp(type, "DGRAM") ||
191 + !strcasecmp(type, "SOCK_DGRAM")) {
192 + config[config_cnt].type = SOCK_DGRAM;
193 + } else if (strcmp(type, "*")) {
197 + if (!strcasecmp(proto, "TCP") ||
198 + !strcasecmp(proto, "IPPROTO_TCP")) {
199 + config[config_cnt].protocol = IPPROTO_TCP;
200 + } else if (!strcasecmp(proto, "UDP") ||
201 + !strcasecmp(proto, "IPPROTO_UDP")) {
202 + config[config_cnt].protocol = IPPROTO_UDP;
203 + } else if (strcmp(proto, "*")) {
207 + if (strcmp(prog, "*")) {
208 + if (!(config[config_cnt].name = strdup(prog)))
217 + atexit(free_config);
220 +static int intercept_socket(int domain, int type, int protocol)
228 + if (type == SOCK_STREAM)
229 + protocol = IPPROTO_TCP;
230 + else if (type == SOCK_DGRAM)
231 + protocol = IPPROTO_UDP;
234 + for (i = 0; i < config_cnt; i++) {
235 + if ((!config[i].name ||
236 + !strncasecmp(config[i].name, program_invocation_short_name,
237 + strlen(config[i].name))) &&
238 + (!config[i].domain || config[i].domain == domain) &&
239 + (!config[i].type || config[i].type == type) &&
240 + (!config[i].protocol || config[i].protocol == protocol))
247 static int fd_open(void)
251 rs.fcntl = dlsym(RTLD_DEFAULT, "rfcntl");
257 pthread_mutex_unlock(&mut);
258 @@ -404,10 +538,11 @@
259 static __thread int recursive;
265 + if (recursive || !intercept_socket(domain, type, protocol))
272 diff -Nur librdmacm-1.0.19/src/rsocket.c librdmacm-1.0.19.ssa1/src/rsocket.c
273 --- librdmacm-1.0.19/src/rsocket.c 2014-07-17 00:30:15.000000000 +0200
274 +++ librdmacm-1.0.19.ssa1/src/rsocket.c 2015-01-22 18:11:29.000000000 +0100
277 - * Copyright (c) 2008-2013 Intel Corporation. All rights reserved.
278 + * Copyright (c) 2008-2014 Intel Corporation. All rights reserved.
280 * This software is available to you under a choice of one of two
281 * licenses. You may choose to be licensed under the terms of the GNU
283 dlist_entry iomap_list;
284 dlist_entry iomap_queue;
289 #define DS_UDP_TAG 0x55555555
294 - if (rs->index >= 0)
300 @@ -993,11 +991,16 @@
303 rs_free_iomappings(rs);
305 + if (rs->cm_id->qp) {
306 + ibv_ack_cq_events(rs->cm_id->recv_cq, rs->unack_cqe);
307 rdma_destroy_qp(rs->cm_id);
309 rdma_destroy_id(rs->cm_id);
312 + if (rs->index >= 0)
315 fastlock_destroy(&rs->map_lock);
316 fastlock_destroy(&rs->cq_wait_lock);
317 fastlock_destroy(&rs->cq_lock);
318 @@ -1174,9 +1177,14 @@
319 rs = idm_lookup(&idm, socket);
322 - ret = rdma_listen(rs->cm_id, backlog);
324 - rs->state = rs_listening;
326 + if (rs->state != rs_listening) {
327 + ret = rdma_listen(rs->cm_id, backlog);
329 + rs->state = rs_listening;
336 @@ -1965,9 +1973,12 @@
338 ret = ibv_get_cq_event(rs->cm_id->recv_cq_channel, &cq, &context);
340 - ibv_ack_cq_events(rs->cm_id->recv_cq, 1);
341 + if (++rs->unack_cqe >= rs->sq_size + rs->rq_size) {
342 + ibv_ack_cq_events(rs->cm_id->recv_cq, rs->unack_cqe);
346 - } else if (errno != EAGAIN) {
347 + } else if (!(errno == EAGAIN || errno == EINTR)) {
348 rs->state = rs_error;
351 @@ -2383,7 +2394,7 @@
354 uint32_t end_size, rsize;
358 rs = idm_at(&idm, socket);
359 if (rs->type == SOCK_DGRAM) {
360 @@ -2410,7 +2421,6 @@
365 if (flags & MSG_PEEK) {
366 left = len - rs_peek(rs, buf, left);
368 @@ -2445,7 +2455,7 @@
369 } while (left && (flags & MSG_WAITALL) && (rs->state & rs_readable));
371 fastlock_release(&rs->rlock);
372 - return ret ? ret : len - left;
373 + return (ret && left == len) ? ret : len - left;
376 ssize_t rrecvfrom(int socket, void *buf, size_t len, int flags,