[openib-general] [PATCH] ib_mad.c: Filter SMI and GSI packets if received on wrong QPN

Hal Rosenstock halr at voltaire.com
Tue Sep 14 08:23:55 PDT 2004


ib_mad.c: Filter SMI and GSI packets if received on wrong QPN

Index: ib_mad.c
===================================================================
--- ib_mad.c	(revision 822)
+++ ib_mad.c	(working copy)
@@ -317,6 +317,7 @@
 		/* Initialize MAD send WR tracking structure */
 		mad_send_wr->agent = mad_agent;
 		mad_send_wr->wr_id = cur_send_wr->wr_id;
+		/* Timeout valid only when MAD is a request !!! */
 		mad_send_wr->timeout_ms = cur_send_wr->wr.ud.timeout_ms;
 
 		wr.list.next = NULL;
@@ -636,7 +637,7 @@
 	return mad_agent;
 }
 
-static int validate_mad(struct ib_mad *mad)
+static int validate_mad(struct ib_mad *mad, u32 qp_num)
 {
 	int valid = 0;
 
@@ -647,14 +648,15 @@
 		goto ret;
 	}
 
-	/* Need DQPN from incoming MAD !!! */
 	/* Filter SMI packets sent to other than QP0 */
 	if ((mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED) ||
 	    (mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)) {
-
+		if (qp_num == 0)
+			valid = 1;
 	} else {
 		/* Filter GSI packets sent to QP0 */
-	
+		if (qp_num != 0)
+			valid = 1;	
 	}
 
 ret:
@@ -708,7 +710,7 @@
 	}
 
 	/* Validate MAD */
-	if (!validate_mad(recv->header.recv_buf.mad))
+	if (!validate_mad(recv->header.recv_buf.mad, qp_num))
 		goto ret;
 
 	/* Determine corresponding MAD agent for incoming receive MAD */
@@ -757,6 +759,8 @@
 			
 			goto error;
 		}
+		/* Check whether timeout was requested !!! */
+
 		/* Remove from posted send MAD list */
 		list_del(&send_wr->send_list);
 		port_priv->send_posted_mad_count--;





More information about the general mailing list