From patchwork Wed Jan 31 08:11:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 10193435 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 95847603EE for ; Wed, 31 Jan 2018 08:13:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8708A285A4 for ; Wed, 31 Jan 2018 08:13:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B730285A8; Wed, 31 Jan 2018 08:13:00 +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=-6.9 required=2.0 tests=BAYES_00,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 0256D285A4 for ; Wed, 31 Jan 2018 08:13:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753430AbeAaIMP (ORCPT ); Wed, 31 Jan 2018 03:12:15 -0500 Received: from mail.kernel.org ([198.145.29.99]:53958 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753337AbeAaIMN (ORCPT ); Wed, 31 Jan 2018 03:12:13 -0500 Received: from localhost (unknown [213.57.247.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8288E214DA; Wed, 31 Jan 2018 08:12:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8288E214DA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=leon@kernel.org From: Leon Romanovsky To: David Ahern Cc: RDMA mailing list , Steve Wise , Leon Romanovsky , netdev , Stephen Hemminger , Leon Romanovsky Subject: [PATCH iproute2-next 04/10] rdma: Set pointer to device name position Date: Wed, 31 Jan 2018 10:11:50 +0200 Message-Id: <20180131081156.19607-5-leon@kernel.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180131081156.19607-1-leon@kernel.org> References: <20180131081156.19607-1-leon@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 From: Leon Romanovsky The dev and link execution callbacks expects that next command line argument is device or port name. Set pointer to device or port name position prior calls to rd_exec_dev()/rd_exec_link(). Signed-off-by: Leon Romanovsky --- rdma/rdma.h | 1 + rdma/utils.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/rdma/rdma.h b/rdma/rdma.h index 8e60ce26..35506a96 100644 --- a/rdma/rdma.h +++ b/rdma/rdma.h @@ -87,6 +87,7 @@ int rd_exec_cmd(struct rd *rd, const struct rd_cmd *c, const char *str); int rd_exec_dev(struct rd *rd, int (*cb)(struct rd *rd)); int rd_exec_link(struct rd *rd, int (*cb)(struct rd *rd), bool strict_port); void rd_free(struct rd *rd); +int rd_set_arg_to_devname(struct rd *rd); int rd_argc(struct rd *rd); /* diff --git a/rdma/utils.c b/rdma/utils.c index 157699c0..f93f05e1 100644 --- a/rdma/utils.c +++ b/rdma/utils.c @@ -412,6 +412,25 @@ void rd_free(struct rd *rd) filters_cleanup(rd); } +int rd_set_arg_to_devname(struct rd *rd) +{ + int ret = 0; + + while (!rd_no_arg(rd)) { + if (rd_argv_match(rd, "dev") || rd_argv_match(rd, "link")) { + rd_arg_inc(rd); + if (rd_no_arg(rd)) { + pr_err("No device name was supplied\n"); + ret = -EINVAL; + } + goto out; + } + rd_arg_inc(rd); + } +out: + return ret; +} + int rd_exec_link(struct rd *rd, int (*cb)(struct rd *rd), bool strict_port) { struct dev_map *dev_map;