[ofa-general] [PATCH] ibsim: Add a Node Description query drop error.

Ira Weiny weiny2 at llnl.gov
Wed Jul 30 17:40:11 PDT 2008


I added this to ibsim to test the patch I am sending next:

[PATCH] OpenSM: Add a Node Description check on light sweep to ensure that the ND has been found for each node.

Thanks,
Ira


>From ec95833fd08204cb67c9803b488c6ef7e9a30792 Mon Sep 17 00:00:00 2001
From: Ira K. Weiny <weiny2 at llnl.gov>
Date: Wed, 30 Jul 2008 16:16:11 -0700
Subject: [PATCH] ibsim: Add a Node Description query drop error.


Signed-off-by: Ira K. Weiny <weiny2 at llnl.gov>
---
 ibsim/sim.h     |    1 +
 ibsim/sim_cmd.c |   74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 ibsim/sim_mad.c |    8 ++++++
 3 files changed, 83 insertions(+), 0 deletions(-)

diff --git a/ibsim/sim.h b/ibsim/sim.h
index 936bb85..3cd253f 100644
--- a/ibsim/sim.h
+++ b/ibsim/sim.h
@@ -207,6 +207,7 @@ struct Port {
 	Node *remotenode;
 	int remoteport;
 	int errrate;
+	int nddrop;
 	Node *node;
 	Portcounters portcounters;
 	uint16_t *pkey_tbl;
diff --git a/ibsim/sim_cmd.c b/ibsim/sim_cmd.c
index a6aab9d..fbf2ca3 100644
--- a/ibsim/sim_cmd.c
+++ b/ibsim/sim_cmd.c
@@ -262,6 +262,74 @@ static int do_seterror(FILE * f, char *line)
 	return set;
 }
 
+static int do_setnddrop(FILE * f, char *line)
+{
+	Port *port, *e;
+	Node *node;
+	char *s = line;
+	char *nodeid = 0, name[NAMELEN], *sp, *orig = 0;
+	int portnum = -1;	// def - all ports
+	int numports, set = 0, rate = 0;
+
+	if (strsep(&s, "\""))
+		orig = strsep(&s, "\"");
+
+	if (!s) {
+		fprintf(f, "# unlink: bad parameter in \"%s\"\n", line);
+		return -1;
+	}
+
+	nodeid = expand_name(orig, name, &sp);
+	if (!sp && *s == '[')
+		sp = s + 1;
+
+	if (!(node = find_node(nodeid))) {
+		fprintf(f, "# nodeid \"%s\" (%s) not found\n", orig, nodeid);
+		return -1;
+	}
+
+	if (sp) {
+		portnum = strtoul(sp, 0, 0);
+		if (portnum < 1 || portnum > node->numports) {
+			fprintf(f, "# bad port number %d at nodeid \"%s\"\n",
+				portnum, nodeid);
+			return -1;
+		}
+	}
+
+	numports = node->numports;
+
+	if (node->type == SWITCH_NODE)
+		numports++;	// To make the for-loop below run up to last port
+	else
+		portnum--;
+
+	if (portnum >= 0) {
+		port = ports + node->portsbase + portnum;
+		if (port->nddrop)
+			port->nddrop = 0;
+		else
+			port->nddrop = 1;
+		DEBUG("nddrop is %d", port->nddrop);
+		printf("Setting NDDrop %s:%d\n", port->node->nodedesc, port->portnum);
+		return 1;
+	}
+
+	for (port = ports + node->portsbase, e = port + numports; port < e;
+	     port++) {
+		port->errrate = rate;
+		if (port->nddrop)
+			port->nddrop = 0;
+		else
+			port->nddrop = 1;
+		DEBUG("nddrop is %d", port->nddrop);
+		printf("Setting NDDrop %s:%d\n", port->node->nodedesc, port->portnum);
+	}
+
+	return set;
+
+}
+
 static int do_unlink(FILE * f, char *line, int clear)
 {
 	Port *port, *e;
@@ -710,6 +778,8 @@ static int dump_help(FILE * f)
 	fprintf(f,
 		"\tError \"nodeid\"[port] <error-rate>: set error rate for port/node\n");
 	fprintf(f,
+		"\tNDError \"nodeid\"[port]: Toggle the dropping of Node Description packets for the port/node\n");
+	fprintf(f,
 		"\tBaselid \"nodeid\"[port] <lid> [lmc] : change port's lid (lmc)\n");
 	fprintf(f, "\tVerbose [newlevel] - show/set simulator verbosity\n");
 	fprintf(f, "\t\t\t0 - silent\n");
@@ -773,6 +843,10 @@ int do_cmd(char *buf, FILE *f)
 	case 'E':
 		r = do_seterror(f, line);
 		break;
+	case 'n':
+	case 'N':
+		r = do_setnddrop(f, line);
+		break;
 	case 'c':
 	case 'C':
 		r = do_unlink(f, line, 1);
diff --git a/ibsim/sim_mad.c b/ibsim/sim_mad.c
index b8ce2ab..ac3321e 100644
--- a/ibsim/sim_mad.c
+++ b/ibsim/sim_mad.c
@@ -1188,6 +1188,14 @@ int process_packet(Client * cl, void *p, int size, Client ** dcl)
 		return sizeof(*r);	// forward only
 	}
 
+	/* check for node desc drop. */
+	if ((rpc.mgtclass == IB_SMI_CLASS || rpc.mgtclass == IB_SMI_DIRECT_CLASS) &&
+			rpc.attr.id == IB_ATTR_NODE_DESC &&
+			port->nddrop) {
+		VERB("drop pkt due to nddrop flag %d", port->nddrop);
+		goto _dropped;
+	}
+
 	if (port->errrate && (random() % 100) < port->errrate) {
 		VERB("drop pkt due error rate %d", port->errrate);
 		goto _dropped;
-- 
1.5.4.5




More information about the general mailing list