From patchwork Tue Jul 17 13:34:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 945044 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 41VLq624sFz9rvt for ; Tue, 17 Jul 2018 23:34:25 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 98F9FCBE; Tue, 17 Jul 2018 13:34:22 +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 E08A4CBB for ; Tue, 17 Jul 2018 13:34:20 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 2C6B9711 for ; Tue, 17 Jul 2018 13:34:20 +0000 (UTC) Received: by mail-wr1-f51.google.com with SMTP id c13-v6so1312090wrt.1 for ; Tue, 17 Jul 2018 06:34:20 -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=pxCkanAygDC1kZ9s4Ej69x26mf2vkF+wJfbRvmGfP3Q=; b=alwSiW1AKGt/sDm8P4it0QmJkZdPGoWlxpExCbRPwnPqoDklEF1K9DNxKBNTSbOJuY sC6r+azptDekxQHctnRXzJHSdOuk+XC75qJgWYO+x1ZX2OhpBPC1LONVFoRO5kIv8j1g Xe9rMGa1aA/EsNjCCC+InVdPiv9NrVedi2u6LNVcSbNtwGm4EZPRSuU2jL25GoJg+7if bS/sckLTeVy5uFAnIL7O7Tp+uNIvj2JsYtQMKxFJFZGX4gs2UlXgXMvcd7qnXEj/Etg8 YXGIeLGFI0MWx5wa+LU3cL3gzKlvKLbtZknpZrUCprNy16wL3vkyH/tpHtTTopdvC5sC AAZQ== X-Gm-Message-State: AOUpUlGFvWHaHqGT7nHgS3ZJSuLOOkbdlAaMGs17laANykd5GSbUDYRz A2QB3qsAOpVehCWztHMABaviS4cnr48= X-Google-Smtp-Source: AAOMgpfsKQOCM+KD7HIFrt10kB3WhZ93DjhFYWDCEvSW6gBMNcsV8Nh8Y20c780AZCrqVfRPOgN+fg== X-Received: by 2002:a5d:52c4:: with SMTP id r4-v6mr1393151wrv.98.1531834458607; Tue, 17 Jul 2018 06:34:18 -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 q11-v6sm2378361wrp.58.2018.07.17.06.34.17 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Jul 2018 06:34:18 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Tue, 17 Jul 2018 15:34:05 +0200 Message-Id: <20180717133415.23781-2-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 01/11] ovn-nbctl: Don't die in pg_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. Also, extend the tests to cover this error path. Signed-off-by: Jakub Sitnicki Acked-by: Mark Michelson --- ovn/utilities/ovn-nbctl.c | 23 ++++++++++++++++------- tests/ovn-nbctl.at | 5 +++++ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index d07524697..0cd11e845 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -609,10 +609,12 @@ lb_by_name_or_uuid(struct ctl_context *ctx, const char *id, bool must_exist, return NULL; } -static const struct nbrec_port_group * -pg_by_name_or_uuid(struct ctl_context *ctx, const char *id, bool must_exist) +static char * OVS_WARN_UNUSED_RESULT +pg_by_name_or_uuid(struct ctl_context *ctx, const char *id, bool must_exist, + const struct nbrec_port_group **pg_p) { const struct nbrec_port_group *pg = NULL; + *pg_p = NULL; struct uuid pg_uuid; bool is_uuid = uuid_from_string(&pg_uuid, id); @@ -632,11 +634,12 @@ pg_by_name_or_uuid(struct ctl_context *ctx, const char *id, bool must_exist) } if (!pg && must_exist) { - ctl_fatal("%s: port group %s not found", id, - is_uuid ? "UUID" : "name"); + return xasprintf("%s: port group %s not found", id, + is_uuid ? "UUID" : "name"); } - return pg; + *pg_p = pg; + return NULL; } static void @@ -1559,7 +1562,10 @@ acl_cmd_get_pg_or_ls(struct ctl_context *ctx, char *error; if (!opt_type) { - *pg = pg_by_name_or_uuid(ctx, ctx->argv[1], false); + error = pg_by_name_or_uuid(ctx, ctx->argv[1], false, pg); + if (error) { + return error; + } error = ls_by_name_or_uuid(ctx, ctx->argv[1], false, ls); if (error) { return error; @@ -1574,7 +1580,10 @@ acl_cmd_get_pg_or_ls(struct ctl_context *ctx, ctx->argv[1]); } } else if (!strcmp(opt_type, "port-group")) { - *pg = pg_by_name_or_uuid(ctx, ctx->argv[1], true); + error = pg_by_name_or_uuid(ctx, ctx->argv[1], true, pg); + if (error) { + return error; + } *ls = NULL; } else if (!strcmp(opt_type, "switch")) { error = ls_by_name_or_uuid(ctx, ctx->argv[1], true, ls); diff --git a/tests/ovn-nbctl.at b/tests/ovn-nbctl.at index 73a61a4be..9f6a2783b 100644 --- a/tests/ovn-nbctl.at +++ b/tests/ovn-nbctl.at @@ -234,6 +234,11 @@ OVN_NBCTL_TEST_ACL([ls1], [--type=switch]) AT_CHECK([ovn-nbctl create port_group name=pg0], [0], [ignore]) OVN_NBCTL_TEST_ACL([pg0], [--type=port-group]) +dnl Test when port group doesn't exist +AT_CHECK([ovn-nbctl --type=port-group acl-add pg1 to-lport 100 ip drop], [1], [], [dnl +ovn-nbctl: pg1: port group name not found +]) + dnl Test when same name exists in logical switches and portgroups AT_CHECK([ovn-nbctl create port_group name=ls0], [0], [ignore]) AT_CHECK([ovn-nbctl acl-add ls0 to-lport 100 ip drop], [1], [], [stderr]) 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); From patchwork Tue Jul 17 13:34:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 945046 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 41VLrC1QY6z9s4V for ; Tue, 17 Jul 2018 23:35:23 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 18437CD1; Tue, 17 Jul 2018 13:34:26 +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 C8D49CC8 for ; Tue, 17 Jul 2018 13:34:24 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 8EA9E711 for ; Tue, 17 Jul 2018 13:34:23 +0000 (UTC) Received: by mail-wr1-f68.google.com with SMTP id h9-v6so1301241wro.3 for ; Tue, 17 Jul 2018 06:34:23 -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=2dDRjdDghCeTiXGHXGfR5UVo9elqTp55L5eUOBzsP+k=; b=NHGJvSzYl2c7GCxw+AalLWZYgINJFWtpWRf3GXIlqtN6q+dAtJdkTQkEIdi7Ajy3Bm JDTbGOOk0OBoc/O3fqvbGzNmcyt5TJ3WVVeRw6cmjReHi9EOjd5zsK1jpZQ8bvVH/pRa 1IjlsIo4CSvJEo739OMPYa5yPfhx4bB114cdpSYQlqez15yjtmKL8UcSkCGwRVSLjkF5 vIFDKs+i+0pw/gDDmGEAj0CbvPkn5Xakd3bSJ9Jyze8GRD+eNcaGzbCRVx8OpNh5yFiw G7wsKCoH5MBRHAuwvbG4rLjcJv/0feFlZVAUHu7eeW5fNwLzL5g05tbdNg0q8Z7KRQpl 4v2g== X-Gm-Message-State: AOUpUlG8HJi41Iq+4TnWpIRQ97+JXkWxO/Xe0QuTvt0F5A+KGRobG7Vb bT7uJxGeZXdSh+mYTTs43zhXmwceWgk= X-Google-Smtp-Source: AAOMgpe+I5uwPcOufiqybOO4BasN28pwqG/5Ksbj+iaTH3lD16gbZikBX2GmNLvhcQhOTegqGF0Swg== X-Received: by 2002:adf:9246:: with SMTP id 64-v6mr1476043wrj.109.1531834461991; Tue, 17 Jul 2018 06:34:21 -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 73-v6sm2469580wmo.21.2018.07.17.06.34.20 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Jul 2018 06:34:21 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Tue, 17 Jul 2018 15:34:07 +0200 Message-Id: <20180717133415.23781-4-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 03/11] ovn-nbctl: Don't die in lsp_to_ls(). 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 df35d11d6..19e99670b 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -952,22 +952,26 @@ lsp_by_name_or_uuid(struct ctl_context *ctx, const char *id, } /* Returns the logical switch that contains 'lsp'. */ -static const struct nbrec_logical_switch * +static char * OVS_WARN_UNUSED_RESULT lsp_to_ls(const struct ovsdb_idl *idl, - const struct nbrec_logical_switch_port *lsp) + const struct nbrec_logical_switch_port *lsp, + const struct nbrec_logical_switch **ls_p) { const struct nbrec_logical_switch *ls; + *ls_p = NULL; + NBREC_LOGICAL_SWITCH_FOR_EACH (ls, idl) { for (size_t i = 0; i < ls->n_ports; i++) { if (ls->ports[i] == lsp) { - return ls; + *ls_p = ls; + return NULL; } } } /* Can't happen because of the database schema */ - ctl_fatal("logical port %s is not part of any logical switch", - lsp->name); + return xasprintf("logical port %s is not part of any logical switch", + lsp->name); } static const char * @@ -1027,7 +1031,11 @@ nbctl_lsp_add(struct ctl_context *ctx) } const struct nbrec_logical_switch *lsw; - lsw = lsp_to_ls(ctx->idl, lsp); + error = lsp_to_ls(ctx->idl, lsp, &lsw); + if (error) { + ctx->error = error; + return; + } if (lsw != ls) { char uuid_s[UUID_LEN + 1]; ctl_error(ctx, "%s: port already exists but in switch %s", 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", From patchwork Tue Jul 17 13:34:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 945048 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 41VLsV1yFmz9rxs for ; Tue, 17 Jul 2018 23:36:30 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id DD190CE4; Tue, 17 Jul 2018 13:34:30 +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 317F0CCA for ; Tue, 17 Jul 2018 13:34:27 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 9B835711 for ; Tue, 17 Jul 2018 13:34:26 +0000 (UTC) Received: by mail-wm0-f65.google.com with SMTP id s14-v6so1560894wmc.1 for ; Tue, 17 Jul 2018 06:34:26 -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=NGPbEnw1sQNRgzqSXLL/CTo1LVWvqkXBQJ2mCvcR4ro=; b=mWKUpyArCzjBFbmh/WV6xyGLp/P9Qx6mvFPeKJMJHJ2YgF4L22sp/zg2ArA8xGUaoY ll3IK+xaIUMUW7m3UfVIzi+Jepalr8M2tVELwJoPUwR56E65uiX+AcG8Lbim7NODfHAO 7s4Kmp9PPravBt6wCMAFxYdPQ8/7S4oSraX5MAh82Z74eMC1JOX7/m48Q6ZWMnBUDwTG BvxFw6nqnMrJdvNokS6yfa882ZjErqxsd4Szbug+LTIzEYWbIVlgmCLGygC8DVKaui00 CvXZBhv3Gh6Kp+Y+cpiAqYktsBvl7qOw42u9YssyBAcUYTg1wIszXXpFmVa5isZj4Sg8 SgWA== X-Gm-Message-State: AOUpUlFiHpRL4Fu5Lg9uHlSg3otRfjEKyRQvku4PsAL7x/rtX7I0fXNk v70NebXfy9QIvl1UQntgTax/4FuDBww= X-Google-Smtp-Source: AAOMgpcFN6JGFr0TM4y9XEkxEywZ3AZNNELpAGZj5cXvLAPPnMios/jbmu/LPt01V7VsgTH3+5a2Sw== X-Received: by 2002:a1c:b45:: with SMTP id 66-v6mr1366432wml.45.1531834465078; Tue, 17 Jul 2018 06:34:25 -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 q140-v6sm2068657wmb.35.2018.07.17.06.34.24 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Jul 2018 06:34:24 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Tue, 17 Jul 2018 15:34:09 +0200 Message-Id: <20180717133415.23781-6-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 05/11] ovn-nbctl: Don't die in parse_priority(). 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 | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index f89ddbc0a..1cee059f2 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -1684,16 +1684,17 @@ parse_direction(const char *arg) } } -static int -parse_priority(const char *arg) +static char * OVS_WARN_UNUSED_RESULT +parse_priority(const char *arg, int64_t *priority_p) { /* Validate priority. */ int64_t priority; if (!ovs_scan(arg, "%"SCNd64, &priority) || priority < 0 || priority > 32767) { - ctl_fatal("%s: priority must in range 0...32767", arg); + return xasprintf("%s: priority must in range 0...32767", arg); } - return priority; + *priority_p = priority; + return NULL; } static void @@ -1710,7 +1711,12 @@ nbctl_acl_add(struct ctl_context *ctx) } const char *direction = parse_direction(ctx->argv[2]); - int64_t priority = parse_priority(ctx->argv[3]); + int64_t priority; + error = parse_priority(ctx->argv[3], &priority); + if (error) { + ctx->error = error; + return; + } /* Validate action. */ if (strcmp(action, "allow") && strcmp(action, "allow-related") @@ -1825,7 +1831,11 @@ nbctl_acl_del(struct ctl_context *ctx) return; } - int64_t priority = parse_priority(ctx->argv[3]); + int64_t priority; + error = parse_priority(ctx->argv[3], &priority); + if (error) { + ctl_fatal("%s", error); + } if (ctx->argc == 4) { ctl_fatal("cannot specify priority without match"); @@ -1908,12 +1918,18 @@ nbctl_qos_add(struct ctl_context *ctx) { const struct nbrec_logical_switch *ls; const char *direction = parse_direction(ctx->argv[2]); - int64_t priority = parse_priority(ctx->argv[3]); + int64_t priority; int64_t dscp = -1; int64_t rate = 0; int64_t burst = 0; + char *error; - char *error = ls_by_name_or_uuid(ctx, ctx->argv[1], true, &ls); + error = parse_priority(ctx->argv[3], &priority); + if (error) { + ctx->error = error; + return; + } + error = ls_by_name_or_uuid(ctx, ctx->argv[1], true, &ls); if (error) { ctx->error = error; return; @@ -2039,7 +2055,11 @@ nbctl_qos_del(struct ctl_context *ctx) return; } - int64_t priority = parse_priority(ctx->argv[3]); + int64_t priority; + error = parse_priority(ctx->argv[3], &priority); + if (error) { + ctl_fatal("%s", error); + } if (ctx->argc == 4) { ctl_fatal("cannot specify priority without match"); @@ -3352,7 +3372,11 @@ nbctl_lrp_set_gateway_chassis(struct ctl_context *ctx) const char *chassis_name = ctx->argv[2]; if (ctx->argv[3]) { - priority = parse_priority(ctx->argv[3]); + error = parse_priority(ctx->argv[3], &priority); + if (error) { + ctx->error = error; + return; + } } gc_name = xasprintf("%s-%s", lrp_name, chassis_name); From patchwork Tue Jul 17 13:34:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 945049 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 41VLsz3YDYz9rxs for ; Tue, 17 Jul 2018 23:36:55 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 8F6B5CE1; Tue, 17 Jul 2018 13:34:31 +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 07E52CCA for ; Tue, 17 Jul 2018 13:34:29 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id C8134FC for ; Tue, 17 Jul 2018 13:34:27 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id h10-v6so1293799wre.6 for ; Tue, 17 Jul 2018 06:34:27 -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=2zhjQrFhpotiDq/lpp8cbLkYtSk12URfshOym6+4DUo=; b=nuLgS/zc5vURXiH/VY0ueDfxL+TsJn3GPdkR/HF1L52T7CJ622muc45nubdH7FGifT YsiZDKoKoWqYP8VH3nSeSBJkUbCqDQLeWXt59X1GtFDu2H8lQqBixnbVNl5KBCXBqy4J zKg3Fcd5Q5nl2H8zwpoxHYL8koY/A1I0Srpv/I+ig9TnHZS35BkukcQlPzKS8epBtt2N qRPIaccSckPJ1F8yGf7ahcuInYKLsYUE+nFM1tN10VWmWKcTM0mkHDZejPOujNs9u1Ie gzLc6nrUKIQmxf5YopHnj2I9XJ5SmfJQrKynXw9OwGINkipV7NeLvOdo3CmYtEATVFS6 pOGA== X-Gm-Message-State: AOUpUlHEZkIDqO+ISf8Sl3LR/pw0ABrg6eDewrxDZLaF7r14eAogmfJW epklcYQc/mJyFgmAOI+wCCXFLybAyMQ= X-Google-Smtp-Source: AAOMgpcF0tnw7VAQ8/JyWnLLJHpuvSD9ky/XzMzvWTjepFIzXfB4dxEEOxAawayyw8UwRwg46F6JSQ== X-Received: by 2002:adf:93a3:: with SMTP id 32-v6mr1422701wrp.140.1531834466294; Tue, 17 Jul 2018 06:34:26 -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 y11-v6sm2039196wrr.84.2018.07.17.06.34.25 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Jul 2018 06:34:25 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Tue, 17 Jul 2018 15:34:10 +0200 Message-Id: <20180717133415.23781-7-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 06/11] ovn-nbctl: Don't die in parse_direction(). 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 | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 1cee059f2..c18fa2825 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -1671,17 +1671,19 @@ qos_cmp(const void *qos1_, const void *qos2_) } } -static const char * -parse_direction(const char *arg) +static char * OVS_WARN_UNUSED_RESULT +parse_direction(const char *arg, const char **direction_p) { /* Validate direction. Only require the first letter. */ if (arg[0] == 't') { - return "to-lport"; + *direction_p = "to-lport"; } else if (arg[0] == 'f') { - return "from-lport"; + *direction_p = "from-lport"; } else { - ctl_fatal("%s: direction must be \"to-lport\" or \"from-lport\"", arg); + return xasprintf("%s: direction must be \"to-lport\" or " + "\"from-lport\"", arg); } + return NULL; } static char * OVS_WARN_UNUSED_RESULT @@ -1710,7 +1712,12 @@ nbctl_acl_add(struct ctl_context *ctx) return; } - const char *direction = parse_direction(ctx->argv[2]); + const char *direction; + error = parse_direction(ctx->argv[2], &direction); + if (error) { + ctx->error = error; + return; + } int64_t priority; error = parse_priority(ctx->argv[3], &priority); if (error) { @@ -1804,7 +1811,11 @@ nbctl_acl_del(struct ctl_context *ctx) return; } - const char *direction = parse_direction(ctx->argv[2]); + const char *direction; + error = parse_direction(ctx->argv[2], &direction); + if (error) { + ctl_fatal("%s", error); + } size_t n_acls = pg ? pg->n_acls : ls->n_acls; struct nbrec_acl **acls = pg ? pg->acls : ls->acls; @@ -1917,13 +1928,18 @@ static void nbctl_qos_add(struct ctl_context *ctx) { const struct nbrec_logical_switch *ls; - const char *direction = parse_direction(ctx->argv[2]); + const char *direction; int64_t priority; int64_t dscp = -1; int64_t rate = 0; int64_t burst = 0; char *error; + error = parse_direction(ctx->argv[2], &direction); + if (error) { + ctx->error = error; + return; + } error = parse_priority(ctx->argv[3], &priority); if (error) { ctx->error = error; @@ -2034,7 +2050,12 @@ nbctl_qos_del(struct ctl_context *ctx) return; } - const char *direction = parse_direction(ctx->argv[2]); + const char *direction; + error = parse_direction(ctx->argv[2], &direction); + if (error) { + ctx->error = error; + return; + } /* If priority and match are not specified, delete all qos_rules with the * specified direction. */ From patchwork Tue Jul 17 13:34:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 945050 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 41VLtb4wZdz9rxs for ; Tue, 17 Jul 2018 23:37:27 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 6214ACE2; Tue, 17 Jul 2018 13:34:32 +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 9EE8BCD3 for ; Tue, 17 Jul 2018 13:34:30 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 6887EFC for ; Tue, 17 Jul 2018 13:34:29 +0000 (UTC) Received: by mail-wr1-f41.google.com with SMTP id h9-v6so1301541wro.3 for ; Tue, 17 Jul 2018 06:34:29 -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=cXRNnbFgGqApZLqtximdDQCHnzL9HhWbhRiY1HmDXxo=; b=BSfUDBAj5TTViquICyFH1olp0kEJlu6Mj+wWXgLSifVJyTkvSo7GRBZ32xsrkwtzfy truBJp/B32oomAeC2qRaIX06qRTStAAMeZZ9G/0mfoqXJn7rQ3XKb3wCL6kkL63StAT8 bEhgbOQD8c8UfCFpVUy3uczjNOQPr6p8GY8xqW/YSmDlc4JiDhoZwZDv1WZ2xHu7u4AW RdtYTU6Lr+VJtNkp+PhX7/Ce6tWq4jVRygYRDgCgAhS9ulXArVz7x7Q4l9AohdIas21D b1UenC8hyyLFJ5tZXjBS2meySCqn/mqRiLu8+cWIGaFW7uGMWoZNdfZ82BuJ4+gr6R/r eRXw== X-Gm-Message-State: AOUpUlHBoxmV+NwuRC4+IeePYoSmmMzKmGq4w+nMi+kY1wruqVnGZE04 4jesUIDebZ+/boQx8vYStdbu6DECWS8= X-Google-Smtp-Source: AAOMgpe35R8EC466NzrXOtHttFG2AjInI4Zab3Q9robVMq0Z4sWTO1lMVpTObIGFP+qzgckMu/9Ieg== X-Received: by 2002:adf:9a55:: with SMTP id z79-v6mr1329568wrb.153.1531834467882; Tue, 17 Jul 2018 06:34:27 -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 p184-v6sm822025wmp.31.2018.07.17.06.34.26 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Jul 2018 06:34:27 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Tue, 17 Jul 2018 15:34:11 +0200 Message-Id: <20180717133415.23781-8-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 07/11] ovn-nbctl: Don't die in dhcp_options_get(). 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 | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index c18fa2825..cf49a6b11 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -86,8 +86,9 @@ static void run_prerequisites(struct ctl_command[], size_t n_commands, struct ovsdb_idl *); static bool do_nbctl(const char *args, struct ctl_command *, size_t n, struct ovsdb_idl *); -static const struct nbrec_dhcp_options *dhcp_options_get( - struct ctl_context *ctx, const char *id, bool must_exist); +static char * OVS_WARN_UNUSED_RESULT dhcp_options_get( + struct ctl_context *ctx, const char *id, bool must_exist, + const struct nbrec_dhcp_options **); int main(int argc, char *argv[]) @@ -1448,7 +1449,10 @@ nbctl_lsp_set_dhcpv4_options(struct ctl_context *ctx) } const struct nbrec_dhcp_options *dhcp_opt = NULL; if (ctx->argc == 3 ) { - dhcp_opt = dhcp_options_get(ctx, ctx->argv[2], true); + error = dhcp_options_get(ctx, ctx->argv[2], true, &dhcp_opt); + if (error) { + ctl_fatal("%s", error); + } } if (dhcp_opt) { @@ -1475,7 +1479,10 @@ nbctl_lsp_set_dhcpv6_options(struct ctl_context *ctx) } const struct nbrec_dhcp_options *dhcp_opt = NULL; if (ctx->argc == 3) { - dhcp_opt = dhcp_options_get(ctx, ctx->argv[2], true); + error = dhcp_options_get(ctx, ctx->argv[2], true, &dhcp_opt); + if (error) { + ctl_fatal("%s", error); + } } if (dhcp_opt) { @@ -2696,8 +2703,9 @@ nbctl_lr_list(struct ctl_context *ctx) free(nodes); } -static const struct nbrec_dhcp_options * -dhcp_options_get(struct ctl_context *ctx, const char *id, bool must_exist) +static char * +dhcp_options_get(struct ctl_context *ctx, const char *id, bool must_exist, + const struct nbrec_dhcp_options **dhcp_opts_p) { struct uuid dhcp_opts_uuid; const struct nbrec_dhcp_options *dhcp_opts = NULL; @@ -2706,9 +2714,10 @@ dhcp_options_get(struct ctl_context *ctx, const char *id, bool must_exist) } if (!dhcp_opts && must_exist) { - ctl_fatal("%s: dhcp options UUID not found", id); + return xasprintf("%s: dhcp options UUID not found", id); } - return dhcp_opts; + *dhcp_opts_p = dhcp_opts; + return NULL; } static void @@ -2750,8 +2759,11 @@ nbctl_dhcp_options_create(struct ctl_context *ctx) static void nbctl_dhcp_options_set_options(struct ctl_context *ctx) { - const struct nbrec_dhcp_options *dhcp_opts = dhcp_options_get( - ctx, ctx->argv[1], true); + const struct nbrec_dhcp_options *dhcp_opts; + char *error = dhcp_options_get(ctx, ctx->argv[1], true, &dhcp_opts); + if (error) { + ctl_fatal("%s", error); + } struct smap dhcp_options = SMAP_INITIALIZER(&dhcp_options); for (size_t i = 2; i < ctx->argc; i++) { @@ -2771,8 +2783,11 @@ nbctl_dhcp_options_set_options(struct ctl_context *ctx) static void nbctl_dhcp_options_get_options(struct ctl_context *ctx) { - const struct nbrec_dhcp_options *dhcp_opts = dhcp_options_get( - ctx, ctx->argv[1], true); + const struct nbrec_dhcp_options *dhcp_opts; + char *error = dhcp_options_get(ctx, ctx->argv[1], true, &dhcp_opts); + if (error) { + ctl_fatal("%s", error); + } struct smap_node *node; SMAP_FOR_EACH(node, &dhcp_opts->options) { @@ -2787,7 +2802,10 @@ nbctl_dhcp_options_del(struct ctl_context *ctx) const char *id = ctx->argv[1]; const struct nbrec_dhcp_options *dhcp_opts; - dhcp_opts = dhcp_options_get(ctx, id, must_exist); + char *error = dhcp_options_get(ctx, id, must_exist, &dhcp_opts); + if (error) { + ctl_fatal("%s", error); + } if (!dhcp_opts) { return; } From patchwork Tue Jul 17 13:34:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 945051 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 41VLv91sPnz9rxs for ; Tue, 17 Jul 2018 23:37:57 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 1E8BFCF7; Tue, 17 Jul 2018 13:34:35 +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 BCCF1CED for ; Tue, 17 Jul 2018 13:34:32 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f43.google.com (mail-wm0-f43.google.com [74.125.82.43]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 68256789 for ; Tue, 17 Jul 2018 13:34:31 +0000 (UTC) Received: by mail-wm0-f43.google.com with SMTP id c14-v6so1528237wmb.4 for ; Tue, 17 Jul 2018 06:34:31 -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=+kYRQ6d7Aa81BP2n6MZKjrRjxr6g73gLtYswMcw3lLs=; b=Ulpz7wLLMeKHFz7/6ZVzpCWaVd2JjR+FymyWQw2GTMCxtcDE3jce8eyUzxRniwK1YL fzW0hDm/tadMv1gfSnsg1a9VjcmRkEu6MKlLmWH/AbebvYTS+xjVISccARmMbB2PaLGJ z7YBa+ART1QSltxBbIjew6S+WhRxMwaulYbDy1STrPfxcLVyu0EF3k9nWuR4poQPNJO9 w0sqSmB0LX4OOUJat05p0XljtUZTpqhpuNuPHui6OhP3aYdpy/4/b20Qf2/yAJcESXF9 zY2wfbZIpX97q+c70F/3u7wJUUUtNbwy3Ka6phy3nKHJYCDvMZkqXsY2covl+rInzYpD ksrw== X-Gm-Message-State: AOUpUlES4fx/I0hAaSmylqj2GJz+EaH9ZtyCOKFtIah+he7wDeQaAJ0a kRIm7cTnEgrEJh8RYDn8gPAymujqoTc= X-Google-Smtp-Source: AAOMgpdkyEmlhkAtBn1RrYGABhJyzjW0XVQQk3xbFXjQ11NfS7EEYvXj1YGv0CVzGvr6QAwOPnQWWA== X-Received: by 2002:a1c:ac42:: with SMTP id v63-v6mr1453403wme.92.1531834469691; Tue, 17 Jul 2018 06:34:29 -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 t9-v6sm1658844wra.62.2018.07.17.06.34.28 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Jul 2018 06:34:29 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Tue, 17 Jul 2018 15:34:12 +0200 Message-Id: <20180717133415.23781-9-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 08/11] ovn-nbctl: Propagate error thru the context. 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 Instead of dying let the main loop handle the error. This will allow us to report errors when running in daemon mode. This is a result of applying the following semantic patch: @@ identifier F; identifier C; identifier E; @@ static void F(struct ctl_context *C) { <... if (E) { - ctl_fatal("%s", E); + C->error = E; + return; } ...> } Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 135 ++++++++++++++++++++++++++++++---------------- 1 file changed, 90 insertions(+), 45 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index cf49a6b11..cf2b8eced 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -813,7 +813,8 @@ nbctl_show(struct ctl_context *ctx) if (ctx->argc == 2) { char *error = ls_by_name_or_uuid(ctx, ctx->argv[1], false, &ls); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } if (ls) { print_ls(ls, &ctx->output); @@ -828,7 +829,8 @@ nbctl_show(struct ctl_context *ctx) if (ctx->argc == 2) { char *error = lr_by_name_or_uuid(ctx, ctx->argv[1], false, &lr); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } if (lr) { print_lr(lr, &ctx->output); @@ -1126,7 +1128,8 @@ nbctl_lsp_del(struct ctl_context *ctx) char *error = lsp_by_name_or_uuid(ctx, ctx->argv[1], must_exist, &lsp); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } if (!lsp) { return; @@ -1158,7 +1161,8 @@ nbctl_lsp_list(struct ctl_context *ctx) char *error = ls_by_name_or_uuid(ctx, id, true, &ls); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } smap_init(&lsps); @@ -1183,7 +1187,8 @@ nbctl_lsp_get_parent(struct ctl_context *ctx) char *error = lsp_by_name_or_uuid(ctx, ctx->argv[1], true, &lsp); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } if (lsp->parent_name) { ds_put_format(&ctx->output, "%s\n", lsp->parent_name); @@ -1197,7 +1202,8 @@ nbctl_lsp_get_tag(struct ctl_context *ctx) char *error = lsp_by_name_or_uuid(ctx, ctx->argv[1], true, &lsp); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } if (lsp->n_tag > 0) { ds_put_format(&ctx->output, "%"PRId64"\n", lsp->tag[0]); @@ -1212,7 +1218,8 @@ nbctl_lsp_set_addresses(struct ctl_context *ctx) char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } int i; @@ -1245,7 +1252,8 @@ nbctl_lsp_get_addresses(struct ctl_context *ctx) char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } svec_init(&addresses); @@ -1267,7 +1275,8 @@ nbctl_lsp_set_port_security(struct ctl_context *ctx) char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } nbrec_logical_switch_port_set_port_security(lsp, (const char **) ctx->argv + 2, ctx->argc - 2); @@ -1284,7 +1293,8 @@ nbctl_lsp_get_port_security(struct ctl_context *ctx) char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } svec_init(&addrs); for (i = 0; i < lsp->n_port_security; i++) { @@ -1305,7 +1315,8 @@ nbctl_lsp_get_up(struct ctl_context *ctx) char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } ds_put_format(&ctx->output, "%s\n", (lsp->up && *lsp->up) ? "up" : "down"); @@ -1336,12 +1347,14 @@ nbctl_lsp_set_enabled(struct ctl_context *ctx) char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } bool enabled; error = parse_enabled(state, &enabled); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } nbrec_logical_switch_port_set_enabled(lsp, &enabled, 1); } @@ -1354,7 +1367,8 @@ nbctl_lsp_get_enabled(struct ctl_context *ctx) char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } ds_put_format(&ctx->output, "%s\n", !lsp->enabled || *lsp->enabled ? "enabled" : "disabled"); @@ -1389,7 +1403,8 @@ nbctl_lsp_get_type(struct ctl_context *ctx) char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } ds_put_format(&ctx->output, "%s\n", lsp->type); } @@ -1404,7 +1419,8 @@ nbctl_lsp_set_options(struct ctl_context *ctx) char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } for (i = 2; i < ctx->argc; i++) { char *key, *value; @@ -1430,7 +1446,8 @@ nbctl_lsp_get_options(struct ctl_context *ctx) char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } SMAP_FOR_EACH(node, &lsp->options) { ds_put_format(&ctx->output, "%s=%s\n", node->key, node->value); @@ -1445,13 +1462,15 @@ nbctl_lsp_set_dhcpv4_options(struct ctl_context *ctx) char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } const struct nbrec_dhcp_options *dhcp_opt = NULL; if (ctx->argc == 3 ) { error = dhcp_options_get(ctx, ctx->argv[2], true, &dhcp_opt); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } } @@ -1475,13 +1494,15 @@ nbctl_lsp_set_dhcpv6_options(struct ctl_context *ctx) char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } const struct nbrec_dhcp_options *dhcp_opt = NULL; if (ctx->argc == 3) { error = dhcp_options_get(ctx, ctx->argv[2], true, &dhcp_opt); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } } @@ -1505,7 +1526,8 @@ nbctl_lsp_get_dhcpv4_options(struct ctl_context *ctx) char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } if (lsp->dhcpv4_options) { ds_put_format(&ctx->output, UUID_FMT " (%s)\n", @@ -1522,7 +1544,8 @@ nbctl_lsp_get_dhcpv6_options(struct ctl_context *ctx) char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } if (lsp->dhcpv6_options) { ds_put_format(&ctx->output, UUID_FMT " (%s)\n", @@ -1623,7 +1646,8 @@ nbctl_acl_list(struct ctl_context *ctx) char *error = acl_cmd_get_pg_or_ls(ctx, &ls, &pg); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } size_t n_acls = pg ? pg->n_acls : ls->n_acls; @@ -1802,7 +1826,8 @@ nbctl_acl_del(struct ctl_context *ctx) char *error = acl_cmd_get_pg_or_ls(ctx, &ls, &pg); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } if (ctx->argc == 2) { @@ -1821,7 +1846,8 @@ nbctl_acl_del(struct ctl_context *ctx) const char *direction; error = parse_direction(ctx->argv[2], &direction); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } size_t n_acls = pg ? pg->n_acls : ls->n_acls; @@ -1852,7 +1878,8 @@ nbctl_acl_del(struct ctl_context *ctx) int64_t priority; error = parse_priority(ctx->argv[3], &priority); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } if (ctx->argc == 4) { @@ -1892,7 +1919,8 @@ nbctl_qos_list(struct ctl_context *ctx) char *error = ls_by_name_or_uuid(ctx, ctx->argv[1], true, &ls); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } qos_rules = xmalloc(sizeof *qos_rules * ls->n_qos_rules); @@ -2046,7 +2074,8 @@ nbctl_qos_del(struct ctl_context *ctx) const struct nbrec_logical_switch *ls; char *error = ls_by_name_or_uuid(ctx, ctx->argv[1], true, &ls); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } if (ctx->argc == 2) { @@ -2086,7 +2115,8 @@ nbctl_qos_del(struct ctl_context *ctx) int64_t priority; error = parse_priority(ctx->argv[3], &priority); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } if (ctx->argc == 4) { @@ -2433,7 +2463,8 @@ nbctl_lr_lb_del(struct ctl_context *ctx) const struct nbrec_load_balancer *del_lb; char *error = lr_by_name_or_uuid(ctx, ctx->argv[1], true, &lr); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } if (ctx->argc == 2) { @@ -2446,7 +2477,8 @@ nbctl_lr_lb_del(struct ctl_context *ctx) error = lb_by_name_or_uuid(ctx, ctx->argv[2], true, &del_lb); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } for (size_t i = 0; i < lr->n_load_balancer; i++) { const struct nbrec_load_balancer *lb @@ -2484,7 +2516,8 @@ nbctl_lr_lb_list(struct ctl_context *ctx) char *error = lr_by_name_or_uuid(ctx, lr_name, true, &lr); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } for (int i = 0; i < lr->n_load_balancer; i++) { const struct nbrec_load_balancer *lb @@ -2554,7 +2587,8 @@ nbctl_ls_lb_del(struct ctl_context *ctx) const struct nbrec_load_balancer *del_lb; char *error = ls_by_name_or_uuid(ctx, ctx->argv[1], true, &ls); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } if (ctx->argc == 2) { @@ -2567,7 +2601,8 @@ nbctl_ls_lb_del(struct ctl_context *ctx) error = lb_by_name_or_uuid(ctx, ctx->argv[2], true, &del_lb); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } for (size_t i = 0; i < ls->n_load_balancer; i++) { const struct nbrec_load_balancer *lb @@ -2605,7 +2640,8 @@ nbctl_ls_lb_list(struct ctl_context *ctx) char *error = ls_by_name_or_uuid(ctx, ls_name, true, &ls); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } for (int i = 0; i < ls->n_load_balancer; i++) { const struct nbrec_load_balancer *lb @@ -2762,7 +2798,8 @@ nbctl_dhcp_options_set_options(struct ctl_context *ctx) const struct nbrec_dhcp_options *dhcp_opts; char *error = dhcp_options_get(ctx, ctx->argv[1], true, &dhcp_opts); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } struct smap dhcp_options = SMAP_INITIALIZER(&dhcp_options); @@ -2786,7 +2823,8 @@ nbctl_dhcp_options_get_options(struct ctl_context *ctx) const struct nbrec_dhcp_options *dhcp_opts; char *error = dhcp_options_get(ctx, ctx->argv[1], true, &dhcp_opts); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } struct smap_node *node; @@ -2804,7 +2842,8 @@ nbctl_dhcp_options_del(struct ctl_context *ctx) char *error = dhcp_options_get(ctx, id, must_exist, &dhcp_opts); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } if (!dhcp_opts) { return; @@ -3265,7 +3304,8 @@ nbctl_lr_nat_list(struct ctl_context *ctx) const struct nbrec_logical_router *lr; char *error = lr_by_name_or_uuid(ctx, ctx->argv[1], true, &lr); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } struct smap lr_nats = SMAP_INITIALIZER(&lr_nats); @@ -3422,7 +3462,8 @@ nbctl_lrp_set_gateway_chassis(struct ctl_context *ctx) const struct nbrec_gateway_chassis *existing_gc; error = gc_by_name_or_uuid(ctx, gc_name, false, &existing_gc); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } if (existing_gc) { nbrec_gateway_chassis_set_priority(existing_gc, priority); @@ -3714,7 +3755,8 @@ nbctl_lrp_del(struct ctl_context *ctx) char *error = lrp_by_name_or_uuid(ctx, ctx->argv[1], must_exist, &lrp); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } if (!lrp) { return; @@ -3747,7 +3789,8 @@ nbctl_lrp_list(struct ctl_context *ctx) char *error = lr_by_name_or_uuid(ctx, id, true, &lr); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } smap_init(&lrps); @@ -3800,7 +3843,8 @@ nbctl_lrp_get_enabled(struct ctl_context *ctx) char *error = lrp_by_name_or_uuid(ctx, id, true, &lrp); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } if (!lrp) { return; @@ -3883,7 +3927,8 @@ nbctl_lr_route_list(struct ctl_context *ctx) char *error = lr_by_name_or_uuid(ctx, ctx->argv[1], true, &lr); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } ipv4_routes = xmalloc(sizeof *ipv4_routes * lr->n_static_routes); From patchwork Tue Jul 17 13:34:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 945052 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 41VLvl4F1wz9rxs for ; Tue, 17 Jul 2018 23:38:27 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id CBC33CFD; Tue, 17 Jul 2018 13:34:35 +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 7E088CF1 for ; Tue, 17 Jul 2018 13:34:33 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id AAFB079C for ; Tue, 17 Jul 2018 13:34:32 +0000 (UTC) Received: by mail-wr1-f67.google.com with SMTP id s11-v6so1278646wra.13 for ; Tue, 17 Jul 2018 06:34:32 -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=KlQCXEKPhnThOSGBqWa7yICgNxr13EbB9//nDvu0w8A=; b=dO1/8HSO9zG3ecl3mPJ352xRFQCMUwr8lbwd1F6b9RINzcDjhr5qJFTqvTjlbjvhMc YJwZ0gRcvsQEwh/APMJdW8yJ55TaW2EgcSA8jXn0qhfr6yB87U9FtM47AsSdEgQvbnde v6QyzrkR4Ur3AZXzZbW/4BzZS6CNQEvXVq1PC0Ho68nxRAPwuzz3T9b/OqPLk+ugPeWB mJRZOeUKofYhgiSQ0BX9i/dNwvHXb6ZSJWSCgD2D/7MWWkYgHbCtD3X3O5X/e1UfdV5r RUasFPcyeVd1ljbJF17ie4ibYHi/dQ1oSOyaL9eowRJAX4xGzs4hxXTuj0gJ4uS4UnoO 90OQ== X-Gm-Message-State: AOUpUlEcYoyga8xhLQ9POsF3dWQ3BnanwYYA2ge6PwsUEKcRYaPhUhFE rjw74ZzvnJoAIR3VDuoFb8Cr71dKYX8= X-Google-Smtp-Source: AAOMgpfWNwRyURYDl/p747AV9B/ZHODyPE/OFOCHBmGTJUj6+ejcUxqVLcW4nVRTKCeH0wB6C9pDMg== X-Received: by 2002:adf:9051:: with SMTP id h75-v6mr1485400wrh.65.1531834471033; Tue, 17 Jul 2018 06:34:31 -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 o8-v6sm1370076wro.68.2018.07.17.06.34.30 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Jul 2018 06:34:30 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Tue, 17 Jul 2018 15:34:13 +0200 Message-Id: <20180717133415.23781-10-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 09/11] ovn-nbctl: Use ctl_error() in command handlers. 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 Instead of dying with ctl_fatal(), propagate the error thru the context. This will allow us to report errors when running in daemon mode. This patch is a result of applying the following semantic patch: @@ identifier F, C; expression S; @@ static void F(struct ctl_context *C) { <... - ctl_fatal(S); + ctl_error(C, S); + return; ...> } @@ identifier F, C; expression S, A; @@ static void F(struct ctl_context *C) { <... - ctl_fatal(S, A); + ctl_error(C, S, A); + return; ...> } Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index cf2b8eced..8301e74cc 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -1147,8 +1147,9 @@ nbctl_lsp_del(struct ctl_context *ctx) } /* Can't happen because of the database schema. */ - ctl_fatal("logical port %s is not part of any logical switch", + ctl_error(ctx, "logical port %s is not part of any logical switch", ctx->argv[1]); + return; } static void @@ -1230,10 +1231,11 @@ nbctl_lsp_set_addresses(struct ctl_context *ctx) && strcmp(ctx->argv[i], "router") && !ovs_scan(ctx->argv[i], ETH_ADDR_SCAN_FMT, ETH_ADDR_SCAN_ARGS(ea))) { - ctl_fatal("%s: Invalid address format. See ovn-nb(5). " + ctl_error(ctx, "%s: Invalid address format. See ovn-nb(5). " "Hint: An Ethernet address must be " "listed before an IP address, together as a single " "argument.", ctx->argv[i]); + return; } } @@ -1480,7 +1482,9 @@ nbctl_lsp_set_dhcpv4_options(struct ctl_context *ctx) error = ip_parse_cidr(dhcp_opt->cidr, &ip, &plen); if (error){ free(error); - ctl_fatal("DHCP options cidr '%s' is not IPv4", dhcp_opt->cidr); + ctl_error(ctx, "DHCP options cidr '%s' is not IPv4", + dhcp_opt->cidr); + return; } } nbrec_logical_switch_port_set_dhcpv4_options(lsp, dhcp_opt); @@ -1512,7 +1516,9 @@ nbctl_lsp_set_dhcpv6_options(struct ctl_context *ctx) error = ipv6_parse_cidr(dhcp_opt->cidr, &ip, &plen); if (error) { free(error); - ctl_fatal("DHCP options cidr '%s' is not IPv6", dhcp_opt->cidr); + ctl_error(ctx, "DHCP options cidr '%s' is not IPv6", + dhcp_opt->cidr); + return; } } nbrec_logical_switch_port_set_dhcpv6_options(lsp, dhcp_opt); @@ -1883,7 +1889,8 @@ nbctl_acl_del(struct ctl_context *ctx) } if (ctx->argc == 4) { - ctl_fatal("cannot specify priority without match"); + ctl_error(ctx, "cannot specify priority without match"); + return; } /* Remove the matching rule. */ @@ -2120,7 +2127,8 @@ nbctl_qos_del(struct ctl_context *ctx) } if (ctx->argc == 4) { - ctl_fatal("cannot specify priority without match"); + ctl_error(ctx, "cannot specify priority without match"); + return; } /* Remove the matching rule. */ @@ -2501,8 +2509,9 @@ nbctl_lr_lb_del(struct ctl_context *ctx) bool must_exist = !shash_find(&ctx->options, "--if-exists"); if (must_exist) { - ctl_fatal("load balancer %s is not part of any logical router.", - del_lb->name); + ctl_error(ctx, "load balancer %s is not part of any logical router.", + del_lb->name); + return; } } @@ -2625,8 +2634,9 @@ nbctl_ls_lb_del(struct ctl_context *ctx) bool must_exist = !shash_find(&ctx->options, "--if-exists"); if (must_exist) { - ctl_fatal("load balancer %s is not part of any logical switch.", - del_lb->name); + ctl_error(ctx, "load balancer %s is not part of any logical switch.", + del_lb->name); + return; } } @@ -2770,7 +2780,8 @@ nbctl_dhcp_options_create(struct ctl_context *ctx) error = ipv6_parse_cidr(ctx->argv[1], &ipv6, &plen); if (error) { free(error); - ctl_fatal("Invalid cidr format '%s'", ctx->argv[1]); + ctl_error(ctx, "Invalid cidr format '%s'", ctx->argv[1]); + return; } } @@ -3774,8 +3785,9 @@ nbctl_lrp_del(struct ctl_context *ctx) } /* Can't happen because of the database schema. */ - ctl_fatal("logical port %s is not part of any logical router", + ctl_error(ctx, "logical port %s is not part of any logical router", ctx->argv[1]); + return; } /* Print a list of logical router ports. */ From patchwork Tue Jul 17 13:34:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 945053 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 41VLwX4TjQz9rxs for ; Tue, 17 Jul 2018 23:39:08 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id E23FFCDF; Tue, 17 Jul 2018 13:34:36 +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 8D5A8CEE for ; Tue, 17 Jul 2018 13:34:34 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 20449FC for ; Tue, 17 Jul 2018 13:34:34 +0000 (UTC) Received: by mail-wr1-f45.google.com with SMTP id b15-v6so1284838wrv.10 for ; Tue, 17 Jul 2018 06:34:33 -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=0UrVT4Y1Xv5GwNK836PM61kF9Lys5pWUwWHAD7j0Jb8=; b=sq5PFBeIkio8xGNLNJQa40Ov2BD1WOsuGOkofAgxPphN44/+aat8mRcU2YrJUwXyOB m2z+YtvjZVgYAFsBJIStURpYOVxyNsaV00EmxcI2J7l84KN5W0GRMGvShPNulf8vf2fd LQlqdyouvfJB2PrBQ0sH836ED70FzRGPq4Hilk4Mqy66aRvz96c4Z1Rsy+BX4p0lkJfQ nZWT4xLGSwac5C8dVL7d2ua+NcH6v/+Hqz1ppPb2fZBJ0PpPAE98lZzf/Le2oAI1t0VB G0zX3fDiUkChXT44rsCLyyz6Es/bGJdFBdldzn/wuZNJZGcwehHQdFmDYmxXJ/OLhrar UKzA== X-Gm-Message-State: AOUpUlHuuspcEkACLOJ6X2KPj6xrVl3YcsB9gG5eY3r+iibg7JGmISVO Yn8+DOfHPLjl05I/Xzjxl+o/6wPl/s8= X-Google-Smtp-Source: AAOMgpdD3SwjKr7yIagGCys7KJQ8YHNebEwjlCY9BaKPHutiwb8yviJo+dr/YUAHMQfCn9S/JxDFLA== X-Received: by 2002:adf:c98d:: with SMTP id f13-v6mr1446225wrh.148.1531834472525; Tue, 17 Jul 2018 06:34:32 -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 v10-v6sm1720702wrm.18.2018.07.17.06.34.31 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Jul 2018 06:34:32 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Tue, 17 Jul 2018 15:34:14 +0200 Message-Id: <20180717133415.23781-11-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 10/11] ovn-nbctl: Remove pointless "return; " at ends of functions. 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 Fix fall-out from applying a semantic patch that converts ctl_fatal() calls to use ctl_error(). Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 8301e74cc..27e3151a8 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -1149,7 +1149,6 @@ nbctl_lsp_del(struct ctl_context *ctx) /* Can't happen because of the database schema. */ ctl_error(ctx, "logical port %s is not part of any logical switch", ctx->argv[1]); - return; } static void @@ -3787,7 +3786,6 @@ nbctl_lrp_del(struct ctl_context *ctx) /* Can't happen because of the database schema. */ ctl_error(ctx, "logical port %s is not part of any logical router", ctx->argv[1]); - return; } /* Print a list of logical router ports. */ From patchwork Tue Jul 17 13:34:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 945054 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 41VLx168g9z9rxs for ; Tue, 17 Jul 2018 23:39:33 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id AD722D08; Tue, 17 Jul 2018 13:34:37 +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 C7D31CFC for ; Tue, 17 Jul 2018 13:34:35 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 584D3798 for ; Tue, 17 Jul 2018 13:34:35 +0000 (UTC) Received: by mail-wr1-f66.google.com with SMTP id g6-v6so1312793wrp.0 for ; Tue, 17 Jul 2018 06:34:35 -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=K0gJj7icBSaYgDNDVsllrSIsjJo5b4buepzcTBoLecA=; b=tphSGit60eO2GEKRvt6AWFHo1z0qVAkPTZY1Kgb5QKKoPagq8xiN7j7m3+4qn5o7m8 sLyXzx9XU9DFCzSMzbVt/gkAc0fqzrhotI3Qtztthb4bu/Sijf83YLy2q4E5juYKGOEp tHCiFiDjs7oDCQPgHHCf+/dJnPj/HpnwMD6OSAj7hqS/MEDNyb52lcqFnXbkU5lf7TOa gX4SoY5WNxSnp0VBV4OJ053GKhbiBVePnAeEQG9oW3BOsUA+KjTQn/1bsuK/vYOt4oFK up30nVl7Q1MX9muNC6UasZ84off+Dt51RSLAbX6u/fz4CDdF1mZkimb4cCnID0uit7PK CxLg== X-Gm-Message-State: AOUpUlEfka6nqXrYbhsO8TrPhwL/xY3MFWrDe0Wm3AmMRM7xhaIGiHdm 8QkJ7V1sTsZQ75KQ68p2Axa4DUAe4fA= X-Google-Smtp-Source: AAOMgpebRU1F8GYy9UI635M7afyikOjR7eR6Vo8Y2LcXQ5zZx1fEwBVRLhOWUiwZoHm/sh1kz+MbeA== X-Received: by 2002:adf:fb92:: with SMTP id a18-v6mr1384522wrr.278.1531834473859; Tue, 17 Jul 2018 06:34:33 -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 b11-v6sm1644759wrv.82.2018.07.17.06.34.33 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Jul 2018 06:34:33 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Tue, 17 Jul 2018 15:34:15 +0200 Message-Id: <20180717133415.23781-12-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 11/11] ovn-nbctl: Fix mem leak in nbctl_lrp_set_gateway_chassis(). 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 Fix fall-out from applying a semantic patch to propagate the error. Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 27e3151a8..12845a035 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -3473,6 +3473,7 @@ nbctl_lrp_set_gateway_chassis(struct ctl_context *ctx) error = gc_by_name_or_uuid(ctx, gc_name, false, &existing_gc); if (error) { ctx->error = error; + free(gc_name); return; } if (existing_gc) {