From patchwork Thu Feb 21 16:19:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Wise X-Patchwork-Id: 10824547 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 204B21390 for ; Thu, 21 Feb 2019 18:25:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1157D32053 for ; Thu, 21 Feb 2019 18:25:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0580A32056; Thu, 21 Feb 2019 18:25:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A6EE832053 for ; Thu, 21 Feb 2019 18:25:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726279AbfBUSZ4 (ORCPT ); Thu, 21 Feb 2019 13:25:56 -0500 Received: from opengridcomputing.com ([72.48.214.68]:52644 "EHLO smtp.opengridcomputing.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726241AbfBUSZ4 (ORCPT ); Thu, 21 Feb 2019 13:25:56 -0500 Received: by smtp.opengridcomputing.com (Postfix, from userid 503) id 8AD41227A3; Thu, 21 Feb 2019 12:25:55 -0600 (CST) Message-Id: In-Reply-To: References: From: Steve Wise Date: Thu, 21 Feb 2019 08:19:03 -0800 Subject: [PATCH v1 iproute2-next 1/4] rdma: add helper rd_sendrecv_msg() To: dsahern@gmail.com, leon@kernel.org Cc: stephen@networkplumber.org, netdev@vger.kernel.org, linux-rdma@vger.kernel.org Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This function sends the constructed netlink message and then receives the response, displaying any error text. Change 'rdma dev set' to use it. Signed-off-by: Steve Wise --- rdma/dev.c | 2 +- rdma/rdma.h | 1 + rdma/utils.c | 21 +++++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/rdma/dev.c b/rdma/dev.c index 60ff4b31e320..d2949c378f08 100644 --- a/rdma/dev.c +++ b/rdma/dev.c @@ -273,7 +273,7 @@ static int dev_set_name(struct rd *rd) mnl_attr_put_u32(rd->nlh, RDMA_NLDEV_ATTR_DEV_INDEX, rd->dev_idx); mnl_attr_put_strz(rd->nlh, RDMA_NLDEV_ATTR_DEV_NAME, rd_argv(rd)); - return rd_send_msg(rd); + return rd_sendrecv_msg(rd, seq); } static int dev_one_set(struct rd *rd) diff --git a/rdma/rdma.h b/rdma/rdma.h index 547bb5749a39..20be2f12c4f8 100644 --- a/rdma/rdma.h +++ b/rdma/rdma.h @@ -115,6 +115,7 @@ bool rd_check_is_key_exist(struct rd *rd, const char *key); */ int rd_send_msg(struct rd *rd); int rd_recv_msg(struct rd *rd, mnl_cb_t callback, void *data, uint32_t seq); +int rd_sendrecv_msg(struct rd *rd, unsigned int seq); void rd_prepare_msg(struct rd *rd, uint32_t cmd, uint32_t *seq, uint16_t flags); int rd_dev_init_cb(const struct nlmsghdr *nlh, void *data); int rd_attr_cb(const struct nlattr *attr, void *data); diff --git a/rdma/utils.c b/rdma/utils.c index 069d44fece10..a6f2826c9605 100644 --- a/rdma/utils.c +++ b/rdma/utils.c @@ -664,6 +664,27 @@ int rd_recv_msg(struct rd *rd, mnl_cb_t callback, void *data, unsigned int seq) return ret; } +static int null_cb(const struct nlmsghdr *nlh, void *data) +{ + return MNL_CB_OK; +} + +int rd_sendrecv_msg(struct rd *rd, unsigned int seq) +{ + int ret; + + ret = rd_send_msg(rd); + if (ret) { + perror(NULL); + goto out; + } + ret = rd_recv_msg(rd, null_cb, rd, seq); + if (ret) + perror(NULL); +out: + return ret; +} + static struct dev_map *_dev_map_lookup(struct rd *rd, const char *dev_name) { struct dev_map *dev_map;