From patchwork Tue Jul 17 13:34:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 945047 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41VLrx5CNZz9rvt for ; Tue, 17 Jul 2018 23:36:01 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 0DADECD8; Tue, 17 Jul 2018 13:34:28 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 8B0C9CA8 for ; Tue, 17 Jul 2018 13:34:25 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 0A212FC for ; Tue, 17 Jul 2018 13:34:24 +0000 (UTC) Received: by mail-wm0-f66.google.com with SMTP id o11-v6so1522258wmh.2 for ; Tue, 17 Jul 2018 06:34:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=iJOsduOoX9hMI9tIg8VFltz1TakvfYmvqaEWfCij8rQ=; b=sR4tcrQzkQBfHZEi1j8QStXrKzyIaNod9xvjI9LSSTqm1U+yiCHtoFqi+dlTilGgpL hD8aDGwl4ZvxbpTAG43/ViBtdxlzPI2pmUijn5O7QhNysSPpXJcPt1zgqTl+Q4LXslYE MAv5H85BfI5eZXFh5uzuWDVtudOTwTXhP4454TuAHOLRwRfjZovJV26vX5cXkK+sMJqn FKQ7SPMWH4wQ6077Ayr8KWnnEomWvMlaYE44AL3xU0Msiium8bOeU0jsHZTAgCub5BD3 JBd8Q3ptPqWyEn2Mx5gKnO4D4USTfBLQui9p5aBJ1qEdUU5OJ2ECIlH5JcGvnCg7ALa4 PdcA== X-Gm-Message-State: AOUpUlGzH0kMyP0dBiS+I39otQz+1/mQbdOdyh0BR4JsH2uaHGEbPAxr 5m+oY2X2dkhWBiev34NO7+17/neTiZ8= X-Google-Smtp-Source: AAOMgpfN25LzA56DtA/d7TaGdy/QZVBAfOxO1DRu+00rT+wfeiV/JkDTG9FIXrtvv8MyVRm9Vv30UA== X-Received: by 2002:a1c:78b:: with SMTP id 133-v6mr1486451wmh.59.1531834463530; Tue, 17 Jul 2018 06:34:23 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id z18-v6sm622230wrr.76.2018.07.17.06.34.22 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Jul 2018 06:34:23 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Tue, 17 Jul 2018 15:34:08 +0200 Message-Id: <20180717133415.23781-5-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180717133415.23781-1-jkbs@redhat.com> References: <20180717133415.23781-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 04/11] ovn-nbctl: Don't die in lrp_to_lr(). X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Let the caller handle the error. This prepares us for reporting errors in daemon mode. Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 19e99670b..f89ddbc0a 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -3270,22 +3270,26 @@ lrp_by_name_or_uuid(struct ctl_context *ctx, const char *id, bool must_exist, } /* Returns the logical router that contains 'lrp'. */ -static const struct nbrec_logical_router * +static char * OVS_WARN_UNUSED_RESULT lrp_to_lr(const struct ovsdb_idl *idl, - const struct nbrec_logical_router_port *lrp) + const struct nbrec_logical_router_port *lrp, + const struct nbrec_logical_router **lr_p) { const struct nbrec_logical_router *lr; + *lr_p = NULL; + NBREC_LOGICAL_ROUTER_FOR_EACH (lr, idl) { for (size_t i = 0; i < lr->n_ports; i++) { if (lr->ports[i] == lrp) { - return lr; + *lr_p = lr; + return NULL; } } } /* Can't happen because of the database schema */ - ctl_fatal("port %s is not part of any logical router", - lrp->name); + return xasprintf("port %s is not part of any logical router", + lrp->name); } static const char * @@ -3513,7 +3517,11 @@ nbctl_lrp_add(struct ctl_context *ctx) } const struct nbrec_logical_router *bound_lr; - bound_lr = lrp_to_lr(ctx->idl, lrp); + error = lrp_to_lr(ctx->idl, lrp, &bound_lr); + if (error) { + ctx->error = error; + return; + } if (bound_lr != lr) { char uuid_s[UUID_LEN + 1]; ctl_error(ctx, "%s: port already exists but in router %s",