[Pkg-ofed-commits] [infiniband-diags] 01/07: Imported Upstream version 1.6.6

Mehdi Dogguy mehdi at moszumanska.debian.org
Tue Jan 5 00:27:36 UTC 2016


This is an automated email from the git hooks/post-receive script.

mehdi pushed a commit to branch master
in repository infiniband-diags.

commit 8943aa0b0d827fc47390a65774dd6e281eda8819
Author: Mehdi Dogguy <mehdi at debian.org>
Date:   Tue Jan 5 00:53:38 2016 +0100

    Imported Upstream version 1.6.6
---
 ChangeLog                          | 232 +++++++++++++++++++++++++++++++++++++
 Makefile.am                        |   9 ++
 Makefile.in                        |  58 ++++++----
 README                             |  71 +++++++-----
 config.h.in                        |   7 +-
 configure                          | 181 ++++++++++++++++++-----------
 configure.ac                       |  20 +++-
 doc/man/rdma-ndd.8                 |   3 +
 doc/man/rdma-ndd.8.in              |   3 +
 doc/rst/rdma-ndd.8.in.rst          |   3 +
 etc/rdma-ndd.init                  |   6 +-
 etc/rdma-ndd.init.in               |   6 +-
 include/ibdiag_version.h           |   2 +-
 infiniband-diags.spec              |   4 +-
 libibnetdisc/Makefile.in           |   2 +
 libibnetdisc/src/ibnetdisc.c       |  73 ++++++++----
 libibnetdisc/src/ibnetdisc_cache.c |  19 ++-
 libibnetdisc/src/internal.h        |   5 +-
 libibnetdisc/src/query_smp.c       |   4 +-
 src/dump_fts.c                     |  30 +++--
 src/ibdiag_common.c                |   4 +-
 src/ibdiag_sa.c                    |  22 +++-
 src/iblinkinfo.c                   |  18 ++-
 src/ibqueryerrors.c                |  56 ++++++---
 src/perfquery.c                    |  18 +--
 src/rdma-ndd.c                     |  60 +++++++---
 src/saquery.c                      |   1 +
 src/vendstat.c                     |  82 ++++++++-----
 28 files changed, 735 insertions(+), 264 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 25c738a..e547c7d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,126 @@
 
 ** Version: HEAD
 
+Mon Oct 12 23:27:34 2015 -0400 Ira Weiny
+275cc40ec83956755356eae55ee64dbf85699aec
+
+	* update README/configure.ac for 1.6.6
+
+Wed Sep 30 08:53:51 2015 -0400 Dan Ben Yosef
+d64fcf4a3d0ae20fbf497b5605cb8071e334069d
+
+	* libibnetdisc: Avoid pushing same pointer to the hash table
+
+Mon Oct 12 08:30:31 2015 -0400 Hal Rosenstock
+bcdc2151bad1db24e7d96ac896d57a65c7f40cfc
+
+	* perfquery.c: Fix smp_query_via return value checks
+
+Mon Oct 12 08:31:23 2015 -0400 Hal Rosenstock
+0cd6d05da6a6d3b679535c38a64c9600378de076
+
+	* ibdiag_common.c: Move static to beginning of get_build_version declaration
+
+Thu Sep 10 19:26:08 2015 -0400 Ira Weiny
+14f19aae87a59ef0df30585a7b0c3f6bea7eb274
+
+	* infiniband-diags: rdma-ndd: remove udev logging when not supported
+
+Mon Aug 31 10:49:04 2015 +0300 Dan Ben Yosef
+3f1aed48b0fc27df9615d89399edd0ac623b2017
+
+	* perfquery -T (print Extended Speed Counters) times out on nodes supporting RS_FEC capability.
+
+Wed Sep 9 14:29:38 2015 +0300 Vladimir Koushnir
+1a1565006b2a2996fcac4a117d7ffc9ebc3a1b7d
+
+	* saquery.c: Fix saquery -D option
+
+Wed Jul 22 16:14:03 2015 +0200 Ana Guerrero López
+552063e080c6dde686f961238e019172b3823a42
+
+	* rdma-ndd: fix compiler warnings.
+
+Wed Jul 15 14:08:49 2015 -0400 Hal Rosenstock
+5de1f6de8825ba70d8553be957416ab271716379
+
+	* iblinkinfo.c: Close additional file descriptor in advance
+
+Thu Apr 16 18:27:39 2015 +0300 Vladimir Koushnir
+9912de3d9dbdd31e67f736ea378d429429a81128
+
+	* vendstat: mad_rpc_close_port not called in corner cases
+
+Thu Jun 25 16:12:02 2015 +0200 Michal Schmidt
+efecdfb8219ad3234ea61a349a2f7a28cee76439
+
+	* build-sys: avoid overlinking to libudev
+
+Thu Jun 25 16:12:01 2015 +0200 Michal Schmidt
+01071153c35f18f93b6b19075ffcbc5a7290eaf2
+
+	* rdma-ndd: never use udev_get_sys_path()
+
+Thu May 7 13:54:52 2015 +0300 Hal Rosenstock
+4989004236cb59d281c743a4b91275ef555951d8
+
+	* ibdiag_sa.c: In sa_get_handle, handle umad_open_port and umad_register failures
+
+Sun Apr 26 18:26:16 2015 +0300 Vladimir Koushnir
+f68d857412a4499cdc42ddec1059388d7a94e25d
+
+	* ibqueryerrors: improve code related to DR option
+
+Sun Apr 26 12:24:06 2015 +0300 Vladimir Koushnir
+13e9d76a6af2e66186bd8aa77eab8f811decaee7
+
+	* ibqueryerrors: Close global file descriptor before running ibnd_discover_fabric
+
+Tue Apr 21 17:12:05 2015 +0300 Vladimir Koushnir
+ae4e036450fafaafcf9abee7d2f74bfabd7d5f4a
+
+	* ibqueryerrors: Fix crash when no SM is running
+
+Sun Apr 26 18:29:31 2015 +0300 Vladimir Koushnir
+35c85ad05cff4ca7bc5875320a7a7296cbb16608
+
+	* ibqueryerrors: code improvement
+
+Thu Apr 16 16:56:40 2015 +0300 Vladimir Koushnir
+f427cf58892426d1d9159019b42af94c48d06feb
+
+	* dump_fts: Open global file descriptor after calling ibnd_discover_fabric
+
+Thu Apr 16 14:11:16 2015 +0300 Vladimir Koushnir
+2a8621e70417c2f45e40acefe5ff96d8d85996f3
+
+	* query_smp.c: Avoid busy looping in process_one_recv
+
+Wed Apr 8 12:29:44 2015 +0300 Vladimir Koushnir
+ad743ff6c6e2befa71801bc76bdc5d08d8f41131
+
+	* Remove redundant umad file descriptor from libibnetdisc
+
+Thu Apr 16 16:39:43 2015 +0300 Vladimir Koushnir
+4e6bc81500fecbdece3c16862252a83cdeed3282
+
+	* ibqueryerrors: Resource leak in path_record_query
+
+Thu May 1 10:22:00 2014 -0400 Hal Rosenstock
+1f4e356a5d156cd85d69f3b064bb1b7692778853
+
+	* perfquery.c: Change format of capability mask in IBWARN for consistency
+
+Wed Mar 11 01:41:35 2015 -0400 Ira Weiny
+211eccc0447f4259cbdf9579786865ee8e3657ff
+
+	* infiniband-diags/rdma-ndd: add --pidfile option
+
+Wed Mar 11 01:28:42 2015 -0400 Ira Weiny
+62cbfb4ceb41884cd3563b700af7d46fb99572aa
+
+	* infiniband-diags/rdma-ndd: Fix issues with install
+
 Tue Feb 10 18:45:17 2015 -0500 Ira Weiny
 d5b64231f5c78296bb73724192863f3efe26cefe
 
@@ -3324,6 +3444,118 @@ Sun May 11 15:37:11 2008 +0300 Yevgeny Kliteynik
 
 	* infiniband-diags/Makefile.am: fix location of ibdiag_version.h
 
+** Version: 1.6.5
+
+Tue Feb 10 18:45:17 2015 -0500 Ira Weiny
+d5b64231f5c78296bb73724192863f3efe26cefe
+
+	* update README for 1.6.5
+
+Wed Jan 28 17:58:29 2015 -0500 Dan Ben Yosef
+9d3fcc8179850cf8c86da1567764b6b4762c27a9
+
+	* ibtracert.c: Remove checking the port 0 state for base switch port 0
+
+Thu Feb 5 07:19:15 2015 -0500 Dan Ben Yosef
+03d75bf07463a9f155ef41a5138d3f159d875e08
+
+	* Add new configure flag to enable/disable the rdma-ndd build
+
+Wed Jan 28 16:54:07 2015 -0500 Hal Rosenstock
+10f9628178378fa92d20379d22fb4d93044f06dd
+
+	* Align infiniband-diags MLNX device IDs with OpenSM
+
+Wed Jan 28 11:45:15 2015 -0500 Ira Weiny
+b0a54c1a03d55fb530dd188b6c0e1b5339756c8c
+
+	* infiniband-diags: update for udev changes.
+
+Wed Jan 28 11:23:53 2015 -0500 Ira Weiny
+109b79f9c90fc6a6c573ba91076fa547be6faf60
+
+	* infiniband-diags/test-code: remove unused variables
+
+Wed Jan 14 09:07:10 2015 -0500 Hal Rosenstock
+8c0ec71b83c532a2b7c8d24455798e56b267539f
+
+	* vendstat.c: Add additional vendor IDs to ext_fw_info_device
+
+Wed Jan 14 09:07:03 2015 -0500 Hal Rosenstock
+4b47135d15cec632ebbec28b61a526600e79dfc9
+
+	* ibnetdisc.c: Add additional supported device IDs to is_mlnx_ext_port_info_supported
+
+Wed Jan 14 09:06:54 2015 -0500 Hal Rosenstock
+24c62b083d4f2dbff45a996f472e5ad74db20b5c
+
+	* ibdiag_common.c: Add more supported device IDs in is_mlnx_ext_port_info_supported
+
+Fri Oct 24 19:57:38 2014 -0400 Ira Weiny
+ae505415dabc34caba7e82ed93950823baf1f747
+
+	* infiniband-diags: add rdma-ndd daemon
+
+Fri Jan 9 10:17:36 2015 -0500 Hal Rosenstock
+18f1a0f973cc5cff7328e4576149b26334441c15
+
+	* ibccconfig.c: Account for enhanced switch port 0 in SwitchPortCongestionSetting handling
+
+Fri Jan 9 10:17:30 2015 -0500 Hal Rosenstock
+202382751b5ac01e32573c5ed122214ee0fa9295
+
+	* ibccquery.c: Account for enhanced switch port 0 in SwitchPortCongestionSetting handling
+
+Tue Nov 18 12:35:04 2014 -0500 Ira Weiny
+0e96e79cfe01b82ab1b7e987a0148738d1fe9dfd
+
+	* infiniband-diags: update smpquery man page
+
+Mon Nov 17 16:57:29 2014 +0200 Dan Ben Yosef
+6393c5f7bf32cdf77c679a9abd9be577f9620b65
+
+	* New MAD SM:PortInfoExtended and changing PM:PortExtendedSpeedsCounters
+
+Wed Nov 5 15:22:05 2014 -0500 Hal Rosenstock
+34a5d92f9387ce8d59b19f449e5095ab0fe11f34
+
+	* saquery.c: Return proper status from query_sa_cpi on bad result status
+
+Wed Nov 5 15:21:55 2014 -0500 Hal Rosenstock
+0741d402601c6636e6e3a1f63016b7c860c29044
+
+	* saquery.c: Fix handling of cpi and ClassPortInfo options
+
+Fri Oct 17 17:09:54 2014 -0400 Hal Rosenstock
+c7643611e3b0a05df79fc3126b34bed99aff3849
+
+	* ibping.c: Fix support of OUIs other than IB_OPENIB_OUI
+
+Tue Jun 10 14:23:13 2014 -0400 Hal Rosenstock
+17a8d6db8cee297b9b66b91f36e20c8413b5aa8b
+
+	* ibportstate.c: Cosmetic changes to MLNX Extended PortInfo
+
+Sat Apr 19 15:14:08 2014 -0700 Ira Weiny
+6364d06406a95d1fed2397691ddd012493b0bdf6
+
+	* infiniband-diags: If rst2man is available fix missing source dir in configure
+
+Mon Mar 31 10:03:19 2014 +0300 Dan Ben Yosef
+4549d891c11458b299e94751ef62d9f076dc5b49
+
+	* Fix missing source dir in configure.ac
+
+Wed Feb 26 10:25:43 2014 -0500 Hal Rosenstock
+018c7f43f03a20b45bb4cecfa23063bbf37ae7f4
+
+	* saquery.c: In query_sa_cpi, make error message consistent
+
+Wed Feb 26 10:25:06 2014 -0500 Hal Rosenstock
+b3d11492b5633b214e1843bf46a03f1a6c1288c9
+
+	* saquery.c: In print_node_record, change LID print format
+
 ** Version: 1.6.4
 
 Sat Jan 25 22:10:28 2014 -0800 Ira Weiny
