From 5d521643713122c6d4a120b49b56c595aef10f97 Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Thu, 15 May 2014 14:08:04 -0700 Subject: [PATCH] ibacm: Change acm_query_response to take the response message acm_query_response should take as input the actual response message to send, not the request message. The provider may have already formatted a response message, and the core should not override it. Signed-off-by: Sean Hefty --- src/acm.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/acm.c b/src/acm.c index 318637d..84a6630 100644 --- a/src/acm.c +++ b/src/acm.c @@ -1560,12 +1560,12 @@ static void acmp_process_acm_recv(struct acmp_ep *ep, struct ibv_wc *wc, struct } } -static int acm_query_response(uint64_t id, struct acm_msg *msg, uint8_t status) +static int acm_query_response(uint64_t id, struct acm_msg *msg) { struct acmc_client *client = &client_array[id]; int ret; - acm_log(2, "status 0x%x\n", status); + acm_log(2, "status 0x%x\n", msg->hdr.status); lock_acquire(&client->lock); if (client->sock == INVALID_SOCKET) { acm_log(0, "ERROR - connection lost\n"); @@ -1573,9 +1573,6 @@ static int acm_query_response(uint64_t id, struct acm_msg *msg, uint8_t status) goto release; } - msg->hdr.opcode |= ACM_OP_ACK; - msg->hdr.status = status; - ret = send(client->sock, (char *) msg, msg->hdr.length, 0); if (ret != msg->hdr.length) acm_log(0, "ERROR - failed to send response\n"); @@ -1588,23 +1585,31 @@ release: return ret; } +static int acmc_query_response(uint64_t id, struct acm_msg *msg, uint8_t status) +{ + acm_log(2, "status 0x%x\n", status); + msg->hdr.opcode |= ACM_OP_ACK; + msg->hdr.status = status; + return acm_query_response(id, msg); +} + static void acmp_sa_resp(struct acmp_send_msg *msg, struct ibv_wc *wc, struct acm_mad *mad) { struct acmp_request *req = (struct acmp_request *) msg->context; struct ib_sa_mad *sa_mad = (struct ib_sa_mad *) mad; - uint8_t status; + req->msg.hdr.opcode |= ACM_OP_ACK; if (mad) { - status = (uint8_t) (ntohs(sa_mad->status) >> 8); + req->msg.hdr.status = (uint8_t) (ntohs(sa_mad->status) >> 8); memcpy(&req->msg.resolve_data[0].info.path, sa_mad->data, sizeof(struct ibv_path_record)); } else { - status = ACM_STATUS_ETIMEDOUT; + req->msg.hdr.status = ACM_STATUS_ETIMEDOUT; } - acm_log(2, "status 0x%x\n", status); + acm_log(2, "status 0x%x\n", req->msg.hdr.status); - acm_query_response(req->id, &req->msg, status); + acm_query_response(req->id, &req->msg); acmp_free_req(req); } @@ -2201,13 +2206,13 @@ acm_svr_query_path(struct acmc_client *client, struct acm_msg *msg) acm_log(2, "client %d\n", client->index); if (msg->hdr.length != ACM_MSG_HDR_LENGTH + ACM_MSG_EP_LENGTH) { acm_log(0, "ERROR - invalid length: 0x%x\n", msg->hdr.length); - return acm_query_response(client->index, msg, ACM_STATUS_EINVAL); + return acmc_query_response(client->index, msg, ACM_STATUS_EINVAL); } addr = acm_get_ep_address(&msg->resolve_data[0]); if (!addr) { acm_log(1, "notice - could not find local end point address\n"); - return acm_query_response(client->index, msg, ACM_STATUS_ESRCADDR); + return acmc_query_response(client->index, msg, ACM_STATUS_ESRCADDR); } ep = container_of(addr->addr.endpoint, struct acmc_ep, endpoint); @@ -2263,7 +2268,9 @@ acmp_query(void *addr_context, struct acm_msg *msg, uint64_t id) free: acmp_free_req(req); resp: - return acm_query_response(id, msg, status); + msg->hdr.opcode |= ACM_OP_ACK; + msg->hdr.status = status; + return acm_query_response(id, msg); } static uint8_t -- 2.46.0