From a9e7432319eb26ad90f18a7d215e50341d28ecb2 Mon Sep 17 00:00:00 2001 From: Jack Morgenstein Date: Tue, 24 Apr 2012 16:08:57 -0700 Subject: [PATCH] IB/mad: Don't send response for failed MADs Commit 0b307043049f ("IB/mad: Return error response for unsupported MADs") does not failed MADs (eg those that return IB_MAD_RESULT_FAILURE) properly -- these MADs should be silently discarded. (We should not force the lower-layer drivers to return SUCCESS | CONSUMED in this case, since the MAD is NOT successful). Unsupported MADs are not failures -- they return SUCCESS, but with an "unsupported error" status value inside the response MAD. Reviewed-by: Hal Rosenstock Signed-off-by: Jack Morgenstein Signed-off-by: Roland Dreier --- drivers/infiniband/core/mad.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c index 1c73d8aa4b9..b0d0bc8a6fb 100644 --- a/drivers/infiniband/core/mad.c +++ b/drivers/infiniband/core/mad.c @@ -1871,6 +1871,7 @@ static void ib_mad_recv_done_handler(struct ib_mad_port_private *port_priv, struct ib_mad_list_head *mad_list; struct ib_mad_agent_private *mad_agent; int port_num; + int ret = IB_MAD_RESULT_SUCCESS; mad_list = (struct ib_mad_list_head *)(unsigned long)wc->wr_id; qp_info = mad_list->mad_queue->qp_info; @@ -1954,8 +1955,6 @@ static void ib_mad_recv_done_handler(struct ib_mad_port_private *port_priv, local: /* Give driver "right of first refusal" on incoming MAD */ if (port_priv->device->process_mad) { - int ret; - ret = port_priv->device->process_mad(port_priv->device, 0, port_priv->port_num, wc, &recv->grh, @@ -1983,7 +1982,8 @@ local: * or via recv_handler in ib_mad_complete_recv() */ recv = NULL; - } else if (generate_unmatched_resp(recv, response)) { + } else if ((ret & IB_MAD_RESULT_SUCCESS) && + generate_unmatched_resp(recv, response)) { agent_send_response(&response->mad.mad, &recv->grh, wc, port_priv->device, port_num, qp_info->qp->qp_num); } -- 2.41.0