[openib-general] [PATCH] IPOIB: Use a GRH when appropriate for unicast packets

Roland Dreier rdreier at cisco.com
Fri Jan 26 13:11:56 PST 2007


 > I don't know. The other two users in the tree ignore the return
 > code right now..

The only reason it could fail is if it fails to map a local GID to a
GID index.  Which should never happen under normal circumstance.

But it does look like the two other uses are somewhat buggy since they
might end up using bogus address info.

Maybe the best fix is to have ib_init_ah_from_path() itself print a
warning if the GID index can't be found, just set the gid_index to 0
in that case, and change ib_init_ah_from_path() to return void?

What do you think of doing something like this for 2.6.21:

diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
index e45afba..a70c380 100644
--- a/drivers/infiniband/core/sa_query.c
+++ b/drivers/infiniband/core/sa_query.c
@@ -471,8 +471,8 @@ void ib_sa_cancel_query(int id, struct ib_sa_query *query)
 }
 EXPORT_SYMBOL(ib_sa_cancel_query);
 
-int ib_init_ah_from_path(struct ib_device *device, u8 port_num,
-			 struct ib_sa_path_rec *rec, struct ib_ah_attr *ah_attr)
+void ib_init_ah_from_path(struct ib_device *device, u8 port_num,
+			  struct ib_sa_path_rec *rec, struct ib_ah_attr *ah_attr)
 {
 	int ret;
 	u16 gid_index;
@@ -485,19 +485,30 @@ int ib_init_ah_from_path(struct ib_device *device, u8 port_num,
 
 	if (rec->hop_limit > 1) {
 		ah_attr->ah_flags = IB_AH_GRH;
-		ah_attr->grh.dgid = rec->dgid;
 
 		ret = ib_find_cached_gid(device, &rec->sgid, &port_num,
 					 &gid_index);
 		if (ret)
-			return ret;
-
-		ah_attr->grh.sgid_index    = gid_index;
+			printk(KERN_INFO "%s: GID index not found for "
+			       "device %s, GID "
+			       "%2.2x%2.2x:%2.2x%2.2x:%2.2x%2.2x:%2.2x%2.2x:"
+			       "%2.2x%2.2x:%2.2x%2.2x:%2.2x%2.2x:%2.2x%2.2x",
+			       __func__, device->name,
+			       rec->sgid.raw[ 0], rec->sgid.raw[ 1],
+			       rec->sgid.raw[ 2], rec->sgid.raw[ 3],
+			       rec->sgid.raw[ 4], rec->sgid.raw[ 5],
+			       rec->sgid.raw[ 6], rec->sgid.raw[ 7],
+			       rec->sgid.raw[ 8], rec->sgid.raw[ 9],
+			       rec->sgid.raw[10], rec->sgid.raw[11],
+			       rec->sgid.raw[12], rec->sgid.raw[13],
+			       rec->sgid.raw[14], rec->sgid.raw[15]);
+
+		ah_attr->grh.sgid_index    = !ret ? gid_index : 0;
+		ah_attr->grh.dgid          = rec->dgid;
 		ah_attr->grh.flow_label    = be32_to_cpu(rec->flow_label);
 		ah_attr->grh.hop_limit     = rec->hop_limit;
 		ah_attr->grh.traffic_class = rec->traffic_class;
 	}
-	return 0;
 }
 EXPORT_SYMBOL(ib_init_ah_from_path);
 
diff --git a/include/rdma/ib_sa.h b/include/rdma/ib_sa.h
index 97715b0..7572e98 100644
--- a/include/rdma/ib_sa.h
+++ b/include/rdma/ib_sa.h
@@ -401,8 +401,8 @@ ib_sa_mcmember_rec_delete(struct ib_sa_client *client,
  * ib_init_ah_from_path - Initialize address handle attributes based on an SA
  *   path record.
  */
-int ib_init_ah_from_path(struct ib_device *device, u8 port_num,
-			 struct ib_sa_path_rec *rec,
-			 struct ib_ah_attr *ah_attr);
+void ib_init_ah_from_path(struct ib_device *device, u8 port_num,
+			  struct ib_sa_path_rec *rec,
+			  struct ib_ah_attr *ah_attr);
 
 #endif /* IB_SA_H */




More information about the general mailing list