diff --git a/Makefile.am b/Makefile.am
index 63c4b48..93af707 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -130,6 +130,12 @@ src_ibcacheedit_LDFLAGS = -L$(top_builddir)/libibnetdisc -libnetdisc
 src_dump_fts_SOURCES = src/dump_fts.c
 src_dump_fts_LDFLAGS = -L$(top_builddir)/libibnetdisc -libnetdisc
 
+if ENABLE_RDMA_NDD
+src_rdma_ndd_SOURCES = src/rdma-ndd.c
+src_rdma_ndd_CFLAGS = $(AM_CFLAGS) $(UDEV_CFLAGS)
+src_rdma_ndd_LDADD = libcommon.a $(UDEV_LIBS)
+endif
+
 BUILT_SOURCES = ibdiag_version
 ibdiag_version:
 	if [ -x $(top_srcdir)/gen_ver.sh ] ; then \
@@ -162,6 +168,9 @@ install-data-hook:
 	if test ! -d $(DESTDIR)/$(sysconfdir)/infiniband-diags; then \
 		$(top_srcdir)/config/install-sh -m 755 -d $(DESTDIR)/$(sysconfdir)/infiniband-diags; \
 	fi
+	if test ! -d $(DESTDIR)/$(localstatedir)/run; then \
+		mkdir -p $(DESTDIR)/$(localstatedir)/run; \
+	fi
 	$(top_srcdir)/config/install-sh -c -m 444 $(top_srcdir)/scripts/IBswcountlimits.pm $(DESTDIR)/$(PERL_INSTALLDIR)/IBswcountlimits.pm
 	$(top_srcdir)/config/install-sh -c -m 444 $(top_srcdir)/etc/error_thresholds $(DESTDIR)/$(sysconfdir)/infiniband-diags
 	$(top_srcdir)/config/install-sh -c -m 400 $(top_srcdir)/etc/ibdiag.conf $(DESTDIR)/$(sysconfdir)/infiniband-diags
diff --git a/Makefile.in b/Makefile.in
index 4de5db4..6573884 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -315,10 +315,16 @@ am_src_perfquery_OBJECTS = perfquery.$(OBJEXT)
 src_perfquery_OBJECTS = $(am_src_perfquery_OBJECTS)
 src_perfquery_LDADD = $(LDADD)
 src_perfquery_DEPENDENCIES = libcommon.a
-src_rdma_ndd_SOURCES = src/rdma-ndd.c
-src_rdma_ndd_OBJECTS = rdma-ndd.$(OBJEXT)
-src_rdma_ndd_LDADD = $(LDADD)
-src_rdma_ndd_DEPENDENCIES = libcommon.a
+am__src_rdma_ndd_SOURCES_DIST = src/rdma-ndd.c
+ at ENABLE_RDMA_NDD_TRUE@am_src_rdma_ndd_OBJECTS =  \
+ at ENABLE_RDMA_NDD_TRUE@	src_rdma_ndd-rdma-ndd.$(OBJEXT)
+src_rdma_ndd_OBJECTS = $(am_src_rdma_ndd_OBJECTS)
+am__DEPENDENCIES_1 =
+ at ENABLE_RDMA_NDD_TRUE@src_rdma_ndd_DEPENDENCIES = libcommon.a \
+ at ENABLE_RDMA_NDD_TRUE@	$(am__DEPENDENCIES_1)
+src_rdma_ndd_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(src_rdma_ndd_CFLAGS) \
+	$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
 am_src_saquery_OBJECTS = saquery.$(OBJEXT)
 src_saquery_OBJECTS = $(am_src_saquery_OBJECTS)
 src_saquery_LDADD = $(LDADD)
@@ -410,9 +416,9 @@ SOURCES = $(libcommon_a_SOURCES) $(src_dump_fts_SOURCES) \
 	$(src_ibsendtrap_SOURCES) $(src_ibstat_SOURCES) \
 	$(src_ibsysstat_SOURCES) $(src_ibtracert_SOURCES) \
 	$(src_mcm_rereg_test_SOURCES) $(src_perfquery_SOURCES) \
-	src/rdma-ndd.c $(src_saquery_SOURCES) $(src_sminfo_SOURCES) \
-	$(src_smpdump_SOURCES) $(src_smpquery_SOURCES) \
-	$(src_vendstat_SOURCES)
+	$(src_rdma_ndd_SOURCES) $(src_saquery_SOURCES) \
+	$(src_sminfo_SOURCES) $(src_smpdump_SOURCES) \
+	$(src_smpquery_SOURCES) $(src_vendstat_SOURCES)
 DIST_SOURCES = $(libcommon_a_SOURCES) $(src_dump_fts_SOURCES) \
 	$(src_ibaddr_SOURCES) $(src_ibcacheedit_SOURCES) \
 	$(src_ibccconfig_SOURCES) $(src_ibccquery_SOURCES) \
@@ -422,9 +428,9 @@ DIST_SOURCES = $(libcommon_a_SOURCES) $(src_dump_fts_SOURCES) \
 	$(src_ibsendtrap_SOURCES) $(src_ibstat_SOURCES) \
 	$(src_ibsysstat_SOURCES) $(src_ibtracert_SOURCES) \
 	$(src_mcm_rereg_test_SOURCES) $(src_perfquery_SOURCES) \
-	src/rdma-ndd.c $(src_saquery_SOURCES) $(src_sminfo_SOURCES) \
-	$(src_smpdump_SOURCES) $(src_smpquery_SOURCES) \
-	$(src_vendstat_SOURCES)
+	$(am__src_rdma_ndd_SOURCES_DIST) $(src_saquery_SOURCES) \
+	$(src_sminfo_SOURCES) $(src_smpdump_SOURCES) \
+	$(src_smpquery_SOURCES) $(src_vendstat_SOURCES)
 RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
 	ctags-recursive dvi-recursive html-recursive info-recursive \
 	install-data-recursive install-dvi-recursive \
@@ -765,6 +771,8 @@ SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
 TARBALL = @TARBALL@
+UDEV_CFLAGS = @UDEV_CFLAGS@
+UDEV_LIBS = @UDEV_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -888,6 +896,9 @@ src_ibcacheedit_SOURCES = src/ibcacheedit.c
 src_ibcacheedit_LDFLAGS = -L$(top_builddir)/libibnetdisc -libnetdisc
 src_dump_fts_SOURCES = src/dump_fts.c
 src_dump_fts_LDFLAGS = -L$(top_builddir)/libibnetdisc -libnetdisc
+ at ENABLE_RDMA_NDD_TRUE@src_rdma_ndd_SOURCES = src/rdma-ndd.c
+ at ENABLE_RDMA_NDD_TRUE@src_rdma_ndd_CFLAGS = $(AM_CFLAGS) $(UDEV_CFLAGS)
+ at ENABLE_RDMA_NDD_TRUE@src_rdma_ndd_LDADD = libcommon.a $(UDEV_LIBS)
 BUILT_SOURCES = ibdiag_version
 @HAVE_DASH_TRUE at TESTS = tests/check_shells.sh
 EXTRA_DIST = doc scripts include infiniband-diags.spec.in infiniband-diags.spec \
@@ -1186,7 +1197,7 @@ src/perfquery$(EXEEXT): $(src_perfquery_OBJECTS) $(src_perfquery_DEPENDENCIES) $
 
 src/rdma-ndd$(EXEEXT): $(src_rdma_ndd_OBJECTS) $(src_rdma_ndd_DEPENDENCIES) $(EXTRA_src_rdma_ndd_DEPENDENCIES) src/$(am__dirstamp)
 	@rm -f src/rdma-ndd$(EXEEXT)
-	$(AM_V_CCLD)$(LINK) $(src_rdma_ndd_OBJECTS) $(src_rdma_ndd_LDADD) $(LIBS)
+	$(AM_V_CCLD)$(src_rdma_ndd_LINK) $(src_rdma_ndd_OBJECTS) $(src_rdma_ndd_LDADD) $(LIBS)
 
 src/saquery$(EXEEXT): $(src_saquery_OBJECTS) $(src_saquery_DEPENDENCIES) $(EXTRA_src_saquery_DEPENDENCIES) src/$(am__dirstamp)
 	@rm -f src/saquery$(EXEEXT)
@@ -1268,11 +1279,11 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ibtracert.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/mcm_rereg_test.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/perfquery.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/rdma-ndd.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/saquery.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/sminfo.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/smpdump.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/smpquery.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/src_rdma_ndd-rdma-ndd.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/vendstat.Po at am__quote@
 
 .c.o:
@@ -1562,19 +1573,19 @@ perfquery.obj: src/perfquery.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o perfquery.obj `if test -f 'src/perfquery.c'; then $(CYGPATH_W) 'src/perfquery.c'; else $(CYGPATH_W) '$(srcdir)/src/perfquery.c'; fi`
 
