[openib-general] [PATCH] RFC: allow send only registration from userspace

Roland Dreier roland at topspin.com
Mon Mar 28 19:43:56 PST 2005


It seems that ib_umad does not allow userspace to register an agent
for solicited MADs only.  The documentation says that if userspace
passes a mgmt_class of 0 then the agent will not receive any
unsolicited MADs, but in this case ib_umad still passes a
ib_mad_reg_req struct to ib_register_mad_agent() so the registration
just fails.

I'm surprised that no one has complained about this yet.  How did
ibping work in userspace if the kernel had already registered for the
ping class?

Does this patch look right to everyone?

 - R.

Index: infiniband/core/user_mad.c
===================================================================
--- infiniband/core/user_mad.c	(revision 2060)
+++ infiniband/core/user_mad.c	(working copy)
@@ -389,15 +389,17 @@ static int ib_umad_reg_agent(struct ib_u
 	goto out;
 
 found:
-	req.mgmt_class         = ureq.mgmt_class;
-	req.mgmt_class_version = ureq.mgmt_class_version;
-	memcpy(req.method_mask, ureq.method_mask, sizeof req.method_mask);
-	memcpy(req.oui,         ureq.oui,         sizeof req.oui);
+	if (ureq.mgmt_class) {
+		req.mgmt_class         = ureq.mgmt_class;
+		req.mgmt_class_version = ureq.mgmt_class_version;
+		memcpy(req.method_mask, ureq.method_mask, sizeof req.method_mask);
+		memcpy(req.oui,         ureq.oui,         sizeof req.oui);
+	}
 
 	agent = ib_register_mad_agent(file->port->ib_dev, file->port->port_num,
 				      ureq.qpn ? IB_QPT_GSI : IB_QPT_SMI,
-				      &req, 0, send_handler, recv_handler,
-				      file);
+				      ureq.mgmt_class ? &req : NULL,
+				      0, send_handler, recv_handler, file);
 	if (IS_ERR(agent)) {
 		ret = PTR_ERR(agent);
 		goto out;



More information about the general mailing list