[ofa-general] ***SPAM*** [PATCHv3] opensm/osm_helper.c: Add more info for traps 144 and 256-259 in osm_dump_notice

Hal Rosenstock hnrose at comcast.net
Tue Apr 14 07:45:47 PDT 2009


Signed-off-by: Hal Rosenstock <hal.rosenstock at gmail.com>

---
Changes from v2:
In trap 256, use snprintf to preclude buffer overflow
Also added new line at end

Changes from v1:
In trap 144, display local changes as %u rather than %d
In trap 256, don't use additional buffer and eliminate buffer copying

diff --git a/opensm/opensm/osm_helper.c b/opensm/opensm/osm_helper.c
index 3fa4ed7..b0faf26 100644
--- a/opensm/opensm/osm_helper.c
+++ b/opensm/opensm/osm_helper.c
@@ -2,6 +2,7 @@
  * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
  * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
  * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -1687,6 +1688,7 @@ void osm_dump_notice(IN osm_log_t * p_log,
 {
 	if (osm_log_is_active(p_log, log_level)) {
 		if (ib_notice_is_generic(p_ntci)) {
+			int i, n;
 			char buff[1024];
 			buff[0] = '\0';
 
@@ -1725,11 +1727,16 @@ void osm_dump_notice(IN osm_log_t * p_log,
 			case 144:
 				sprintf(buff,
 					"\t\t\t\tlid......................%u\n"
-					"\t\t\t\tnew_cap_mask.............0x%08x\n",
+					"\t\t\t\tlocal_changes............%u\n"
+					"\t\t\t\tnew_cap_mask.............0x%08x\n"
+					"\t\t\t\tchange_flags.............0x%x\n",
 					cl_ntoh16(p_ntci->data_details.ntc_144.
 						  lid),
+					p_ntci->data_details.ntc_144.local_changes,
 					cl_ntoh32(p_ntci->data_details.ntc_144.
-						  new_cap_mask));
+						  new_cap_mask),
+					cl_ntoh16(p_ntci->data_details.ntc_144.
+						  change_flgs));
 				break;
 			case 145:
 				sprintf(buff,
@@ -1741,6 +1748,95 @@ void osm_dump_notice(IN osm_log_t * p_log,
 					cl_ntoh64(p_ntci->data_details.ntc_145.
 						  new_sys_guid));
 				break;
+			case 256:
+				n = sprintf(buff,
+					"\t\t\t\tlid......................%u\n"
+					"\t\t\t\tdrslid...................%u\n"
+					"\t\t\t\tmethod...................0x%x\n"
+					"\t\t\t\tattr_id..................0x%x\n"
+					"\t\t\t\tattr_mod.................0x%x\n"
+					"\t\t\t\tm_key....................0x%016" PRIx64 "\n"
+					"\t\t\t\tdr_notice................%d\n"
+					"\t\t\t\tdr_path_truncated........%d\n"
+					"\t\t\t\tdr_hop_count.............%u\n",
+					cl_ntoh16(p_ntci->data_details.ntc_256.lid),
+					cl_ntoh16(p_ntci->data_details.ntc_256.dr_slid),
+					p_ntci->data_details.ntc_256.method,
+					cl_ntoh16(p_ntci->data_details.ntc_256.attr_id),
+					cl_ntoh32(p_ntci->data_details.ntc_256.attr_mod),
+					cl_ntoh64(p_ntci->data_details.ntc_256.mkey),
+					p_ntci->data_details.ntc_256.dr_trunc_hop >> 7,
+					p_ntci->data_details.ntc_256.dr_trunc_hop >> 6,
+					p_ntci->data_details.ntc_256.dr_trunc_hop & 0x3f);
+				n += snprintf(buff + n, sizeof(buff) - n,
+					"Directed Path Dump of %u hop path:"
+					"\n\t\t\t\tPath = ",
+					p_ntci->data_details.ntc_256.dr_trunc_hop & 0x3f);
+				for (i = 0;
+				     i <= (p_ntci->data_details.ntc_256.dr_trunc_hop & 0x3f);
+				     i++) {
+					if (i == 0)
+						n += snprintf(buff + n, sizeof(buff) - n, "%d",
+							p_ntci->data_details.ntc_256.dr_rtn_path[i]);
+					else
+						n += snprintf(buff + n, sizeof(buff) - n, ",%d",
+							p_ntci->data_details.ntc_256.dr_rtn_path[i]);
+				}
+				snprintf(buff + n, sizeof(buff) - n, "\n");
+				break;
+			case 257:
+			case 258:
+				sprintf(buff,
+					"\t\t\t\tlid1.....................%u\n"
+					"\t\t\t\tlid2.....................%u\n"
+					"\t\t\t\tkey......................0x%x\n"
+					"\t\t\t\tsl.......................%d\n"
+					"\t\t\t\tqp1......................0x%x\n"
+					"\t\t\t\tqp2......................0x%x\n"
+					"\t\t\t\tgid1.....................0x%016" PRIx64 " : "
+					"0x%016" PRIx64 "\n"
+					"\t\t\t\tgid2.....................0x%016" PRIx64 " : "
+					"0x%016" PRIx64 "\n",
+					cl_ntoh16(p_ntci->data_details.ntc_257_258.lid1),
+					cl_ntoh16(p_ntci->data_details.ntc_257_258.lid2),
+					cl_ntoh32(p_ntci->data_details.ntc_257_258.key),
+					cl_ntoh32(p_ntci->data_details.ntc_257_258.qp1) >> 24,
+					cl_ntoh32(p_ntci->data_details.ntc_257_258.qp1) & 0xffffff,
+					cl_ntoh32(p_ntci->data_details.ntc_257_258.qp2),
+					cl_ntoh64(p_ntci->data_details.ntc_257_258.gid1.unicast.prefix),
+					cl_ntoh64(p_ntci->data_details.ntc_257_258.gid1.unicast.interface_id),
+					cl_ntoh64(p_ntci->data_details.ntc_257_258.gid2.unicast.prefix),
+					cl_ntoh64(p_ntci->data_details.ntc_257_258.gid2.unicast.interface_id));
+				break;
+			case 259:
+				sprintf(buff,
+					"\t\t\t\tdata_valid...............0x%x\n"
+					"\t\t\t\tlid1.....................%u\n"
+					"\t\t\t\tlid2.....................%u\n"
+					"\t\t\t\tpkey.....................0x%x\n"
+					"\t\t\t\tsl.......................%d\n"
+					"\t\t\t\tqp1......................0x%x\n"
+					"\t\t\t\tqp2......................0x%x\n"
+					"\t\t\t\tgid1.....................0x%016" PRIx64 " : "
+					"0x%016" PRIx64 "\n"
+					"\t\t\t\tgid2.....................0x%016" PRIx64 " : "
+					"0x%016" PRIx64 "\n"
+					"\t\t\t\tsw_lid...................%u\n"
+					"\t\t\t\tport_no..................%u\n",
+					cl_ntoh16(p_ntci->data_details.ntc_259.data_valid),
+					cl_ntoh16(p_ntci->data_details.ntc_259.lid1),
+					cl_ntoh16(p_ntci->data_details.ntc_259.lid2),
+					cl_ntoh16(p_ntci->data_details.ntc_259.pkey),
+					cl_ntoh32(p_ntci->data_details.ntc_259.sl_qp1) >> 24,
+					cl_ntoh32(p_ntci->data_details.ntc_259.sl_qp1) & 0xffffff,
+					cl_ntoh32(p_ntci->data_details.ntc_259.qp2),
+					cl_ntoh64(p_ntci->data_details.ntc_259.gid1.unicast.prefix),
+					cl_ntoh64(p_ntci->data_details.ntc_259.gid1.unicast.interface_id),
+					cl_ntoh64(p_ntci->data_details.ntc_259.gid2.unicast.prefix),
+					cl_ntoh64(p_ntci->data_details.ntc_259.gid2.unicast.interface_id),
+					cl_ntoh16(p_ntci->data_details.ntc_259.sw_lid),
+					p_ntci->data_details.ntc_259.port_no);
+				break;
 			}
 
 			osm_log(p_log, log_level,



More information about the general mailing list