-rdma-ndd.o: src/rdma-ndd.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT rdma-ndd.o -MD -MP -MF $(DEPDIR)/rdma-ndd.Tpo -c -o rdma-ndd.o `test -f 'src/rdma-ndd.c' || echo '$(srcdir)/'`src/rdma-ndd.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/rdma-ndd.Tpo $(DEPDIR)/rdma-ndd.Po
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='src/rdma-ndd.c' object='rdma-ndd.o' libtool=no @AMDEPBACKSLASH@
+src_rdma_ndd-rdma-ndd.o: src/rdma-ndd.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(src_rdma_ndd_CFLAGS) $(CFLAGS) -MT src_rdma_ndd-rdma-ndd.o -MD -MP -MF $(DEPDIR)/src_rdma_ndd-rdma-ndd.Tpo -c -o src_rdma_ndd-rdma-ndd.o `test -f 'src/rdma-ndd.c' || echo '$(srcdir)/'`src/rdma-ndd.c
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/src_rdma_ndd-rdma-ndd.Tpo $(DEPDIR)/src_rdma_ndd-rdma-ndd.Po
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='src/rdma-ndd.c' object='src_rdma_ndd-rdma-ndd.o' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o rdma-ndd.o `test -f 'src/rdma-ndd.c' || echo '$(srcdir)/'`src/rdma-ndd.c
+ at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(src_rdma_ndd_CFLAGS) $(CFLAGS) -c -o src_rdma_ndd-rdma-ndd.o `test -f 'src/rdma-ndd.c' || echo '$(srcdir)/'`src/rdma-ndd.c
 
-rdma-ndd.obj: src/rdma-ndd.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT rdma-ndd.obj -MD -MP -MF $(DEPDIR)/rdma-ndd.Tpo -c -o rdma-ndd.obj `if test -f 'src/rdma-ndd.c'; then $(CYGPATH_W) 'src/rdma-ndd.c'; else $(CYGPATH_W) '$(srcdir)/src/rdma-ndd.c'; fi`
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/rdma-ndd.Tpo $(DEPDIR)/rdma-ndd.Po
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='src/rdma-ndd.c' object='rdma-ndd.obj' libtool=no @AMDEPBACKSLASH@
+src_rdma_ndd-rdma-ndd.obj: src/rdma-ndd.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(src_rdma_ndd_CFLAGS) $(CFLAGS) -MT src_rdma_ndd-rdma-ndd.obj -MD -MP -MF $(DEPDIR)/src_rdma_ndd-rdma-ndd.Tpo -c -o src_rdma_ndd-rdma-ndd.obj `if test -f 'src/rdma-ndd.c'; then $(CYGPATH_W) 'src/rdma-ndd.c'; else $(CYGPATH_W) '$(srcdir)/src/rdma-ndd.c'; fi`
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/src_rdma_ndd-rdma-ndd.Tpo $(DEPDIR)/src_rdma_ndd-rdma-ndd.Po
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='src/rdma-ndd.c' object='src_rdma_ndd-rdma-ndd.obj' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o rdma-ndd.obj `if test -f 'src/rdma-ndd.c'; then $(CYGPATH_W) 'src/rdma-ndd.c'; else $(CYGPATH_W) '$(srcdir)/src/rdma-ndd.c'; fi`
+ at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(src_rdma_ndd_CFLAGS) $(CFLAGS) -c -o src_rdma_ndd-rdma-ndd.obj `if test -f 'src/rdma-ndd.c'; then $(CYGPATH_W) 'src/rdma-ndd.c'; else $(CYGPATH_W) '$(srcdir)/src/rdma-ndd.c'; fi`
 
 saquery.o: src/saquery.c
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT saquery.o -MD -MP -MF $(DEPDIR)/saquery.Tpo -c -o saquery.o `test -f 'src/saquery.c' || echo '$(srcdir)/'`src/saquery.c
@@ -2327,6 +2338,9 @@ install-data-hook:
 	if test ! -d $(DESTDIR)/$(sysconfdir)/infiniband-diags; then \
 		$(top_srcdir)/config/install-sh -m 755 -d $(DESTDIR)/$(sysconfdir)/infiniband-diags; \
 	fi
+	if test ! -d $(DESTDIR)/$(localstatedir)/run; then \
+		mkdir -p $(DESTDIR)/$(localstatedir)/run; \
+	fi
 	$(top_srcdir)/config/install-sh -c -m 444 $(top_srcdir)/scripts/IBswcountlimits.pm $(DESTDIR)/$(PERL_INSTALLDIR)/IBswcountlimits.pm
 	$(top_srcdir)/config/install-sh -c -m 444 $(top_srcdir)/etc/error_thresholds $(DESTDIR)/$(sysconfdir)/infiniband-diags
 	$(top_srcdir)/config/install-sh -c -m 400 $(top_srcdir)/etc/ibdiag.conf $(DESTDIR)/$(sysconfdir)/infiniband-diags
diff --git a/README b/README
index 8d76866..9bf1a93 100644
--- a/README
+++ b/README
@@ -17,39 +17,46 @@ Dependencies:
 	5) glib2
 
 
-Release notes v1.6.4 => 1.6.5
+Release notes v1.6.5 => 1.6.6
 
    1) bug fixes
-   2) updates for new hardware device IDs
-   3) rdma-ndd daemon
-
-Authors since 1.6.4
-
-Dan Ben Yosef <danby at mellanox.com>
-	ibtracert.c: Remove checking the port 0 state for base switch port 0
-	Add new configure flag to enable/disable the rdma-ndd build
-	New MAD SM:PortInfoExtended and changing PM:PortExtendedSpeedsCounters
-	Fix missing source dir in configure.ac
-
-Hal Rosenstock <hal at dev.mellanox.co.il>
-	Align infiniband-diags MLNX device IDs with OpenSM
-	vendstat.c: Add additional vendor IDs to ext_fw_info_device
-	ibnetdisc.c: Add additional supported device IDs to is_mlnx_ext_port_info_supported
-	ibdiag_common.c: Add more supported device IDs in is_mlnx_ext_port_info_supported
-	ibccconfig.c: Account for enhanced switch port 0 in SwitchPortCongestionSetting handling
-	ibccquery.c: Account for enhanced switch port 0 in SwitchPortCongestionSetting handling
-	saquery.c: Return proper status from query_sa_cpi on bad result status
-	saquery.c: Fix handling of cpi and ClassPortInfo options
-	ibping.c: Fix support of OUIs other than IB_OPENIB_OUI
-	ibportstate.c: Cosmetic changes to MLNX Extended PortInfo
-	saquery.c: In query_sa_cpi, make error message consistent
-	saquery.c: In print_node_record, change LID print format
-
-Ira Weiny <ira.weiny at intel.com>
-	infiniband-diags: update for udev changes.
-	infiniband-diags/test-code: remove unused variables
-	infiniband-diags: add rdma-ndd daemon
-	infiniband-diags: update smpquery man page
-	infiniband-diags: If rst2man is available fix missing source dir in configure
+
+
+Authors since 1.6.5
+
+Ana Guerrero López (1):
+      rdma-ndd: fix compiler warnings.
+
+Dan Ben Yosef (2):
+      perfquery -T (print Extended Speed Counters) times out on nodes supporting
+      libibnetdisc: Avoid pushing same pointer to the hash table
+
+Hal Rosenstock (5):
+      perfquery.c: Change format of capability mask in IBWARN for consistency
+      ibdiag_sa.c: In sa_get_handle, handle umad_open_port and umad_register fai
+      iblinkinfo.c: Close additional file descriptor in advance
+      ibdiag_common.c: Move static to beginning of get_build_version declaration
+      perfquery.c: Fix smp_query_via return value checks
+
+Ira Weiny (3):
+      infiniband-diags/rdma-ndd: Fix issues with install
+      infiniband-diags/rdma-ndd: add --pidfile option
+      infiniband-diags: rdma-ndd: remove udev logging when not supported
+
+Michal Schmidt (2):
+      rdma-ndd: never use udev_get_sys_path()
+      build-sys: avoid overlinking to libudev
+
+Vladimir Koushnir (10):
+      ibqueryerrors: Resource leak in path_record_query
+      Remove redundant umad file descriptor from libibnetdisc
+      query_smp.c: Avoid busy looping in process_one_recv
+      dump_fts: Open global file descriptor after calling ibnd_discover_fabric
+      ibqueryerrors: code improvement
+      ibqueryerrors: Fix crash when no SM is running
+      ibqueryerrors: Close global file descriptor before running ibnd_discover_f
+      ibqueryerrors: improve code related to DR option
+      vendstat: mad_rpc_close_port not called in corner cases
+      saquery.c: Fix saquery -D option
 
 
diff --git a/config.h.in b/config.h.in
index 5318a86..58a4ef5 100644
--- a/config.h.in
+++ b/config.h.in
@@ -24,9 +24,6 @@
 /* Define to 1 if you have the `osmcomp' library (-losmcomp). */
 #undef HAVE_LIBOSMCOMP
 
-/* Define to 1 if you have the `udev' library (-ludev). */
-#undef HAVE_LIBUDEV
-
 /* Define to 1 if you have the <memory.h> header file. */
 #undef HAVE_MEMORY_H
 
@@ -72,8 +69,8 @@
 /* Define to 1 if you have the <sys/types.h> header file. */
 #undef HAVE_SYS_TYPES_H
 
-/* Define to 1 if you have the `udev_get_sys_path' function. */
-#undef HAVE_UDEV_GET_SYS_PATH
+/* whether libudev logging can be used */
+#undef HAVE_UDEV_LOGGING
 
 /* Define to 1 if struct umad_port has link_layer member */
 #undef HAVE_UMAD_PORT_LINK_LAYER
diff --git a/configure b/configure
index 16c834f..074e1c7 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for infiniband-diags 1.6.5.
+# Generated by GNU Autoconf 2.69 for infiniband-diags 1.6.6.
 #
 # Report bugs to <linux-rdma at vger.kernel.org>.
 #
@@ -590,8 +590,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='infiniband-diags'
 PACKAGE_TARNAME='infiniband-diags'
-PACKAGE_VERSION='1.6.5'
-PACKAGE_STRING='infiniband-diags 1.6.5'
+PACKAGE_VERSION='1.6.6'
+PACKAGE_STRING='infiniband-diags 1.6.6'
 PACKAGE_BUGREPORT='linux-rdma at vger.kernel.org'
 PACKAGE_URL=''
 
@@ -631,12 +631,13 @@ ac_includes_default="\
 # include <unistd.h>
 #endif"
 
-ac_func_list=
 ac_subst_vars='am__EXEEXT_FALSE
 am__EXEEXT_TRUE
 LTLIBOBJS
 have_rst2man
 BUILD_DATE
+UDEV_LIBS
+UDEV_CFLAGS
 DEFAULT_STOP
 DEFAULT_START
 RDMA_SERVICE
@@ -814,7 +815,9 @@ PKG_CONFIG
 PKG_CONFIG_PATH
 PKG_CONFIG_LIBDIR
 GLIB_CFLAGS
-GLIB_LIBS'
+GLIB_LIBS
+UDEV_CFLAGS
+UDEV_LIBS'
 
 
 # Initialize some variables set by options.
@@ -1355,7 +1358,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures infiniband-diags 1.6.5 to adapt to many kinds of systems.
+\`configure' configures infiniband-diags 1.6.6 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1426,7 +1429,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of infiniband-diags 1.6.5:";;
+     short | recursive ) echo "Configuration of infiniband-diags 1.6.6:";;
    esac
   cat <<\_ACEOF
 
@@ -1484,6 +1487,8 @@ Some influential environment variables:
               path overriding pkg-config's built-in search path
   GLIB_CFLAGS C compiler flags for GLIB, overriding pkg-config
   GLIB_LIBS   linker flags for GLIB, overriding pkg-config
+  UDEV_CFLAGS C compiler flags for UDEV, overriding pkg-config
+  UDEV_LIBS   linker flags for UDEV, overriding pkg-config
 
 Use these variables to override the choices made by `configure' or to help
 it to find libraries and programs with nonstandard names/locations.
