From patchwork Tue Jul 17 13:34:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 945045 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 41VLqd2Yvnz9s4V for ; Tue, 17 Jul 2018 23:34:53 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 5BB78CC3; Tue, 17 Jul 2018 13:34:24 +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 2EAEFCA8 for ; Tue, 17 Jul 2018 13:34:22 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id B183A711 for ; Tue, 17 Jul 2018 13:34:21 +0000 (UTC) Received: by mail-wr1-f42.google.com with SMTP id q10-v6so1303235wrd.4 for ; Tue, 17 Jul 2018 06:34:21 -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=1I1TBNFIGhRk/axFvRRbnyWt14mwhPdBeCtqwOI2G8g=; b=LA+QC20xvATLSad9qqIuEtO9VOhaGdMnls8kw1B79RUA9eGemWx/AQWsKsgKS68dJN NrJDMOSGPqwyWwL+MNMnmRjN4Sy1cCpUkLy674czziFqmeylB9UGbzkYm9GuJox0VGZM xEsrRLOuqQkZs/xpyVfIEdYnvDb8t/sIgWXjTUiker1Ut9wq6nqRG9UP5Fza3GrS5prN nP1W9NVzNzBhmdx/6xaGBE/jwz9QbfyngNr4dYBJCj3J2ha9thoHYaWEJvQ/E1eNWX3V 6K97kelPzcFr4jj6iz7jGLf57Cmmr74MPGi9czmUDQ/mKWSex+T954ad7EcyNLBJkiJk zRIw== X-Gm-Message-State: AOUpUlG/pYJ66XHGsSQSZaYSa77CVHBfx1nvFkOqerc88AztRRlJMnxq XU90+yrQGpGH+F+OdEz6BNJ5wcBzGoQ= X-Google-Smtp-Source: AAOMgpefC5pm1/mRmeaSffywNH57ArDOCkOxa/sAMXAz7f/PnI0GkPDON2P42hnF0BLluuVwp0QErg== X-Received: by 2002:adf:88e3:: with SMTP id g32-v6mr1356720wrg.62.1531834460164; Tue, 17 Jul 2018 06:34:20 -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 z3-v6sm1838652wmf.12.2018.07.17.06.34.19 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Jul 2018 06:34:19 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Tue, 17 Jul 2018 15:34:06 +0200 Message-Id: <20180717133415.23781-3-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 02/11] ovn-nbctl: Don't die in gc_by_name_or_uuid(). 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 | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 0cd11e845..df35d11d6 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -3291,10 +3291,12 @@ lr_get_name(const struct nbrec_logical_router *lr, char uuid_s[UUID_LEN + 1], return uuid_s; } -static const struct nbrec_gateway_chassis * -gc_by_name_or_uuid(struct ctl_context *ctx, const char *id, bool must_exist) +static char * OVS_WARN_UNUSED_RESULT +gc_by_name_or_uuid(struct ctl_context *ctx, const char *id, bool must_exist, + const struct nbrec_gateway_chassis **gc_p) { const struct nbrec_gateway_chassis *gc = NULL; + *gc_p = NULL; struct uuid gc_uuid; bool is_uuid = uuid_from_string(&gc_uuid, id); @@ -3311,11 +3313,12 @@ gc_by_name_or_uuid(struct ctl_context *ctx, const char *id, bool must_exist) } if (!gc && must_exist) { - ctl_fatal("%s: gateway chassis %s not found", id, - is_uuid ? "UUID" : "name"); + return xasprintf("%s: gateway chassis %s not found", id, + is_uuid ? "UUID" : "name"); } - return gc; + *gc_p = gc; + return NULL; } static void @@ -3342,7 +3345,10 @@ nbctl_lrp_set_gateway_chassis(struct ctl_context *ctx) gc_name = xasprintf("%s-%s", lrp_name, chassis_name); const struct nbrec_gateway_chassis *existing_gc; - existing_gc = gc_by_name_or_uuid(ctx, gc_name, false); + error = gc_by_name_or_uuid(ctx, gc_name, false, &existing_gc); + if (error) { + ctl_fatal("%s", error); + } if (existing_gc) { nbrec_gateway_chassis_set_priority(existing_gc, priority); free(gc_name);