diff mbox

[2/4] sim_ctl_get_pkeys

Message ID 4BA63967.2000004@voltaire.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Doron Shoham March 21, 2010, 3:21 p.m. UTC
None
diff mbox

Patch

diff --git a/ibsim/ibsim.c b/ibsim/ibsim.c
index 9326d37..3cb97e4 100644
--- a/ibsim/ibsim.c
+++ b/ibsim/ibsim.c
@@ -354,11 +354,18 @@  static int sim_ctl_set_issm(Client * cl, struct sim_ctl * ctl)
 
 static int sim_ctl_get_pkeys(Client * cl, struct sim_ctl * ctl)
 {
-	Port *port = cl->port;
-	unsigned size = (port->node->sw && port->portnum) ?
-	    mad_get_field(port->node->sw->switchinfo, 0,
-			  IB_SW_PARTITION_ENFORCE_CAP_F) :
-	    mad_get_field(port->node->nodeinfo, 0, IB_NODE_PARTITION_CAP_F);
+	Port *port;
+	uint8_t port_num = ctl->data[0];
+	unsigned size;
+
+	if (port_num == 0 || port_num > cl->port->node->numports)
+		port = cl->port;
+	else
+		port = node_get_port(cl->port->node, port_num);
+	size = (port->node->sw && port->portnum) ?
+			mad_get_field(port->node->sw->switchinfo, 0,
+					IB_SW_PARTITION_ENFORCE_CAP_F) :
+			mad_get_field(port->node->nodeinfo, 0, IB_NODE_PARTITION_CAP_F);
 
 	size *= sizeof(port->pkey_tbl[0]);
 	if (size > sizeof(ctl->data))