@@ -1551,7 +1556,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-infiniband-diags configure 1.6.5
+infiniband-diags configure 1.6.6
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1977,7 +1982,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by infiniband-diags $as_me 1.6.5, which was
+It was created by infiniband-diags $as_me 1.6.6, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -2257,7 +2262,6 @@ $as_echo "$as_me: creating cache $cache_file" >&6;}
   >$cache_file
 fi
 
-as_fn_append ac_func_list " udev_get_sys_path"
 # Check that the precious variables saved in the cache have kept the same
 # value.
 ac_cache_corrupted=false
@@ -2844,7 +2848,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='infiniband-diags'
- VERSION='1.6.5'
+ VERSION='1.6.6'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -12605,81 +12609,122 @@ DEFAULT_START=$default_start
 DEFAULT_STOP=$default_stop
 
 
-if test x$rdmandd = xyes; then
-    ac_fn_c_check_header_mongrel "$LINENO" "libudev.h" "ac_cv_header_libudev_h" "$ac_includes_default"
-if test "x$ac_cv_header_libudev_h" = xyes; then :
-  with_udev="yes"
-else
-  with_udev="no"
-fi
+if test x$rdmandd = xyes; then :
 
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for udev_monitor_ref in -ludev" >&5
-$as_echo_n "checking for udev_monitor_ref in -ludev... " >&6; }
-if ${ac_cv_lib_udev_udev_monitor_ref+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-ludev  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for UDEV" >&5
+$as_echo_n "checking for UDEV... " >&6; }
 
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char udev_monitor_ref ();
-int
-main ()
-{
-return udev_monitor_ref ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_udev_udev_monitor_ref=yes
+if test -n "$UDEV_CFLAGS"; then
+    pkg_cv_UDEV_CFLAGS="$UDEV_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libudev\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "libudev") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_UDEV_CFLAGS=`$PKG_CONFIG --cflags "libudev" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
 else
-  ac_cv_lib_udev_udev_monitor_ref=no
+  pkg_failed=yes
 fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+ else
+    pkg_failed=untried
+fi
+if test -n "$UDEV_LIBS"; then
+    pkg_cv_UDEV_LIBS="$UDEV_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libudev\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "libudev") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_UDEV_LIBS=`$PKG_CONFIG --libs "libudev" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
+else
+  pkg_failed=yes
+fi
+ else
+    pkg_failed=untried
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_udev_udev_monitor_ref" >&5
-$as_echo "$ac_cv_lib_udev_udev_monitor_ref" >&6; }
-if test "x$ac_cv_lib_udev_udev_monitor_ref" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBUDEV 1
-_ACEOF
 
-  LIBS="-ludev $LIBS"
 
+
+if test $pkg_failed = yes; then
+   	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
 else
-  as_fn_error $? "libudev is required for rdma-ndd..." "$LINENO" 5
+        _pkg_short_errors_supported=no
 fi
+        if test $_pkg_short_errors_supported = yes; then
+	        UDEV_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libudev" 2>&1`
+        else
+	        UDEV_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libudev" 2>&1`
+        fi
+	# Put the nasty error message in config.log where it belongs
+	echo "$UDEV_PKG_ERRORS" >&5
 
-    ac_config_files="$ac_config_files doc/man/rdma-ndd.8 etc/rdma-ndd.init"
+	as_fn_error $? "Package requirements (libudev) were not met:
 
+$UDEV_PKG_ERRORS
 
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
 
