From 2933de950fa2a1fc036813fb90ed7cf0419f23d9 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Nov 03 2016 05:50:44 +0000 Subject: import perftest-3.0-7.el7 --- diff --git a/.gitignore b/.gitignore index 7c2ed54..f8372c9 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -SOURCES/perftest-2.4-0.8.gd3c2b22.tar.gz +SOURCES/perftest-3.0-3.1.gb36a595.tar.gz diff --git a/.perftest.metadata b/.perftest.metadata index ee2f981..ce2a2e1 100644 --- a/.perftest.metadata +++ b/.perftest.metadata @@ -1 +1 @@ -e00843a4147055238797a267d59ac4d14be3f074 SOURCES/perftest-2.4-0.8.gd3c2b22.tar.gz +51d3ab35a949a329050a873527d7fc8a75826541 SOURCES/perftest-3.0-3.1.gb36a595.tar.gz diff --git a/SOURCES/ib_atomic_bw.1 b/SOURCES/ib_atomic_bw.1 new file mode 100644 index 0000000..890b65a --- /dev/null +++ b/SOURCES/ib_atomic_bw.1 @@ -0,0 +1,298 @@ +.\" Copyright (c) 2014, Jan Chaloupka +.\" +.\" %%%LICENSE_START(GPLv2+_DOC_FULL) +.\" This is free documentation; you can redistribute it and/or +.\" modify it under the terms of the GNU General Public License as +.\" published by the Free Software Foundation; either version 2 of +.\" the License, or (at your option) any later version. +.\" +.\" The GNU General Public License's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" This manual is distributed in the hope that it will be useful, +.\" but WITHOUT ANY WARRANTY; without even the implied warranty of +.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +.\" GNU General Public License for more details. +.\" +.\" You should have received a copy of the GNU General Public +.\" License along with this manual; if not, see +.\" . +.\" %%%LICENSE_END +.TH "IB_ATOMIC_BW" 1 2014 "Open Fabrics Enterprise Distribution" +.\" IB_ATOMIC_BW +.SH NAME +ib_atomic_bw, ib_atomic_lat, ib_read_bw, ib_read_lat, ib_send_bw, +ib_send_lat, ib_write_bw, ib_write_lat +\- Collection of tests written over uverbs intended for use as a +performance micro-benchmark +.SH SYNOPSIS +.sp +.B ib_atomic_bw [] [options] +.sp +.B ib_atomic_lat [] [options] +.sp +.B ib_read_bw [] [options] +.sp +.B ib_read_lat [] [options] +.sp +.B ib_write_bw [] [options] +.sp +.B ib_write_lat [] [options] +.SH DESCRIPTION +This is a collection of tests written over uverbs intended for use as a +performance micro-benchmark. As an example, the tests can be used for +HW or SW tuning and/or functional testing. + +The collection conatains a set of BW and latency benchmark such as : +.sp +* Read - ib_read_bw and ib_read_lat. +.sp +* Write - ib_write_bw and ib_wriet_lat. +.sp +* Send - ib_send_bw and ib_send_lat. +.sp +* Atomic - ib_atomic_bw and ib_atomic_lat +.sp +* Raw Etherent (when working with MOFED2) - raw_ethernet_bw, raw_ethernet_lat + +The benchmark used the CPU cycle counter to get time stamps without context +switch. Some CPU architectures (e.g., Intel's 80486 or older PPC) do NOT +have such capability. + +The latency benchmarks measures round-trip time but reports half of that as +one-way latency. +This means that it may not be sufficiently accurate for asymmetrical +configurations. + +On Bw benchmarks, we calculate the BW on send side only, as he calculates +the Bw after collecting completion from the receive side. +In case we use the bidirectional flag , BW is calculated on both sides. +in ib_send_bw, server side also calculate the received throughput. + +Min/Median/Max result is reported in latency tests. +The median (vs average) is less sensitive to extreme scores. +Typically, the "Max" value is the first value measured. + +Larger samples help marginally only. The default (1000) is pretty good. +Note that an array of cycles_t (typically unsigned long) is allocated +once to collect samples and again to store the difference between them. +Really big sample sizes (e.g., 1 million) might expose other problems +with the program. In this case you can use -N flag (No Peak) to instruct +the test sample only 2 times (begining and end). + +All throughput tests now have duration feature as well (-D ) +to instruct the test to run for . +Another feature added is --run_infinitely, which instruct the test to run +all te time and print throughput every 5 seconds. + +The "-H" option (latency) will dump the histogram for additional statistical +analysis. +See xgraph, ygraph, r-base (http://www.r-project.org/), pspp, or other +statistical math programs. + + +Architectures tested: i686, x86_64, ia64 +.SH OPTIONS +The SAME OPTIONS must be passed to both server and client. + +If +.I +is not presented, command starts a server and waits for connection. +If it is, command connects to server at +.I . +.sp +.B Common Options: +.RS 4 +.TP +\fB\-h\fR, \fB\-\-help\fR +Display this help message screen. +.TP +\fB\-p\fR, \fB\-\-port\fR=\fI\fR +Listen on/connect to port (default: 18515) when exchaning data. +.TP +\fB\-R\fR, \fB\-\-rdma_cm\fR +Connect QPs with rdma_cm and run test on those QPs. +.TP +\fB\-z\fR, \fB\-\-com_rdma_cm\fR +Communicate with rdma_cm module to exchange data \- use regular QPs. +.TP +\fB\-m\fR, \fB\-\-mtu\fR=\fI\fR + QP Mtu size (default: active_mtu from ibv_devinfo). +.TP +\fB\-c\fR, \fB\-\-connection\fR=\fI\fR +Connection type RC/UC/UD (default RC) +.TP +\fB\-d\fR, \fB\-\-ib\-dev\fR=\fI\fR +Use IB device (default: first device found). +.TP +\fB\-i\fR, \fB\-\-ib\-port\fR=\fI\fR +Use port of IB device (default: 1). +.TP +\fB\-s\fR, \fB\-\-size\fR=\fI\fR +Size of message to exchange (default: 1). +.TP +\fB\-a\fR, \fB\-\-all\fR +Run sizes from 2 till 2^23. +.TP +\fB\-n\fR, \fB\-\-iters\fR=\fI\fR +Number of exchanges (at least 100, default: 1000). +.TP +\fB\-x\fR, \fB\-\-gid\-index\fR=\fI\fR +Test uses GID with GID index taken from command +.TP +\fB\-V\fR, \fB\-\-version\fR +Display version number. +.TP +\fB\-e\fR, \fB\-\-events\fR +Sleep on CQ events (default poll). +.TP +\fB\-F\fR, \fB\-\-CPU\-freq\fR +Do not fail even if cpufreq_ondemand module. +.TP +\fB\-I\fR, \fB\-\-inline_size\fR=\fI\fR +Max size of message to be sent in inline mode. +.TP +\fB\-u\fR, \fB\-\-qp\-timeout\fR=\fI\fR +QP timeout, timeout value is 4 usec*2 ^timeout (default: 14). +.TP +\fB\-S\fR, \fB\-\-sl\fR=\fI\fR +SL \- Service Level (default 0) +.TP +\fB\-r\fR, \fB\-\-rx\-depth\fR=\fI\fR +Make rx queue bigger than tx (default 600). +.RE +.sp +.B Latenct tests options: +.RS 4 +.TP +\fB\-C\fR, \fB\-\-report\-cycles\fR +Report times in cpu cycle units. +.TP +\fB\-H\fR, \fB\-\-report\-histogram\fR +Print out all results (Default: summary only). +.TP +\fB\-U\fR, \fB\-\-report\-unsorted\fR +Print out unsorted results (default sorted). +.RE +.sp +.B BW tests options: +.RS 4 +.TP +\fB\-b\fR, \fB\-\-bidirectional\fR +Measure bidirectional bandwidth (default uni). +.TP +\fB\-N\fR, \fB\-\-no\fR +peak\-bw Cancel peak\-bw calculation (default with peak\-bw) +.TP +\fB\-Q\fR, \fB\-\-cq\-mod\fR +Generate Cqe only after completion +.TP +\fB\-t\fR, \fB\-\-tx\-depth=\fR +Size of tx queue (default: 128). +.TP +\fB\-O\fR, \fB\-\-dualport\fR +Run test in dual\-port mode (2 QPs). both ports must be active (default OFF). +.TP +\fB\-D\fR, \fB\-\-duration=\fR +Run test for period of seconds. +.TP +\fB\-f\fR, \fB\-\-margin=\fR +When in Duration, measure results within margins (default: 2) +.TP +\fB\-l\fR, \fB\-\-post_list=\fR +Post list of WQEs of size (instead of single post). +.TP +\fB\-q\fR, \fB\-\-qp=\fR +Num of QPs running in the process (default: 1). +.TP +\fB\-\-run_infinitely \fR +Run test forever\fR, \fBprint results every 5 seconds. +.RE +.sp +.B SEND tests options: +.RS 4 +.TP +\fB\-r\fR, \fB\-\-rx\-depth=\fR +Size of RX queue (default: 512 in BW test). +.TP +\fB\-g\fR, \fB\-\-mcg=\fR +Send messages to multicast group with qps attached to it. +.TP +\fB\-M\fR, \fB\-\-MGID=\fR +In multicast, uses as the group MGID. +.RE +.sp +.B Raw Ethernet BW test options: +.RS 4 +.TP +\fB\-A\fR, \fB\-\-atomic_type=\fR +type of atomic operation from {CMP_AND_SWAP,FETCH_AND_ADD}. +.TP +\fB\-o\fR, \fB\-\-outs=\fR +Number of outstanding read/atomic requests \- also on READ tests. +.TP +\fB\-B\fR, \fB\-\-source_mac\fR +source MAC address by this format XX:XX:XX:XX:XX:XX (default take the MAC address form GID). +.TP +\fB\-E\fR, \fB\-\-dest_mac\fR +destination MAC address by this format XX:XX:XX:XX:XX:XX **MUST** be entered. +.TP +\fB\-J\fR, \fB\-\-server_ip\fR +server ip address by this format X.X.X.X (using to send packets with IP header). +.TP +\fB\-j\fR, \fB\-\-client_ip\fR +client ip address by this format X.X.X.X (using to send packets with IP header). +.TP +\fB\-K\fR, \fB\-\-server_port\fR +server udp port number (using to send packets with UPD header). +.TP +\fB\-k\fR, \fB\-\-client_port\fR +client udp port number (using to send packets with UDP header). +.TP +\fB\-Z\fR, \fB\-\-server\fR +choose server side for the current machine (\-\-server/\-\-client must be selected ). +.TP +\fB\-P\fR, \fB\-\-client\fR +choose client side for the current machine (\-\-server/\-\-client must be selected). +.RE +.SH ENVIRONMENT +.B Prerequisites: +.RS +kernel 2.6 +.RE +.RS +(kernel module) matches libibverbs +.RE +.RS +(kernel module) matches librdmacm +.RE +.RS +(kernel module) matches libibumad +.RE +.RS +(kernel module) matches libmath (lm). +.RE +.SH NOTES +You need to be running a Subnet Manager on the switch or on one of the nodes in your fabric, in case you are in IB fabric. +.SH BUGS +1. Multicast feauture in ib_send_lat and in ib_send_bw still have many problems! +Will increase the support and bug fixes in this Q, but now the tests may stuck +and could produce undefine behaviours. +.sp +2. Bidirectional feature in ib_send_bw test, when running in UD or UC mode. +The algorithm we use for the bidirectional measurement is designed for RC connection type. +When running in UC or UD connection types, there is a small probablity the test will be stuck. +.sp +3. RDMA_CM feature in read tests still doesn't work. +.sp +4. Dual-port support currently works only with ib_write_bw. +.sp +5. Compabilty issues may occur between different versions of perftest. +Please make sure you work with the same version on both sides to ensure +consistency of the test. +.SH AUTHORS +Please post results/observations to the openib-general mailing list. +See "Contact Us" at http://openib.org/mailman/listinfo/openib-general and +http://www.openib.org. diff --git a/SOURCES/perftest-2.0-cflags.patch b/SOURCES/perftest-2.0-cflags.patch deleted file mode 100644 index f8a849c..0000000 --- a/SOURCES/perftest-2.0-cflags.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff -up perftest-2.3/configure.ac.cflags perftest-2.3/configure.ac ---- perftest-2.3/configure.ac.cflags 2014-10-17 13:47:35.543196518 -0400 -+++ perftest-2.3/configure.ac 2014-10-17 13:47:51.302043917 -0400 -@@ -143,7 +143,7 @@ if [test "$CUDA_H_PATH" ]; then - LIBS=$LIBS" -lcuda" - fi - --CFLAGS="-g -Wall -D_GNU_SOURCE -O3" -+CFLAGS+=" -g -Wall -D_GNU_SOURCE -O3" - AC_SUBST([LIBUMAD]) - AC_SUBST([LIBMATH]) - AC_CONFIG_FILES([Makefile]) diff --git a/SOURCES/perftest-3.0-cflags.patch b/SOURCES/perftest-3.0-cflags.patch new file mode 100644 index 0000000..3336a13 --- /dev/null +++ b/SOURCES/perftest-3.0-cflags.patch @@ -0,0 +1,13 @@ +Index: perftest-3.0/configure.ac +=================================================================== +--- perftest-3.0.orig/configure.ac ++++ perftest-3.0/configure.ac +@@ -189,7 +189,7 @@ if [test $HAVE_GID_ATTR = yes] && [test + AC_DEFINE([HAVE_GID_ATTR], [1], [Enable GID Attribute query feature]) + fi + +-CFLAGS="-g -Wall -D_GNU_SOURCE -O3" ++CFLAGS+=" -g -Wall -D_GNU_SOURCE -O3" + AC_SUBST([LIBUMAD]) + AC_SUBST([LIBMATH]) + AC_CONFIG_FILES([Makefile]) diff --git a/SOURCES/perftest-3.0-fix-memory-leaks.patch b/SOURCES/perftest-3.0-fix-memory-leaks.patch new file mode 100644 index 0000000..9de8156 --- /dev/null +++ b/SOURCES/perftest-3.0-fix-memory-leaks.patch @@ -0,0 +1,2321 @@ + src/atomic_bw.c | 55 +++++++++++++----------- + src/atomic_lat.c | 52 +++++++++++++--------- + src/multicast_resources.c | 2 +- + src/perftest_communication.c | 19 +++++--- + src/perftest_parameters.c | 7 ++- + src/perftest_resources.c | 25 +++++++---- + src/raw_ethernet_resources.c | 7 ++- + src/raw_ethernet_send_lat.c | 65 ++++++++++++++++------------ + src/read_bw.c | 76 +++++++++++++++++++------------- + src/read_lat.c | 55 +++++++++++++++--------- + src/send_bw.c | 100 +++++++++++++++++++++++++------------------ + src/send_lat.c | 71 ++++++++++++++++++------------ + src/write_bw.c | 81 +++++++++++++++++++---------------- + src/write_lat.c | 38 +++++++++------- + 14 files changed, 391 insertions(+), 262 deletions(-) + +diff --git a/src/atomic_bw.c b/src/atomic_bw.c +index 479cb1d..05e56ab 100755 +--- a/src/atomic_bw.c ++++ b/src/atomic_bw.c +@@ -69,7 +69,7 @@ int main(int argc, char *argv[]) + if (ret_parser) { + if (ret_parser != VERSION_EXIT && ret_parser != HELP_EXIT) + fprintf(stderr, " Parser function exited with Error\n"); +- return 1; ++ return FAILURE; + } + + if (user_param.use_xrc && user_param.duplex) { +@@ -84,7 +84,7 @@ int main(int argc, char *argv[]) + ctx.context = ibv_open_device(ib_dev); + if (!ctx.context) { + fprintf(stderr, " Couldn't get context for the device\n"); +- return 1; ++ return FAILURE; + } + + #ifdef HAVE_MASKED_ATOMICS +@@ -95,7 +95,7 @@ int main(int argc, char *argv[]) + + if (user_param.masked_atomics && (user_param.work_rdma_cm || user_param.use_rdma_cm)) { + fprintf(stderr, "atomic test is not supported with -R/-z flag (rdma_cm) with this device.\n"); +- return 1; ++ return FAILURE; + } + #endif + +@@ -108,7 +108,7 @@ int main(int argc, char *argv[]) + /* copy the relevant user parameters to the comm struct + creating rdma_cm resources. */ + if (create_comm_struct(&user_comm, &user_param)) { + fprintf(stderr, " Unable to create RDMA_CM resources\n"); +- return 1; ++ return FAILURE; + } + + if (user_param.output == FULL_VERBOSITY && user_param.machine == SERVER) { +@@ -147,17 +147,17 @@ int main(int argc, char *argv[]) + if (user_param.machine == CLIENT) { + if (retry_rdma_connect(&ctx, &user_param)) { + fprintf(stderr, "Unable to perform rdma_client function\n"); +- return FAILURE; ++ goto fail_free_dests; + } + + } else { + if (create_rdma_resources(&ctx, &user_param)) { + fprintf(stderr, " Unable to create the rdma_resources\n"); +- return FAILURE; ++ goto fail_free_dests; + } + if (rdma_server_connect(&ctx, &user_param)) { + fprintf(stderr, "Unable to perform rdma_client function\n"); +- return FAILURE; ++ goto fail_free_dests; + } + } + +@@ -166,14 +166,14 @@ int main(int argc, char *argv[]) + /* create all the basic IB resources. */ + if (ctx_init(&ctx, &user_param)) { + fprintf(stderr, " Couldn't create IB resources\n"); +- return FAILURE; ++ goto fail_free_dests; + } + } + + /* Set up the Connection. */ + if (set_up_connection(&ctx, &user_param, my_dest)) { + fprintf(stderr, " Unable to set up socket connection\n"); +- return FAILURE; ++ goto fail_destroy_ctx; + } + + /* Print basic test information. */ +@@ -189,7 +189,7 @@ int main(int argc, char *argv[]) + /* shaking hands and gather the other side info. */ + if (ctx_hand_shake(&user_comm, &my_dest[i], &rem_dest[i])) { + fprintf(stderr, "Failed to exchange data between server and clients\n"); +- return 1; ++ goto fail_destroy_ctx; + } + ctx_print_pingpong_data(&rem_dest[i], &user_comm); + } +@@ -198,21 +198,21 @@ int main(int argc, char *argv[]) + if (ctx_check_gid_compatibility(&my_dest[0], &rem_dest[0])) { + fprintf(stderr, "\n Found Incompatibility issue with GID types.\n"); + fprintf(stderr, " Please Try to use a different IP version.\n\n"); +- return 1; ++ goto fail_destroy_ctx; + } + } + + if (user_param.work_rdma_cm == OFF) { + if (ctx_connect(&ctx, rem_dest, &user_param, my_dest)) { + fprintf(stderr, " Unable to Connect the HCA's through the link\n"); +- return 1; ++ goto fail_destroy_ctx; + } + } + + /* An additional handshake is required after moving qp to RTR. */ + if (ctx_hand_shake(&user_comm, &my_dest[0], &rem_dest[0])) { + fprintf(stderr, "Failed to exchange data between server and clients\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + /* For half duplex tests, server just waits for client to exit */ +@@ -225,7 +225,7 @@ int main(int argc, char *argv[]) + + if (ctx_hand_shake(&user_comm, &my_dest[0], &rem_dest[0])) { + fprintf(stderr, " Failed to exchange data between server and clients\n"); +- return FAILURE; ++ goto fail_destroy_ctx; + } + + xchg_bw_reports(&user_comm, &my_bw_rep, &rem_bw_rep, atof(user_param.rem_version)); +@@ -237,7 +237,7 @@ int main(int argc, char *argv[]) + + if (ctx_close_connection(&user_comm, &my_dest[0], &rem_dest[0])) { + fprintf(stderr, "Failed to close connection between server and client\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + return destroy_ctx(&ctx, &user_param); +@@ -246,7 +246,7 @@ int main(int argc, char *argv[]) + if (user_param.use_event) { + if (ibv_req_notify_cq(ctx.send_cq, 0)) { + fprintf(stderr, "Couldn't request CQ notification\n"); +- return 1; ++ goto fail_destroy_ctx; + } + } + if (user_param.output == FULL_VERBOSITY) { +@@ -261,19 +261,19 @@ int main(int argc, char *argv[]) + + if (perform_warm_up(&ctx, &user_param)) { + fprintf(stderr, "Problems with warm up\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + if (user_param.duplex) { + if (ctx_hand_shake(&user_comm, &my_dest[0], &rem_dest[0])) { + fprintf(stderr, "Failed to sync between server and client between different msg sizes\n"); +- return 1; ++ goto fail_destroy_ctx; + } + } + + if (run_iter_bw(&ctx, &user_param)) { + fprintf(stderr, " Error occured in run_iter function\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + print_report_bw(&user_param, &my_bw_rep); +@@ -302,7 +302,7 @@ int main(int argc, char *argv[]) + + if (run_iter_bw_infinitely(&ctx, &user_param)) { + fprintf(stderr, " Error occured while running infinitely! aborting ...\n"); +- return 1; ++ goto fail_destroy_ctx; + } + } + +@@ -314,7 +314,7 @@ int main(int argc, char *argv[]) + + if (ctx_hand_shake(&user_comm, &my_dest[0], &rem_dest[0])) { + fprintf(stderr, " Failed to exchange data between server and clients\n"); +- return FAILURE; ++ goto fail_destroy_ctx; + } + + xchg_bw_reports(&user_comm, &my_bw_rep, &rem_bw_rep, atof(user_param.rem_version)); +@@ -322,18 +322,25 @@ int main(int argc, char *argv[]) + + if (ctx_close_connection(&user_comm, &my_dest[0], &rem_dest[0])) { + fprintf(stderr, "Failed to close connection between server and client\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + if (!user_param.is_bw_limit_passed && (user_param.is_limit_bw == ON)) { + fprintf(stderr, "Error: BW result is below bw limit\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + if (!user_param.is_msgrate_limit_passed && (user_param.is_limit_bw == ON)) { + fprintf(stderr, "Error: Msg rate is below msg_rate limit\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + return destroy_ctx(&ctx, &user_param); ++ ++fail_destroy_ctx: ++ destroy_ctx(&ctx,&user_param); ++fail_free_dests: ++ free(my_dest); ++ free(rem_dest); ++ return FAILURE; + } +diff --git a/src/atomic_lat.c b/src/atomic_lat.c +index fd61a14..9d53b61 100755 +--- a/src/atomic_lat.c ++++ b/src/atomic_lat.c +@@ -55,6 +55,7 @@ + int main(int argc, char *argv[]) + { + int ret_parser, i; ++ int ret_val = FAILURE; + struct report_options report; + struct pingpong_context ctx; + struct pingpong_dest *my_dest = NULL; +@@ -77,7 +78,7 @@ int main(int argc, char *argv[]) + if (ret_parser) { + if (ret_parser != VERSION_EXIT && ret_parser != HELP_EXIT) + fprintf(stderr," Parser function exited with Error\n"); +- return 1; ++ return FAILURE; + } + + if(user_param.use_xrc) +@@ -94,7 +95,7 @@ int main(int argc, char *argv[]) + ctx.context = ibv_open_device(ib_dev); + if (!ctx.context) { + fprintf(stderr, " Couldn't get context for the device\n"); +- return 1; ++ return FAILURE; + } + + #ifdef HAVE_MASKED_ATOMICS +@@ -105,7 +106,7 @@ int main(int argc, char *argv[]) + + if (user_param.masked_atomics && (user_param.work_rdma_cm || user_param.use_rdma_cm)) { + fprintf(stderr, "atomic test is not supported with -R/-z flag (rdma_cm) with this device.\n"); +- return 1; ++ return FAILURE; + } + + #endif +@@ -119,7 +120,7 @@ int main(int argc, char *argv[]) + /* copy the relevant user parameters to the comm struct + creating rdma_cm resources. */ + if (create_comm_struct(&user_comm,&user_param)) { + fprintf(stderr," Unable to create RDMA_CM resources\n"); +- return 1; ++ return FAILURE; + } + + if (user_param.output == FULL_VERBOSITY && user_param.machine == SERVER) { +@@ -158,17 +159,17 @@ int main(int argc, char *argv[]) + if (user_param.machine == CLIENT) { + if (retry_rdma_connect(&ctx,&user_param)) { + fprintf(stderr,"Unable to perform rdma_client function\n"); +- return FAILURE; ++ goto fail_free_dests; + } + + } else { + if (create_rdma_resources(&ctx,&user_param)) { + fprintf(stderr," Unable to create the rdma_resources\n"); +- return FAILURE; ++ goto fail_free_dests; + } + if (rdma_server_connect(&ctx,&user_param)) { + fprintf(stderr,"Unable to perform rdma_client function\n"); +- return FAILURE; ++ goto fail_free_dests; + } + } + +@@ -177,14 +178,14 @@ int main(int argc, char *argv[]) + /* create all the basic IB resources (data buffer, PD, MR, CQ and events channel) */ + if (ctx_init(&ctx,&user_param)) { + fprintf(stderr, " Couldn't create IB resources\n"); +- return FAILURE; ++ goto fail_free_dests; + } + } + + /* Set up the Connection. */ + if (set_up_connection(&ctx,&user_param,my_dest)) { + fprintf(stderr," Unable to set up socket connection\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + /* Print basic test information. */ +@@ -196,7 +197,7 @@ int main(int argc, char *argv[]) + /* shaking hands and gather the other side info. */ + if (ctx_hand_shake(&user_comm,my_dest,rem_dest)) { + fprintf(stderr,"Failed to exchange data between server and clients\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + user_comm.rdma_params->side = REMOTE; +@@ -205,7 +206,7 @@ int main(int argc, char *argv[]) + /* shaking hands and gather the other side info. */ + if (ctx_hand_shake(&user_comm,&my_dest[i],&rem_dest[i])) { + fprintf(stderr,"Failed to exchange data between server and clients\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + ctx_print_pingpong_data(&rem_dest[i],&user_comm); +@@ -215,39 +216,39 @@ int main(int argc, char *argv[]) + if (ctx_check_gid_compatibility(&my_dest[0], &rem_dest[0])) { + fprintf(stderr,"\n Found Incompatibility issue with GID types.\n"); + fprintf(stderr," Please Try to use a different IP version.\n\n"); +- return 1; ++ goto fail_destroy_ctx; + } + } + + if (user_param.work_rdma_cm == OFF) { + if (ctx_connect(&ctx,rem_dest,&user_param,my_dest)) { + fprintf(stderr," Unable to Connect the HCA's through the link\n"); +- return 1; ++ goto fail_destroy_ctx; + } + } + + /* An additional handshake is required after moving qp to RTR. */ + if (ctx_hand_shake(&user_comm,my_dest,rem_dest)) { + fprintf(stderr,"Failed to exchange data between server and clients\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + /* Only Client post read request. */ + if (user_param.machine == SERVER) { + if (ctx_close_connection(&user_comm,my_dest,rem_dest)) { + fprintf(stderr,"Failed to close connection between server and client\n"); +- return 1; ++ goto fail_destroy_ctx; + } + if (user_param.output == FULL_VERBOSITY) { + printf(RESULT_LINE); + } +- return 0; ++ goto out_success; + } + + if (user_param.use_event) { + if (ibv_req_notify_cq(ctx.send_cq, 0)) { + fprintf(stderr, "Couldn't request CQ notification\n"); +- return 1; ++ goto fail_destroy_ctx; + } + } + +@@ -258,19 +259,28 @@ int main(int argc, char *argv[]) + printf("%s",(user_param.test_type == ITERATIONS) ? RESULT_FMT_LAT : RESULT_FMT_LAT_DUR); + printf((user_param.cpu_util_data.enable ? RESULT_EXT_CPU_UTIL : RESULT_EXT)); + } +- if(run_iter_lat(&ctx,&user_param)) +- return 17; ++ if(run_iter_lat(&ctx,&user_param)) { ++ ret_val = 17; ++ goto fail_destroy_ctx; ++ } + + user_param.test_type == ITERATIONS ? print_report_lat(&user_param) : print_report_lat_duration(&user_param); + + if (ctx_close_connection(&user_comm,my_dest,rem_dest)) { + fprintf(stderr,"Failed to close connection between server and client\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + if (user_param.output == FULL_VERBOSITY) { + printf(RESULT_LINE); + } + +- return 0; ++out_success: ++ ret_val = 0; ++fail_destroy_ctx: ++ destroy_ctx(&ctx,&user_param); ++fail_free_dests: ++ free(my_dest); ++ free(rem_dest); ++ return ret_val; + } +diff --git a/src/multicast_resources.c b/src/multicast_resources.c +index 3a8edba..f5e4bea 100755 +--- a/src/multicast_resources.c ++++ b/src/multicast_resources.c +@@ -160,7 +160,7 @@ void set_multicast_gid(struct mcast_parameters *params,uint32_t qp_num,int is_cl + } + pstr += term - pstr + 1; + +- strcpy(tmp, pstr); ++ strncpy(tmp, pstr, sizeof(tmp) - 1); + mcg_gid[15] = (unsigned char)strtoll(tmp, NULL, 0); + } + +diff --git a/src/perftest_communication.c b/src/perftest_communication.c +index fd71436..6b3b1d9 100755 +--- a/src/perftest_communication.c ++++ b/src/perftest_communication.c +@@ -686,7 +686,11 @@ static int ethernet_server_connect(struct perftest_comm *comm) + + if (sockfd >= 0) { + n = 1; +- setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &n, sizeof n); ++ if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &n, sizeof n)) { ++ freeaddrinfo(res); ++ close(sockfd); ++ return 1; ++ } + if (!bind(sockfd, t->ai_addr, t->ai_addrlen)) + break; + close(sockfd); +@@ -761,7 +765,7 @@ int set_up_connection(struct pingpong_context *ctx, + return 0; + + if (user_param->use_gid_user) { +- if (ibv_query_gid(ctx->context, user_param->ib_port2, user_param->gid_index, &temp_gid2)) ++ if (ibv_query_gid(ctx->context, user_param->ib_port2, user_param->gid_index2, &temp_gid2)) + return -1; + } else { + user_param->gid_index2 = get_best_gid_index(ctx, user_param, &attr, user_param->ib_port2); +@@ -876,11 +880,13 @@ int rdma_client_connect(struct pingpong_context *ctx,struct perftest_parameters + } + + if (res->ai_family != PF_INET) { ++ freeaddrinfo(res); + return FAILURE; + } + + memcpy(&sin, res->ai_addr, sizeof(sin)); + sin.sin_port = htons((unsigned short)user_param->port); ++ freeaddrinfo(res); + + while (1) { + +@@ -1005,7 +1011,7 @@ int rdma_client_connect(struct pingpong_context *ctx,struct perftest_parameters + + ctx->ah[0] = ibv_create_ah(ctx->pd,&event->param.ud.ah_attr); + +- if (!ctx->ah) { ++ if (ctx->ah[0]) { + printf(" Unable to create address handler for UD QP\n"); + return FAILURE; + } +@@ -1074,10 +1080,12 @@ int rdma_server_connect(struct pingpong_context *ctx, + } + + if (res->ai_family != PF_INET) { ++ freeaddrinfo(res); + return FAILURE; + } + memcpy(&sin, res->ai_addr, sizeof(sin)); + sin.sin_port = htons((unsigned short)user_param->port); ++ freeaddrinfo(res); + + if (rdma_bind_addr(ctx->cm_id_control,(struct sockaddr *)&sin)) { + fprintf(stderr," rdma_bind_addr failed\n"); +@@ -1160,7 +1168,6 @@ int rdma_server_connect(struct pingpong_context *ctx, + + rdma_ack_cm_event(event); + rdma_destroy_id(ctx->cm_id_control); +- freeaddrinfo(res); + return 0; + } + +@@ -1703,8 +1710,8 @@ void check_sys_data(struct perftest_comm *user_comm, struct perftest_parameters + ******************************************************************************/ + int check_mtu(struct ibv_context *context,struct perftest_parameters *user_param, struct perftest_comm *user_comm) { + int curr_mtu=0, rem_mtu=0; +- char cur[2]; +- char rem[2]; ++ char cur[4]; ++ char rem[4]; + int size_of_cur; + + if (user_param->connection_type == RawEth) { +diff --git a/src/perftest_parameters.c b/src/perftest_parameters.c +index e316143..b18588f 100755 +--- a/src/perftest_parameters.c ++++ b/src/perftest_parameters.c +@@ -147,7 +147,10 @@ static int get_cache_line_size() + if (fp == NULL) { + return DEF_CACHE_LINE_SIZE; + } +- fgets(line,10,fp); ++ if (fgets(line,10,fp) == NULL) { ++ fclose(fp); ++ return DEF_CACHE_LINE_SIZE; ++ } + size = atoi(line); + fclose(fp); + } +@@ -308,7 +311,7 @@ static void usage(const char *argv0, VerbType verb, TestType tst, int connection + + if (tst == BW) { + printf(" -t, --tx-depth= "); +- printf(" Size of tx queue (default %d)\n",tst == LAT ? DEF_TX_LAT : DEF_TX_BW); ++ printf(" Size of tx queue (default %d)\n", DEF_TX_BW); + } + + printf(" -T, --tos= "); +diff --git a/src/perftest_resources.c b/src/perftest_resources.c +index f23dabb..959a5df 100755 +--- a/src/perftest_resources.c ++++ b/src/perftest_resources.c +@@ -230,7 +230,10 @@ static void get_cpu_stats(struct perftest_parameters *duration_param,int stat_in + int index=0; + fp = fopen(file_name, "r"); + if (fp != NULL) { +- fgets(line,100,fp); ++ if (fgets(line,100,fp) == NULL) { ++ fclose(fp); ++ return; ++ } + compress_spaces(line,line); + index=get_n_word_string(line,tmp,index,2); /* skip first word */ + duration_param->cpu_util_data.ustat[stat_index-1] = atoll(tmp); +@@ -647,7 +650,7 @@ void alloc_ctx(struct pingpong_context *ctx,struct perftest_parameters *user_par + + ALLOCATE(user_param->port_by_qp, uint64_t, user_param->num_of_qps); + +- tarr_size = (user_param->noPeak) ? 1 : user_param->iters*user_param->num_of_qps; ++ tarr_size = (user_param->noPeak) ? 1UL : (uint64_t)user_param->iters*user_param->num_of_qps; + ALLOCATE(user_param->tposted, cycles_t, tarr_size); + memset(user_param->tposted, 0, sizeof(cycles_t)*tarr_size); + +@@ -1827,6 +1830,8 @@ int ctx_modify_dc_qp_to_init(struct ibv_qp *qp,struct perftest_parameters *user_ + + if (user_param->duplex || user_param->tst == LAT) { + num_of_qps /= 2; ++ if (num_of_qps < 2) ++ num_of_qps = 2; + num_of_qps_per_port = num_of_qps / 2; + } + +@@ -1855,7 +1860,7 @@ int ctx_modify_dc_qp_to_init(struct ibv_qp *qp,struct perftest_parameters *user_ + #endif + + if (err) { +- fprintf(stderr, "Failed to modify QP to INIT\n"); ++ fprintf(stderr, "Failed to modify QP to INIT (%s)\n", strerror(err)); + return 1; + } + return 0; +@@ -1893,6 +1898,8 @@ int ctx_modify_qp_to_init(struct ibv_qp *qp,struct perftest_parameters *user_par + + if ( user_param->use_xrc && (user_param->duplex || user_param->tst == LAT)) { + num_of_qps /= 2; ++ if (num_of_qps < 2) ++ num_of_qps = 2; + num_of_qps_per_port = num_of_qps / 2; + } + +@@ -1951,7 +1958,7 @@ int ctx_modify_qp_to_init(struct ibv_qp *qp,struct perftest_parameters *user_par + ret = ibv_modify_qp(qp,&attr,flags); + + if (ret) { +- fprintf(stderr, "Failed to modify QP to INIT, ret=%d\n",ret); ++ fprintf(stderr, "Failed to modify QP to INIT, (%s)\n",strerror(ret)); + return 1; + } + return 0; +@@ -2261,7 +2268,7 @@ int ctx_connect(struct pingpong_context *ctx, + + err = ibv_query_qp(ctx->qp[i], &qp_attr, IBV_QP_AV, &init_attr); + if (err) +- fprintf(stderr, "ibv_query_qp failed to get ah_attr\n"); ++ fprintf(stderr, "ibv_query_qp failed to get ah_attr (%s)\n", strerror(err)); + else + qp_static_rate = (int)(qp_attr.ah_attr.static_rate); + +@@ -2816,7 +2823,7 @@ int perform_warm_up(struct pingpong_context *ctx,struct perftest_parameters *use + #endif + + if (err) { +- fprintf(stderr,"Couldn't post send during warm up: qp %d scnt=%d \n",index,warmindex); ++ fprintf(stderr,"Couldn't post send during warm up: qp %d scnt=%d, err=%s\n",index,warmindex,strerror(err)); + return_value = 1; + goto cleaning; + } +@@ -4016,7 +4023,7 @@ int run_iter_lat_write(struct pingpong_context *ctx,struct perftest_parameters * + err = ibv_post_send(ctx->qp[0],&ctx->wr[0],&bad_wr); + #endif + if (err) { +- fprintf(stderr,"Couldn't post send: scnt=%lu\n",scnt); ++ fprintf(stderr,"%s: Couldn't post send: scnt=%lu, err=%s\n",__func__,scnt,strerror(err)); + return 1; + } + } +@@ -4110,7 +4117,7 @@ int run_iter_lat(struct pingpong_context *ctx,struct perftest_parameters *user_p + err = ibv_post_send(ctx->qp[0],&ctx->wr[0],&bad_wr); + #endif + if (err) { +- fprintf(stderr,"Couldn't post send: scnt=%lu\n",scnt); ++ fprintf(stderr,"%s: Couldn't post send: scnt=%lu, err=%s\n",__func__,scnt,strerror(err)); + return 1; + } + +@@ -4310,7 +4317,7 @@ int run_iter_lat_send(struct pingpong_context *ctx,struct perftest_parameters *u + err = ibv_post_send(ctx->qp[0],&ctx->wr[0],&bad_wr); + #endif + if (err) { +- fprintf(stderr,"Couldn't post send: scnt=%lu \n",scnt); ++ fprintf(stderr,"%s: Couldn't post send: scnt=%lu, err=%s \n",__func__,scnt,strerror(err)); + return 1; + } + +diff --git a/src/raw_ethernet_resources.c b/src/raw_ethernet_resources.c +index 3b1516e..22e1bab 100755 +--- a/src/raw_ethernet_resources.c ++++ b/src/raw_ethernet_resources.c +@@ -69,7 +69,10 @@ int check_flow_steering_support(char *dev_name) + fp = fopen(file_name, "r"); + if (fp == NULL) + return 0; +- fgets(line,4,fp); ++ if (fgets(line,4,fp) == NULL) { ++ fclose(fp); ++ return 0; ++ } + + int val = atoi(line); + if (val >= 0) { +@@ -406,11 +409,11 @@ void build_pkt_on_buffer(struct ETH_header* eth_header, + int is_udp_or_tcp = user_param->is_client_port && user_param->is_server_port; + + gen_eth_header(eth_header, my_dest_info->mac, rem_dest_info->mac, eth_type); ++ header_buff = (void*)eth_header + sizeof(struct ETH_header); + + if(have_ip_header) { + int offset = is_udp_or_tcp ? 0 : flows_offset; + +- header_buff = (void*)eth_header + sizeof(struct ETH_header); + gen_ip_header(header_buff, &my_dest_info->ip, &rem_dest_info->ip, + ip_next_protocol, pkt_size, user_param->tos, offset); + } +diff --git a/src/raw_ethernet_send_lat.c b/src/raw_ethernet_send_lat.c +index 4663714..b6bce26 100755 +--- a/src/raw_ethernet_send_lat.c ++++ b/src/raw_ethernet_send_lat.c +@@ -64,6 +64,7 @@ int main(int argc, char *argv[]) + struct pingpong_context ctx; + struct raw_ethernet_info my_dest_info,rem_dest_info; + int ret_parser; ++ int ret_val = FAILURE; + struct perftest_parameters user_param; + #ifdef HAVE_RAW_ETH_EXP + struct ibv_exp_flow **flow_create_result; +@@ -74,7 +75,7 @@ int main(int argc, char *argv[]) + struct ibv_flow_attr **flow_rules; + #endif + struct report_options report; +- int i; ++ int i, flows; + + /* allocate memory space for user parameters &*/ + memset(&ctx, 0, sizeof(struct pingpong_context)); +@@ -101,14 +102,15 @@ int main(int argc, char *argv[]) + if (ret_parser != VERSION_EXIT && ret_parser != HELP_EXIT) + fprintf(stderr," Parser function exited with Error\n"); + DEBUG_LOG(TRACE,"<<<<<<%s",__FUNCTION__); +- return 1; ++ return FAILURE; + } ++ flows = user_param.flows; + #ifdef HAVE_RAW_ETH_EXP +- ALLOCATE(flow_create_result, struct ibv_exp_flow*, user_param.flows); +- ALLOCATE(flow_rules, struct ibv_exp_flow_attr*, user_param.flows); ++ ALLOCATE(flow_create_result, struct ibv_exp_flow*, flows); ++ ALLOCATE(flow_rules, struct ibv_exp_flow_attr*, flows); + #else +- ALLOCATE(flow_create_result, struct ibv_flow*, user_param.flows); +- ALLOCATE(flow_rules, struct ibv_flow_attr*, user_param.flows); ++ ALLOCATE(flow_create_result, struct ibv_flow*, flows); ++ ALLOCATE(flow_rules, struct ibv_flow_attr*, flows); + #endif + + +@@ -122,12 +124,12 @@ int main(int argc, char *argv[]) + if (!ib_dev) { + fprintf(stderr," Unable to find the Infiniband/RoCE device\n"); + DEBUG_LOG(TRACE,"<<<<<<%s",__FUNCTION__); +- return 1; ++ goto free_flows; + } + GET_STRING(user_param.ib_devname, ibv_get_device_name(ib_dev)); + + if (check_flow_steering_support(user_param.ib_devname)) { +- return 1; ++ goto free_flows; + } + + /* Getting the relevant context from the device */ +@@ -135,14 +137,14 @@ int main(int argc, char *argv[]) + if (!ctx.context) { + fprintf(stderr, " Couldn't get context for the device\n"); + DEBUG_LOG(TRACE,"<<<<<<%s",__FUNCTION__); +- return 1; ++ goto free_flows; + } + + /* See if MTU and link type are valid and supported. */ + if (check_link_and_mtu(ctx.context, &user_param)) { + fprintf(stderr, " Couldn't get context for the device\n"); + DEBUG_LOG(TRACE,"<<<<<<%s",__FUNCTION__); +- return FAILURE; ++ goto free_flows; + } + + /* Allocating arrays needed for the test. */ +@@ -153,13 +155,13 @@ int main(int argc, char *argv[]) + */ + if (send_set_up_connection(flow_rules, &ctx, &user_param, &my_dest_info, &rem_dest_info)) { + fprintf(stderr," Unable to set up socket connection\n"); +- return 1; ++ goto free_flows; + } + + /* Print basic test information. */ + ctx_print_test_info(&user_param); + +- for (i = 0; i < user_param.flows; i++) ++ for (i = 0; i < flows; i++) + print_spec(flow_rules[i], &user_param); + + /* Create (if necessary) the rdma_cm ids and channel. */ +@@ -167,7 +169,7 @@ int main(int argc, char *argv[]) + + if (create_rdma_resources(&ctx, &user_param)) { + fprintf(stderr," Unable to create the rdma_resources\n"); +- return FAILURE; ++ goto free_flows; + } + + if (user_param.machine == CLIENT) { +@@ -175,13 +177,13 @@ int main(int argc, char *argv[]) + /* Connects the client to a QP on the other machine with rdma_cm */ + if (rdma_client_connect(&ctx, &user_param)) { + fprintf(stderr,"Unable to perform rdma_client function\n"); +- return FAILURE; ++ goto free_flows; + } + + } else if (rdma_server_connect(&ctx, &user_param)) { + /* Assigning a server to listen on rdma_cm port and connect to it. */ + fprintf(stderr,"Unable to perform rdma_server function\n"); +- return FAILURE; ++ goto free_flows; + } + + } else { +@@ -189,13 +191,13 @@ int main(int argc, char *argv[]) + /* initalize IB resources (data buffer, PD, MR, CQ and events channel) */ + if (ctx_init(&ctx, &user_param)) { + fprintf(stderr, " Couldn't create IB resources\n"); +- return FAILURE; ++ goto free_flows; + } + } + + + /* attaching the qp to the spec */ +- for (i = 0; i < user_param.flows; i++) { ++ for (i = 0; i < flows; i++) { + #ifdef HAVE_RAW_ETH_EXP + flow_create_result[i] = ibv_exp_create_flow(ctx.qp[0], flow_rules[i]); + #else +@@ -205,7 +207,7 @@ int main(int argc, char *argv[]) + if (!flow_create_result[i]){ + perror("error"); + fprintf(stderr, "Couldn't attach QP\n"); +- return FAILURE; ++ goto destroy_ctx; + } + } + +@@ -239,7 +241,7 @@ int main(int argc, char *argv[]) + if (ctx_connect(&ctx, NULL, &user_param, NULL)) { + fprintf(stderr," Unable to Connect the HCA's through the link\n"); + DEBUG_LOG(TRACE,"<<<<<<%s",__FUNCTION__); +- return 1; ++ goto destroy_ctx; + } + } + +@@ -247,12 +249,12 @@ int main(int argc, char *argv[]) + + if (ctx_set_recv_wqes(&ctx,&user_param)) { + fprintf(stderr," Failed to post receive recv_wqes\n"); +- return 1; ++ goto destroy_ctx; + } + + /* latency test function for SEND verb latency test. */ + if (run_iter_lat_send(&ctx, &user_param)) { +- return 17; ++ goto eexists; + } + + /* print report (like print_report_bw) in the correct format +@@ -267,13 +269,13 @@ int main(int argc, char *argv[]) + if (ibv_exp_destroy_flow(flow_promisc)) { + perror("error"); + fprintf(stderr, "Couldn't Destory promisc flow\n"); +- return FAILURE; ++ goto destroy_ctx; + } + } + #endif + + /* destroy flow */ +- for (i = 0; i < user_param.flows; i++) { ++ for (i = 0; i < flows; i++) { + #ifdef HAVE_RAW_ETH_EXP + if (ibv_exp_destroy_flow(flow_create_result[i])) { + #else +@@ -281,7 +283,7 @@ int main(int argc, char *argv[]) + #endif + perror("error"); + fprintf(stderr, "Couldn't Destory flow\n"); +- return FAILURE; ++ goto destroy_ctx; + } + + free(flow_rules[i]); +@@ -291,13 +293,22 @@ int main(int argc, char *argv[]) + if (destroy_ctx(&ctx, &user_param)) { + fprintf(stderr,"Failed to destroy_ctx\n"); + DEBUG_LOG(TRACE,"<<<<<<%s",__FUNCTION__); +- return 1; ++ goto free_flows; + } + + if (user_param.output == FULL_VERBOSITY) + printf(RESULT_LINE); + + DEBUG_LOG(TRACE,"<<<<<<%s",__FUNCTION__); +- return 0; +- ++ ret_val = SUCCESS; ++ goto free_flows; ++ ++eexists: ++ ret_val = 17; ++destroy_ctx: ++ destroy_ctx(&ctx, &user_param); ++free_flows: ++ free(flow_create_result); ++ free(flow_rules); ++ return ret_val; + } +diff --git a/src/read_bw.c b/src/read_bw.c +index 47afcdb..d72c1a5 100755 +--- a/src/read_bw.c ++++ b/src/read_bw.c +@@ -48,6 +48,7 @@ + int main(int argc, char *argv[]) + { + int ret_parser,i = 0; ++ int ret_val = FAILURE; + struct ibv_device *ib_dev = NULL; + struct pingpong_context ctx; + struct pingpong_dest *my_dest = NULL; +@@ -69,7 +70,7 @@ int main(int argc, char *argv[]) + if (ret_parser) { + if (ret_parser != VERSION_EXIT && ret_parser != HELP_EXIT) + fprintf(stderr," Parser function exited with Error\n"); +- return 1; ++ return FAILURE; + } + + if((user_param.connection_type == DC || user_param.use_xrc) && user_param.duplex) { +@@ -84,7 +85,7 @@ int main(int argc, char *argv[]) + ctx.context = ibv_open_device(ib_dev); + if (!ctx.context) { + fprintf(stderr, " Couldn't get context for the device\n"); +- return 1; ++ return FAILURE; + } + + /* See if MTU and link type are valid and supported. */ +@@ -96,7 +97,7 @@ int main(int argc, char *argv[]) + /* copy the relevant user parameters to the comm struct + creating rdma_cm resources. */ + if (create_comm_struct(&user_comm,&user_param)) { + fprintf(stderr," Unable to create RDMA_CM resources\n"); +- return 1; ++ return FAILURE; + } + + if (user_param.output == FULL_VERBOSITY && user_param.machine == SERVER) { +@@ -135,17 +136,17 @@ int main(int argc, char *argv[]) + if (user_param.machine == CLIENT) { + if (retry_rdma_connect(&ctx,&user_param)) { + fprintf(stderr,"Unable to perform rdma_client function\n"); +- return FAILURE; ++ goto fail_free_dests; + } + + } else { + if (create_rdma_resources(&ctx,&user_param)) { + fprintf(stderr," Unable to create the rdma_resources\n"); +- return FAILURE; ++ goto fail_free_dests; + } + if (rdma_server_connect(&ctx,&user_param)) { + fprintf(stderr,"Unable to perform rdma_client function\n"); +- return FAILURE; ++ goto fail_free_dests; + } + } + +@@ -153,14 +154,14 @@ int main(int argc, char *argv[]) + /* create all the basic IB resources. */ + if (ctx_init(&ctx,&user_param)) { + fprintf(stderr, " Couldn't create IB resources\n"); +- return FAILURE; ++ goto fail_free_dests; + } + } + + /* Set up the Connection. */ + if (set_up_connection(&ctx,&user_param,my_dest)) { + fprintf(stderr," Unable to set up socket connection\n"); +- return FAILURE; ++ goto fail_destroy_ctx; + } + + /* Print basic test information. */ +@@ -177,7 +178,7 @@ int main(int argc, char *argv[]) + /* shaking hands and gather the other side info. */ + if (ctx_hand_shake(&user_comm,&my_dest[i],&rem_dest[i])) { + fprintf(stderr,"Failed to exchange data between server and clients\n"); +- return 1; ++ goto fail_destroy_ctx; + } + ctx_print_pingpong_data(&rem_dest[i],&user_comm); + } +@@ -186,7 +187,7 @@ int main(int argc, char *argv[]) + if (ctx_check_gid_compatibility(&my_dest[0], &rem_dest[0])) { + fprintf(stderr,"\n Found Incompatibility issue with GID types.\n"); + fprintf(stderr," Please Try to use a different IP version.\n\n"); +- return 1; ++ goto fail_destroy_ctx; + } + } + +@@ -194,14 +195,14 @@ int main(int argc, char *argv[]) + + if (ctx_connect(&ctx,rem_dest,&user_param,my_dest)) { + fprintf(stderr," Unable to Connect the HCA's through the link\n"); +- return 1; ++ goto fail_destroy_ctx; + } + } + + /* An additional handshake is required after moving qp to RTR. */ + if (ctx_hand_shake(&user_comm,&my_dest[0],&rem_dest[0])) { + fprintf(stderr,"Failed to exchange data between server and clients\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + if (user_param.output == FULL_VERBOSITY) { +@@ -221,7 +222,7 @@ int main(int argc, char *argv[]) + + if (ctx_hand_shake(&user_comm,&my_dest[0],&rem_dest[0])) { + fprintf(stderr," Failed to exchange data between server and clients\n"); +- return FAILURE; ++ goto fail_destroy_ctx; + } + + xchg_bw_reports(&user_comm, &my_bw_rep,&rem_bw_rep,atof(user_param.rem_version)); +@@ -229,7 +230,7 @@ int main(int argc, char *argv[]) + + if (ctx_close_connection(&user_comm,&my_dest[0],&rem_dest[0])) { + fprintf(stderr,"Failed to close connection between server and client\n"); +- return 1; ++ goto fail_destroy_ctx; + } + if (user_param.output == FULL_VERBOSITY) { + if (user_param.report_per_port) +@@ -241,12 +242,16 @@ int main(int argc, char *argv[]) + if (user_param.work_rdma_cm == ON) { + if (destroy_ctx(&ctx,&user_param)) { + fprintf(stderr, "Failed to destroy resources\n"); +- return 1; ++ goto fail_free_dests; + } + user_comm.rdma_params->work_rdma_cm = ON; ++ free(my_dest); ++ free(rem_dest); + return destroy_ctx(user_comm.rdma_ctx,user_comm.rdma_params); + } + ++ free(my_dest); ++ free(rem_dest); + return destroy_ctx(&ctx,&user_param); + + } +@@ -254,7 +259,7 @@ int main(int argc, char *argv[]) + if (user_param.use_event) { + if (ibv_req_notify_cq(ctx.send_cq, 0)) { + fprintf(stderr, "Couldn't request CQ notification\n"); +- return 1; ++ goto fail_destroy_ctx; + } + } + +@@ -267,23 +272,23 @@ int main(int argc, char *argv[]) + + if(perform_warm_up(&ctx,&user_param)) { + fprintf(stderr,"Problems with warm up\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + if(user_param.duplex) { + if (ctx_hand_shake(&user_comm,&my_dest[0],&rem_dest[0])) { + fprintf(stderr,"Failed to sync between server and client between different msg sizes\n"); +- return 1; ++ goto fail_destroy_ctx; + } + } + + if(run_iter_bw(&ctx,&user_param)) +- return 17; ++ goto fail_eexists; + + if (user_param.duplex && (atof(user_param.version) >= 4.6)) { + if (ctx_hand_shake(&user_comm,&my_dest[0],&rem_dest[0])) { + fprintf(stderr,"Failed to sync between server and client between different msg sizes\n"); +- return 1; ++ goto fail_destroy_ctx; + } + } + +@@ -301,19 +306,19 @@ int main(int argc, char *argv[]) + + if(perform_warm_up(&ctx,&user_param)) { + fprintf(stderr,"Problems with warm up\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + if(user_param.duplex) { + if (ctx_hand_shake(&user_comm,&my_dest[0],&rem_dest[0])) { + fprintf(stderr,"Failed to sync between server and client between different msg sizes\n"); +- return 1; ++ goto fail_destroy_ctx; + } + } + + if(run_iter_bw(&ctx,&user_param)) { + fprintf(stderr," Failed to complete run_iter_bw function successfully\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + print_report_bw(&user_param,&my_bw_rep); +@@ -344,7 +349,7 @@ int main(int argc, char *argv[]) + + if(run_iter_bw_infinitely(&ctx,&user_param)) { + fprintf(stderr," Error occured while running! aborting ...\n"); +- return 1; ++ goto fail_destroy_ctx; + } + } + +@@ -360,7 +365,7 @@ int main(int argc, char *argv[]) + + if (ctx_hand_shake(&user_comm,&my_dest[0],&rem_dest[0])) { + fprintf(stderr," Failed to exchange data between server and clients\n"); +- return FAILURE; ++ goto fail_destroy_ctx; + } + + xchg_bw_reports(&user_comm, &my_bw_rep,&rem_bw_rep,atof(user_param.rem_version)); +@@ -368,27 +373,40 @@ int main(int argc, char *argv[]) + + if (ctx_close_connection(&user_comm,&my_dest[0],&rem_dest[0])) { + fprintf(stderr,"Failed to close connection between server and client\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + if (!user_param.is_bw_limit_passed && (user_param.is_limit_bw == ON ) ) { + fprintf(stderr,"Error: BW result is below bw limit\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + if (!user_param.is_msgrate_limit_passed && (user_param.is_limit_bw == ON )) { + fprintf(stderr,"Error: Msg rate is below msg_rate limit\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + if (user_param.work_rdma_cm == ON) { + if (destroy_ctx(&ctx,&user_param)) { + fprintf(stderr, "Failed to destroy resources\n"); +- return 1; ++ goto fail_free_dests; + } + user_comm.rdma_params->work_rdma_cm = ON; ++ free(my_dest); ++ free(rem_dest); + return destroy_ctx(user_comm.rdma_ctx,user_comm.rdma_params); + } + ++ free(my_dest); ++ free(rem_dest); + return destroy_ctx(&ctx,&user_param); ++ ++fail_eexists: ++ ret_val = 17; ++fail_destroy_ctx: ++ destroy_ctx(&ctx, &user_param); ++fail_free_dests: ++ free(my_dest); ++ free(rem_dest); ++ return ret_val; + } +diff --git a/src/read_lat.c b/src/read_lat.c +index 247c70d..f25d42e 100755 +--- a/src/read_lat.c ++++ b/src/read_lat.c +@@ -54,6 +54,7 @@ + int main(int argc, char *argv[]) + { + int ret_parser,i = 0; ++ int ret_val = FAILURE; + struct report_options report; + struct pingpong_context ctx; + struct ibv_device *ib_dev; +@@ -95,7 +96,7 @@ int main(int argc, char *argv[]) + ctx.context = ibv_open_device(ib_dev); + if (!ctx.context) { + fprintf(stderr, " Couldn't get context for the device\n"); +- return 1; ++ return FAILURE; + } + + /* See if MTU and link type are valid and supported. */ +@@ -107,7 +108,7 @@ int main(int argc, char *argv[]) + /* copy the relevant user parameters to the comm struct + creating rdma_cm resources. */ + if (create_comm_struct(&user_comm,&user_param)) { + fprintf(stderr," Unable to create RDMA_CM resources\n"); +- return 1; ++ return FAILURE; + } + + if (user_param.output == FULL_VERBOSITY && user_param.machine == SERVER) { +@@ -146,17 +147,17 @@ int main(int argc, char *argv[]) + if (user_param.machine == CLIENT) { + if (retry_rdma_connect(&ctx,&user_param)) { + fprintf(stderr,"Unable to perform rdma_client function\n"); +- return FAILURE; ++ goto fail_free_dests; + } + + } else { + if (create_rdma_resources(&ctx,&user_param)) { + fprintf(stderr," Unable to create the rdma_resources\n"); +- return FAILURE; ++ goto fail_free_dests; + } + if (rdma_server_connect(&ctx,&user_param)) { + fprintf(stderr,"Unable to perform rdma_client function\n"); +- return FAILURE; ++ goto fail_free_dests; + } + } + +@@ -165,14 +166,14 @@ int main(int argc, char *argv[]) + /* create all the basic IB resources (data buffer, PD, MR, CQ and events channel) */ + if (ctx_init(&ctx,&user_param)) { + fprintf(stderr, " Couldn't create IB resources\n"); +- return FAILURE; ++ goto fail_free_dests; + } + } + + /* Set up the Connection. */ + if (set_up_connection(&ctx,&user_param,my_dest)) { + fprintf(stderr," Unable to set up socket connection\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + /* Print basic test information. */ +@@ -184,7 +185,7 @@ int main(int argc, char *argv[]) + /* shaking hands and gather the other side info. */ + if (ctx_hand_shake(&user_comm,my_dest,rem_dest)) { + fprintf(stderr,"Failed to exchange data between server and clients\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + user_comm.rdma_params->side = REMOTE; +@@ -193,7 +194,7 @@ int main(int argc, char *argv[]) + /* shaking hands and gather the other side info. */ + if (ctx_hand_shake(&user_comm,&my_dest[i],&rem_dest[i])) { + fprintf(stderr,"Failed to exchange data between server and clients\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + ctx_print_pingpong_data(&rem_dest[i],&user_comm); +@@ -203,7 +204,7 @@ int main(int argc, char *argv[]) + if (ctx_check_gid_compatibility(&my_dest[0], &rem_dest[0])) { + fprintf(stderr,"\n Found Incompatibility issue with GID types.\n"); + fprintf(stderr," Please Try to use a different IP version.\n\n"); +- return 1; ++ goto fail_destroy_ctx; + } + } + +@@ -211,14 +212,14 @@ int main(int argc, char *argv[]) + + if (ctx_connect(&ctx,rem_dest,&user_param,my_dest)) { + fprintf(stderr," Unable to Connect the HCA's through the link\n"); +- return 1; ++ goto fail_destroy_ctx; + } + } + + /* An additional handshake is required after moving qp to RTR. */ + if (ctx_hand_shake(&user_comm,my_dest,rem_dest)) { + fprintf(stderr,"Failed to exchange data between server and clients\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + /* Only Client post read request. */ +@@ -226,19 +227,19 @@ int main(int argc, char *argv[]) + + if (ctx_close_connection(&user_comm,my_dest,rem_dest)) { + fprintf(stderr,"Failed to close connection between server and client\n"); +- return 1; ++ goto fail_destroy_ctx; + } + if (user_param.output == FULL_VERBOSITY) { + printf(RESULT_LINE); + } +- return 0; ++ goto out_success; + + } + + if (user_param.use_event) { + if (ibv_req_notify_cq(ctx.send_cq, 0)) { + fprintf(stderr, "Couldn't request CQ notification\n"); +- return 1; ++ goto fail_destroy_ctx; + } + } + +@@ -253,25 +254,37 @@ int main(int argc, char *argv[]) + if (user_param.test_method == RUN_ALL) { + for (i = 1; i < 24 ; ++i) { + user_param.size = (uint64_t)1 << i; +- if(run_iter_lat(&ctx,&user_param)) +- return 17; ++ if(run_iter_lat(&ctx,&user_param)) { ++ ret_val = 17; ++ goto fail_destroy_ctx; ++ } + + user_param.test_type == ITERATIONS ? print_report_lat(&user_param) : print_report_lat_duration(&user_param); + } + } else { +- if(run_iter_lat(&ctx,&user_param)) +- return 18; ++ if(run_iter_lat(&ctx,&user_param)) { ++ ret_val = 18; ++ goto fail_destroy_ctx; ++ } + + user_param.test_type == ITERATIONS ? print_report_lat(&user_param) : print_report_lat_duration(&user_param); + } + + if (ctx_close_connection(&user_comm,my_dest,rem_dest)) { + fprintf(stderr,"Failed to close connection between server and client\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + if (user_param.output == FULL_VERBOSITY) { + printf(RESULT_LINE); + } +- return 0; ++ ++out_success: ++ ret_val = 0; ++fail_destroy_ctx: ++ destroy_ctx(&ctx, &user_param); ++fail_free_dests: ++ free(my_dest); ++ free(rem_dest); ++ return ret_val; + } +diff --git a/src/send_bw.c b/src/send_bw.c +index b018aa1..18b2351 100755 +--- a/src/send_bw.c ++++ b/src/send_bw.c +@@ -162,6 +162,7 @@ int main(int argc, char *argv[]) + struct bw_report_data my_bw_rep, rem_bw_rep; + int ret_parser,i = 0; + int size_max_pow = 24; ++ int ret_val = FAILURE; + + /* init default values to user's parameters */ + memset(&ctx, 0,sizeof(struct pingpong_context)); +@@ -178,7 +179,7 @@ int main(int argc, char *argv[]) + if (ret_parser) { + if (ret_parser != VERSION_EXIT && ret_parser != HELP_EXIT) + fprintf(stderr," Parser function exited with Error\n"); +- return 1; ++ return ret_val; + } + if((user_param.connection_type == DC || user_param.use_xrc) && user_param.duplex) { + user_param.num_of_qps *= 2; +@@ -187,14 +188,14 @@ int main(int argc, char *argv[]) + if (user_param.connection_type == RawEth) { + fprintf(stderr," This test cannot run Raw Ethernet QPs (you have chosen RawEth as connection type\n"); + fprintf(stderr," For this we have raw_ethernet_bw test in this package.\n"); +- return FAILURE; ++ return ret_val; + } + + /* Finding the IB device selected (or defalut if no selected). */ + ib_dev = ctx_find_dev(user_param.ib_devname); + if (!ib_dev) { + fprintf(stderr," Unable to find the Infiniband/RoCE device\n"); +- return 1; ++ return ret_val; + } + + if (user_param.use_mcg) +@@ -204,20 +205,20 @@ int main(int argc, char *argv[]) + ctx.context = ibv_open_device(ib_dev); + if (!ctx.context) { + fprintf(stderr, " Couldn't get context for the device\n"); +- return 1; ++ goto fail_free_ib_devname; + } + + + /* See if MTU and link type are valid and supported. */ + if (check_link(ctx.context,&user_param)) { + fprintf(stderr, " Couldn't get context for the device\n"); +- return FAILURE; ++ goto fail_free_ib_devname; + } + + /* copy the relevant user parameters to the comm struct + creating rdma_cm resources. */ + if (create_comm_struct(&user_comm,&user_param)) { + fprintf(stderr," Unable to create RDMA_CM resources\n"); +- return 1; ++ goto fail_free_ib_devname; + } + + if (user_param.output == FULL_VERBOSITY && user_param.machine == SERVER) { +@@ -229,7 +230,7 @@ int main(int argc, char *argv[]) + /* Initialize the connection and print the local data. */ + if (establish_connection(&user_comm)) { + fprintf(stderr," Unable to init the socket connection\n"); +- return FAILURE; ++ goto fail_free_ib_devname; + } + + exchange_versions(&user_comm, &user_param); +@@ -239,7 +240,7 @@ int main(int argc, char *argv[]) + /* See if MTU and link type are valid and supported. */ + if (check_mtu(ctx.context,&user_param, &user_comm)) { + fprintf(stderr, " Couldn't get context for the device\n"); +- return FAILURE; ++ goto fail_free_ib_devname; + } + + ALLOCATE(my_dest , struct pingpong_dest , user_param.num_of_qps); +@@ -259,17 +260,17 @@ int main(int argc, char *argv[]) + if (user_param.machine == CLIENT) { + if (retry_rdma_connect(&ctx,&user_param)) { + fprintf(stderr,"Unable to perform rdma_client function\n"); +- return FAILURE; ++ goto fail_free_dests; + } + + } else { + if (create_rdma_resources(&ctx,&user_param)) { + fprintf(stderr," Unable to create the rdma_resources\n"); +- return FAILURE; ++ goto fail_free_dests; + } + if (rdma_server_connect(&ctx,&user_param)) { + fprintf(stderr,"Unable to perform rdma_client function\n"); +- return FAILURE; ++ goto fail_free_dests; + } + } + +@@ -278,14 +279,14 @@ int main(int argc, char *argv[]) + /* create all the basic IB resources (data buffer, PD, MR, CQ and events channel) */ + if (ctx_init(&ctx,&user_param)) { + fprintf(stderr, " Couldn't create IB resources\n"); +- return FAILURE; ++ goto fail_free_dests; + } + } + + /* Set up the Connection. */ + if (send_set_up_connection(&ctx,&user_param,my_dest,&mcg_params,&user_comm)) { + fprintf(stderr," Unable to set up socket connection\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + /* Print basic test information. */ +@@ -303,7 +304,7 @@ int main(int argc, char *argv[]) + /* shaking hands and gather the other side info. */ + if (ctx_hand_shake(&user_comm,&my_dest[i],&rem_dest[i])) { + fprintf(stderr,"Failed to exchange data between server and clients\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + ctx_print_pingpong_data(&rem_dest[i],&user_comm); +@@ -313,7 +314,7 @@ int main(int argc, char *argv[]) + if (ctx_check_gid_compatibility(&my_dest[0], &rem_dest[0])) { + fprintf(stderr,"\n Found Incompatibility issue with GID types.\n"); + fprintf(stderr," Please Try to use a different IP version.\n\n"); +- return 1; ++ goto fail_destroy_ctx; + } + } + +@@ -330,7 +331,7 @@ int main(int argc, char *argv[]) + memcpy(mcg_params.mgid.raw, rem_dest[0].gid.raw, 16); + if (set_mcast_group(&ctx,&user_param,&mcg_params)) { + fprintf(stderr," Unable to Join Sender to Mcast gid\n"); +- return 1; ++ goto fail_destroy_ctx; + } + /* + * The next stall in code (50 ms sleep) is a work around for fixing the +@@ -349,26 +350,26 @@ int main(int argc, char *argv[]) + /* Prepare IB resources for rtr/rts. */ + if (ctx_connect(&ctx,rem_dest,&user_param,my_dest)) { + fprintf(stderr," Unable to Connect the HCA's through the link\n"); +- return 1; ++ goto fail_destroy_ctx; + } + } + + /* shaking hands and gather the other side info. */ + if (ctx_hand_shake(&user_comm,&my_dest[0],&rem_dest[0])) { + fprintf(stderr,"Failed to exchange data between server and clients\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + if (user_param.use_event) { + + if (ibv_req_notify_cq(ctx.send_cq, 0)) { + fprintf(stderr, " Couldn't request CQ notification\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + if (ibv_req_notify_cq(ctx.recv_cq, 0)) { + fprintf(stderr, " Couldn't request CQ notification\n"); +- return 1; ++ goto fail_destroy_ctx; + } + } + +@@ -399,13 +400,13 @@ int main(int argc, char *argv[]) + if (user_param.machine == SERVER || user_param.duplex) { + if (ctx_set_recv_wqes(&ctx,&user_param)) { + fprintf(stderr," Failed to post receive recv_wqes\n"); +- return 1; ++ goto fail_destroy_ctx; + } + } + + if (ctx_hand_shake(&user_comm,&my_dest[0],&rem_dest[0])) { + fprintf(stderr,"Failed to exchange data between server and clients\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + if (ctx.send_rcredit) { +@@ -415,19 +416,23 @@ int main(int argc, char *argv[]) + } + + if (user_param.duplex) { +- if(run_iter_bi(&ctx,&user_param)) +- return 17; ++ if(run_iter_bi(&ctx,&user_param)) { ++ ret_val = 17; ++ goto fail_destroy_ctx; ++ } + + } else if (user_param.machine == CLIENT) { + + if(run_iter_bw(&ctx,&user_param)) { +- return 17; ++ ret_val = 17; ++ goto fail_destroy_ctx; + } + + } else { + + if(run_iter_bw_server(&ctx,&user_param)) { +- return 17; ++ ret_val = 17; ++ goto fail_destroy_ctx; + } + } + +@@ -439,7 +444,7 @@ int main(int argc, char *argv[]) + } + if (ctx_hand_shake(&user_comm,&my_dest[0],&rem_dest[0])) { + fprintf(stderr,"Failed to exchange data between server and clients\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + /* Check if last iteration ended well in UC/UD */ +@@ -456,29 +461,33 @@ int main(int argc, char *argv[]) + if (user_param.machine == SERVER || user_param.duplex) { + if (ctx_set_recv_wqes(&ctx,&user_param)) { + fprintf(stderr," Failed to post receive recv_wqes\n"); +- return 1; ++ goto fail_destroy_ctx; + } + } + + if (ctx_hand_shake(&user_comm,&my_dest[0],&rem_dest[0])) { + fprintf(stderr,"Failed to exchange data between server and clients\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + if (user_param.duplex) { + +- if(run_iter_bi(&ctx,&user_param)) +- return 17; ++ if(run_iter_bi(&ctx,&user_param)) { ++ ret_val = 17; ++ goto fail_destroy_ctx; ++ } + + } else if (user_param.machine == CLIENT) { + + if(run_iter_bw(&ctx,&user_param)) { +- return 17; ++ ret_val = 17; ++ goto fail_destroy_ctx; + } + + } else if(run_iter_bw_server(&ctx,&user_param)) { + +- return 17; ++ ret_val = 17; ++ goto fail_destroy_ctx; + } + + print_report_bw(&user_param,&my_bw_rep); +@@ -512,27 +521,27 @@ int main(int argc, char *argv[]) + + if (ctx_set_recv_wqes(&ctx,&user_param)) { + fprintf(stderr," Failed to post receive recv_wqes\n"); +- return 1; ++ goto fail_destroy_ctx; + } + } + + if (ctx_hand_shake(&user_comm,&my_dest[0],&rem_dest[0])) { + fprintf(stderr,"Failed to exchange data between server and clients\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + if (user_param.machine == CLIENT) { + + if(run_iter_bw_infinitely(&ctx,&user_param)) { + fprintf(stderr," Error occured while running infinitely! aborting ...\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + } else if (user_param.machine == SERVER) { + + if(run_iter_bw_infinitely_server(&ctx,&user_param)) { + fprintf(stderr," Error occured while running infinitely on server! aborting ...\n"); +- return 1; ++ goto fail_destroy_ctx; + } + } + } +@@ -552,25 +561,34 @@ int main(int argc, char *argv[]) + /* Destory all test resources, including Mcast if exists */ + if (send_destroy_ctx(&ctx,&user_param,&mcg_params)) { + fprintf(stderr,"Couldn't Destory all SEND resources\n"); +- return FAILURE; ++ goto fail_destroy_ctx; + } + if (user_param.work_rdma_cm == ON) { + user_comm.rdma_params->work_rdma_cm = ON; + if (destroy_ctx(user_comm.rdma_ctx,user_comm.rdma_params)) { + fprintf(stderr,"Failed to destroy resources\n"); +- return 1; ++ goto fail_destroy_ctx; + } + } + + if (!user_param.is_bw_limit_passed && (user_param.is_limit_bw == ON ) ) { + fprintf(stderr,"Error: BW result is below bw limit\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + if (!user_param.is_msgrate_limit_passed && (user_param.is_limit_bw == ON )) { + fprintf(stderr,"Error: Msg rate is below msg_rate limit\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + return 0; ++ ++fail_destroy_ctx: ++ destroy_ctx(&ctx,&user_param); ++fail_free_dests: ++ free(my_dest); ++ free(rem_dest); ++fail_free_ib_devname: ++ free(mcg_params.ib_devname); ++ return ret_val; + } +diff --git a/src/send_lat.c b/src/send_lat.c +index 282cf11..88dd00c 100755 +--- a/src/send_lat.c ++++ b/src/send_lat.c +@@ -205,9 +205,11 @@ int main(int argc, char *argv[]) + if (ret_val) { + if (ret_val != VERSION_EXIT && ret_val != HELP_EXIT) + fprintf(stderr," Parser function exited with Error\n"); +- return 1; ++ return FAILURE; + } + ++ ret_val = FAILURE; ++ + if(user_param.use_xrc || user_param.connection_type == DC) { + user_param.num_of_qps *= 2; + } +@@ -215,14 +217,14 @@ int main(int argc, char *argv[]) + /* Checking that the user did not run with RawEth. for this we have raw_etherent_bw test. */ + if (user_param.connection_type == RawEth) { + fprintf(stderr," This test cannot run Raw Ethernet QPs (you have chosen RawEth as connection type\n"); +- return FAILURE; ++ return ret_val; + } + + /* Finding the IB device selected (or defalut if no selected). */ + ib_dev = ctx_find_dev(user_param.ib_devname); + if (!ib_dev) { + fprintf(stderr," Unable to find the Infiniband/RoCE device\n"); +- return 1; ++ return ret_val; + } + + if (user_param.use_mcg) +@@ -232,19 +234,19 @@ int main(int argc, char *argv[]) + ctx.context = ibv_open_device(ib_dev); + if (!ctx.context) { + fprintf(stderr, " Couldn't get context for the device\n"); +- return 1; ++ goto fail_free_ib_devname; + } + + /* See if MTU and link type are valid and supported. */ + if (check_link(ctx.context,&user_param)) { + fprintf(stderr, " Couldn't get context for the device\n"); +- return FAILURE; ++ goto fail_free_ib_devname; + } + + /* copy the relevant user parameters to the comm struct + creating rdma_cm resources. */ + if (create_comm_struct(&user_comm,&user_param)) { + fprintf(stderr," Unable to create RDMA_CM resources\n"); +- return 1; ++ goto fail_free_ib_devname; + } + + if (user_param.output == FULL_VERBOSITY && user_param.machine == SERVER) { +@@ -256,7 +258,7 @@ int main(int argc, char *argv[]) + /* Initialize the connection and print the local data. */ + if (establish_connection(&user_comm)) { + fprintf(stderr," Unable to init the socket connection\n"); +- return FAILURE; ++ goto fail_free_ib_devname; + } + + exchange_versions(&user_comm, &user_param); +@@ -266,7 +268,7 @@ int main(int argc, char *argv[]) + /* See if MTU and link type are valid and supported. */ + if (check_mtu(ctx.context,&user_param, &user_comm)) { + fprintf(stderr, " Couldn't get context for the device\n"); +- return FAILURE; ++ goto fail_free_ib_devname; + } + + ALLOCATE(my_dest , struct pingpong_dest , user_param.num_of_qps); +@@ -283,17 +285,17 @@ int main(int argc, char *argv[]) + if (user_param.machine == CLIENT) { + if (retry_rdma_connect(&ctx,&user_param)) { + fprintf(stderr,"Unable to perform rdma_client function\n"); +- return FAILURE; ++ goto fail_free_dests; + } + + } else { + if (create_rdma_resources(&ctx,&user_param)) { + fprintf(stderr," Unable to create the rdma_resources\n"); +- return FAILURE; ++ goto fail_free_dests; + } + if (rdma_server_connect(&ctx,&user_param)) { + fprintf(stderr,"Unable to perform rdma_client function\n"); +- return FAILURE; ++ goto fail_free_dests; + } + } + +@@ -302,14 +304,14 @@ int main(int argc, char *argv[]) + /* create all the basic IB resources (data buffer, PD, MR, CQ and events channel) */ + if (ctx_init(&ctx,&user_param)) { + fprintf(stderr, " Couldn't create IB resources\n"); +- return FAILURE; ++ goto fail_free_dests; + } + } + + /* Set up the Connection. */ + if (send_set_up_connection(&ctx,&user_param,my_dest,&mcg_params,&user_comm)) { + fprintf(stderr," Unable to set up socket connection\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + /* Print basic test information. */ +@@ -324,7 +326,7 @@ int main(int argc, char *argv[]) + /* shaking hands and gather the other side info. */ + if (ctx_hand_shake(&user_comm,&my_dest[i],&rem_dest[i])) { + fprintf(stderr,"Failed to exchange data between server and clients\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + ctx_print_pingpong_data(&rem_dest[i],&user_comm); +@@ -334,7 +336,7 @@ int main(int argc, char *argv[]) + if (ctx_check_gid_compatibility(&my_dest[0], &rem_dest[0])) { + fprintf(stderr,"\n Found Incompatibility issue with GID types.\n"); + fprintf(stderr," Please Try to use a different IP version.\n\n"); +- return 1; ++ goto fail_destroy_ctx; + } + } + +@@ -348,7 +350,7 @@ int main(int argc, char *argv[]) + /* Request for Mcast group create registery in SM. */ + if (join_multicast_group(SUBN_ADM_METHOD_SET,&mcg_params)) { + fprintf(stderr," Failed to Join Mcast request\n"); +- return 1; ++ goto fail_destroy_ctx; + } + } + +@@ -369,26 +371,26 @@ int main(int argc, char *argv[]) + /* Prepare IB resources for rtr/rts. */ + if (ctx_connect(&ctx,rem_dest,&user_param,my_dest)) { + fprintf(stderr," Unable to Connect the HCA's through the link\n"); +- return 1; ++ goto fail_destroy_ctx; + } + } + + /* shaking hands and gather the other side info. */ + if (ctx_hand_shake(&user_comm,&my_dest[0],&rem_dest[0])) { + fprintf(stderr,"Failed to exchange data between server and clients\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + if (user_param.use_event) { + + if (ibv_req_notify_cq(ctx.send_cq, 0)) { + fprintf(stderr, "Couldn't request RCQ notification\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + if (ibv_req_notify_cq(ctx.recv_cq, 0)) { + fprintf(stderr, "Couldn't request RCQ notification\n"); +- return 1; ++ goto fail_destroy_ctx; + } + } + if (user_param.output == FULL_VERBOSITY) { +@@ -411,7 +413,7 @@ int main(int argc, char *argv[]) + /* Post receive recv_wqes fo current message size */ + if (ctx_set_recv_wqes(&ctx,&user_param)) { + fprintf(stderr," Failed to post receive recv_wqes\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + /* Sync between the client and server so the client won't send packets +@@ -420,11 +422,13 @@ int main(int argc, char *argv[]) + + if (ctx_hand_shake(&user_comm,&my_dest[0],&rem_dest[0])) { + fprintf(stderr,"Failed to exchange data between server and clients\n"); +- return 1; ++ goto fail_destroy_ctx; + } + +- if(run_iter_lat_send(&ctx, &user_param)) +- return 17; ++ if(run_iter_lat_send(&ctx, &user_param)) { ++ ret_val = 17; ++ goto fail_destroy_ctx; ++ } + + user_param.test_type == ITERATIONS ? print_report_lat(&user_param) : print_report_lat_duration(&user_param); + } +@@ -434,7 +438,7 @@ int main(int argc, char *argv[]) + /* Post recevie recv_wqes fo current message size */ + if (ctx_set_recv_wqes(&ctx,&user_param)) { + fprintf(stderr," Failed to post receive recv_wqes\n"); +- return 1; ++ goto fail_destroy_ctx; + } + + /* Sync between the client and server so the client won't send packets +@@ -443,11 +447,13 @@ int main(int argc, char *argv[]) + + if (ctx_hand_shake(&user_comm,my_dest,rem_dest)) { + fprintf(stderr,"Failed to exchange data between server and clients\n"); +- return 1; ++ goto fail_destroy_ctx; + } + +- if(run_iter_lat_send(&ctx, &user_param)) +- return 17; ++ if(run_iter_lat_send(&ctx, &user_param)) { ++ ret_val = 17; ++ goto fail_destroy_ctx; ++ } + + user_param.test_type == ITERATIONS ? print_report_lat(&user_param) : print_report_lat_duration(&user_param); + } +@@ -462,4 +468,13 @@ int main(int argc, char *argv[]) + } + + return send_destroy_ctx(&ctx,&user_param,&mcg_params); ++ ++fail_destroy_ctx: ++ destroy_ctx(&ctx,&user_param); ++fail_free_dests: ++ free(my_dest); ++ free(rem_dest); ++fail_free_ib_devname: ++ free(mcg_params.ib_devname); ++ return ret_val; + } +diff --git a/src/write_bw.c b/src/write_bw.c +index 63422a8..1ee426c 100755 +--- a/src/write_bw.c ++++ b/src/write_bw.c +@@ -48,6 +48,7 @@ + int main(int argc, char *argv[]) + { + int ret_parser,i = 0; ++ int ret_val = FAILURE; + struct ibv_device *ib_dev = NULL; + struct pingpong_context ctx; + struct pingpong_dest *my_dest,*rem_dest; +@@ -69,7 +70,7 @@ int main(int argc, char *argv[]) + if (ret_parser) { + if (ret_parser != VERSION_EXIT && ret_parser != HELP_EXIT) + fprintf(stderr," Parser function exited with Error\n"); +- return 1; ++ return FAILURE; + } + + if((user_param.connection_type == DC || user_param.use_xrc) && user_param.duplex) { +@@ -80,14 +81,14 @@ int main(int argc, char *argv[]) + ib_dev = ctx_find_dev(user_param.ib_devname); + if (!ib_dev) { + fprintf(stderr," Unable to find the Infiniband/RoCE device\n"); +- return 1; ++ return FAILURE; + } + + /* Getting the relevant context from the device */ + ctx.context = ibv_open_device(ib_dev); + if (!ctx.context) { + fprintf(stderr, " Couldn't get context for the device\n"); +- return 1; ++ return FAILURE; + } + + /* See if MTU and link type are valid and supported. */ +@@ -99,7 +100,7 @@ int main(int argc, char *argv[]) + /* copy the relevant user parameters to the comm struct + creating rdma_cm resources. */ + if (create_comm_struct(&user_comm,&user_param)) { + fprintf(stderr," Unable to create RDMA_CM resources\n"); +- return 1; ++ return FAILURE; + } + + if (user_param.output == FULL_VERBOSITY && user_param.machine == SERVER) { +@@ -138,17 +139,17 @@ int main(int argc, char *argv[]) + if (user_param.machine == CLIENT) { + if (retry_rdma_connect(&ctx,&user_param)) { + fprintf(stderr,"Unable to perform rdma_client function\n"); +- return FAILURE; ++ goto free_dests; + } + + } else { + if (create_rdma_resources(&ctx,&user_param)) { + fprintf(stderr," Unable to create the rdma_resources\n"); +- return FAILURE; ++ goto free_dests; + } + if (rdma_server_connect(&ctx,&user_param)) { + fprintf(stderr,"Unable to perform rdma_client function\n"); +- return FAILURE; ++ goto free_dests; + } + } + +@@ -157,14 +158,14 @@ int main(int argc, char *argv[]) + /* create all the basic IB resources (data buffer, PD, MR, CQ and events channel) */ + if (ctx_init(&ctx, &user_param)) { + fprintf(stderr, " Couldn't create IB resources\n"); +- return FAILURE; ++ goto free_dests; + } + } + + /* Set up the Connection. */ + if (set_up_connection(&ctx,&user_param,my_dest)) { + fprintf(stderr," Unable to set up socket connection\n"); +- return FAILURE; ++ goto destroy_ctx; + } + + /* Print basic test information. */ +@@ -181,7 +182,7 @@ int main(int argc, char *argv[]) + + if (ctx_hand_shake(&user_comm,&my_dest[i],&rem_dest[i])) { + fprintf(stderr," Failed to exchange data between server and clients\n"); +- return 1; ++ goto destroy_ctx; + } + + ctx_print_pingpong_data(&rem_dest[i],&user_comm); +@@ -191,21 +192,21 @@ int main(int argc, char *argv[]) + if (ctx_check_gid_compatibility(&my_dest[0], &rem_dest[0])) { + fprintf(stderr,"\n Found Incompatibility issue with GID types.\n"); + fprintf(stderr," Please Try to use a different IP version.\n\n"); +- return 1; ++ goto destroy_ctx; + } + } + + if (user_param.work_rdma_cm == OFF) { + if (ctx_connect(&ctx,rem_dest,&user_param,my_dest)) { + fprintf(stderr," Unable to Connect the HCA's through the link\n"); +- return FAILURE; ++ goto destroy_ctx; + } + } + + /* An additional handshake is required after moving qp to RTR. */ + if (ctx_hand_shake(&user_comm,&my_dest[0],&rem_dest[0])) { + fprintf(stderr," Failed to exchange data between server and clients\n"); +- return FAILURE; ++ goto destroy_ctx; + } + + if (user_param.output == FULL_VERBOSITY) { +@@ -226,7 +227,7 @@ int main(int argc, char *argv[]) + + if (ctx_hand_shake(&user_comm,&my_dest[0],&rem_dest[0])) { + fprintf(stderr," Failed to exchange data between server and clients\n"); +- return FAILURE; ++ goto destroy_ctx; + } + + xchg_bw_reports(&user_comm, &my_bw_rep,&rem_bw_rep,atof(user_param.rem_version)); +@@ -234,7 +235,7 @@ int main(int argc, char *argv[]) + + if (ctx_close_connection(&user_comm,&my_dest[0],&rem_dest[0])) { + fprintf(stderr,"Failed to close connection between server and client\n"); +- return 1; ++ goto destroy_ctx; + } + + if (user_param.output == FULL_VERBOSITY) { +@@ -247,13 +248,15 @@ int main(int argc, char *argv[]) + if (user_param.work_rdma_cm == ON) { + if (destroy_ctx(&ctx,&user_param)) { + fprintf(stderr, "Failed to destroy resources\n"); +- return 1; ++ goto free_dests; + } + user_comm.rdma_params->work_rdma_cm = ON; +- return destroy_ctx(user_comm.rdma_ctx,user_comm.rdma_params); ++ ret_val = destroy_ctx(user_comm.rdma_ctx,user_comm.rdma_params); ++ goto free_dests; + } + +- return destroy_ctx(&ctx,&user_param); ++ ret_val = destroy_ctx(&ctx,&user_param); ++ goto free_dests; + } + + if (user_param.test_method == RUN_ALL) { +@@ -265,25 +268,25 @@ int main(int argc, char *argv[]) + + if(perform_warm_up(&ctx,&user_param)) { + fprintf(stderr,"Problems with warm up\n"); +- return 1; ++ goto destroy_ctx; + } + + if(user_param.duplex) { + if (ctx_hand_shake(&user_comm,&my_dest[0],&rem_dest[0])) { + fprintf(stderr,"Failed to sync between server and client between different msg sizes\n"); +- return 1; ++ goto destroy_ctx; + } + } + + if(run_iter_bw(&ctx,&user_param)) { + fprintf(stderr," Failed to complete run_iter_bw function successfully\n"); +- return 1; ++ goto destroy_ctx; + } + + if (user_param.duplex && (atof(user_param.version) >= 4.6)) { + if (ctx_hand_shake(&user_comm,&my_dest[0],&rem_dest[0])) { + fprintf(stderr,"Failed to sync between server and client between different msg sizes\n"); +- return 1; ++ goto destroy_ctx; + } + } + +@@ -302,20 +305,20 @@ int main(int argc, char *argv[]) + if (user_param.verb != SEND) { + if(perform_warm_up(&ctx,&user_param)) { + fprintf(stderr,"Problems with warm up\n"); +- return 1; ++ goto destroy_ctx; + } + } + + if(user_param.duplex) { + if (ctx_hand_shake(&user_comm,&my_dest[0],&rem_dest[0])) { + fprintf(stderr,"Failed to sync between server and client between different msg sizes\n"); +- return 1; ++ goto destroy_ctx; + } + } + + if(run_iter_bw(&ctx,&user_param)) { + fprintf(stderr," Failed to complete run_iter_bw function successfully\n"); +- return 1; ++ goto destroy_ctx; + } + + print_report_bw(&user_param,&my_bw_rep); +@@ -346,7 +349,7 @@ int main(int argc, char *argv[]) + + if(run_iter_bw_infinitely(&ctx,&user_param)) { + fprintf(stderr," Error occured while running infinitely! aborting ...\n"); +- return 1; ++ goto destroy_ctx; + } + } + +@@ -362,7 +365,7 @@ int main(int argc, char *argv[]) + + if (ctx_hand_shake(&user_comm,&my_dest[0],&rem_dest[0])) { + fprintf(stderr," Failed to exchange data between server and clients\n"); +- return FAILURE; ++ goto destroy_ctx; + } + + xchg_bw_reports(&user_comm, &my_bw_rep,&rem_bw_rep,atof(user_param.rem_version)); +@@ -371,30 +374,36 @@ int main(int argc, char *argv[]) + /* Closing connection. */ + if (ctx_close_connection(&user_comm,&my_dest[0],&rem_dest[0])) { + fprintf(stderr,"Failed to close connection between server and client\n"); +- return 1; ++ goto destroy_ctx; + } + + if (!user_param.is_bw_limit_passed && (user_param.is_limit_bw == ON ) ) { + fprintf(stderr,"Error: BW result is below bw limit\n"); +- return 1; ++ goto destroy_ctx; + } + + if (!user_param.is_msgrate_limit_passed && (user_param.is_limit_bw == ON )) { + fprintf(stderr,"Error: Msg rate is below msg_rate limit\n"); +- return 1; ++ goto destroy_ctx; + } + +- free(my_dest); +- free(rem_dest); +- + if (user_param.work_rdma_cm == ON) { + if (destroy_ctx(&ctx,&user_param)) { + fprintf(stderr, "Failed to destroy resources\n"); +- return 1; ++ goto free_dests; + } + user_comm.rdma_params->work_rdma_cm = ON; +- return destroy_ctx(user_comm.rdma_ctx,user_comm.rdma_params); ++ ret_val = destroy_ctx(user_comm.rdma_ctx,user_comm.rdma_params); ++ goto free_dests; + } + +- return destroy_ctx(&ctx,&user_param); ++ ret_val = destroy_ctx(&ctx,&user_param); ++ goto free_dests; ++ ++destroy_ctx: ++ destroy_ctx(&ctx, &user_param); ++free_dests: ++ free(my_dest); ++ free(rem_dest); ++ return ret_val; + } +diff --git a/src/write_lat.c b/src/write_lat.c +index 4cb3e36..232ca14 100755 +--- a/src/write_lat.c ++++ b/src/write_lat.c +@@ -54,6 +54,7 @@ + int main(int argc, char *argv[]) + { + int ret_parser,i = 0; ++ int ret_val = FAILURE; + struct report_options report; + struct pingpong_context ctx; + struct pingpong_dest *my_dest = NULL; +@@ -95,7 +96,7 @@ int main(int argc, char *argv[]) + ctx.context = ibv_open_device(ib_dev); + if (!ctx.context) { + fprintf(stderr, " Couldn't get context for the device\n"); +- return 1; ++ return FAILURE; + } + + /* See if MTU and link type are valid and supported. */ +@@ -107,7 +108,7 @@ int main(int argc, char *argv[]) + /* copy the relevant user parameters to the comm struct + creating rdma_cm resources. */ + if (create_comm_struct(&user_comm,&user_param)) { + fprintf(stderr," Unable to create RDMA_CM resources\n"); +- return 1; ++ return FAILURE; + } + + if (user_param.output == FULL_VERBOSITY && user_param.machine == SERVER) { +@@ -146,17 +147,17 @@ int main(int argc, char *argv[]) + if (user_param.machine == CLIENT) { + if (retry_rdma_connect(&ctx,&user_param)) { + fprintf(stderr,"Unable to perform rdma_client function\n"); +- return FAILURE; ++ goto free_dests; + } + + } else { + if (create_rdma_resources(&ctx,&user_param)) { + fprintf(stderr," Unable to create the rdma_resources\n"); +- return FAILURE; ++ goto free_dests; + } + if (rdma_server_connect(&ctx,&user_param)) { + fprintf(stderr,"Unable to perform rdma_client function\n"); +- return FAILURE; ++ goto free_dests; + } + } + +@@ -165,14 +166,14 @@ int main(int argc, char *argv[]) + /* create all the basic IB resources (data buffer, PD, MR, CQ and events channel) */ + if (ctx_init(&ctx,&user_param)) { + fprintf(stderr, " Couldn't create IB resources\n"); +- return FAILURE; ++ goto free_dests; + } + } + + /* Set up the Connection. */ + if (set_up_connection(&ctx,&user_param,my_dest)) { + fprintf(stderr," Unable to set up socket connection\n"); +- return 1; ++ goto destroy_ctx; + } + + /* Print basic test information. */ +@@ -184,7 +185,7 @@ int main(int argc, char *argv[]) + /* shaking hands and gather the other side info. */ + if (ctx_hand_shake(&user_comm,my_dest,rem_dest)) { + fprintf(stderr,"Failed to exchange data between server and clients\n"); +- return 1; ++ goto destroy_ctx; + } + + user_comm.rdma_params->side = REMOTE; +@@ -193,7 +194,7 @@ int main(int argc, char *argv[]) + /* shaking hands and gather the other side info. */ + if (ctx_hand_shake(&user_comm,&my_dest[i],&rem_dest[i])) { + fprintf(stderr,"Failed to exchange data between server and clients\n"); +- return 1; ++ goto destroy_ctx; + } + + ctx_print_pingpong_data(&rem_dest[i],&user_comm); +@@ -203,21 +204,21 @@ int main(int argc, char *argv[]) + if (ctx_check_gid_compatibility(&my_dest[0], &rem_dest[0])) { + fprintf(stderr,"\n Found Incompatibility issue with GID types.\n"); + fprintf(stderr," Please Try to use a different IP version.\n\n"); +- return 1; ++ goto destroy_ctx; + } + } + + if (user_param.work_rdma_cm == OFF) { + if (ctx_connect(&ctx,rem_dest,&user_param,my_dest)) { + fprintf(stderr," Unable to Connect the HCA's through the link\n"); +- return 1; ++ goto destroy_ctx; + } + } + + /* An additional handshake is required after moving qp to RTR. */ + if (ctx_hand_shake(&user_comm,my_dest,rem_dest)) { + fprintf(stderr,"Failed to exchange data between server and clients\n"); +- return 1; ++ goto destroy_ctx; + } + + ctx_set_send_wqes(&ctx,&user_param,rem_dest); +@@ -234,7 +235,7 @@ int main(int argc, char *argv[]) + user_param.size = (uint64_t)1 << i; + if(run_iter_lat_write(&ctx,&user_param)) { + fprintf(stderr,"Test exited with Error\n"); +- return FAILURE; ++ goto destroy_ctx; + } + + user_param.test_type == ITERATIONS ? print_report_lat(&user_param) : print_report_lat_duration(&user_param); +@@ -244,7 +245,7 @@ int main(int argc, char *argv[]) + + if(run_iter_lat_write(&ctx,&user_param)) { + fprintf(stderr,"Test exited with Error\n"); +- return FAILURE; ++ goto destroy_ctx; + } + user_param.test_type == ITERATIONS ? print_report_lat(&user_param) : print_report_lat_duration(&user_param); + } +@@ -252,5 +253,12 @@ int main(int argc, char *argv[]) + if (user_param.output == FULL_VERBOSITY) { + printf(RESULT_LINE); + } +- return 0; ++ ret_val = 0; ++ ++destroy_ctx: ++ destroy_ctx(&ctx, &user_param); ++free_dests: ++ free(my_dest); ++ free(rem_dest); ++ return ret_val; + } diff --git a/SOURCES/perftest-enable-s390x-platform-support.patch b/SOURCES/perftest-enable-s390x-platform-support.patch index 6576a5c..18b5860 100644 --- a/SOURCES/perftest-enable-s390x-platform-support.patch +++ b/SOURCES/perftest-enable-s390x-platform-support.patch @@ -14,11 +14,11 @@ Signed-off-by: Alexey Ishchuk src/get_clock.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) -diff --git a/README b/README -index 3eb2eda67d..f2c7c3feeb 100644 ---- a/README -+++ b/README -@@ -237,7 +237,7 @@ Special feature detailed explanation in tests: +Index: perftest-3.0/README +=================================================================== +--- perftest-3.0.orig/README ++++ perftest-3.0/README +@@ -237,7 +237,7 @@ Special feature detailed explanation in ./configure --disable-verbs_exp make @@ -27,22 +27,22 @@ index 3eb2eda67d..f2c7c3feeb 100644 7. perftest-2.3 release includes support for dualport VPI test - port1-Ethernet , port2-IB. (in addition to Eth:Eth, IB:IB) Currently, running dualport when port1-IB , port2-Ethernet still not working. -diff --git a/src/get_clock.c b/src/get_clock.c -index e6a78eac95..e6c3c14005 100755 ---- a/src/get_clock.c -+++ b/src/get_clock.c +Index: perftest-3.0/src/get_clock.c +=================================================================== +--- perftest-3.0.orig/src/get_clock.c ++++ perftest-3.0/src/get_clock.c @@ -133,7 +133,7 @@ static double sample_get_cpu_mhz(void) return b; } -#ifndef __s390x__ +#ifndef __s390__ - static double proc_get_cpu_mhz(int no_cpu_freq_fail) + static double proc_get_cpu_mhz(int no_cpu_freq_warn) { FILE* f; -@@ -205,8 +205,8 @@ static double proc_get_cpu_mhz(int no_cpu_freq_fail) +@@ -200,8 +200,8 @@ static double proc_get_cpu_mhz(int no_cp - double get_cpu_mhz(int no_cpu_freq_fail) + double get_cpu_mhz(int no_cpu_freq_warn) { - #ifdef __s390x__ - return sample_get_cpu_mgz(); @@ -51,10 +51,10 @@ index e6a78eac95..e6c3c14005 100755 #else double sample, proc, delta; sample = sample_get_cpu_mhz(); -diff --git a/src/get_clock.h b/src/get_clock.h -index c0f1cfc0a7..b9a750ff3d 100755 ---- a/src/get_clock.h -+++ b/src/get_clock.h +Index: perftest-3.0/src/get_clock.h +=================================================================== +--- perftest-3.0.orig/src/get_clock.h ++++ perftest-3.0/src/get_clock.h @@ -70,7 +70,7 @@ static inline cycles_t get_cycles() asm volatile ("mov %0=ar.itc" : "=r" (ret)); return ret; @@ -64,5 +64,3 @@ index c0f1cfc0a7..b9a750ff3d 100755 typedef unsigned long long cycles_t; static inline cycles_t get_cycles(void) { --- -2.4.3 diff --git a/SPECS/perftest.spec b/SPECS/perftest.spec index 645ff40..1f0e6ed 100644 --- a/SPECS/perftest.spec +++ b/SPECS/perftest.spec @@ -1,12 +1,15 @@ Name: perftest Summary: IB Performance Tests -Version: 2.4 -Release: 1%{?dist} +Version: 3.0 +%define tar_release 3.1.gb36a595 +Release: 7%{?dist} License: GPLv2 or BSD Group: Productivity/Networking/Diagnostic -Source: https://www.openfabrics.org/downloads/%{name}/%{name}-%{version}-0.8.gd3c2b22.tar.gz -Patch0: perftest-2.0-cflags.patch +Source0: https://www.openfabrics.org/downloads/%{name}/%{name}-%{version}-%{tar_release}.tar.gz +Source1: ib_atomic_bw.1 +Patch0: perftest-3.0-cflags.patch Patch1: perftest-enable-s390x-platform-support.patch +Patch2: perftest-3.0-fix-memory-leaks.patch Url: http://www.openfabrics.org BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: libibverbs-devel > 1.1.4, librdmacm-devel > 1.0.14 @@ -24,6 +27,7 @@ RDMA networks. %setup -q %patch0 -p1 -b .cflags %patch1 -p1 +%patch2 -p1 autoreconf --force --install %build @@ -35,13 +39,54 @@ rm -rf %{buildroot} for file in ib_{atomic,read,send,write}_{lat,bw}; do install -D -m 0755 $file %{buildroot}%{_bindir}/$file done +for file in raw_ethernet_{lat,bw}; do + install -D -m 0755 $file %{buildroot}%{_bindir}/$file +done +mkdir -p %{buildroot}%{_mandir}/man1/ +install -D -m 0644 %{SOURCE1} %{buildroot}%{_mandir}/man1/ +pushd %{buildroot}%{_mandir}/man1/ +for file in ib_atomic_lat ib_{read,send,write}_{lat,bw} raw_ethernet_{lat,bw}; do + ln -s ib_atomic_bw.1 ${file}.1 +done +popd %files %defattr(-, root, root) %doc README COPYING -%_bindir/* +%{_bindir}/* +%{_mandir}/man1/* %changelog +* Thu Aug 18 2016 Jarod Wilson - 3.0-7 +- Address a myriad more coverity/clang warnings +- Add raw_ethernet_* man page symlinks +- Related: rhbz#1273176 +- Related: rhbz#948476 + +* Mon Aug 15 2016 Jarod Wilson - 3.0-6 +- Update to upstream 3.0-3.1.gb36a595 tarball for upstream fixes +- Add in manpages +- Related: rhbz#1365750 +- Resolves: rhbz#948476 + +* Fri Aug 12 2016 Jarod Wilson - 3.0-5 +- Make it possible to actually test with XRC connections again +- Resolves: rhbz#1365750 + +* Mon Aug 08 2016 Jarod Wilson - 3.0-4 +- Install raw_ethernet{lat,bw} tools +- Resolves: rhbz#1365182 + +* Wed May 18 2016 Jarod Wilson - 3.0-3 +- Fix additional memory leaks reported and spotted after last fix + +* Wed May 18 2016 Jarod Wilson - 3.0-2 +- Fix issues uncovered by coverity + +* Wed May 04 2016 Jarod Wilson - 3.0-1 +- Update to upstream release v3.0 +- Resolves: bz1309586, bz1273176 + * Tue Jun 16 2015 Michal Schmidt - 2.4-1 - Update to latest upstream release - Enable s390x platform