+Alternatively, you may set the environment variables UDEV_CFLAGS
+and UDEV_LIBS to avoid the need to call pkg-config.
+See the pkg-config man page for more details." "$LINENO" 5
+elif test $pkg_failed = untried; then
+     	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+	{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "The pkg-config script could not be found or is too old.  Make sure it
+is in your PATH or set the PKG_CONFIG environment variable to the full
+path to pkg-config.
 
-  for ac_func in $ac_func_list
-do :
-  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
+Alternatively, you may set the environment variables UDEV_CFLAGS
+and UDEV_LIBS to avoid the need to call pkg-config.
+See the pkg-config man page for more details.
+
+To get pkg-config, see <http://pkg-config.freedesktop.org/>.
+See \`config.log' for more details" "$LINENO" 5; }
+else
+	UDEV_CFLAGS=$pkg_cv_UDEV_CFLAGS
+	UDEV_LIBS=$pkg_cv_UDEV_LIBS
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
 
 fi
-done
+    ac_config_files="$ac_config_files doc/man/rdma-ndd.8 etc/rdma-ndd.init"
 
 
 
+    if test "$with_udev" = "yes"; then
+	if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libudev >= 218\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "libudev >= 218") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  with_dev_logging=no
+else
+  with_udev_logging=yes
+fi
+	if test "$with_udev_logging" = "yes"; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_UDEV_LOGGING 1
+_ACEOF
+
+	fi
+    fi
 
 fi
 
@@ -13331,7 +13376,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by infiniband-diags $as_me 1.6.5, which was
+This file was extended by infiniband-diags $as_me 1.6.6, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -13397,7 +13442,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-infiniband-diags config.status 1.6.5
+infiniband-diags config.status 1.6.6
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff --git a/configure.ac b/configure.ac
index b9b7ad8..9a5e47a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,7 +1,7 @@
 dnl Process this file with autoconf to produce a configure script.
 
 AC_PREREQ(2.57)
-AC_INIT(infiniband-diags, 1.6.5, linux-rdma at vger.kernel.org)
+AC_INIT(infiniband-diags, 1.6.6, linux-rdma at vger.kernel.org)
 AC_CONFIG_AUX_DIR(config)
 AC_CONFIG_MACRO_DIR(config)
 AM_CONFIG_HEADER(config.h)
@@ -210,12 +210,20 @@ default_start="null"
 AC_SUBST(DEFAULT_START, $default_start)
 AC_SUBST(DEFAULT_STOP, $default_stop)
 
-if test x$rdmandd = xyes; then
-    AC_CHECK_HEADER(libudev.h, with_udev="yes", with_udev="no")
-    AC_CHECK_LIB(udev, udev_monitor_ref, [], AC_MSG_ERROR(libudev is required for rdma-ndd...))
+AS_IF([test x$rdmandd = xyes], [
+    PKG_CHECK_MODULES([UDEV], [libudev])
     AC_CONFIG_FILES([doc/man/rdma-ndd.8 etc/rdma-ndd.init])
-    AC_CHECK_FUNCS_ONCE(udev_get_sys_path)
-fi
+    AC_SUBST([UDEV_CFLAGS])
+    AC_SUBST([UDEV_LIBS])
+    if test "$with_udev" = "yes"; then
+	PKG_CHECK_EXISTS(libudev >= 218, [with_dev_logging=no],
+			[with_udev_logging=yes])
+	if test "$with_udev_logging" = "yes"; then
+		AC_DEFINE_UNQUOTED([HAVE_UDEV_LOGGING], 1,
+				[whether libudev logging can be used])
+	fi
+    fi
+])
 
 dnl Generate doc/man/*.in files if possible
 DOC_DATE="`date +%Y-%m-%d`"
diff --git a/doc/man/rdma-ndd.8 b/doc/man/rdma-ndd.8
index a4b4a0d..4906aac 100644
--- a/doc/man/rdma-ndd.8
+++ b/doc/man/rdma-ndd.8
@@ -64,6 +64,9 @@ Number of times to attempt to retry setting of the node description on failure.
 .sp
 \fB\-\-foreground, \-f\fP
 Run in the foreground instead of as a daemon
+.sp
+\fB\-\-pidfile <pidfile>\fP
+specify a pid file (daemon mode only)
 .SS Configuration flags
 .\" Define the common option -z
 .
diff --git a/doc/man/rdma-ndd.8.in b/doc/man/rdma-ndd.8.in
index 1a7a1bb..f0a542d 100644
--- a/doc/man/rdma-ndd.8.in
+++ b/doc/man/rdma-ndd.8.in
@@ -64,6 +64,9 @@ Number of times to attempt to retry setting of the node description on failure.
 .sp
 \fB\-\-foreground, \-f\fP
 Run in the foreground instead of as a daemon
+.sp
+\fB\-\-pidfile <pidfile>\fP
+specify a pid file (daemon mode only)
 .SS Configuration flags
 .\" Define the common option -z
 .
diff --git a/doc/rst/rdma-ndd.8.in.rst b/doc/rst/rdma-ndd.8.in.rst
index afe7470..708a5ab 100644
--- a/doc/rst/rdma-ndd.8.in.rst
+++ b/doc/rst/rdma-ndd.8.in.rst
@@ -58,6 +58,9 @@ Number of times to attempt to retry setting of the node description on failure.
 **--foreground, -f**
 Run in the foreground instead of as a daemon
 
+**--pidfile <pidfile>**
+specify a pid file (daemon mode only)
+
 
 Configuration flags
 -------------------
diff --git a/etc/rdma-ndd.init b/etc/rdma-ndd.init
index 95e5e52..ec8c18d 100644
--- a/etc/rdma-ndd.init
+++ b/etc/rdma-ndd.init
@@ -41,7 +41,9 @@
 # notice, one of the license notices in the documentation
 # and/or other materials provided with the distribution.
 
-pidfile=/var/run/rdma-ndd.pid
+prefix=/usr/local
+exec_prefix=${prefix}
+pidfile=${prefix}/var/run/rdma-ndd.pid
 
 # Source function library.
 if [[ -s /etc/init.d/functions ]]; then
@@ -73,7 +75,7 @@ start () {
 	return 1
     fi
     echo -n "Starting RDMA Node Description Daemon: "
-    ${exec_prefix}/sbin/rdma-ndd > /dev/null
+    ${exec_prefix}/sbin/rdma-ndd --pidfile $pidfile > /dev/null
     RETVAL=$?
     if [[ $RETVAL -eq 0 ]]; then
         success
diff --git a/etc/rdma-ndd.init.in b/etc/rdma-ndd.init.in
index 41747f2..75e6d37 100644
--- a/etc/rdma-ndd.init.in
+++ b/etc/rdma-ndd.init.in
@@ -41,7 +41,9 @@
 # notice, one of the license notices in the documentation
 # and/or other materials provided with the distribution.
 
-pidfile=/var/run/rdma-ndd.pid
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+pidfile=@localstatedir@/run/rdma-ndd.pid
 
 # Source function library.
 if [[ -s /etc/init.d/functions ]]; then
@@ -73,7 +75,7 @@ start () {
 	return 1
     fi
     echo -n "Starting RDMA Node Description Daemon: "
-    @sbindir@/rdma-ndd > /dev/null
+    @sbindir@/rdma-ndd --pidfile $pidfile > /dev/null
     RETVAL=$?
     if [[ $RETVAL -eq 0 ]]; then
         success
diff --git a/include/ibdiag_version.h b/include/ibdiag_version.h
index 50ca560..cadb35e 100644
--- a/include/ibdiag_version.h
+++ b/include/ibdiag_version.h
@@ -34,6 +34,6 @@
 #ifndef _IBDIAG_VERSION_H_
 #define _IBDIAG_VERSION_H_
 
-#define IBDIAG_VERSION "1.6.5"
+#define IBDIAG_VERSION "1.6.6"
 
 #endif	/* _IBDIAG_VERSION_H_ */
diff --git a/infiniband-diags.spec b/infiniband-diags.spec
index 629b35b..58bacd1 100644
--- a/infiniband-diags.spec
+++ b/infiniband-diags.spec
@@ -4,12 +4,12 @@
 
 Summary: OpenFabrics Alliance InfiniBand Diagnostic Tools
 Name: infiniband-diags
-Version: 1.6.5
+Version: 1.6.6
 Release: %rel%{?dist}
 License: GPLv2 or BSD
 Group: System Environment/Libraries
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-Source: http://www.openfabrics.org/downloads/management/infiniband-diags-1.6.5.tar.gz
+Source: http://www.openfabrics.org/downloads/management/infiniband-diags-1.6.6.tar.gz
 Url: http://openfabrics.org/
 BuildRequires: libibmad-devel, opensm-devel, libibumad-devel, glib2-devel, libudev-devel
 Requires: libibmad, opensm-libs, libibumad, glib2
diff --git a/libibnetdisc/Makefile.in b/libibnetdisc/Makefile.in
index e467498..030e43f 100644
--- a/libibnetdisc/Makefile.in
+++ b/libibnetdisc/Makefile.in
@@ -293,6 +293,8 @@ SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
 TARBALL = @TARBALL@
+UDEV_CFLAGS = @UDEV_CFLAGS@
+UDEV_LIBS = @UDEV_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
diff --git a/libibnetdisc/src/ibnetdisc.c b/libibnetdisc/src/ibnetdisc.c
index e346905..938a516 100644
--- a/libibnetdisc/src/ibnetdisc.c
+++ b/libibnetdisc/src/ibnetdisc.c
@@ -127,12 +127,6 @@ static int extend_dpath(smp_engine_t * engine, ib_portid_t * portid,
 
 	if (portid->lid) {
 		/* If we were LID routed we need to set up the drslid */
-		if (!scan->selfportid.lid)
-			if (ib_resolve_self_via(&scan->selfportid, NULL, NULL,
-						scan->ibmad_port) < 0) {
-				IBND_ERROR("Failed to resolve self\n");
-				return -1;
-			}
 		portid->drpath.drslid = (uint16_t) scan->selfportid.lid;
 		portid->drpath.drdlid = 0xFFFF;
 	}
@@ -359,7 +353,12 @@ static int recv_port_info(smp_engine_t * engine, ibnd_smp_t * smp,
 		port->lmc = node->smalmc;
 	}
 
-	add_to_portguid_hash(port, f_int->fabric.portstbl);
+	int rc1 = add_to_portguid_hash(port, f_int->fabric.portstbl);
+	if (rc1)
+		IBND_ERROR("Error Occurred when trying"
+			   " to insert new port guid 0x%016" PRIx64 " to DB\n",
+			   port->guid);
+
 	add_to_portlid_hash(port, f_int->lid2guid);
 
 	if ((scan->cfg->flags & IBND_CONFIG_MLX_EPI)
@@ -464,7 +463,11 @@ static ibnd_node_t *create_node(smp_engine_t * engine, ib_portid_t * path,
 	rc->path_portid = *path;
 	memcpy(rc->info, node_info, sizeof(rc->info));
 
-	add_to_nodeguid_hash(rc, f_int->fabric.nodestbl);
+	int rc1 = add_to_nodeguid_hash(rc, f_int->fabric.nodestbl);
+	if (rc1)
+		IBND_ERROR("Error Occurred when trying"
+			   " to insert new node guid 0x%016" PRIx64 " to DB\n",
+			   rc->guid);
 
 	/* add this to the all nodes list */
 	rc->next = f_int->fabric.nodes;
@@ -613,20 +616,42 @@ ibnd_node_t *ibnd_find_node_dr(ibnd_fabric_t * fabric, char *dr_str)
 	return rc->node;
 }
 
-void add_to_nodeguid_hash(ibnd_node_t * node, ibnd_node_t * hash[])
+int add_to_nodeguid_hash(ibnd_node_t * node, ibnd_node_t * hash[])
 {
+	int rc = 0;
+	ibnd_node_t *tblnode;
 	int hash_idx = HASHGUID(node->guid) % HTSZ;
 
+	for (tblnode = hash[hash_idx]; tblnode; tblnode = tblnode->htnext) {
+		if (tblnode == node) {
+			IBND_ERROR("Duplicate Node: Node with guid 0x%016"
+				   PRIx64 " already exists in nodes DB\n",
+				   node->guid);
+			return 1;
+		}
+	}
 	node->htnext = hash[hash_idx];
 	hash[hash_idx] = node;
+	return rc;
 }
 
-void add_to_portguid_hash(ibnd_port_t * port, ibnd_port_t * hash[])
+int add_to_portguid_hash(ibnd_port_t * port, ibnd_port_t * hash[])
 {
+	int rc = 0;
+	ibnd_port_t *tblport;
 	int hash_idx = HASHGUID(port->guid) % HTSZ;
 
+	for (tblport = hash[hash_idx]; tblport; tblport = tblport->htnext) {
+		if (tblport == port) {
+			IBND_ERROR("Duplicate Port: Port with guid 0x%016"
+				   PRIx64 " already exists in ports DB\n",
+				   port->guid);
+			return 1;
+		}
+	}
 	port->htnext = hash[hash_idx];
 	hash[hash_idx] = port;
+	return rc;
 }
 
 void create_lid2guid(f_internal_t *f_int)
@@ -712,6 +737,7 @@ ibnd_fabric_t *ibnd_discover_fabric(char * ca_name, int ca_port,
 	ib_portid_t my_portid = { 0 };
 	smp_engine_t engine;
 	ibnd_scan_t scan;
+	struct ibmad_port *ibmad_port;
 	int nc = 2;
 	int mc[2] = { IB_SMI_CLASS, IB_SMI_DIRECT_CLASS };
 
@@ -735,20 +761,27 @@ ibnd_fabric_t *ibnd_discover_fabric(char * ca_name, int ca_port,
 	scan.cfg = &config;
 	scan.initial_hops = from->drpath.cnt;
 
-	if (smp_engine_init(&engine, ca_name, ca_port, &scan, &config)) {
-		free(f_int);
+	ibmad_port = mad_rpc_open_port(ca_name, ca_port, mc, nc);
+	if (!ibmad_port) {
+		IBND_ERROR("can't open MAD port (%s:%d)\n", ca_name, ca_port);
 		return (NULL);
 	}
+	mad_rpc_set_timeout(ibmad_port, cfg->timeout_ms);
+	mad_rpc_set_retries(ibmad_port, cfg->retries);
+	smp_mkey_set(ibmad_port, cfg->mkey);
 
-	scan.ibmad_port = mad_rpc_open_port(ca_name, ca_port, mc, nc);
-	if (!scan.ibmad_port) {
-		IBND_ERROR("can't open MAD port (%s:%d)\n", ca_name, ca_port);
-		smp_engine_destroy(&engine);
+	if (ib_resolve_self_via(&scan.selfportid,
+				NULL, NULL, ibmad_port) < 0) {
+		IBND_ERROR("Failed to resolve self\n");
+		mad_rpc_close_port(ibmad_port);
+		return NULL;
+	}
+	mad_rpc_close_port(ibmad_port);
+
+	if (smp_engine_init(&engine, ca_name, ca_port, &scan, &config)) {
+		free(f_int);
 		return (NULL);
 	}
-	mad_rpc_set_timeout(scan.ibmad_port, cfg->timeout_ms);
-	mad_rpc_set_retries(scan.ibmad_port, cfg->retries);
-	smp_mkey_set(scan.ibmad_port, cfg->mkey);
 
 	IBND_DEBUG("from %s\n", portid2str(from));
 
@@ -763,11 +796,9 @@ ibnd_fabric_t *ibnd_discover_fabric(char * ca_name, int ca_port,
 		goto error;
 
 	smp_engine_destroy(&engine);
-	mad_rpc_close_port(scan.ibmad_port);
 	return (ibnd_fabric_t *)f_int;
 error:
 	smp_engine_destroy(&engine);
-	mad_rpc_close_port(scan.ibmad_port);
 	ibnd_destroy_fabric(&f_int->fabric);
 	return NULL;
 }
diff --git a/libibnetdisc/src/ibnetdisc_cache.c b/libibnetdisc/src/ibnetdisc_cache.c
index d4663bf..94dd004 100644
--- a/libibnetdisc/src/ibnetdisc_cache.c
+++ b/libibnetdisc/src/ibnetdisc_cache.c
@@ -515,7 +515,13 @@ static int _fill_port(ibnd_fabric_cache_t * fabric_cache, ibnd_node_t * node,
 	/* achu: needed if user wishes to re-cache a loaded fabric.
 	 * Otherwise, mostly unnecessary to do this.
 	 */
-	add_to_portguid_hash(port_cache->port, fabric_cache->f_int->fabric.portstbl);
+	int rc = add_to_portguid_hash(port_cache->port,
+				      fabric_cache->f_int->fabric.portstbl);
+	if (rc) {
+		IBND_DEBUG("Error Occurred when trying"
+			   " to insert new port guid 0x%016" PRIx64 " to DB\n",
+			   port_cache->port->guid);
+	}
 	return 0;
 }
 
@@ -538,8 +544,15 @@ static int _rebuild_nodes(ibnd_fabric_cache_t * fabric_cache)
 		node->next = fabric_cache->f_int->fabric.nodes;
 		fabric_cache->f_int->fabric.nodes = node;
 
-		add_to_nodeguid_hash(node_cache->node,
-				     fabric_cache->f_int->fabric.nodestbl);
+		int rc = add_to_nodeguid_hash(node_cache->node,
+					      fabric_cache->
+					      f_int->
+					      fabric.nodestbl);
+		if (rc) {
+			IBND_DEBUG("Error Occurred when trying"
+				   " to insert new node guid 0x%016" PRIx64 " to DB\n",
+				   node_cache->node->guid);
+		}
 
 		add_to_type_list(node_cache->node, fabric_cache->f_int);
 
diff --git a/libibnetdisc/src/internal.h b/libibnetdisc/src/internal.h
index 1ccd29c..5a32cd2 100644
--- a/libibnetdisc/src/internal.h
+++ b/libibnetdisc/src/internal.h
@@ -71,7 +71,6 @@ typedef struct ibnd_scan {
 	ib_portid_t selfportid;
 	f_internal_t *f_int;
 	struct ibnd_config *cfg;
-	struct ibmad_port *ibmad_port;
 	unsigned initial_hops;
 } ibnd_scan_t;
 
@@ -107,9 +106,9 @@ int issue_smp(smp_engine_t * engine, ib_portid_t * portid,
 int process_mads(smp_engine_t * engine);
 void smp_engine_destroy(smp_engine_t * engine);
 
-void add_to_nodeguid_hash(ibnd_node_t * node, ibnd_node_t * hash[]);
+int add_to_nodeguid_hash(ibnd_node_t * node, ibnd_node_t * hash[]);
 
-void add_to_portguid_hash(ibnd_port_t * port, ibnd_port_t * hash[]);
+int add_to_portguid_hash(ibnd_port_t * port, ibnd_port_t * hash[]);
 void add_to_portlid_hash(ibnd_port_t * port, GHashTable *htable);
 
 void add_to_type_list(ibnd_node_t * node, f_internal_t * fabric);
diff --git a/libibnetdisc/src/query_smp.c b/libibnetdisc/src/query_smp.c
index 28620b4..8f179e4 100644
--- a/libibnetdisc/src/query_smp.c
+++ b/libibnetdisc/src/query_smp.c
@@ -171,9 +171,7 @@ static int process_one_recv(smp_engine_t * engine)
 
 	/* wait for the next message */
 	if ((rc = umad_recv(engine->umad_fd, umad, &length,
-			    0)) < 0) {
-		if (rc == -EWOULDBLOCK)
-			return 0;
+			    -1)) < 0) {
 		IBND_ERROR("umad_recv failed: %d\n", rc);
 		return -1;
 	}
diff --git a/src/dump_fts.c b/src/dump_fts.c
index 0de61da..387211f 100644
--- a/src/dump_fts.c
+++ b/src/dump_fts.c
@@ -457,33 +457,41 @@ int main(int argc, char **argv)
 	if (argc > 1)
 		endlid = strtoul(argv[1], 0, 0);
 
-	srcport = mad_rpc_open_port(ibd_ca, ibd_ca_port, mgmt_classes, 3);
-	if (!srcport)
-		IBEXIT("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);
-
 	node_name_map = open_node_name_map(node_name_map_file);
 
-	smp_mkey_set(srcport, ibd_mkey);
-
-	if (ibd_timeout) {
-		mad_rpc_set_timeout(srcport, ibd_timeout);
+	if (ibd_timeout)
 		config.timeout_ms = ibd_timeout;
-	}
 
 	config.flags = ibd_ibnetdisc_flags;
 	config.mkey = ibd_mkey;
 
 	if ((fabric = ibnd_discover_fabric(ibd_ca, ibd_ca_port, NULL,
 						&config)) != NULL) {
+
+		srcport = mad_rpc_open_port(ibd_ca, ibd_ca_port, mgmt_classes, 3);
+		if (!srcport) {
+			fprintf(stderr,
+				"Failed to open '%s' port '%d'\n", ibd_ca, ibd_ca_port);
+			rc = -1;
+			goto Exit;
+		}
+		smp_mkey_set(srcport, ibd_mkey);
+
+		if (ibd_timeout) {
+			mad_rpc_set_timeout(srcport, ibd_timeout);
+		}
+
 		ibnd_iter_nodes_type(fabric, process_switch, IB_NODE_SWITCH, fabric);
+
+		mad_rpc_close_port(srcport);
+
 	} else {
 		fprintf(stderr, "Failed to discover fabric\n");
 		rc = -1;
 	}
-
+Exit:
 	ibnd_destroy_fabric(fabric);
 
-	mad_rpc_close_port(srcport);
 	close_node_name_map(node_name_map);
 	exit(rc);
 }
diff --git a/src/ibdiag_common.c b/src/ibdiag_common.c
index e09623d..5ec0167 100644
--- a/src/ibdiag_common.c
+++ b/src/ibdiag_common.c
@@ -82,7 +82,7 @@ static const char **prog_examples;
 static struct option *long_opts = NULL;
 static const struct ibdiag_opt *opts_map[256];
 
-const static char *get_build_version(void)
+static const char *get_build_version(void)
 {
 	return "BUILD VERSION: " IBDIAG_VERSION " Build date: " __DATE__ " "
 	    __TIME__;
@@ -507,7 +507,7 @@ int is_port_info_extended_supported(ib_portid_t * dest, int port,
 	uint32_t cap_mask;
 	uint16_t cap_mask2;
 
-	if (smp_query_via(data, dest, IB_ATTR_PORT_INFO, port, 0, srcport) < 0)
+	if (!smp_query_via(data, dest, IB_ATTR_PORT_INFO, port, 0, srcport))
 		IBEXIT("port info query failed");
 
 	mad_decode_field(data, IB_PORT_CAPMASK_F, &cap_mask);
diff --git a/src/ibdiag_sa.c b/src/ibdiag_sa.c
index 018a428..1dc43d8 100644
--- a/src/ibdiag_sa.c
+++ b/src/ibdiag_sa.c
@@ -60,18 +60,32 @@ struct sa_handle * sa_get_handle(void)
 		IBWARN("No SM/SA found on port %s:%d",
 			ibd_ca ? "" : ibd_ca,
 			ibd_ca_port);
-		free(handle);
-		return (NULL);
+		goto err;
 	}
 
 	handle->dport.qp = 1;
 	if (!handle->dport.qkey)
 		handle->dport.qkey = IB_DEFAULT_QP1_QKEY;
 
-	handle->fd = umad_open_port(ibd_ca, ibd_ca_port);
-	handle->agent = umad_register(handle->fd, IB_SA_CLASS, 2, 1, NULL);
+	if ((handle->fd = umad_open_port(ibd_ca, ibd_ca_port)) < 0) {
+		IBWARN("umad_open_port on port %s:%d failed",
+			ibd_ca ? "" : ibd_ca,
+			ibd_ca_port);
+		goto err;
+	}
+	if ((handle->agent = umad_register(handle->fd, IB_SA_CLASS, 2, 1, NULL)) < 0) {
+		umad_close_port(handle->fd);
+		IBWARN("umad_register for SA class failed on port %s:%d",
+		       ibd_ca ? "" : ibd_ca,
+		       ibd_ca_port);
+		goto err;
+	}
 
 	return handle;
+
+err:
+	free(handle);
+	return (NULL);
 }
 
 void sa_free_handle(struct sa_handle * h)
diff --git a/src/iblinkinfo.c b/src/iblinkinfo.c
index 92ff3c6..5f2b677 100644
--- a/src/iblinkinfo.c
+++ b/src/iblinkinfo.c
@@ -594,6 +594,7 @@ int main(int argc, char **argv)
 	ibnd_fabric_t *diff_fabric = NULL;
 	struct ibmad_port *ibmad_port;
 	ib_portid_t port_id = { 0 };
+	uint8_t ni[IB_SMP_DATA_SIZE] = { 0 };
 	int mgmt_classes[3] =
 	    { IB_SMI_CLASS, IB_SMI_DIRECT_CLASS, IB_SA_CLASS };
 
@@ -659,6 +660,7 @@ int main(int argc, char **argv)
 	node_name_map = open_node_name_map(node_name_map_file);
 
 	if (dr_path && load_cache_file) {
+		mad_rpc_close_port(ibmad_port);
 		fprintf(stderr, "Cannot specify cache and direct route path\n");
 		exit(1);
 	}
@@ -679,6 +681,16 @@ int main(int argc, char **argv)
 			       guid_str);
 	}
 
+	if (!all && dr_path) {
+		if (!smp_query_via(ni, &port_id, IB_ATTR_NODE_INFO, 0,
+				   ibd_timeout, ibmad_port)){
+			mad_rpc_close_port(ibmad_port);
+			fprintf(stderr, "Failed to get local Node Info\n");
+			exit(1);
+		}
+	}
+	mad_rpc_close_port(ibmad_port);
+
 	if (diff_cache_file &&
 	    !(diff_fabric = ibnd_load_fabric(diff_cache_file, 0)))
 		IBEXIT("loading cached fabric for diff failed\n");
@@ -723,11 +735,6 @@ int main(int argc, char **argv)
 			fprintf(stderr, "Failed to find port: %s\n", guid_str);
 	} else if (!all && dr_path) {
 		ibnd_port_t *p = NULL;
-		uint8_t ni[IB_SMP_DATA_SIZE] = { 0 };
-
-		if (!smp_query_via(ni, &port_id, IB_ATTR_NODE_INFO, 0,
-				   ibd_timeout, ibmad_port))
-			return -1;
 		mad_decode_field(ni, IB_NODE_PORT_GUID_F, &(guid));
 
 		p = ibnd_find_port_guid(fabric, guid);
@@ -758,6 +765,5 @@ int main(int argc, char **argv)
 
 close_port:
 	close_node_name_map(node_name_map);
-	mad_rpc_close_port(ibmad_port);
 	exit(rc);
 }
diff --git a/src/ibqueryerrors.c b/src/ibqueryerrors.c
index 9d9ec45..40a8ad1 100644
--- a/src/ibqueryerrors.c
+++ b/src/ibqueryerrors.c
@@ -326,7 +326,9 @@ static int path_record_query(ib_gid_t sgid,uint64_t dguid)
      uint8_t reversible = 0;
      struct sa_handle * h;
 
-     h = sa_get_handle();
+     if (!(h = sa_get_handle()))
+	return -1;
+
      ibd_timeout = DEFAULT_HALF_WORLD_PR_TIMEOUT;
      memset(&pr, 0, sizeof(pr));
 
@@ -344,6 +346,7 @@ static int path_record_query(ib_gid_t sgid,uint64_t dguid)
                         (uint16_t)IB_SA_ATTR_PATHRECORD,0,cl_ntoh64(comp_mask),ibd_sakey,
                         &pr, sizeof(pr), &result);
      if (ret) {
+             sa_free_handle(h);
              fprintf(stderr, "Query SA failed: %s; sa call path_query failed\n", strerror(ret));
              return ret;
      }
@@ -355,6 +358,7 @@ static int path_record_query(ib_gid_t sgid,uint64_t dguid)
 
      insert_lid2sl_table(&result);
 Exit:
+     sa_free_handle(h);
      sa_free_result_mad(&result);
      return ret;
 }
@@ -998,18 +1002,19 @@ int main(int argc, char **argv)
 	config.flags = ibd_ibnetdisc_flags;
 	config.mkey = ibd_mkey;
 
-	node_name_map = open_node_name_map(node_name_map_file);
-
 	if (dr_path && load_cache_file) {
+		mad_rpc_close_port(ibmad_port);
 		fprintf(stderr, "Cannot specify cache and direct route path\n");
 		exit(-1);
 	}
 
 	if (resolve_self(ibd_ca, ibd_ca_port, &self_portid, &port, &self_gid.raw) < 0) {
+		mad_rpc_close_port(ibmad_port);
 		IBEXIT("can't resolve self port %s", argv[0]);
-		goto close_port;
 	}
 
+	node_name_map = open_node_name_map(node_name_map_file);
+
 	/* limit the scan the fabric around the target */
 	if (dr_path) {
 		if ((resolved =
@@ -1028,10 +1033,13 @@ int main(int argc, char **argv)
 			lid2sl_table[portid.lid] = portid.sl;
 	}
 
+	mad_rpc_close_port(ibmad_port);
+
 	if (load_cache_file) {
 		if ((fabric = ibnd_load_fabric(load_cache_file, 0)) == NULL) {
 			fprintf(stderr, "loading cached fabric failed\n");
-			exit(-1);
+			rc = -1;
+			goto close_name_map;
 		}
 	} else {
 		if (resolved >= 0) {
@@ -1049,12 +1057,27 @@ int main(int argc, char **argv)
 							       &config))) {
 			fprintf(stderr, "discover failed\n");
 			rc = -1;
-			goto close_port;
+			goto close_name_map;
 		}
 	}
 
 	set_thresholds(threshold_file);
 
+	/* reopen the global ibmad_port */
+	ibmad_port = mad_rpc_open_port(ibd_ca, ibd_ca_port,
+				       mgmt_classes, 4);
+	if (!ibmad_port) {
+		ibnd_destroy_fabric(fabric);
+		close_node_name_map(node_name_map);
+		IBEXIT("Failed to reopen port: %s:%d\n",
+			ibd_ca, ibd_ca_port);
+	}
+
+	smp_mkey_set(ibmad_port, ibd_mkey);
+
+	if (ibd_timeout)
+		mad_rpc_set_timeout(ibmad_port, ibd_timeout);
+
 	if (port_guid_str) {
 		ibnd_port_t *port = ibnd_find_port_guid(fabric, port_guid);
 		if (port)
@@ -1063,28 +1086,29 @@ int main(int argc, char **argv)
 			fprintf(stderr, "Failed to find node: %s\n",
 				port_guid_str);
 	} else if (dr_path) {
-		ibnd_port_t *port = ibnd_find_port_dr(fabric, dr_path);
+		ibnd_port_t *port;
 		uint8_t ni[IB_SMP_DATA_SIZE] = { 0 };
-
 		if (!smp_query_via(ni, &portid, IB_ATTR_NODE_INFO, 0,
-				   ibd_timeout, ibmad_port)) {
-			rc = -1;
-			goto destroy_fabric;
+			   ibd_timeout, ibmad_port)) {
+				fprintf(stderr, "Failed to query local Node Info\n");
+				goto close_port;
 		}
+
 		mad_decode_field(ni, IB_NODE_PORT_GUID_F, &(port_guid));
 
 		port = ibnd_find_port_guid(fabric, port_guid);
 		if (port) {
 			if(obtain_sl)
 				if(path_record_query(self_gid,port->guid))
-					goto destroy_fabric;
+					goto close_port;
 			print_node(port->node, NULL);
 		} else
 			fprintf(stderr, "Failed to find node: %s\n", dr_path);
 	} else {
 		if(obtain_sl)
 			if(path_record_query(self_gid,0))
-				goto destroy_fabric;
+				goto close_port;
+
 		ibnd_iter_nodes(fabric, print_node, NULL);
 	}
 
@@ -1092,11 +1116,11 @@ int main(int argc, char **argv)
 	if (rc)
 		rc = 1;
 
-destroy_fabric:
-	ibnd_destroy_fabric(fabric);
-
 close_port:
 	mad_rpc_close_port(ibmad_port);
+	ibnd_destroy_fabric(fabric);
+
+close_name_map:
 	close_node_name_map(node_name_map);
 	exit(rc);
 }
diff --git a/src/perfquery.c b/src/perfquery.c
index 3202502..948ce52 100644
--- a/src/perfquery.c
+++ b/src/perfquery.c
@@ -327,7 +327,7 @@ static void dump_perfcounters(int extended, int timeout, uint16_t cap_mask,
 		if (!(cap_mask & IB_PM_EXT_WIDTH_SUPPORTED) &&
 		    !(cap_mask & IB_PM_EXT_WIDTH_NOIETF_SUP))
 			IBWARN
-			    ("PerfMgt ClassPortInfo 0x%x; No extended counter support indicated\n",
+			    ("PerfMgt ClassPortInfo CapMask 0x%02X; No extended counter support indicated\n",
 			     ntohs(cap_mask));
 
 		memset(pc, 0, sizeof(pc));
@@ -469,7 +469,7 @@ static uint8_t is_rsfec_mode_active(ib_portid_t * portid, int port,
 				  uint16_t cap_mask)
 {
 	uint8_t data[IB_SMP_DATA_SIZE] = { 0 };
-	uint16_t fec_mode_active = 0;
+	uint32_t fec_mode_active = 0;
 	uint32_t pie_capmask = 0;
 	if (cap_mask & IS_PM_RSFEC_COUNTERS_SUP) {
 		if (!is_port_info_extended_supported(portid, port, srcport)) {
@@ -477,8 +477,8 @@ static uint8_t is_rsfec_mode_active(ib_portid_t * portid, int port,
 			return 0;
 		}
 
-		if (smp_query_via(data, portid, IB_ATTR_PORT_INFO_EXT, port, 0,
-				  srcport) < 0)
+		if (!smp_query_via(data, portid, IB_ATTR_PORT_INFO_EXT, port, 0,
+				   srcport))
 			IBEXIT("smp query portinfo extended failed");
 
 		mad_decode_field(data, IB_PORT_EXT_CAPMASK_F, &pie_capmask);
@@ -486,7 +486,7 @@ static uint8_t is_rsfec_mode_active(ib_portid_t * portid, int port,
 				 &fec_mode_active);
 		if((pie_capmask &
 		    CL_NTOH32(IB_PORT_EXT_CAP_IS_FEC_MODE_SUPPORTED)) &&
-		   (CL_NTOH16(IB_PORT_EXT_RS_FEC_MODE_ACTIVE) == fec_mode_active))
+		   (CL_NTOH16(IB_PORT_EXT_RS_FEC_MODE_ACTIVE) == (fec_mode_active & 0xffff)))
 			return 1;
 	}
 
@@ -915,8 +915,8 @@ int main(int argc, char **argv)
 
 
 	if (all_ports_loop || (loop_ports && (all_ports || port == ALL_PORTS))) {
-		if (smp_query_via(data, &portid, IB_ATTR_NODE_INFO, 0, 0,
-				  srcport) < 0)
+		if (!smp_query_via(data, &portid, IB_ATTR_NODE_INFO, 0, 0,
+				   srcport))
 			IBEXIT("smp query nodeinfo failed");
 		node_type = mad_get_field(data, 0, IB_NODE_TYPE_F);
 		mad_decode_field(data, IB_NODE_NPORTS_F, &num_ports);
@@ -924,8 +924,8 @@ int main(int argc, char **argv)
 			IBEXIT("smp query nodeinfo: num ports invalid");
 
 		if (node_type == IB_NODE_SWITCH) {
-			if (smp_query_via(data, &portid, IB_ATTR_SWITCH_INFO,
-					  0, 0, srcport) < 0)
+			if (!smp_query_via(data, &portid, IB_ATTR_SWITCH_INFO,
+					   0, 0, srcport))
 				IBEXIT("smp query nodeinfo failed");
 			enhancedport0 =
 			    mad_get_field(data, 0, IB_SW_ENHANCED_PORT0_F);
diff --git a/src/rdma-ndd.c b/src/rdma-ndd.c
index bbde6af..9860824 100644
--- a/src/rdma-ndd.c
+++ b/src/rdma-ndd.c
@@ -58,9 +58,7 @@ struct udev_monitor *mon;
 #include "ibdiag_common.h"
 
 #define SYS_HOSTNAME "/proc/sys/kernel/hostname"
-#define DEF_SYS_DIR "/sys"
-char *sys_dir = DEF_SYS_DIR;
-#define SYS_INFINIBAND "class/infiniband"
+#define SYS_INFINIBAND "/sys/class/infiniband"
 #define DEFAULT_RETRY_RATE 60
 #define DEFAULT_RETRY_COUNT 0
 #define DEFAULT_ND_FORMAT "%h %d"
@@ -68,6 +66,7 @@ char *sys_dir = DEF_SYS_DIR;
 int failure_retry_rate = DEFAULT_RETRY_RATE;
 int set_retry_cnt = DEFAULT_RETRY_COUNT;
 int foreground = 0;
+char *pidfile = NULL;
 
 static void newline_to_null(char *str)
 {
@@ -121,8 +120,8 @@ static int update_node_desc(const char *device, const char *hostname, int force)
 	char nd_file[PATH_MAX];
 	FILE *f;
 
-	snprintf(nd_file, sizeof(nd_file), "%s/%s/%s/node_desc",
-			sys_dir, SYS_INFINIBAND, device);
+	snprintf(nd_file, sizeof(nd_file), SYS_INFINIBAND "/%s/node_desc",
+			device);
 	nd_file[sizeof(nd_file)-1] = '\0';
 
 	f = fopen(nd_file, "r+");
@@ -146,7 +145,7 @@ static int update_node_desc(const char *device, const char *hostname, int force)
 		syslog(LOG_INFO, "%s: change (%s) -> (%s)\n",
 			device, nd, new_nd);
 		rewind(f);
-		fprintf(f, new_nd);
+		fprintf(f, "%s", new_nd);
 	}
 
 	rc = 0;
@@ -159,14 +158,10 @@ static int set_rdma_node_desc(const char *hostname, int force)
 {
 	DIR *class_dir;
 	struct dirent *dent;
-	char dev_dir[PATH_MAX];
 
-	snprintf(dev_dir, sizeof(dev_dir), "%s/%s", sys_dir, SYS_INFINIBAND);
-	dev_dir[sizeof(dev_dir)-1] = '\0';
-
-	class_dir = opendir(dev_dir);
+	class_dir = opendir(SYS_INFINIBAND);
 	if (!class_dir) {
-		syslog(LOG_INFO, "Failed to open %s", dev_dir);
+		syslog(LOG_INFO, "Failed to open " SYS_INFINIBAND);
 		return -ENOSYS;
 	}
 
@@ -205,6 +200,9 @@ static int process_opts(void *context, int ch, char *optarg)
 {
 	unsigned long tmp;
 	switch (ch) {
+	case 0:
+		pidfile = optarg;
+		break;
 	case 'f':
 		foreground = 1;
 		break;
@@ -234,6 +232,7 @@ static int process_opts(void *context, int ch, char *optarg)
 	return 0;
 }
 
+#if HAVE_UDEV_LOGGING
 #define MSG_MAX 2048
 static void udev_log_fn(struct udev *ud, int priority, const char *file, int line,
 		const char *fn, const char *format, va_list args)
@@ -244,8 +243,9 @@ static void udev_log_fn(struct udev *ud, int priority, const char *file, int lin
 			file, line, fn);
 	if (off < MSG_MAX-1)
 		vsnprintf(msg+off, MSG_MAX-off, format, args);
-	syslog(LOG_ERR, msg);
+	syslog(LOG_ERR, "%s", msg);
 }
+#endif
 
 static void setup_udev(void)
 {
@@ -255,10 +255,9 @@ static void setup_udev(void)
 		return;
 	}
 
+#if HAVE_UDEV_LOGGING
 	udev_set_log_fn(udev, udev_log_fn);
 	udev_set_log_priority(udev, LOG_INFO);
-#if HAVE_UDEV_GET_SYS_PATH
-	sys_dir = (char *)udev_get_sys_path(udev);
 #endif
 }
 
@@ -352,6 +351,29 @@ static void monitor(void)
 	}
 }
 
+static void remove_pidfile(void)
+{
+        if (pidfile)
+		unlink(pidfile);
+}
+
+static void write_pidfile(void)
+{
+	FILE *f;
+	if (pidfile) {
+		remove_pidfile();
+		f = fopen(pidfile, "w");
+		if (f) {
+			fprintf(f, "%d\n", getpid());
+			fclose(f);
+		} else {
+			syslog(LOG_ERR, "Failed to write pidfile : %s\n",
+				pidfile);
+			exit(errno);
+		}
+	}
+}
+
 int main(int argc, char *argv[])
 {
 	int fd;
@@ -368,6 +390,7 @@ int main(int argc, char *argv[])
 			"Number of times to attempt to retry setting "
 			"of the node description on failure\n"},
 		{"foreground", 'f', 0, NULL, "run in the foreground instead of as a daemon\n"},
+		{"pidfile", 0, 1, "<pidfile>", "specify a pid file (daemon mode only)\n"},
 		{0}
 	};
 
@@ -377,8 +400,6 @@ int main(int argc, char *argv[])
 	if (!ibd_nd_format)
 		ibd_nd_format = DEFAULT_ND_FORMAT;
 
-	setup_udev();
-
 	if (!foreground) {
 		closelog();
 		openlog("rdma-ndd", LOG_PID, LOG_DAEMON);
@@ -386,8 +407,11 @@ int main(int argc, char *argv[])
 			syslog(LOG_ERR, "Failed to daemonize\n");
 			exit(errno);
 		}
+		write_pidfile();
 	}
 
+	setup_udev();
+
 	syslog(LOG_INFO, "Node Descriptor format (%s)\n", ibd_nd_format);
 
 	fd = open(SYS_HOSTNAME, O_RDONLY);
@@ -398,5 +422,7 @@ int main(int argc, char *argv[])
 
 	monitor();
 
+	remove_pidfile();
+
 	return 0;
 }
diff --git a/src/saquery.c b/src/saquery.c
index eae7fee..cc8d8dc 100644
--- a/src/saquery.c
+++ b/src/saquery.c
@@ -1567,6 +1567,7 @@ static int process_opt(void *context, int ch, char *optarg)
 		break;
 	case 'D':
 		node_print_desc = ALL_DESC;
+		command = SAQUERY_CMD_NODE_RECORD;
 		break;
 	case 'c':
 		command = SAQUERY_CMD_CLASS_PORT_INFO;
diff --git a/src/vendstat.c b/src/vendstat.c
index 11ee73e..baade3e 100644
--- a/src/vendstat.c
+++ b/src/vendstat.c
@@ -172,13 +172,14 @@ static int do_vendor(ib_portid_t *portid, struct ibmad_port *srcport,
 	call.attrid = attr_id;
 	call.mod = attr_mod;
 
-	if (!ib_vendor_call_via(data, portid, &call, srcport))
-		IBEXIT("vendstat: method %u, attribute %u", method, attr_id);
-
+	if (!ib_vendor_call_via(data, portid, &call, srcport)) {
+		fprintf(stderr,"vendstat: method %u, attribute %u failure\n", method, attr_id);
+		return -1;
+	}
 	return 0;
 }
 
-static void do_config_space_records(ib_portid_t *portid, unsigned set,
+static int do_config_space_records(ib_portid_t *portid, unsigned set,
 				    is3_config_space_t *cs, unsigned records)
 {
 	unsigned i;
@@ -194,17 +195,19 @@ static void do_config_space_records(ib_portid_t *portid, unsigned set,
 	if (do_vendor(portid, srcport, IB_MLX_VENDOR_CLASS,
 		      set ? IB_MAD_METHOD_SET : IB_MAD_METHOD_GET,
 		      IB_MLX_IS3_CONFIG_SPACE_ACCESS, 2 << 22 | records << 16,
-		      cs))
-		IBEXIT("cannot %s config space records", set ? "set" : "get");
-
+		      cs)) {
+		fprintf(stderr,"cannot %s config space records\n", set ? "set" : "get");
+		return -1;
+	}
 	for (i = 0; i < records; i++) {
 		printf("Config space record at 0x%x: 0x%x\n",
 		       ntohl(cs->record[i].address),
 		       ntohl(cs->record[i].data & cs->record[i].mask));
 	}
+	return 0;
 }
 
-static void counter_groups_info(ib_portid_t * portid, int port)
+static int counter_groups_info(ib_portid_t * portid, int port)
 {
 	char buf[1024];
 	is4_counter_group_info_t *cg_info;
@@ -213,15 +216,17 @@ static void counter_groups_info(ib_portid_t * portid, int port)
 	/* Counter Group Info */
 	memset(&buf, 0, sizeof(buf));
 	if (do_vendor(portid, srcport, IB_MLX_VENDOR_CLASS, IB_MAD_METHOD_GET,
-		      IB_MLX_IS4_COUNTER_GROUP_INFO, port, buf))
-		IBEXIT("counter group info query");
-
+		      IB_MLX_IS4_COUNTER_GROUP_INFO, port, buf)) {
+		fprintf(stderr,"counter group info query failure\n");
+		return -1;
+	}
 	cg_info = (is4_counter_group_info_t *) & buf;
 	num_cg = cg_info->num_of_counter_groups;
 	printf("counter_group_info:\n");
 	printf("%d counter groups\n", num_cg);
 	for (i = 0; i < num_cg; i++)
 		printf("group%d mask %#x\n", i, ntohl(cg_info->group_masks[i]));
+	return 0;
 }
 
 /* Group0 counter config values */
@@ -236,7 +241,7 @@ static void counter_groups_info(ib_portid_t * portid, int port)
 
 static int cg0, cg1;
 
-static void config_counter_groups(ib_portid_t * portid, int port)
+static int config_counter_groups(ib_portid_t * portid, int port)
 {
 	char buf[1024];
 	is4_config_counter_groups_t *cg_config;
@@ -251,15 +256,19 @@ static void config_counter_groups(ib_portid_t * portid, int port)
 	cg_config->group_selects[1].group_select = (uint8_t) cg1;
 
 	if (do_vendor(portid, srcport, IB_MLX_VENDOR_CLASS, IB_MAD_METHOD_SET,
-		      IB_MLX_IS4_CONFIG_COUNTER_GROUP, port, buf))
-		IBEXIT("config counter group set");
-
+		      IB_MLX_IS4_CONFIG_COUNTER_GROUP, port, buf)) {
+		fprintf(stderr, "config counter group set failure\n");
+		return -1;
+	}
 	/* get config counter groups */
 	memset(&buf, 0, sizeof(buf));
 
 	if (do_vendor(portid, srcport, IB_MLX_VENDOR_CLASS, IB_MAD_METHOD_GET,
-		      IB_MLX_IS4_CONFIG_COUNTER_GROUP, port, buf))
-		IBEXIT("config counter group query");
+		      IB_MLX_IS4_CONFIG_COUNTER_GROUP, port, buf)) {
+		fprintf(stderr, "config counter group query failure\n");
+		return -1;
+	}
+	return 0;
 }
 
 static int general_info, xmit_wait, counter_group_info, config_counter_group;
@@ -364,20 +373,26 @@ int main(int argc, char **argv)
 
 	if (argc) {
 		if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[0],
-				       ibd_dest_type, ibd_sm_id, srcport) < 0)
+				       ibd_dest_type, ibd_sm_id, srcport) < 0) {
+			mad_rpc_close_port(srcport);
 			IBEXIT("can't resolve destination port %s", argv[0]);
+		}
 	} else {
-		if (resolve_self(ibd_ca, ibd_ca_port, &portid, &port, 0) < 0)
+		if (resolve_self(ibd_ca, ibd_ca_port, &portid, &port, 0) < 0) {
+			mad_rpc_close_port(srcport);
 			IBEXIT("can't resolve self port %s", argv[0]);
+		}
 	}
 
 	if (counter_group_info) {
 		counter_groups_info(&portid, port);
+		mad_rpc_close_port(srcport);
 		exit(0);
 	}
 
 	if (config_counter_group) {
 		config_counter_groups(&portid, port);
+		mad_rpc_close_port(srcport);
 		exit(0);
 	}
 
@@ -388,6 +403,7 @@ int main(int argc, char **argv)
 		if (write_cs_records)
 			do_config_space_records(&portid, 1, &write_cs,
 						write_cs_records);
+		mad_rpc_close_port(srcport);
 		exit(0);
 	}
 
@@ -395,23 +411,27 @@ int main(int argc, char **argv)
 	/* but vendors change the VendorId so how know for sure ? */
 	/* Only General Info and Port Xmit Wait Counters */
 	/* queries are currently supported */
-	if (!general_info && !xmit_wait)
+	if (!general_info && !xmit_wait) {
+		mad_rpc_close_port(srcport);
 		IBEXIT("at least one of -N and -w must be specified");
-
+	}
 	/* Would need a list of these and it might not be complete */
 	/* so for right now, punt on this */
 
 	/* vendor ClassPortInfo is required attribute if class supported */
 	memset(&buf, 0, sizeof(buf));
 	if (do_vendor(&portid, srcport, IB_MLX_VENDOR_CLASS, IB_MAD_METHOD_GET,
-		      CLASS_PORT_INFO, 0, buf))
+		      CLASS_PORT_INFO, 0, buf)) {
+		mad_rpc_close_port(srcport);
 		IBEXIT("classportinfo query");
-
+	}
 	memset(&buf, 0, sizeof(buf));
 	gi_is3 = (is3_general_info_t *) &buf;
 	if (do_vendor(&portid, srcport, IB_MLX_VENDOR_CLASS, IB_MAD_METHOD_GET,
-		      IB_MLX_IS3_GENERAL_INFO, 0, gi_is3))
+		      IB_MLX_IS3_GENERAL_INFO, 0, gi_is3)) {
+		mad_rpc_close_port(srcport);
 		IBEXIT("generalinfo query");
+	}
 
 	if (is_ext_fw_info_supported(ntohs(gi_is3->hw_info.device_id))) {
 		gi_is4 = (is4_general_info_t *) &buf;
@@ -452,10 +472,11 @@ int main(int argc, char **argv)
 		is3_config_space_t *cs;
 		unsigned i;
 
-		if (ntohs(gi_is3->hw_info.device_id) != IS3_DEVICE_ID)
+		if (ntohs(gi_is3->hw_info.device_id) != IS3_DEVICE_ID) {
+			mad_rpc_close_port(srcport);
 			IBEXIT("Unsupported device ID 0x%x",
 				ntohs(gi_is3->hw_info.device_id));
-
+		}
 		memset(&buf, 0, sizeof(buf));
 		/* Set record addresses for each port */
 		cs = (is3_config_space_t *) & buf;
@@ -464,9 +485,10 @@ int main(int argc, char **argv)
 			    htonl(IB_MLX_IS3_PORT_XMIT_WAIT + ((i + 1) << 12));
 		if (do_vendor(&portid, srcport, IB_MLX_VENDOR_CLASS,
 			      IB_MAD_METHOD_GET, IB_MLX_IS3_CONFIG_SPACE_ACCESS,
-			      2 << 22 | 16 << 16, cs))
+			      2 << 22 | 16 << 16, cs)) {
+			mad_rpc_close_port(srcport);
 			IBEXIT("vendstat");
-
+		}
 		for (i = 0; i < 16; i++)
 			if (cs->record[i].data)	/* PortXmitWait is 32 bit counter */
 				printf("Port %d: PortXmitWait 0x%x\n", i + 4, ntohl(cs->record[i].data));	/* port 4 is first port */
@@ -480,8 +502,10 @@ int main(int argc, char **argv)
 			    htonl(IB_MLX_IS3_PORT_XMIT_WAIT + ((i + 17) << 12));
 		if (do_vendor(&portid, srcport, IB_MLX_VENDOR_CLASS,
 			      IB_MAD_METHOD_GET, IB_MLX_IS3_CONFIG_SPACE_ACCESS,
-			      2 << 22 | 8 << 16, cs))
+			      2 << 22 | 8 << 16, cs)) {
+			mad_rpc_close_port(srcport);
 			IBEXIT("vendstat");
+		}
 
 		for (i = 0; i < 8; i++)
 			if (cs->record[i].data)	/* PortXmitWait is 32 bit counter */

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ofed/infiniband-diags.git



More information about the Pkg-ofed-commits mailing list