From patchwork Sat Jul 7 11:09:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 940794 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 41N85N0WvNz9s0n for ; Sat, 7 Jul 2018 21:10:15 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id D8269C03; Sat, 7 Jul 2018 11:10:11 +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 E8D5BBE6 for ; Sat, 7 Jul 2018 11:10:09 +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 B96A4318 for ; Sat, 7 Jul 2018 11:10:08 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id r16-v6so6406449wrt.11 for ; Sat, 07 Jul 2018 04:10:08 -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=NR9OhG6+ZMYRSm/b5PTNgZVrSFsh1Nn0m4UIuaLkfX8=; b=Ka0/R8Hu+/yIkrbDPEMsOB6HtZGbUZey3muOUvwDOwoKciIBuRwxwwkgSjumRFIG/L 7a0ncIgy/5St+6uu3bWBv0vIwcXjP3GKUC+CWBgUMg7fgolxSS8g3EZ3NK5BlO2ZbiHi 3riAI57z47o488kqV75KeoeB06fNSvQ/V+j7GFPutasL1PsQIAR+m7QnA7v/X0zbfhxu MB0/I5ELWYqbOk1sIgrw3stDfs4VZRSmMuxOewloX21oU302aIbWdntQ9790uRifX6TG YPQHkdQZgdinRnOLz5HQev0nZMD0Pe1M2WhjH91ImlaqzvT1VdmIB1MSn+Lh/tKlKpM/ IwGA== X-Gm-Message-State: APt69E3dBUCwKY4zPrn2dFzKP8KHoc4STvctFXKcdmURkQUugsN2r8He y5jHLncsCxf1CB777cn2yhKAYuLBKsA= X-Google-Smtp-Source: AAOMgpfNE8mi83cHa2u5BRHvec/NDjBCT5RAkqG7oMb+8d1jZ8RbbsrlFh40GjJKmlF9xUlsWwNaeQ== X-Received: by 2002:adf:fe42:: with SMTP id m2-v6mr5323499wrs.171.1530961807178; Sat, 07 Jul 2018 04:10:07 -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 n16-v6sm18019876wrg.58.2018.07.07.04.10.06 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 07 Jul 2018 04:10:06 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Sat, 7 Jul 2018 13:09:35 +0200 Message-Id: <20180707111004.8320-2-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180707111004.8320-1-jkbs@redhat.com> References: <20180707111004.8320-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/30] db-ctl-base: Don't die in cmd_add() on error. 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 Return the error via the context instead of calling ctl_fatal() so that the caller can decide how to handle it. Signed-off-by: Jakub Sitnicki --- lib/db-ctl-base.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c index a59ac30c4..0aba5b6a3 100644 --- a/lib/db-ctl-base.c +++ b/lib/db-ctl-base.c @@ -1494,11 +1494,12 @@ cmd_add(struct ctl_context *ctx) ovsdb_datum_destroy(&add, type); } if (old.n > type->n_max) { - ctl_fatal("\"add\" operation would put %u %s in column %s of " + ctl_error(ctx, "\"add\" operation would put %u %s in column %s of " "table %s but the maximum number is %u", old.n, type->value.type == OVSDB_TYPE_VOID ? "values" : "pairs", column->name, table->name, type->n_max); + return; } ovsdb_idl_txn_verify(row, column); ovsdb_idl_txn_write(row, column, &old); From patchwork Sat Jul 7 11:09:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 940795 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 41N85p4Wnwz9s0n for ; Sat, 7 Jul 2018 21:10:38 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 9FAADC3C; Sat, 7 Jul 2018 11:10:12 +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 42EECBE6 for ; Sat, 7 Jul 2018 11:10:11 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f48.google.com (mail-wm0-f48.google.com [74.125.82.48]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 12B96318 for ; Sat, 7 Jul 2018 11:10:10 +0000 (UTC) Received: by mail-wm0-f48.google.com with SMTP id s12-v6so17004749wmc.1 for ; Sat, 07 Jul 2018 04:10:09 -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=s7BH4dX7CtYeCz/6wpbvTrlR4M2lOP5VDsTT0S36+Xc=; b=ksaEasxIeQT+nzbjtfVn3WIk0XLMyTk7AVSFItlfXwGeUvCGBFSkVMEgKcm9tJB/// NJmu5ABeC2rEcUy5JfrTkFgnKEASLN2Jcc+UH0OacLYpLU2NwMHpoymZgfr/bIdLf9px OhwJfREN/pxqbDKFWlj87JosXG4hYC1F5YvaAZkbrO0+J/V9UPUMjFdLyn9CJ4G/tkmZ jn3ojePs0iNLb3FQcLupcfmkGbzda97WKEqXuKuHv8TQbVD07Q/WUXmKdFt9tJZpcu/H +J11W+dQZCP7QnUnGl4zUOdp/O2xCKuJlCKhXn0NNllSBRTC93i8Ag32vDqehXSu223t USSQ== X-Gm-Message-State: APt69E2kMH2t6m7edd0I9IzPPEUTZ8DbdY0EVAAhbyFjWrBUTbcKNFD4 WCZnkIYfo+IUpvrSMJS4WFLGyhRD+VU= X-Google-Smtp-Source: AAOMgpdkcQsvsaQUlmozHRJLB/aSmKKyFdVviYQeFXdm8/GDQNKGstKAyHsiwk7MejfyR3ChiHsLFQ== X-Received: by 2002:a1c:228b:: with SMTP id i133-v6mr8919906wmi.69.1530961808516; Sat, 07 Jul 2018 04:10:08 -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 130-v6sm24818931wmr.1.2018.07.07.04.10.07 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 07 Jul 2018 04:10:07 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Sat, 7 Jul 2018 13:09:36 +0200 Message-Id: <20180707111004.8320-3-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180707111004.8320-1-jkbs@redhat.com> References: <20180707111004.8320-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/30] ovn-nbctl: Report the actual error from the command handler. 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 a typo that went undetected by tests because we don't have any test cases for error paths when using database commands with ovn-nbctl. Fixes: 675b152e999f ("db-ctl-base: Extend ctl_context with an error message.") Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index fbdb5a4d9..762348ccb 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -3843,7 +3843,7 @@ do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands, (c->syntax->run)(&ctx); } if (ctx.error) { - ctl_fatal("%s", error); + ctl_fatal("%s", ctx.error); } ctl_context_done_command(&ctx, c); From patchwork Sat Jul 7 11:09:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 940796 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 41N86J6XFdz9s0n for ; Sat, 7 Jul 2018 21:11:04 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 6EFE6C8A; Sat, 7 Jul 2018 11:10:15 +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 B2427C50 for ; Sat, 7 Jul 2018 11:10:12 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id DF938765 for ; Sat, 7 Jul 2018 11:10:11 +0000 (UTC) Received: by mail-wr1-f44.google.com with SMTP id c13-v6so6363909wrt.1 for ; Sat, 07 Jul 2018 04:10:11 -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=1NCgXvFWC/O+J8P7WlgJDH9/emPBi9H3GsNA/inTx3Y=; b=sIQdGV1YRir/OKsbR70ctJG7Snj2g/NKvlxrf/98IJ9C8oNBMQBZMf67zpYejTkmo1 umkT+IAvOgYcVUWbN4mtIw2OPOTmYjeuOopJQYeosFqkq17F87W44I1ZgkeF5ZLf2see 0Oa5W6xSCvOIMGyA//XXtaw4yeucnBatZdCuA74s4umh+lfXPAblP7M3Uew08+o77+/n XgeIOONvY4KOSO85NmRb0MPMNwo8MjGAXzJgyooLzzt2Qo4T3rvwvWuAR4ImnDvOtzU0 LhZspuBruvbwYcpCVeU2BMZmpWc3wv1Ugdwyor36m+LDkfzeY+PcApfnWOApwXX2UagV R30w== X-Gm-Message-State: APt69E2oIArIK0AvU2jjvsbrCSAFPG6Er3Hn6EBz3P067UmVk9ButeO7 VrcBNeCLlCxYnUzcOWhubch4uJSheKw= X-Google-Smtp-Source: AAOMgpd5KrjA1Gg0kiDhAKRrQ1JFYyJulIB86029k5ZKZBRHS8CIvTEUdl0cch/hdMo2NxbSN//VAw== X-Received: by 2002:adf:96b2:: with SMTP id u47-v6mr10298627wrb.204.1530961810229; Sat, 07 Jul 2018 04:10:10 -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 d102-v6sm20347967wma.10.2018.07.07.04.10.09 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 07 Jul 2018 04:10:09 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Sat, 7 Jul 2018 13:09:37 +0200 Message-Id: <20180707111004.8320-4-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180707111004.8320-1-jkbs@redhat.com> References: <20180707111004.8320-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/30] ovn-nbctl: Don't die in ls_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. Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 84 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 64 insertions(+), 20 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 762348ccb..0f9cec0a9 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -531,8 +531,9 @@ lr_by_name_or_uuid(struct ctl_context *ctx, const char *id, return lr; } -static const struct nbrec_logical_switch * -ls_by_name_or_uuid(struct ctl_context *ctx, const char *id, bool must_exist) +static char * OVS_WARN_UNUSED_RESULT +ls_by_name_or_uuid(struct ctl_context *ctx, const char *id, bool must_exist, + const struct nbrec_logical_switch **ls_p) { const struct nbrec_logical_switch *ls = NULL; @@ -550,18 +551,22 @@ ls_by_name_or_uuid(struct ctl_context *ctx, const char *id, bool must_exist) continue; } if (ls) { - ctl_fatal("Multiple logical switches named '%s'. " - "Use a UUID.", id); + return xasprintf("Multiple logical switches named '%s'. " + "Use a UUID.", id); } ls = iter; } } if (!ls && must_exist) { - ctl_fatal("%s: switch %s not found", id, is_uuid ? "UUID" : "name"); + return xasprintf("%s: switch %s not found", + id, is_uuid ? "UUID" : "name"); } - return ls; + if (ls_p) { + *ls_p = ls; + } + return NULL; } static const struct nbrec_load_balancer * @@ -796,7 +801,10 @@ nbctl_show(struct ctl_context *ctx) const struct nbrec_logical_switch *ls; if (ctx->argc == 2) { - ls = ls_by_name_or_uuid(ctx, ctx->argv[1], false); + char *error = ls_by_name_or_uuid(ctx, ctx->argv[1], false, &ls); + if (error) { + ctl_fatal("%s", error); + } if (ls) { print_ls(ls, &ctx->output); } @@ -863,7 +871,10 @@ nbctl_ls_del(struct ctl_context *ctx) const char *id = ctx->argv[1]; const struct nbrec_logical_switch *ls; - ls = ls_by_name_or_uuid(ctx, id, must_exist); + char *error = ls_by_name_or_uuid(ctx, id, must_exist, &ls); + if (error) { + ctl_fatal("%s", error); + } if (!ls) { return; } @@ -954,7 +965,10 @@ nbctl_lsp_add(struct ctl_context *ctx) bool may_exist = shash_find(&ctx->options, "--may-exist") != NULL; const struct nbrec_logical_switch *ls; - ls = ls_by_name_or_uuid(ctx, ctx->argv[1], true); + char *error = ls_by_name_or_uuid(ctx, ctx->argv[1], true, &ls); + if (error) { + ctl_fatal("%s", error); + } const char *parent_name; int64_t tag; @@ -1094,7 +1108,10 @@ nbctl_lsp_list(struct ctl_context *ctx) struct smap lsps; size_t i; - ls = ls_by_name_or_uuid(ctx, id, true); + char *error = ls_by_name_or_uuid(ctx, id, true, &ls); + if (error) { + ctl_fatal("%s", error); + } smap_init(&lsps); for (i = 0; i < ls->n_ports; i++) { @@ -1442,9 +1459,14 @@ acl_cmd_get_pg_or_ls(struct ctl_context *ctx, const struct nbrec_port_group **pg) { const char *opt_type = shash_find_data(&ctx->options, "--type"); + char *error; + if (!opt_type) { *pg = pg_by_name_or_uuid(ctx, ctx->argv[1], false); - *ls = ls_by_name_or_uuid(ctx, ctx->argv[1], false); + error = ls_by_name_or_uuid(ctx, ctx->argv[1], false, ls); + if (error) { + ctl_fatal("%s", error); + } if (*pg && *ls) { ctl_fatal("Same name '%s' exists in both port-groups and " "logical switches. Specify --type=port-group or " @@ -1458,7 +1480,10 @@ acl_cmd_get_pg_or_ls(struct ctl_context *ctx, *pg = pg_by_name_or_uuid(ctx, ctx->argv[1], true); *ls = NULL; } else if (!strcmp(opt_type, "switch")) { - *ls = ls_by_name_or_uuid(ctx, ctx->argv[1], true); + error = ls_by_name_or_uuid(ctx, ctx->argv[1], true, ls); + if (error) { + ctl_fatal("%s", error); + } *pg = NULL; } else { ctl_fatal("Invalid value '%s' for option --type", opt_type); @@ -1708,7 +1733,10 @@ nbctl_qos_list(struct ctl_context *ctx) const struct nbrec_qos **qos_rules; size_t i; - ls = ls_by_name_or_uuid(ctx, ctx->argv[1], true); + char *error = ls_by_name_or_uuid(ctx, ctx->argv[1], true, &ls); + if (error) { + ctl_fatal("%s", error); + } qos_rules = xmalloc(sizeof *qos_rules * ls->n_qos_rules); for (i = 0; i < ls->n_qos_rules; i++) { @@ -1749,14 +1777,18 @@ nbctl_qos_list(struct ctl_context *ctx) static void nbctl_qos_add(struct ctl_context *ctx) { - const struct nbrec_logical_switch *ls - = ls_by_name_or_uuid(ctx, ctx->argv[1], true); + const struct nbrec_logical_switch *ls; const char *direction = parse_direction(ctx->argv[2]); int64_t priority = parse_priority(ctx->argv[3]); int64_t dscp = -1; int64_t rate = 0; int64_t burst = 0; + char *error = ls_by_name_or_uuid(ctx, ctx->argv[1], true, &ls); + if (error) { + ctl_fatal("%s", error); + } + for (int i = 5; i < ctx->argc; i++) { if (!strncmp(ctx->argv[i], "dscp=", 5)) { if (!ovs_scan(ctx->argv[i] + 5, "%"SCNd64, &dscp) @@ -1840,8 +1872,11 @@ nbctl_qos_add(struct ctl_context *ctx) static void nbctl_qos_del(struct ctl_context *ctx) { - const struct nbrec_logical_switch *ls - = ls_by_name_or_uuid(ctx, ctx->argv[1], true); + 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); + } if (ctx->argc == 2) { /* If direction, priority, and match are not specified, delete @@ -2260,7 +2295,10 @@ nbctl_ls_lb_add(struct ctl_context *ctx) const struct nbrec_logical_switch *ls; const struct nbrec_load_balancer *new_lb; - ls = ls_by_name_or_uuid(ctx, ctx->argv[1], true); + char *error = ls_by_name_or_uuid(ctx, ctx->argv[1], true, &ls); + if (error) { + ctl_fatal("%s", error); + } new_lb = lb_by_name_or_uuid(ctx, ctx->argv[2], true); bool may_exist = shash_find(&ctx->options, "--may-exist") != NULL; @@ -2296,7 +2334,10 @@ nbctl_ls_lb_del(struct ctl_context *ctx) { const struct nbrec_logical_switch *ls; const struct nbrec_load_balancer *del_lb; - ls = ls_by_name_or_uuid(ctx, ctx->argv[1], true); + char *error = ls_by_name_or_uuid(ctx, ctx->argv[1], true, &ls); + if (error) { + ctl_fatal("%s", error); + } if (ctx->argc == 2) { /* If load-balancer is not specified, remove @@ -2341,7 +2382,10 @@ nbctl_ls_lb_list(struct ctl_context *ctx) struct smap lbs = SMAP_INITIALIZER(&lbs); int vip_width = 0; - ls = ls_by_name_or_uuid(ctx, ls_name, true); + char *error = ls_by_name_or_uuid(ctx, ls_name, true, &ls); + if (error) { + ctl_fatal("%s", error); + } for (int i = 0; i < ls->n_load_balancer; i++) { const struct nbrec_load_balancer *lb = ls->load_balancer[i]; From patchwork Sat Jul 7 11:09:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 940797 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 41N86s164sz9s0w for ; Sat, 7 Jul 2018 21:11:33 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 28AB4C7F; Sat, 7 Jul 2018 11:10:16 +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 4E0DAC77 for ; Sat, 7 Jul 2018 11:10:14 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 3C8F5318 for ; Sat, 7 Jul 2018 11:10:13 +0000 (UTC) Received: by mail-wr1-f49.google.com with SMTP id k7-v6so6400014wrq.0 for ; Sat, 07 Jul 2018 04:10:13 -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=5QYzJJ8yq/39FQ3EOa4w26+ZTmS4gOSW0BAxDhaaxY0=; b=VBsDjs7pt3iP31fwsbO4VIAc2uYMUWPf+V+3ZxDnrWDQAiUqF0Idv6y593H6BgVODw Ctt/sIKtKKX0tNbpt0YbhAc1HffTHSrikFv75Jy4SRGn2TN0VmtWJRHLoNIjbMep1K2+ eAz3UYAF5SzzCZNOwOCrX8Xakm8u1JCeDf7kTcJwboKdvSErIJolnzomIxBQ658DjPBK 6u1TBVqBB09j1nW1sJ6akGCPFtWhM3Yx5jwCIglBQ0R/GI4C+rItfxAYe4phr8HFm5+N mOUzhB+jTtraHmnixFpoD4FgHHwU6W4A/EodUJHRP8O3U4dz8lXlSdWAyseDgTq7GBCp M37g== X-Gm-Message-State: APt69E3B0zl9qLrYJqEIbZ+5oqTYk3otkDOxuFnliSPzyO7ts2D+HaoB fTS9yCSGM/lhr/1SuHgXOYJbp952h94= X-Google-Smtp-Source: AAOMgpd5tEWYyb/MFhnRr1o+cJ9O76hY2+48Mm/VNHjgTGYS4a4qRb0p9VmSsHX6FsPjeMXUYCGLaA== X-Received: by 2002:adf:af45:: with SMTP id z63-v6mr9503604wrc.238.1530961811581; Sat, 07 Jul 2018 04:10:11 -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 i4-v6sm16318614wmf.4.2018.07.07.04.10.10 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 07 Jul 2018 04:10:11 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Sat, 7 Jul 2018 13:09:38 +0200 Message-Id: <20180707111004.8320-5-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180707111004.8320-1-jkbs@redhat.com> References: <20180707111004.8320-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/30] ovn-nbctl: Don't die in lsp_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. Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 117 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 91 insertions(+), 26 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 0f9cec0a9..8a07bc912 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -902,9 +902,10 @@ nbctl_ls_list(struct ctl_context *ctx) free(nodes); } -static const struct nbrec_logical_switch_port * +static char * OVS_WARN_UNUSED_RESULT lsp_by_name_or_uuid(struct ctl_context *ctx, const char *id, - bool must_exist) + bool must_exist, + const struct nbrec_logical_switch_port **lsp_p) { const struct nbrec_logical_switch_port *lsp = NULL; @@ -923,10 +924,14 @@ lsp_by_name_or_uuid(struct ctl_context *ctx, const char *id, } if (!lsp && must_exist) { - ctl_fatal("%s: port %s not found", id, is_uuid ? "UUID" : "name"); + return xasprintf("%s: port %s not found", + id, is_uuid ? "UUID" : "name"); } - return lsp; + if (lsp_p) { + *lsp_p = lsp; + } + return NULL; } /* Returns the logical switch that contains 'lsp'. */ @@ -989,7 +994,10 @@ nbctl_lsp_add(struct ctl_context *ctx) const char *lsp_name = ctx->argv[2]; const struct nbrec_logical_switch_port *lsp; - lsp = lsp_by_name_or_uuid(ctx, lsp_name, false); + error = lsp_by_name_or_uuid(ctx, lsp_name, false, &lsp); + if (error) { + ctl_fatal("%s", error); + } if (lsp) { if (!may_exist) { ctl_fatal("%s: a port with this name already exists", @@ -1079,7 +1087,10 @@ nbctl_lsp_del(struct ctl_context *ctx) bool must_exist = !shash_find(&ctx->options, "--if-exists"); const struct nbrec_logical_switch_port *lsp; - lsp = lsp_by_name_or_uuid(ctx, ctx->argv[1], must_exist); + char *error = lsp_by_name_or_uuid(ctx, ctx->argv[1], must_exist, &lsp); + if (error) { + ctl_fatal("%s", error); + } if (!lsp) { return; } @@ -1133,7 +1144,10 @@ nbctl_lsp_get_parent(struct ctl_context *ctx) { const struct nbrec_logical_switch_port *lsp; - lsp = lsp_by_name_or_uuid(ctx, ctx->argv[1], true); + char *error = lsp_by_name_or_uuid(ctx, ctx->argv[1], true, &lsp); + if (error) { + ctl_fatal("%s", error); + } if (lsp->parent_name) { ds_put_format(&ctx->output, "%s\n", lsp->parent_name); } @@ -1144,7 +1158,10 @@ nbctl_lsp_get_tag(struct ctl_context *ctx) { const struct nbrec_logical_switch_port *lsp; - lsp = lsp_by_name_or_uuid(ctx, ctx->argv[1], true); + char *error = lsp_by_name_or_uuid(ctx, ctx->argv[1], true, &lsp); + if (error) { + ctl_fatal("%s", error); + } if (lsp->n_tag > 0) { ds_put_format(&ctx->output, "%"PRId64"\n", lsp->tag[0]); } @@ -1156,7 +1173,10 @@ nbctl_lsp_set_addresses(struct ctl_context *ctx) const char *id = ctx->argv[1]; const struct nbrec_logical_switch_port *lsp; - lsp = lsp_by_name_or_uuid(ctx, id, true); + char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp); + if (error) { + ctl_fatal("%s", error); + } int i; for (i = 2; i < ctx->argc; i++) { @@ -1186,7 +1206,10 @@ nbctl_lsp_get_addresses(struct ctl_context *ctx) const char *mac; size_t i; - lsp = lsp_by_name_or_uuid(ctx, id, true); + char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp); + if (error) { + ctl_fatal("%s", error); + } svec_init(&addresses); for (i = 0; i < lsp->n_addresses; i++) { @@ -1205,7 +1228,10 @@ nbctl_lsp_set_port_security(struct ctl_context *ctx) const char *id = ctx->argv[1]; const struct nbrec_logical_switch_port *lsp; - lsp = lsp_by_name_or_uuid(ctx, id, true); + char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp); + if (error) { + ctl_fatal("%s", error); + } nbrec_logical_switch_port_set_port_security(lsp, (const char **) ctx->argv + 2, ctx->argc - 2); } @@ -1219,7 +1245,10 @@ nbctl_lsp_get_port_security(struct ctl_context *ctx) const char *addr; size_t i; - lsp = lsp_by_name_or_uuid(ctx, id, true); + char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp); + if (error) { + ctl_fatal("%s", error); + } svec_init(&addrs); for (i = 0; i < lsp->n_port_security; i++) { svec_add(&addrs, lsp->port_security[i]); @@ -1237,7 +1266,10 @@ nbctl_lsp_get_up(struct ctl_context *ctx) const char *id = ctx->argv[1]; const struct nbrec_logical_switch_port *lsp; - lsp = lsp_by_name_or_uuid(ctx, id, true); + char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp); + if (error) { + ctl_fatal("%s", error); + } ds_put_format(&ctx->output, "%s\n", (lsp->up && *lsp->up) ? "up" : "down"); } @@ -1261,7 +1293,10 @@ nbctl_lsp_set_enabled(struct ctl_context *ctx) const char *state = ctx->argv[2]; const struct nbrec_logical_switch_port *lsp; - lsp = lsp_by_name_or_uuid(ctx, id, true); + char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp); + if (error) { + ctl_fatal("%s", error); + } bool enabled = parse_enabled(state); nbrec_logical_switch_port_set_enabled(lsp, &enabled, 1); } @@ -1272,7 +1307,10 @@ nbctl_lsp_get_enabled(struct ctl_context *ctx) const char *id = ctx->argv[1]; const struct nbrec_logical_switch_port *lsp; - lsp = lsp_by_name_or_uuid(ctx, id, true); + char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp); + if (error) { + ctl_fatal("%s", error); + } ds_put_format(&ctx->output, "%s\n", !lsp->enabled || *lsp->enabled ? "enabled" : "disabled"); } @@ -1284,7 +1322,10 @@ nbctl_lsp_set_type(struct ctl_context *ctx) const char *type = ctx->argv[2]; const struct nbrec_logical_switch_port *lsp; - lsp = lsp_by_name_or_uuid(ctx, id, true); + char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp); + if (error) { + ctl_fatal("%s", error); + } if (ovn_is_known_nb_lsp_type(type)) { nbrec_logical_switch_port_set_type(lsp, type); } else { @@ -1299,7 +1340,10 @@ nbctl_lsp_get_type(struct ctl_context *ctx) const char *id = ctx->argv[1]; const struct nbrec_logical_switch_port *lsp; - lsp = lsp_by_name_or_uuid(ctx, id, true); + char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp); + if (error) { + ctl_fatal("%s", error); + } ds_put_format(&ctx->output, "%s\n", lsp->type); } @@ -1311,7 +1355,10 @@ nbctl_lsp_set_options(struct ctl_context *ctx) size_t i; struct smap options = SMAP_INITIALIZER(&options); - lsp = lsp_by_name_or_uuid(ctx, id, true); + char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp); + if (error) { + ctl_fatal("%s", error); + } for (i = 2; i < ctx->argc; i++) { char *key, *value; value = xstrdup(ctx->argv[i]); @@ -1334,7 +1381,10 @@ nbctl_lsp_get_options(struct ctl_context *ctx) const struct nbrec_logical_switch_port *lsp; struct smap_node *node; - lsp = lsp_by_name_or_uuid(ctx, id, true); + char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp); + if (error) { + ctl_fatal("%s", error); + } SMAP_FOR_EACH(node, &lsp->options) { ds_put_format(&ctx->output, "%s=%s\n", node->key, node->value); } @@ -1346,7 +1396,10 @@ nbctl_lsp_set_dhcpv4_options(struct ctl_context *ctx) const char *id = ctx->argv[1]; const struct nbrec_logical_switch_port *lsp; - lsp = lsp_by_name_or_uuid(ctx, id, true); + char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp); + if (error) { + ctl_fatal("%s", error); + } const struct nbrec_dhcp_options *dhcp_opt = NULL; if (ctx->argc == 3 ) { dhcp_opt = dhcp_options_get(ctx, ctx->argv[2], true); @@ -1355,7 +1408,7 @@ nbctl_lsp_set_dhcpv4_options(struct ctl_context *ctx) if (dhcp_opt) { ovs_be32 ip; unsigned int plen; - char *error = ip_parse_cidr(dhcp_opt->cidr, &ip, &plen); + 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); @@ -1370,7 +1423,10 @@ nbctl_lsp_set_dhcpv6_options(struct ctl_context *ctx) const char *id = ctx->argv[1]; const struct nbrec_logical_switch_port *lsp; - lsp = lsp_by_name_or_uuid(ctx, id, true); + char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp); + if (error) { + ctl_fatal("%s", error); + } const struct nbrec_dhcp_options *dhcp_opt = NULL; if (ctx->argc == 3) { dhcp_opt = dhcp_options_get(ctx, ctx->argv[2], true); @@ -1379,7 +1435,7 @@ nbctl_lsp_set_dhcpv6_options(struct ctl_context *ctx) if (dhcp_opt) { struct in6_addr ip; unsigned int plen; - char *error = ipv6_parse_cidr(dhcp_opt->cidr, &ip, &plen); + 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); @@ -1394,7 +1450,10 @@ nbctl_lsp_get_dhcpv4_options(struct ctl_context *ctx) const char *id = ctx->argv[1]; const struct nbrec_logical_switch_port *lsp; - lsp = lsp_by_name_or_uuid(ctx, id, true); + char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp); + if (error) { + ctl_fatal("%s", error); + } if (lsp->dhcpv4_options) { ds_put_format(&ctx->output, UUID_FMT " (%s)\n", UUID_ARGS(&lsp->dhcpv4_options->header_.uuid), @@ -1408,7 +1467,10 @@ nbctl_lsp_get_dhcpv6_options(struct ctl_context *ctx) const char *id = ctx->argv[1]; const struct nbrec_logical_switch_port *lsp; - lsp = lsp_by_name_or_uuid(ctx, id, true); + char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp); + if (error) { + ctl_fatal("%s", error); + } if (lsp->dhcpv6_options) { ds_put_format(&ctx->output, UUID_FMT " (%s)\n", UUID_ARGS(&lsp->dhcpv6_options->header_.uuid), @@ -2847,7 +2909,10 @@ nbctl_lr_nat_add(struct ctl_context *ctx) } logical_port = ctx->argv[5]; - lsp_by_name_or_uuid(ctx, logical_port, true); + char *error = lsp_by_name_or_uuid(ctx, logical_port, true, NULL); + if (error) { + ctl_fatal("%s", error); + } external_mac = ctx->argv[6]; struct eth_addr ea; From patchwork Sat Jul 7 11:09:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 940798 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 41N87c2f4Zz9s0n for ; Sat, 7 Jul 2018 21:12:12 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 14F6CCA1; Sat, 7 Jul 2018 11:10:17 +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 7C1DFC7A for ; Sat, 7 Jul 2018 11:10:15 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id DD4B676E for ; Sat, 7 Jul 2018 11:10:14 +0000 (UTC) Received: by mail-wr1-f49.google.com with SMTP id h10-v6so6399960wre.6 for ; Sat, 07 Jul 2018 04:10:14 -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=kkeWOlJmBiuAunYooSg6V+4DkdHdzfVMD4es5e4iaCo=; b=q/B6LMNXl8Z0FQchXlwDQBMZhhT8Ram53lUVjvApL0sdkDmnE1VTGSkrIVopSq1QZP asSuYT5KN133W+WINKcBgL77HI2iI8gbLUE90LrEspVOMScx0WTWRR1UsmtmWt1jB+Gh 18jqn+PDn0FRsohTJaQ7h9pYGpuq9UY4DL/DYxn546NsfcRkMspbR/0bGyrFve4D++2y tzAeg0iCgOXeJgcvG82BxE8Sa+D9MhL6apYmDHj50C6sGPEWc01LtYFdI0bYGkYCmDn1 noBPQcM5tl/abYzImvIrcvkM9Ac0gZcc8LrWfjPbGXwmVL3pIKYrI+87NmHqvSSpIZs7 1vbw== X-Gm-Message-State: APt69E1wwvL2uah2lIKN03vnAD/S6m6dWVvLVsuliT5PoUDDd0yXt+un pg//ASNHUrIy6t4DvK6GnhMjtwVBCGI= X-Google-Smtp-Source: AAOMgpe6XbVIUgKWbHClPa5mIw0ksXJ1deaQpppG39uKoYMd1yVYU8KgxLHnQwFbPSdgLzSPvUdSYg== X-Received: by 2002:adf:aa0b:: with SMTP id p11-v6mr7116840wrd.220.1530961813302; Sat, 07 Jul 2018 04:10:13 -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 j11-v6sm111081wrr.37.2018.07.07.04.10.12 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 07 Jul 2018 04:10:12 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Sat, 7 Jul 2018 13:09:39 +0200 Message-Id: <20180707111004.8320-6-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180707111004.8320-1-jkbs@redhat.com> References: <20180707111004.8320-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/30] ovn-nbctl: Don't die in lb_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. Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 48 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 8a07bc912..8a0198ce3 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -569,8 +569,9 @@ ls_by_name_or_uuid(struct ctl_context *ctx, const char *id, bool must_exist, return NULL; } -static const struct nbrec_load_balancer * -lb_by_name_or_uuid(struct ctl_context *ctx, const char *id, bool must_exist) +static char * OVS_WARN_UNUSED_RESULT +lb_by_name_or_uuid(struct ctl_context *ctx, const char *id, bool must_exist, + const struct nbrec_load_balancer **lb_p) { const struct nbrec_load_balancer *lb = NULL; @@ -588,19 +589,22 @@ lb_by_name_or_uuid(struct ctl_context *ctx, const char *id, bool must_exist) continue; } if (lb) { - ctl_fatal("Multiple load balancers named '%s'. " - "Use a UUID.", id); + return xasprintf("Multiple load balancers named '%s'. " + "Use a UUID.", id); } lb = iter; } } if (!lb && must_exist) { - ctl_fatal("%s: load balancer %s not found", id, - is_uuid ? "UUID" : "name"); + return xasprintf("%s: load balancer %s not found", id, + is_uuid ? "UUID" : "name"); } - return lb; + if (lb_p) { + *lb_p = lb; + } + return NULL; } static const struct nbrec_port_group * @@ -2069,7 +2073,10 @@ nbctl_lb_add(struct ctl_context *ctx) const struct nbrec_load_balancer *lb = NULL; if (!add_duplicate) { - lb = lb_by_name_or_uuid(ctx, lb_name, false); + char *error = lb_by_name_or_uuid(ctx, lb_name, false, &lb); + if (error) { + ctl_fatal("%s", error); + } if (lb) { if (smap_get(&lb->vips, lb_vip_normalized)) { if (!may_exist) { @@ -2118,7 +2125,10 @@ nbctl_lb_del(struct ctl_context *ctx) const struct nbrec_load_balancer *lb = NULL; bool must_exist = !shash_find(&ctx->options, "--if-exists"); - lb = lb_by_name_or_uuid(ctx, id, false); + char *error = lb_by_name_or_uuid(ctx, id, false, &lb); + if (error) { + ctl_fatal("%s", error); + } if (!lb) { return; } @@ -2255,7 +2265,10 @@ nbctl_lr_lb_add(struct ctl_context *ctx) const struct nbrec_load_balancer *new_lb; lr = lr_by_name_or_uuid(ctx, ctx->argv[1], true); - new_lb = lb_by_name_or_uuid(ctx, ctx->argv[2], true); + char *error = lb_by_name_or_uuid(ctx, ctx->argv[2], true, &new_lb); + if (error) { + ctl_fatal("%s", error); + } bool may_exist = shash_find(&ctx->options, "--may-exist") != NULL; for (int i = 0; i < lr->n_load_balancer; i++) { @@ -2300,7 +2313,10 @@ nbctl_lr_lb_del(struct ctl_context *ctx) return; } - del_lb = lb_by_name_or_uuid(ctx, ctx->argv[2], true); + char *error = lb_by_name_or_uuid(ctx, ctx->argv[2], true, &del_lb); + if (error) { + ctl_fatal("%s", error); + } for (size_t i = 0; i < lr->n_load_balancer; i++) { const struct nbrec_load_balancer *lb = lr->load_balancer[i]; @@ -2361,7 +2377,10 @@ nbctl_ls_lb_add(struct ctl_context *ctx) if (error) { ctl_fatal("%s", error); } - new_lb = lb_by_name_or_uuid(ctx, ctx->argv[2], true); + error = lb_by_name_or_uuid(ctx, ctx->argv[2], true, &new_lb); + if (error) { + ctl_fatal("%s", error); + } bool may_exist = shash_find(&ctx->options, "--may-exist") != NULL; for (int i = 0; i < ls->n_load_balancer; i++) { @@ -2409,7 +2428,10 @@ nbctl_ls_lb_del(struct ctl_context *ctx) return; } - del_lb = lb_by_name_or_uuid(ctx, ctx->argv[2], true); + error = lb_by_name_or_uuid(ctx, ctx->argv[2], true, &del_lb); + if (error) { + ctl_fatal("%s", error); + } for (size_t i = 0; i < ls->n_load_balancer; i++) { const struct nbrec_load_balancer *lb = ls->load_balancer[i]; From patchwork Sat Jul 7 11:09:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 940799 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 41N88740Bxz9s0n for ; Sat, 7 Jul 2018 21:12:39 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id C3497CAD; Sat, 7 Jul 2018 11:10:18 +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 6B126C94 for ; Sat, 7 Jul 2018 11:10:17 +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 6D67D318 for ; Sat, 7 Jul 2018 11:10:16 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id b15-v6so6406715wrv.10 for ; Sat, 07 Jul 2018 04:10:16 -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=YLtPQuI8WhgXAT/Is1DoWRUORbFzNpRGbGIwRgBOQ3k=; b=lNEoKlcNCnMZ4xHEVG3JgJ3eQAvqbvPLLjJQKp/IEJe15MAAujmxWC5XR95ehoEiw1 uloMtxgAAKWEWdwngC4BGO+/88VbplVSPH1DFQnHgkDfrNHWSSVd4NIepK4e7hDp//6p XGu8L9/pxK8QE1HVY7mqFHuuMB2t1USMpY0yO9gNwz5HJevZJstBxilJ5VUP2EteMbTT GGQzNMWwyi3b62IMAERtAWNjgH2zVUQ7fiopExAOTAyYjhDf3Di23EYlV59eD+1vlLXk 4H6rjMuXkERgyCChC+aqMjIhWy6+mti6FTvEqi3OUhW9hWS38qoE+1CWVnwWMwJZn+1Y sYtw== X-Gm-Message-State: APt69E3M/noEgHhMVgUSZFCIP3mghfGKpPtgM68660+35+FGTrd+e0Tu +loqZvZDrJ2UzxK4l/Ux5xKphg9/UuQ= X-Google-Smtp-Source: AAOMgpeO1FCWlD72/GF1TFH7wl46xCwhVEjglAPxm5bssC4SKNxTQKuj79bt6KmiL74OhhGx4Mulqg== X-Received: by 2002:adf:a401:: with SMTP id d1-v6mr9443936wra.121.1530961814748; Sat, 07 Jul 2018 04:10:14 -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 w24-v6sm8444776wmc.15.2018.07.07.04.10.13 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 07 Jul 2018 04:10:14 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Sat, 7 Jul 2018 13:09:40 +0200 Message-Id: <20180707111004.8320-7-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180707111004.8320-1-jkbs@redhat.com> References: <20180707111004.8320-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/30] ovn-nbctl: Don't die in lr_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. Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 96 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 69 insertions(+), 27 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 8a0198ce3..812901617 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -496,9 +496,9 @@ Other options:\n\ /* Find a logical router given its id. */ -static const struct nbrec_logical_router * +static char * OVS_WARN_UNUSED_RESULT lr_by_name_or_uuid(struct ctl_context *ctx, const char *id, - bool must_exist) + bool must_exist, const struct nbrec_logical_router **lr_p) { const struct nbrec_logical_router *lr = NULL; bool is_uuid = false; @@ -517,18 +517,22 @@ lr_by_name_or_uuid(struct ctl_context *ctx, const char *id, continue; } if (lr) { - ctl_fatal("Multiple logical routers named '%s'. " - "Use a UUID.", id); + return xasprintf("Multiple logical routers named '%s'. " + "Use a UUID.", id); } lr = iter; } } if (!lr && must_exist) { - ctl_fatal("%s: router %s not found", id, is_uuid ? "UUID" : "name"); + return xasprintf("%s: router %s not found", + id, is_uuid ? "UUID" : "name"); } - return lr; + if (lr_p) { + *lr_p = lr; + } + return NULL; } static char * OVS_WARN_UNUSED_RESULT @@ -820,7 +824,10 @@ nbctl_show(struct ctl_context *ctx) const struct nbrec_logical_router *lr; if (ctx->argc == 2) { - lr = lr_by_name_or_uuid(ctx, ctx->argv[1], false); + char *error = lr_by_name_or_uuid(ctx, ctx->argv[1], false, &lr); + if (error) { + ctl_fatal("%s", error); + } if (lr) { print_lr(lr, &ctx->output); } @@ -2264,8 +2271,11 @@ nbctl_lr_lb_add(struct ctl_context *ctx) const struct nbrec_logical_router *lr; const struct nbrec_load_balancer *new_lb; - lr = lr_by_name_or_uuid(ctx, ctx->argv[1], true); - char *error = lb_by_name_or_uuid(ctx, ctx->argv[2], true, &new_lb); + char *error = lr_by_name_or_uuid(ctx, ctx->argv[1], true, &lr); + if (error) { + ctl_fatal("%s", error); + } + error = lb_by_name_or_uuid(ctx, ctx->argv[2], true, &new_lb); if (error) { ctl_fatal("%s", error); } @@ -2303,7 +2313,10 @@ nbctl_lr_lb_del(struct ctl_context *ctx) { const struct nbrec_logical_router *lr; const struct nbrec_load_balancer *del_lb; - lr = lr_by_name_or_uuid(ctx, ctx->argv[1], true); + char *error = lr_by_name_or_uuid(ctx, ctx->argv[1], true, &lr); + if (error) { + ctl_fatal("%s", error); + } if (ctx->argc == 2) { /* If load-balancer is not specified, remove @@ -2313,7 +2326,7 @@ nbctl_lr_lb_del(struct ctl_context *ctx) return; } - char *error = lb_by_name_or_uuid(ctx, ctx->argv[2], true, &del_lb); + error = lb_by_name_or_uuid(ctx, ctx->argv[2], true, &del_lb); if (error) { ctl_fatal("%s", error); } @@ -2351,7 +2364,10 @@ nbctl_lr_lb_list(struct ctl_context *ctx) struct smap lbs = SMAP_INITIALIZER(&lbs); int vip_width = 0; - lr = lr_by_name_or_uuid(ctx, lr_name, true); + char *error = lr_by_name_or_uuid(ctx, lr_name, true, &lr); + if (error) { + ctl_fatal("%s", error); + } for (int i = 0; i < lr->n_load_balancer; i++) { const struct nbrec_load_balancer *lb = lr->load_balancer[i]; @@ -2529,7 +2545,10 @@ nbctl_lr_del(struct ctl_context *ctx) const char *id = ctx->argv[1]; const struct nbrec_logical_router *lr; - lr = lr_by_name_or_uuid(ctx, id, must_exist); + char *error = lr_by_name_or_uuid(ctx, id, must_exist, &lr); + if (error) { + ctl_fatal("%s", error); + } if (!lr) { return; } @@ -2733,7 +2752,10 @@ static void nbctl_lr_route_add(struct ctl_context *ctx) { const struct nbrec_logical_router *lr; - lr = lr_by_name_or_uuid(ctx, ctx->argv[1], true); + char *error = lr_by_name_or_uuid(ctx, ctx->argv[1], true, &lr); + if (error) { + ctl_fatal("%s", error); + } char *prefix, *next_hop; const char *policy = shash_find_data(&ctx->options, "--policy"); @@ -2838,7 +2860,10 @@ static void nbctl_lr_route_del(struct ctl_context *ctx) { const struct nbrec_logical_router *lr; - lr = lr_by_name_or_uuid(ctx, ctx->argv[1], true); + char *error = lr_by_name_or_uuid(ctx, ctx->argv[1], true, &lr); + if (error) { + ctl_fatal("%s", error); + } if (ctx->argc == 2) { /* If a prefix is not specified, delete all routes. */ @@ -2890,7 +2915,10 @@ nbctl_lr_nat_add(struct ctl_context *ctx) const char *logical_ip = ctx->argv[4]; char *new_logical_ip = NULL; - lr = lr_by_name_or_uuid(ctx, ctx->argv[1], true); + char *error = lr_by_name_or_uuid(ctx, ctx->argv[1], true, &lr); + if (error) { + ctl_fatal("%s", error); + } if (strcmp(nat_type, "dnat") && strcmp(nat_type, "snat") && strcmp(nat_type, "dnat_and_snat")) { @@ -2910,7 +2938,7 @@ nbctl_lr_nat_add(struct ctl_context *ctx) } new_logical_ip = xstrdup(logical_ip); } else { - char *error = ip_parse_cidr(logical_ip, &ipv4, &plen); + error = ip_parse_cidr(logical_ip, &ipv4, &plen); if (error) { free(error); ctl_fatal("%s: should be an IPv4 address or network.", @@ -2931,7 +2959,7 @@ nbctl_lr_nat_add(struct ctl_context *ctx) } logical_port = ctx->argv[5]; - char *error = lsp_by_name_or_uuid(ctx, logical_port, true, NULL); + error = lsp_by_name_or_uuid(ctx, logical_port, true, NULL); if (error) { ctl_fatal("%s", error); } @@ -3002,7 +3030,10 @@ nbctl_lr_nat_del(struct ctl_context *ctx) { const struct nbrec_logical_router *lr; bool must_exist = !shash_find(&ctx->options, "--if-exists"); - lr = lr_by_name_or_uuid(ctx, ctx->argv[1], true); + char *error = lr_by_name_or_uuid(ctx, ctx->argv[1], true, &lr); + if (error) { + ctl_fatal("%s", error); + } if (ctx->argc == 2) { /* If type, external_ip and logical_ip are not specified, delete @@ -3063,7 +3094,10 @@ static void nbctl_lr_nat_list(struct ctl_context *ctx) { const struct nbrec_logical_router *lr; - lr = lr_by_name_or_uuid(ctx, ctx->argv[1], true); + char *error = lr_by_name_or_uuid(ctx, ctx->argv[1], true, &lr); + if (error) { + ctl_fatal("%s", error); + } struct smap lr_nats = SMAP_INITIALIZER(&lr_nats); for (size_t i = 0; i < lr->n_nat; i++) { @@ -3306,7 +3340,10 @@ nbctl_lrp_add(struct ctl_context *ctx) bool may_exist = shash_find(&ctx->options, "--may-exist") != NULL; const struct nbrec_logical_router *lr; - lr = lr_by_name_or_uuid(ctx, ctx->argv[1], true); + char *error = lr_by_name_or_uuid(ctx, ctx->argv[1], true, &lr); + if (error) { + ctl_fatal("%s", error); + } const char *lrp_name = ctx->argv[2]; const char *mac = ctx->argv[3]; @@ -3390,7 +3427,7 @@ nbctl_lrp_add(struct ctl_context *ctx) for (int i = 0; i < n_networks; i++) { ovs_be32 ipv4; unsigned int plen; - char *error = ip_parse_cidr(networks[i], &ipv4, &plen); + error = ip_parse_cidr(networks[i], &ipv4, &plen); if (error) { free(error); struct in6_addr ipv6; @@ -3410,8 +3447,8 @@ nbctl_lrp_add(struct ctl_context *ctx) nbrec_logical_router_port_set_networks(lrp, networks, n_networks); for (int i = 0; i < n_settings; i++) { - char *error = ctl_set_column("Logical_Router_Port", &lrp->header_, - settings[i], ctx->symtab); + error = ctl_set_column("Logical_Router_Port", &lrp->header_, + settings[i], ctx->symtab); if (error) { ctl_fatal("%s", error); } @@ -3487,7 +3524,10 @@ nbctl_lrp_list(struct ctl_context *ctx) struct smap lrps; size_t i; - lr = lr_by_name_or_uuid(ctx, id, true); + char *error = lr_by_name_or_uuid(ctx, id, true, &lr); + if (error) { + ctl_fatal("%s", error); + } smap_init(&lrps); for (i = 0; i < lr->n_ports; i++) { @@ -3608,7 +3648,10 @@ nbctl_lr_route_list(struct ctl_context *ctx) size_t n_ipv4_routes = 0; size_t n_ipv6_routes = 0; - lr = lr_by_name_or_uuid(ctx, ctx->argv[1], true); + char *error = lr_by_name_or_uuid(ctx, ctx->argv[1], true, &lr); + if (error) { + ctl_fatal("%s", error); + } ipv4_routes = xmalloc(sizeof *ipv4_routes * lr->n_static_routes); ipv6_routes = xmalloc(sizeof *ipv6_routes * lr->n_static_routes); @@ -3619,7 +3662,6 @@ nbctl_lr_route_list(struct ctl_context *ctx) unsigned int plen; ovs_be32 ipv4; const char *policy = route->policy ? route->policy : "dst-ip"; - char *error; error = ip_parse_cidr(route->ip_prefix, &ipv4, &plen); if (!error) { ipv4_routes[n_ipv4_routes].priority = !strcmp(policy, "dst-ip") From patchwork Sat Jul 7 11:09:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 940800 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 41N88t0BQXz9s0n for ; Sat, 7 Jul 2018 21:13:18 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id ACA93CB9; Sat, 7 Jul 2018 11:10:20 +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 4D26FC97 for ; Sat, 7 Jul 2018 11:10:18 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f44.google.com (mail-wm0-f44.google.com [74.125.82.44]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id AE557318 for ; Sat, 7 Jul 2018 11:10:17 +0000 (UTC) Received: by mail-wm0-f44.google.com with SMTP id z13-v6so16534491wma.5 for ; Sat, 07 Jul 2018 04:10:17 -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=ZC2Mva1X541BUjVCb+Zsk/T7mgfdlFCo+VQ68vKH9cs=; b=bDpsxzpXIjF8Kep6XWkE5s+puU1UHLBB8hh1ruw/66ZvEBFOqeqfA/qAMPnK2iqmr4 6E6Gi5KXi/3/HvhSVanuQmNQHg1rj+Y3j7axZZZLL1g9I7FC8l+DTvwJGW43ob6S58DA 3MA+qGdtLNYkCh4zr7tVGgAXFuM/97J7iDnfAqKwxhtvSAGlh670Ri8IAIOpt9LRbTns RjCXLV2KQ1GyUwUVpdRBTpnIb2yT+GTmsFFuTgm4u3XXuFTX0ERS8djlD+F0BRtWb7dY K79HY6HXGNiueE54+veQ+YWKtmDlY6qFodzb71gVkQl3Qo9wYLCdU5Vnk5YG0NuCe+I7 3+Ww== X-Gm-Message-State: APt69E1HyB93KYbCM5+bXal5PMfE2bV7zMokOgkA1AiJtHev8xXa8s1m mnNTp3YAG/1kQ+nFRdgykjdIboSdfOs= X-Google-Smtp-Source: AAOMgpeW4ckwHtSSs8VfxV2D6ziXeY4D3gjEPYu35A3QtqAfP0Ajy+AiO8f2yuo5qksEsxpSydt4Vg== X-Received: by 2002:a1c:5f82:: with SMTP id t124-v6mr8391611wmb.14.1530961816069; Sat, 07 Jul 2018 04:10:16 -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 u6-v6sm9604645wmu.5.2018.07.07.04.10.15 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 07 Jul 2018 04:10:15 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Sat, 7 Jul 2018 13:09:41 +0200 Message-Id: <20180707111004.8320-8-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180707111004.8320-1-jkbs@redhat.com> References: <20180707111004.8320-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/30] ovn-nbctl: Don't die in lrp_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. Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 48 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 812901617..79410a751 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -3129,8 +3129,9 @@ nbctl_lr_nat_list(struct ctl_context *ctx) } -static const struct nbrec_logical_router_port * -lrp_by_name_or_uuid(struct ctl_context *ctx, const char *id, bool must_exist) +static char * OVS_WARN_UNUSED_RESULT +lrp_by_name_or_uuid(struct ctl_context *ctx, const char *id, bool must_exist, + const struct nbrec_logical_router_port **lrp_p) { const struct nbrec_logical_router_port *lrp = NULL; @@ -3149,10 +3150,14 @@ lrp_by_name_or_uuid(struct ctl_context *ctx, const char *id, bool must_exist) } if (!lrp && must_exist) { - ctl_fatal("%s: port %s not found", id, is_uuid ? "UUID" : "name"); + return xasprintf("%s: port %s not found", + id, is_uuid ? "UUID" : "name"); } - return lrp; + if (lrp_p) { + *lrp_p = lrp; + } + return NULL; } /* Returns the logical router that contains 'lrp'. */ @@ -3219,7 +3224,10 @@ nbctl_lrp_set_gateway_chassis(struct ctl_context *ctx) int64_t priority = 0; const char *lrp_name = ctx->argv[1]; const struct nbrec_logical_router_port *lrp; - lrp = lrp_by_name_or_uuid(ctx, lrp_name, true); + char *error = lrp_by_name_or_uuid(ctx, lrp_name, true, &lrp); + if (error) { + ctl_fatal("%s", error); + } if (!lrp) { ctl_fatal("router port %s is required", lrp_name); return; @@ -3293,7 +3301,10 @@ static void nbctl_lrp_del_gateway_chassis(struct ctl_context *ctx) { const struct nbrec_logical_router_port *lrp; - lrp = lrp_by_name_or_uuid(ctx, ctx->argv[1], true); + char *error = lrp_by_name_or_uuid(ctx, ctx->argv[1], true, &lrp); + if (error) { + ctl_fatal("%s", error); + } if (!lrp) { return; } @@ -3322,7 +3333,10 @@ nbctl_lrp_get_gateway_chassis(struct ctl_context *ctx) const struct nbrec_gateway_chassis **gcs; size_t i; - lrp = lrp_by_name_or_uuid(ctx, id, true); + char *error = lrp_by_name_or_uuid(ctx, id, true, &lrp); + if (error) { + ctl_fatal("%s", error); + } gcs = get_ordered_gw_chassis_prio_list(lrp); for (i = 0; i < lrp->n_gateway_chassis; i++) { @@ -3365,7 +3379,10 @@ nbctl_lrp_add(struct ctl_context *ctx) int n_settings = ctx->argc - 4 - n_networks; const struct nbrec_logical_router_port *lrp; - lrp = lrp_by_name_or_uuid(ctx, lrp_name, false); + error = lrp_by_name_or_uuid(ctx, lrp_name, false, &lrp); + if (error) { + ctl_fatal("%s", error); + } if (lrp) { if (!may_exist) { ctl_fatal("%s: a port with this name already exists", @@ -3494,7 +3511,10 @@ nbctl_lrp_del(struct ctl_context *ctx) bool must_exist = !shash_find(&ctx->options, "--if-exists"); const struct nbrec_logical_router_port *lrp; - lrp = lrp_by_name_or_uuid(ctx, ctx->argv[1], must_exist); + char *error = lrp_by_name_or_uuid(ctx, ctx->argv[1], must_exist, &lrp); + if (error) { + ctl_fatal("%s", error); + } if (!lrp) { return; } @@ -3552,7 +3572,10 @@ nbctl_lrp_set_enabled(struct ctl_context *ctx) const char *state = ctx->argv[2]; const struct nbrec_logical_router_port *lrp; - lrp = lrp_by_name_or_uuid(ctx, id, true); + char *error = lrp_by_name_or_uuid(ctx, id, true, &lrp); + if (error) { + ctl_fatal("%s", error); + } if (!lrp) { return; } @@ -3568,7 +3591,10 @@ nbctl_lrp_get_enabled(struct ctl_context *ctx) const char *id = ctx->argv[1]; const struct nbrec_logical_router_port *lrp; - lrp = lrp_by_name_or_uuid(ctx, id, true); + char *error = lrp_by_name_or_uuid(ctx, id, true, &lrp); + if (error) { + ctl_fatal("%s", error); + } if (!lrp) { return; } From patchwork Sat Jul 7 11:09:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 940801 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 41N89P19DWz9s0n for ; Sat, 7 Jul 2018 21:13:45 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 7BEDBCA6; Sat, 7 Jul 2018 11:10:21 +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 9F17CC9D for ; Sat, 7 Jul 2018 11:10:19 +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 097FD318 for ; Sat, 7 Jul 2018 11:10:18 +0000 (UTC) Received: by mail-wr1-f51.google.com with SMTP id h10-v6so6412631wrq.8 for ; Sat, 07 Jul 2018 04:10:18 -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=jhGJH7jKvGutrTwaGhAvZw+snram22Bv3+bRuQu0L68=; b=QrKAq5JKq5tDT8eBTQVjFQFYKA0Uarsm0tPqE5M0++Vl06XYCix/csW/+nkSYPe26r tHta7IGj28DFAoucrn71AiSeDbtJkJfLbRJuK80G020ooZNfOlGodTzhf7fNrFhlJ/xb JrCgq38vCPQo998OVlFKa7MTXJalQZs2A9HF6UXHJDdWDvC7n/ScFPSWBUgW4j7Y6JTz 6JB0T+rAsW2brpb99WRoobOQQZcBo4KT0kY8nGQ7MJ80nwJ2hL9YOrYHu4KaZ7MLzyRf VwMYfHhzkneq0IHx+4/6oHpfIs1mW76PrLu6ddSaJO+0J3Jl2CQwmETaAJZmKC9WlVad fZag== X-Gm-Message-State: APt69E15swFukED0EYY9rT5ApnVRsOH0s2+dreByCCTCZijIut7J8qur yEZdAxojxKP9T9CWPeDGYMH/vARFKic= X-Google-Smtp-Source: AAOMgpcH4mOd9Dr+pRsdNs90lDG6tDQCwn9ZIZSLWXbqKp4oT5+ViVZ0/yqxU0Ghw/OnWlVZbo2HUA== X-Received: by 2002:adf:9025:: with SMTP id h34-v6mr10707520wrh.123.1530961817391; Sat, 07 Jul 2018 04:10:17 -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 z9-v6sm20265767wre.49.2018.07.07.04.10.16 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 07 Jul 2018 04:10:16 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Sat, 7 Jul 2018 13:09:42 +0200 Message-Id: <20180707111004.8320-9-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180707111004.8320-1-jkbs@redhat.com> References: <20180707111004.8320-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/30] ovn-nbctl: Don't die in acl_cmd_get_pg_or_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. 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 79410a751..56558ddd0 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -1526,7 +1526,7 @@ acl_cmp(const void *acl1_, const void *acl2_) } } -static void +static char * OVS_WARN_UNUSED_RESULT acl_cmd_get_pg_or_ls(struct ctl_context *ctx, const struct nbrec_logical_switch **ls, const struct nbrec_port_group **pg) @@ -1538,16 +1538,16 @@ acl_cmd_get_pg_or_ls(struct ctl_context *ctx, *pg = pg_by_name_or_uuid(ctx, ctx->argv[1], false); error = ls_by_name_or_uuid(ctx, ctx->argv[1], false, ls); if (error) { - ctl_fatal("%s", error); + return error; } if (*pg && *ls) { - ctl_fatal("Same name '%s' exists in both port-groups and " - "logical switches. Specify --type=port-group or " - "switch, or use a UUID.", ctx->argv[1]); + return xasprintf("Same name '%s' exists in both port-groups and " + "logical switches. Specify --type=port-group or " + "switch, or use a UUID.", ctx->argv[1]); } if (!*pg && !*ls) { - ctl_fatal("'%s' is not found for port-group or switch.", - ctx->argv[1]); + return xasprintf("'%s' is not found for port-group or switch.", + ctx->argv[1]); } } else if (!strcmp(opt_type, "port-group")) { *pg = pg_by_name_or_uuid(ctx, ctx->argv[1], true); @@ -1555,12 +1555,14 @@ acl_cmd_get_pg_or_ls(struct ctl_context *ctx, } else if (!strcmp(opt_type, "switch")) { error = ls_by_name_or_uuid(ctx, ctx->argv[1], true, ls); if (error) { - ctl_fatal("%s", error); + return error; } *pg = NULL; } else { - ctl_fatal("Invalid value '%s' for option --type", opt_type); + return xasprintf("Invalid value '%s' for option --type", opt_type); } + + return NULL; } static void @@ -1571,7 +1573,11 @@ nbctl_acl_list(struct ctl_context *ctx) const struct nbrec_acl **acls; size_t i; - acl_cmd_get_pg_or_ls(ctx, &ls, &pg); + char *error = acl_cmd_get_pg_or_ls(ctx, &ls, &pg); + if (error) { + ctl_fatal("%s", error); + } + size_t n_acls = pg ? pg->n_acls : ls->n_acls; struct nbrec_acl **nb_acls = pg ? pg->acls : ls->acls; @@ -1656,7 +1662,10 @@ nbctl_acl_add(struct ctl_context *ctx) const struct nbrec_port_group *pg = NULL; const char *action = ctx->argv[5]; - acl_cmd_get_pg_or_ls(ctx, &ls, &pg); + char *error = acl_cmd_get_pg_or_ls(ctx, &ls, &pg); + if (error) { + ctl_fatal("%s", error); + } const char *direction = parse_direction(ctx->argv[2]); int64_t priority = parse_priority(ctx->argv[3]); @@ -1727,7 +1736,10 @@ nbctl_acl_del(struct ctl_context *ctx) const struct nbrec_logical_switch *ls = NULL; const struct nbrec_port_group *pg = NULL; - acl_cmd_get_pg_or_ls(ctx, &ls, &pg); + char *error = acl_cmd_get_pg_or_ls(ctx, &ls, &pg); + if (error) { + ctl_fatal("%s", error); + } if (ctx->argc == 2) { /* If direction, priority, and match are not specified, delete From patchwork Sat Jul 7 11:09:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 940802 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 41N89z4frGz9s0n for ; Sat, 7 Jul 2018 21:14:15 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 49CD6CBE; Sat, 7 Jul 2018 11:10:23 +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 3C6AACC0 for ; Sat, 7 Jul 2018 11:10:21 +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 B55AA76F for ; Sat, 7 Jul 2018 11:10:20 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id j33-v6so6401643wrj.5 for ; Sat, 07 Jul 2018 04:10: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=R9nBzI/Gjn2Yi3V/ncv3Df3NxM1FxjQwJLCkkXRvlAw=; b=eaguTZvvnTjl7uUNy2skIc4p3zN9m5HWJSJGE0McANVZ9znOdfpmDGQ4prIYbyRV8W sNfyUfc+bThcbpAfrzeOdCPG1/oXX4N40/cvYKL7UEV+6+N7H1FxuG/Pyz93aXKG775J u2Pi+F8nMlPfL/Sk8P/J+5dlPJ5TBM432qEGWJrs1+ytDMPHbchpKACKWP8oyie+bFcr wTS3V8xJwBVkzjMHc6yA55DDQvJDADoodJFc+q8McKXtFMZ0oGanjgTAXS0sfhtIyvlV 64d1VDyKqodVJVXD2iA3KK7OP0sjLVQx5e5jJSFsDpnzpJCylaRpmnr9pS2WCRsJZn3x McBA== X-Gm-Message-State: APt69E2woMj7pIkHBRwWDp1GVSqCMWRa4xinc+kK8u/gxQvMRqip4gMQ qR2G1tTwH89VXDYxSb8yA94K85Xpk/0= X-Google-Smtp-Source: AAOMgpe6hqsyH+X0t+/U4fa0IrNvRyTo6VSPqjzvMtuzcp6d0ULciZz/Qo0tiH3oNZjfPAV+fAx3Ug== X-Received: by 2002:adf:be0f:: with SMTP id n15-v6mr10463850wrh.267.1530961819169; Sat, 07 Jul 2018 04:10:19 -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 f17-v6sm7862441wrs.46.2018.07.07.04.10.18 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 07 Jul 2018 04:10:18 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Sat, 7 Jul 2018 13:09:43 +0200 Message-Id: <20180707111004.8320-10-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180707111004.8320-1-jkbs@redhat.com> References: <20180707111004.8320-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/30] ovn-nbctl: Don't die in parse_enabled(). 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. Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 56558ddd0..f519c6c92 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -1285,16 +1285,20 @@ nbctl_lsp_get_up(struct ctl_context *ctx) "%s\n", (lsp->up && *lsp->up) ? "up" : "down"); } -static bool -parse_enabled(const char *state) +static char * OVS_WARN_UNUSED_RESULT +parse_enabled(const char *state, bool *enabled_p) { + ovs_assert(enabled_p); + if (!strcasecmp(state, "enabled")) { - return true; + *enabled_p = true; } else if (!strcasecmp(state, "disabled")) { - return false; + *enabled_p = false; } else { - ctl_fatal("%s: state must be \"enabled\" or \"disabled\"", state); + return xasprintf("%s: state must be \"enabled\" or \"disabled\"", + state); } + return NULL; } static void @@ -1308,7 +1312,11 @@ nbctl_lsp_set_enabled(struct ctl_context *ctx) if (error) { ctl_fatal("%s", error); } - bool enabled = parse_enabled(state); + bool enabled; + error = parse_enabled(state, &enabled); + if (error) { + ctl_fatal("%s", error); + } nbrec_logical_switch_port_set_enabled(lsp, &enabled, 1); } @@ -3592,7 +3600,11 @@ nbctl_lrp_set_enabled(struct ctl_context *ctx) return; } - bool enabled = parse_enabled(state); + bool enabled; + error = parse_enabled(state, &enabled); + if (error) { + ctl_fatal("%s", error); + } nbrec_logical_router_port_set_enabled(lrp, &enabled, 1); } From patchwork Sat Jul 7 11:09:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 940803 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 41N8Bh46Jkz9s0n for ; Sat, 7 Jul 2018 21:14:52 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 1EA1CCD0; Sat, 7 Jul 2018 11:10: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 7DF4CCB8 for ; Sat, 7 Jul 2018 11:10:22 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 03ED7765 for ; Sat, 7 Jul 2018 11:10:21 +0000 (UTC) Received: by mail-wm0-f68.google.com with SMTP id 69-v6so16442909wmf.3 for ; Sat, 07 Jul 2018 04:10: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=PjAYWNXfSAhqMXjdM6xJXiiBi3bxi6o7swuFz6OJRaY=; b=sCmj7fG6Ypb07lFAYo/cTjOCfl35cqaU8LhFnBwdPosBHkzFasLFVdygUFaZ3MYpaI gGe0fH7jg6fGGDIuqVaE2kXlQK98O5NPR5gyfbG2vomWia8ykjr1QVVD+9oERxaiAqlu J5g21GfjbWEB+9rh/Bl5SYsMnmlPJSMYSBsIE0tQ8ftmrUlIjznV3ChnIzVMJ6X9lA/1 0FVKCCMoi0riQbycF35b/aEYrkskd0mRdYuyGhGl98quph5ket1Yj0nDSWIqfDME+l9x IwMI92e88AQQT+2yufimkeCTgSRI+oYF8yIrbQu1Mi14zM6ZEQUu5ovZ66ln7xhIRpkF afjA== X-Gm-Message-State: APt69E3yhWiHaNiWo6DnI+3LFfyqbCM+NScK0PNZgOsWrUSHL7h/3udT gvt5y4ey8ezIrMlWeWf4TEGr9jKWxY0= X-Google-Smtp-Source: AAOMgpddf7gf9xhTJRSckPfO2wAi+rn67X2plBqLaGH7ngG9wOWTzDkgerEO/5ip26PIACCIoWvrVA== X-Received: by 2002:a1c:ea17:: with SMTP id i23-v6mr7353754wmh.29.1530961820474; Sat, 07 Jul 2018 04:10: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 r14-v6sm15112325wrl.4.2018.07.07.04.10.19 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 07 Jul 2018 04:10:19 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Sat, 7 Jul 2018 13:09:44 +0200 Message-Id: <20180707111004.8320-11-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180707111004.8320-1-jkbs@redhat.com> References: <20180707111004.8320-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/30] ovn-nbctl: Don't die in nbctl_ls_add(). 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 Propagate the error via the context instead. Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index f519c6c92..d331c93c0 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -846,7 +846,9 @@ nbctl_ls_add(struct ctl_context *ctx) bool may_exist = shash_find(&ctx->options, "--may-exist") != NULL; bool add_duplicate = shash_find(&ctx->options, "--add-duplicate") != NULL; if (may_exist && add_duplicate) { - ctl_fatal("--may-exist and --add-duplicate may not be used together"); + ctl_error(ctx, "--may-exist and --add-duplicate may not be used " + "together"); + return; } if (ls_name) { @@ -857,15 +859,18 @@ nbctl_ls_add(struct ctl_context *ctx) if (may_exist) { return; } - ctl_fatal("%s: a switch with this name already exists", - ls_name); + ctl_error(ctx, "%s: a switch with this name already " + "exists", ls_name); + return; } } } } else if (may_exist) { - ctl_fatal("--may-exist requires specifying a name"); + ctl_error(ctx, "--may-exist requires specifying a name"); + return; } else if (add_duplicate) { - ctl_fatal("--add-duplicate requires specifying a name"); + ctl_error(ctx, "--add-duplicate requires specifying a name"); + return; } struct nbrec_logical_switch *ls; From patchwork Sat Jul 7 11:09:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 940804 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 41N8CL1s1Gz9s0n for ; Sat, 7 Jul 2018 21:15:26 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id C6E7BCC8; Sat, 7 Jul 2018 11:10: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 E7466C9D for ; Sat, 7 Jul 2018 11:10:23 +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 7616476E for ; Sat, 7 Jul 2018 11:10:23 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id h10-v6so6400151wre.6 for ; Sat, 07 Jul 2018 04:10: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=cKYb7mk5awi7oTESTde7My2/XM6hhwOlYWwJN9lS7T4=; b=V4+w76dLkVIAzkhNWBsV0MTEUNne1SsBp8jOi5n9jtv/ucBCQwXTXQIX+i44Ef68kQ CUSR0v1zuU371SdKEp0RFYaoguOSpNepexFAFeiFtgfeoRzPAtFBNRNUMDIDws5VCKdi KDUsoNolr/J3PiU1UaTJSglXE3vfNHJnUs/Y5Oydv/3rP2Aq6X/TBfEkSKEzBdfJslBm 2/7CASw7ZmpOUGfN0BcJbo0KaN+ww6gWhg252kyabtM6lzsSQUvBAHpH2K//u0+Fqud+ EmaLbDZbhyBrMIBzKdyZNuZyhEW+806l7FLp6qorfyp60Dvc1OEfAMbPem/3Tmtcmnwy LHyA== X-Gm-Message-State: APt69E2mQVvj3N9udtCWBNoRoi6IYulaCVlwACZf18/LRcZzBzqkh2tp fcQTXdF+h1YiiANTLcpW1H6cgbCujX0= X-Google-Smtp-Source: AAOMgpdGO+JHiywUZWBri7UUFbbXV0G9AjurOz2SFn6B3F76xfSNF1jraFKALnIsYzvWAK9WoljCdA== X-Received: by 2002:adf:e642:: with SMTP id b2-v6mr11104141wrn.254.1530961821938; Sat, 07 Jul 2018 04:10: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 s12-v6sm14202339wrf.0.2018.07.07.04.10.21 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 07 Jul 2018 04:10:21 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Sat, 7 Jul 2018 13:09:45 +0200 Message-Id: <20180707111004.8320-12-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180707111004.8320-1-jkbs@redhat.com> References: <20180707111004.8320-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/30] ovn-nbctl: Don't die in nbctl_ls_del(). 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 Propagate the error via the context instead. Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index d331c93c0..c0e068c38 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -889,7 +889,8 @@ nbctl_ls_del(struct ctl_context *ctx) char *error = ls_by_name_or_uuid(ctx, id, must_exist, &ls); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } if (!ls) { return; From patchwork Sat Jul 7 11:09:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 940805 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 41N8D25Nxhz9s0n for ; Sat, 7 Jul 2018 21:16:02 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 92FF7CD4; Sat, 7 Jul 2018 11:10:27 +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 86D71CAC for ; Sat, 7 Jul 2018 11:10:25 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id F16D6765 for ; Sat, 7 Jul 2018 11:10:24 +0000 (UTC) Received: by mail-wr1-f44.google.com with SMTP id s11-v6so6402572wra.13 for ; Sat, 07 Jul 2018 04:10: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=4zKprq/rYD8pm776fHsDK8FDOFBn1iOUwVMOgylsti8=; b=T0sUogCjHXwXHBsbgOqEsZQyJbXZ4e/Tu1rYh0JjQB4xImmkUNHBKfTnFeW8QL2BVw WO4xDVzKHlcMNUEoVOQpTBGSLNtmVsKtACWiGwbx11tJWR3bBvHHuM3ynM51QMWDfbbR 6aQJUuu7jnastzKpEsZ+zc9fucC+gpZxsF/w56gvb2F0+VuY0KMNaZ/SPwDNO/mP+w2k 0lXQm7Ek0luLx0gSSXlxXdkz4o0qCrVoresVdqkxGtQxmgInyF5S9rKrA7GPyin6opvh x49A70MfLyHZXUIga+aVGR8qIJPlvfS3RC+3wpgqPfBkqWQVvQveBFYkBDtz68VIy4HD mz1w== X-Gm-Message-State: APt69E3qpMAQxbCZlj3b1LIKJp/nGCl+7kv24fKwL4ItnW29DrvQb6M2 17ZpnQ1sbPIJEAAdNpeJTcb8f3g5Yuc= X-Google-Smtp-Source: AAOMgpcOGK47WHna2+oC0UYaBum1YcqmWNIKiEJXZM9Ya/p7X0Z38gHceKXXQaFLqPPf7wDX/AGO4Q== X-Received: by 2002:adf:a401:: with SMTP id d1-v6mr9444192wra.121.1530961823438; Sat, 07 Jul 2018 04:10: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 a2-v6sm7771153wmb.6.2018.07.07.04.10.22 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 07 Jul 2018 04:10:22 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Sat, 7 Jul 2018 13:09:46 +0200 Message-Id: <20180707111004.8320-13-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180707111004.8320-1-jkbs@redhat.com> References: <20180707111004.8320-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 12/30] ovn-nbctl: Don't die in nbctl_lsp_add(). 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 Propagate the error via the context instead. Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index c0e068c38..972ef5fd6 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -989,7 +989,8 @@ nbctl_lsp_add(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; } const char *parent_name; @@ -1002,54 +1003,64 @@ nbctl_lsp_add(struct ctl_context *ctx) parent_name = ctx->argv[3]; if (!ovs_scan(ctx->argv[4], "%"SCNd64, &tag) || tag < 0 || tag > 4095) { - ctl_fatal("%s: invalid tag (must be in range 0 to 4095)", + ctl_error(ctx, "%s: invalid tag (must be in range 0 to 4095)", ctx->argv[4]); + return; } } else { - ctl_fatal("lsp-add with parent must also specify a tag"); + ctl_error(ctx, "lsp-add with parent must also specify a tag"); + return; } const char *lsp_name = ctx->argv[2]; const struct nbrec_logical_switch_port *lsp; error = lsp_by_name_or_uuid(ctx, lsp_name, false, &lsp); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } if (lsp) { if (!may_exist) { - ctl_fatal("%s: a port with this name already exists", + ctl_error(ctx, "%s: a port with this name already exists", lsp_name); + return; } const struct nbrec_logical_switch *lsw; lsw = lsp_to_ls(ctx->idl, lsp); if (lsw != ls) { char uuid_s[UUID_LEN + 1]; - ctl_fatal("%s: port already exists but in switch %s", lsp_name, - ls_get_name(lsw, uuid_s, sizeof uuid_s)); + ctl_error(ctx, "%s: port already exists but in switch %s", + lsp_name, ls_get_name(lsw, uuid_s, sizeof uuid_s)); + return; } if (parent_name) { if (!lsp->parent_name) { - ctl_fatal("%s: port already exists but has no parent", + ctl_error(ctx, "%s: port already exists but has no parent", lsp_name); + return; } else if (strcmp(parent_name, lsp->parent_name)) { - ctl_fatal("%s: port already exists with different parent %s", - lsp_name, lsp->parent_name); + ctl_error(ctx, "%s: port already exists with different parent " + "%s", lsp_name, lsp->parent_name); + return; } if (!lsp->n_tag_request) { - ctl_fatal("%s: port already exists but has no tag_request", - lsp_name); + ctl_error(ctx, "%s: port already exists but has no " + "tag_request", lsp_name); + return; } else if (lsp->tag_request[0] != tag) { - ctl_fatal("%s: port already exists with different " + ctl_error(ctx, "%s: port already exists with different " "tag_request %"PRId64, lsp_name, lsp->tag_request[0]); + return; } } else { if (lsp->parent_name) { - ctl_fatal("%s: port already exists but has parent %s", + ctl_error(ctx, "%s: port already exists but has parent %s", lsp_name, lsp->parent_name); + return; } } From patchwork Sat Jul 7 11:09:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 940806 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 41N8Dn4hlCz9s0n for ; Sat, 7 Jul 2018 21:16:41 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id A07C3CE6; Sat, 7 Jul 2018 11:10:29 +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 ACD91CDA for ; Sat, 7 Jul 2018 11:10:27 +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 701ED771 for ; Sat, 7 Jul 2018 11:10:26 +0000 (UTC) Received: by mail-wr1-f66.google.com with SMTP id j33-v6so6401786wrj.5 for ; Sat, 07 Jul 2018 04:10: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=bLAI9D5JwFlb9a+Q8l42wubxkyWirrswjnWU6A3EGmU=; b=AM/dzyF1Uk4Wz3PDNYfuv8gp0VxZ9vuVYdEceiN9cd1DRnFnlYRjtAq5ujUO5h769K lJRKa/EA7faaLvQEZvw4VbGwU10TYq3ha0A++ynOIAwXFAxuQAqdF5JjMD2UfauBmQyB eZLEviNyxQ5Jhf9IjdWWRTrKbcKvrzr9tAkju7p7pxF+2EA9VZnwcmQMpmHIsfTXc5AN uRsEt/aftUiW1AbhWzqsgEPLjgX6kAV7NdvJRgtNt0/prgvbOIPDYC7U97JWchyRHBZZ KFgv6wMmZRIsl0mHmzalRM/pM8GDqlsq29pBCMAmOOd3HLuJrsU4nyS1MA1lkqBOI5ZM Hphw== X-Gm-Message-State: APt69E3sraUeTILViq8nsgk8KtGsxdqAYEXi+AAn5JWTeINkIajJfwFx QsYR/x2IGrXwWlrwFKs0YdVt8jffe98= X-Google-Smtp-Source: AAOMgpd6Ov8Ww4JA0Dmqqbs4RrLMU4zg1b+x0odNIBhNqxWfxBCvtZ7OYdFU1i7dAoAXCdL10haKMQ== X-Received: by 2002:adf:f64c:: with SMTP id x12-v6mr9308202wrp.97.1530961824883; Sat, 07 Jul 2018 04:10:24 -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 38-v6sm1508039wrm.15.2018.07.07.04.10.24 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 07 Jul 2018 04:10:24 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Sat, 7 Jul 2018 13:09:47 +0200 Message-Id: <20180707111004.8320-14-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180707111004.8320-1-jkbs@redhat.com> References: <20180707111004.8320-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 13/30] ovn-nbctl: Don't die in nbctl_acl(). 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 Propagate the error via the context instead. Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 972ef5fd6..302e4a1b2 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -1689,7 +1689,8 @@ nbctl_acl_add(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; } const char *direction = parse_direction(ctx->argv[2]); @@ -1698,8 +1699,8 @@ nbctl_acl_add(struct ctl_context *ctx) /* Validate action. */ if (strcmp(action, "allow") && strcmp(action, "allow-related") && strcmp(action, "drop") && strcmp(action, "reject")) { - ctl_fatal("%s: action must be one of \"allow\", \"allow-related\", " - "\"drop\", and \"reject\"", action); + ctl_error(ctx, "%s: action must be one of \"allow\", " + "\"allow-related\", \"drop\", and \"reject\"", action); return; } @@ -1719,7 +1720,8 @@ nbctl_acl_add(struct ctl_context *ctx) } if (severity) { if (log_severity_from_string(severity) == UINT8_MAX) { - ctl_fatal("bad severity: %s", severity); + ctl_error(ctx, "bad severity: %s", severity); + return; } nbrec_acl_set_severity(acl, severity); } @@ -1734,8 +1736,9 @@ nbctl_acl_add(struct ctl_context *ctx) if (!acl_cmp(&acls[i], &acl)) { bool may_exist = shash_find(&ctx->options, "--may-exist") != NULL; if (!may_exist) { - ctl_fatal("Same ACL already existed on the ls %s.", + ctl_error(ctx, "Same ACL already existed on the ls %s.", ctx->argv[1]); + return; } return; } From patchwork Sat Jul 7 11:09:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 940807 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 41N8FT6FzNz9s0n for ; Sat, 7 Jul 2018 21:17:17 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 68486CE9; Sat, 7 Jul 2018 11:10: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 88782CD1 for ; Sat, 7 Jul 2018 11:10:28 +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 EC698775 for ; Sat, 7 Jul 2018 11:10:27 +0000 (UTC) Received: by mail-wm0-f66.google.com with SMTP id v3-v6so12937033wmh.0 for ; Sat, 07 Jul 2018 04:10: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=Zo73dFT289sjQ7Me4r/iE62Q8NLs8VPmOJ5VxChZrEM=; b=YE9Cs13nHjwJ8R8QtD0lOV4x7146EdS4Xu4QJLzQ3Kid934Sy0DwuTH/N+okRxm9ue Hfqf/i6h9NkHL95O8RjgVUvV1oIrcHapgW3epZZntkMojrZ64Zhf2uaHmTY/a8LZuCtB Cu8QMWgIqX40vjJNtac1OQmza0drHpXqbm7tCHjoP0ntwsdS7qJQDHTxW4xPt5MskiEg BanfUo0jDfdBytlsC1B2jA/BTOj8unHm8CGgw5WUeTZPR5w7AHtwfom8/KDbRgbOqHOd gY35PrONgV5Gixvch/5RmIaudB1brYNkvNOpDOTu5xJsszLfJT/ckAAmz+rVrBKrBmvw I0bA== X-Gm-Message-State: APt69E0E1eTT1GAkcSdosOnx6RQmgC7ID4Ucoy6d1SsWuVD+cqF1L16z nLcewjjhZFjwPpGrma7nbavt0+Qbcd4= X-Google-Smtp-Source: AAOMgpdNeXgoFadsSE95+36JcWEoRDJH18hS9/kqZWBB4MMy22+6TZiEvvVAxuD/ThL0FSkw6ljCrQ== X-Received: by 2002:a1c:6f06:: with SMTP id k6-v6mr8056556wmc.1.1530961826397; Sat, 07 Jul 2018 04:10: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 r14-v6sm15112487wrl.4.2018.07.07.04.10.25 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 07 Jul 2018 04:10:25 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Sat, 7 Jul 2018 13:09:48 +0200 Message-Id: <20180707111004.8320-15-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180707111004.8320-1-jkbs@redhat.com> References: <20180707111004.8320-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 14/30] ovn-nbctl: Don't die in nbctl_qos_add(). 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 Propagate the error via the context instead. Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 302e4a1b2..83920eb94 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -1899,21 +1899,23 @@ nbctl_qos_add(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; } for (int i = 5; i < ctx->argc; i++) { if (!strncmp(ctx->argv[i], "dscp=", 5)) { if (!ovs_scan(ctx->argv[i] + 5, "%"SCNd64, &dscp) || dscp < 0 || dscp > 63) { - ctl_fatal("%s: dscp must in range 0...63.", ctx->argv[i] + 5); + ctl_error(ctx, "%s: dscp must in range 0...63.", + ctx->argv[i] + 5); return; } } else if (!strncmp(ctx->argv[i], "rate=", 5)) { if (!ovs_scan(ctx->argv[i] + 5, "%"SCNd64, &rate) || rate < 1 || rate > UINT32_MAX) { - ctl_fatal("%s: rate must in range 1...4294967295.", + ctl_error(ctx, "%s: rate must in range 1...4294967295.", ctx->argv[i] + 5); return; } @@ -1921,20 +1923,20 @@ nbctl_qos_add(struct ctl_context *ctx) else if (!strncmp(ctx->argv[i], "burst=", 6)) { if (!ovs_scan(ctx->argv[i] + 6, "%"SCNd64, &burst) || burst < 1 || burst > UINT32_MAX) { - ctl_fatal("%s: burst must in range 1...4294967295.", + ctl_error(ctx, "%s: burst must in range 1...4294967295.", ctx->argv[i] + 6); return; } } else { - ctl_fatal("%s: must be start of \"dscp=\", \"rate=\", \"burst=\".", - ctx->argv[i]); + ctl_error(ctx, "%s: must be start of \"dscp=\", \"rate=\", " + "\"burst=\".", ctx->argv[i]); return; } } /* Validate rate and dscp. */ if (-1 == dscp && !rate) { - ctl_fatal("One of the rate or dscp must be configured."); + ctl_error(ctx, "One of the rate or dscp must be configured."); return; } @@ -1963,8 +1965,9 @@ nbctl_qos_add(struct ctl_context *ctx) if (!qos_cmp(&ls->qos_rules[i], &qos)) { bool may_exist = shash_find(&ctx->options, "--may-exist") != NULL; if (!may_exist) { - ctl_fatal("Same qos already existed on the ls %s.", + ctl_error(ctx, "Same qos already existed on the ls %s.", ctx->argv[1]); + return; } return; } From patchwork Sat Jul 7 11:09:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 940808 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 41N8G65HQgz9s0n for ; Sat, 7 Jul 2018 21:17:50 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 447F0CE1; Sat, 7 Jul 2018 11:10:33 +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 F20B0CD1 for ; Sat, 7 Jul 2018 11:10:29 +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 62675318 for ; Sat, 7 Jul 2018 11:10:29 +0000 (UTC) Received: by mail-wr1-f66.google.com with SMTP id t6-v6so6410196wrn.7 for ; Sat, 07 Jul 2018 04:10: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=ay1cL2kN7qvw3Z76EJ4/R7dTAGe0kMWTzeJ2PnVqMDk=; b=CE9XzI/+jQZFZuNAvCOevHXx3Rx3GaPKbmlvBQtsidg+5CWbFPYJVz1Ddz56wu6uTD CozD+jG/F6GcWeCw6cbnApSnOTg2BXEf88RjN08X3A8CoTf8L0mwG3/PqC0O1HjWtYBv ai/eTycoCcPVFvSL6PTnj54jQIyiGrLsMvb1F4ejrL4fVMHCc081fAxw9kGp2LhGuAK2 EJdGTboyHoGPcUTolgAjDLhS/D46jvMTtiKGsSsm9xiljchmQl5GGqiv5mPzEi/n89Tx OS0lywyEzaYZjWmPaWC1pB56OfUu+B7der6kK1W2JWRfOYF6rJrtDIUxMe+PsId4k+l3 ZwpA== X-Gm-Message-State: APt69E0m5aB0NgsGf4IzskUlCgnnlvRZWwD4j3S8FbeR6UhVP3VJ2cn7 saJD8wMVN030gcFO5UYMKH329JQEaMU= X-Google-Smtp-Source: AAOMgpco8bvsuucElYSibJ7yhJQHMIM1hjE7f0iwxooqmc53Kq708i+lJqjyWHlRkq7fnLd/A7/73A== X-Received: by 2002:a5d:4c4c:: with SMTP id n12-v6mr9478928wrt.71.1530961827832; Sat, 07 Jul 2018 04:10: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 c17-v6sm9105646wrp.54.2018.07.07.04.10.27 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 07 Jul 2018 04:10:27 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Sat, 7 Jul 2018 13:09:49 +0200 Message-Id: <20180707111004.8320-16-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180707111004.8320-1-jkbs@redhat.com> References: <20180707111004.8320-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 15/30] ovn-nbctl: Don't die in nbctl_lr_nat_add(). 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 Propagate the error via the context instead. Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 55 +++++++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 83920eb94..1d165c9b8 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -2960,32 +2960,37 @@ nbctl_lr_nat_add(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; } if (strcmp(nat_type, "dnat") && strcmp(nat_type, "snat") && strcmp(nat_type, "dnat_and_snat")) { - ctl_fatal("%s: type must be one of \"dnat\", \"snat\" and " - "\"dnat_and_snat\".", nat_type); + ctl_error(ctx, "%s: type must be one of \"dnat\", \"snat\" and " + "\"dnat_and_snat\".", nat_type); + return; } ovs_be32 ipv4 = 0; unsigned int plen; if (!ip_parse(external_ip, &ipv4)) { - ctl_fatal("%s: should be an IPv4 address.", external_ip); + ctl_error(ctx, "%s: should be an IPv4 address.", external_ip); + return; } if (strcmp("snat", nat_type)) { if (!ip_parse(logical_ip, &ipv4)) { - ctl_fatal("%s: should be an IPv4 address.", logical_ip); + ctl_error(ctx, "%s: should be an IPv4 address.", logical_ip); + return; } new_logical_ip = xstrdup(logical_ip); } else { error = ip_parse_cidr(logical_ip, &ipv4, &plen); if (error) { free(error); - ctl_fatal("%s: should be an IPv4 address or network.", - logical_ip); + ctl_error(ctx, "%s: should be an IPv4 address or network.", + logical_ip); + return; } new_logical_ip = normalize_ipv4_prefix(ipv4, plen); } @@ -2993,24 +2998,32 @@ nbctl_lr_nat_add(struct ctl_context *ctx) const char *logical_port; const char *external_mac; if (ctx->argc == 6) { - ctl_fatal("lr-nat-add with logical_port " + ctl_error(ctx, "lr-nat-add with logical_port " "must also specify external_mac."); + free(new_logical_ip); + return; } else if (ctx->argc == 7) { if (strcmp(nat_type, "dnat_and_snat")) { - ctl_fatal("logical_port and external_mac are only valid when " + ctl_error(ctx, "logical_port and external_mac are only valid when " "type is \"dnat_and_snat\"."); + free(new_logical_ip); + return; } logical_port = ctx->argv[5]; error = lsp_by_name_or_uuid(ctx, logical_port, true, NULL); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + free(new_logical_ip); + return; } external_mac = ctx->argv[6]; struct eth_addr ea; if (!eth_addr_from_string(external_mac, &ea)) { - ctl_fatal("invalid mac address %s.", external_mac); + ctl_error(ctx, "invalid mac address %s.", external_mac); + free(new_logical_ip); + return; } } else { logical_port = NULL; @@ -3034,15 +3047,19 @@ nbctl_lr_nat_add(struct ctl_context *ctx) free(new_logical_ip); return; } - ctl_fatal("%s, %s: a NAT with this external_ip and " - "logical_ip already exists", - external_ip, new_logical_ip); + ctl_error(ctx, "%s, %s: a NAT with this external_ip " + "and logical_ip already exists", + external_ip, new_logical_ip); + free(new_logical_ip); + return; } else { - ctl_fatal("a NAT with this type (%s) and %s (%s) " - "already exists", - nat_type, - is_snat ? "logical_ip" : "external_ip", - is_snat ? new_logical_ip : external_ip); + ctl_error(ctx, "a NAT with this type (%s) and %s (%s) " + "already exists", + nat_type, + is_snat ? "logical_ip" : "external_ip", + is_snat ? new_logical_ip : external_ip); + free(new_logical_ip); + return; } } } From patchwork Sat Jul 7 11:09:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 940809 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 41N8Gk2f40z9s0n for ; Sat, 7 Jul 2018 21:18:22 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id F2D56CF1; Sat, 7 Jul 2018 11:10:33 +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 5F9B5CE1 for ; Sat, 7 Jul 2018 11:10:31 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id CB53976F for ; Sat, 7 Jul 2018 11:10:30 +0000 (UTC) Received: by mail-wr1-f49.google.com with SMTP id k7-v6so6400548wrq.0 for ; Sat, 07 Jul 2018 04:10:30 -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=Hd8FbjJJnLNCufccGdfkcov1W8Ac4RfHiK1BQazKvuY=; b=O4wHhZ7/fToCppG5EXke0/j82xQqdVbLpvL3PwFD0livui5PAsDFb5xeus8Y+yqXU/ Hd1pZvaLuugFI73gXaVcjAj+Q25wGvCLEW2vO0uDFUGoqX1oB93KgHx6mqfDSvGkZK87 VWemnV1r9Ti7U+jEvWEdScQjE1l/NMOFqdeKOK3ZIWtR1c4QwyrpWtMoBbtx6Bcwq9cI P+1+I6YknIFKxu0aomCPDa+jYo4e3Df5nRfTJjQSyCUUtEo4NeYEQbacmN64p8waUaI8 uBjEZFfIdN/aYiT9TvEQh1cbr+mUpDtzLVI58kCOWbovmmktIvN3etSYWgspyRZba6kY fQBg== X-Gm-Message-State: APt69E2vkhQjoRSK432jptfoIG0nR4SX8t6F4eRJneauYrP1tEPgYPkv LsTXEMAl0XdsnnBKvp5aZwYL2fz+cFw= X-Google-Smtp-Source: AAOMgpf0TbX/5Kc8tjML9oGdmHZZATaIYmjXua7YJAe8VYqSyXHknOtTyhE0VrouuaTDfBKGe1lUIw== X-Received: by 2002:a5d:45c1:: with SMTP id b1-v6mr9783731wrs.106.1530961829389; Sat, 07 Jul 2018 04:10: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 c10-v6sm9940104wrs.6.2018.07.07.04.10.28 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 07 Jul 2018 04:10:28 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Sat, 7 Jul 2018 13:09:50 +0200 Message-Id: <20180707111004.8320-17-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180707111004.8320-1-jkbs@redhat.com> References: <20180707111004.8320-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 16/30] ovn-nbctl: Don't die in nbctl_lr_nat_del(). 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 Propagate the error via the context instead. Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 1d165c9b8..f4d8f4b2f 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -3092,7 +3092,8 @@ nbctl_lr_nat_del(struct ctl_context *ctx) bool must_exist = !shash_find(&ctx->options, "--if-exists"); 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) { @@ -3106,8 +3107,9 @@ nbctl_lr_nat_del(struct ctl_context *ctx) const char *nat_type = ctx->argv[2]; if (strcmp(nat_type, "dnat") && strcmp(nat_type, "snat") && strcmp(nat_type, "dnat_and_snat")) { - ctl_fatal("%s: type must be one of \"dnat\", \"snat\" and " - "\"dnat_and_snat\".", nat_type); + ctl_error(ctx, "%s: type must be one of \"dnat\", \"snat\" and " + "\"dnat_and_snat\".", nat_type); + return; } if (ctx->argc == 3) { @@ -3145,8 +3147,9 @@ nbctl_lr_nat_del(struct ctl_context *ctx) } if (must_exist) { - ctl_fatal("no matching NAT with the type (%s) and %s (%s)", - nat_type, is_snat ? "logical_ip" : "external_ip", nat_ip); + ctl_error(ctx, "no matching NAT with the type (%s) and %s (%s)", + nat_type, is_snat ? "logical_ip" : "external_ip", nat_ip); + return; } } From patchwork Sat Jul 7 11:09:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 940810 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 41N8HJ1Bppz9s0n for ; Sat, 7 Jul 2018 21:18:52 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id B33D6CDA; Sat, 7 Jul 2018 11:10: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 CA9C8C18 for ; Sat, 7 Jul 2018 11:10:32 +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 3B11D76F for ; Sat, 7 Jul 2018 11:10:32 +0000 (UTC) Received: by mail-wm0-f65.google.com with SMTP id 69-v6so16443147wmf.3 for ; Sat, 07 Jul 2018 04:10: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=xcTlS0DUnL1K6QY2vjGElJHmCqyUFoHY5dJFLqIsjcE=; b=J+9quYGjjnRUWMhYAqnAnhFmPChWNiV4pIpz3Vw5i5QSR0GWC6blG8SpskxcR0Taji X5ETWdGqUNfzDHL/WABJcUzcq+njk4MlwNzq5AobwShVD2KbGWLDpQkdeohm69WmGEKG q0ZmjkJmdX9f6ZVWxAR+4VM7fyPQ9Uju+xTDiwzZ115xjoCWUIiJTf2/b2AQ+r78aiUi 0F4fcdADYwxT9MqY6k+APfAh+pyuyyfZr+K0YEabn9ngY3jWh8oxXUFf/8ZPoOtkjyg0 uZEia6KwQzNi2eIdsZhxnWSdmsH8O+jv8EGTZN0pnEHTYC1WZQ3CnTTD4mzLPVaqpc/b MYbg== X-Gm-Message-State: APt69E3yWDFuJ2TDzcifz1IwrDRZ/vB4EZHKGkw3n8a6A/FPG6tKuy92 xNo/WXTcyYOCl84M15ezOb0zJo5/Ojc= X-Google-Smtp-Source: AAOMgpew1WhVG+Za69DJkH/dlhJ5Fk7qyZGtPk9nXYhJATA2OBmgEN5js9pdEmQKkif9jIlzYWkhKA== X-Received: by 2002:a1c:168a:: with SMTP id 132-v6mr8532651wmw.13.1530961830620; Sat, 07 Jul 2018 04:10:30 -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 d15-v6sm6019001wmb.0.2018.07.07.04.10.29 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 07 Jul 2018 04:10:30 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Sat, 7 Jul 2018 13:09:51 +0200 Message-Id: <20180707111004.8320-18-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180707111004.8320-1-jkbs@redhat.com> References: <20180707111004.8320-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 17/30] ovn-nbctl: Don't die in nbctl_lb_add(). 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 Propagate the error via the context instead. Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index f4d8f4b2f..894c88689 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -2069,15 +2069,17 @@ nbctl_lb_add(struct ctl_context *ctx) lb_proto = ctx->argv[4]; is_update_proto = true; if (strcmp(lb_proto, "tcp") && strcmp(lb_proto, "udp")) { - ctl_fatal("%s: protocol must be one of \"tcp\", \"udp\".", - lb_proto); + ctl_error(ctx, "%s: protocol must be one of \"tcp\", \"udp\".", + lb_proto); + return; } } struct sockaddr_storage ss_vip; if (!inet_parse_active(lb_vip, 0, &ss_vip)) { - ctl_fatal("%s: should be an IP address (or an IP address " + ctl_error(ctx, "%s: should be an IP address (or an IP address " "and a port number with : as a separator).", lb_vip); + return; } struct ds lb_vip_normalized_ds = DS_EMPTY_INITIALIZER; @@ -2091,8 +2093,10 @@ nbctl_lb_add(struct ctl_context *ctx) const char *lb_vip_normalized = ds_cstr(&lb_vip_normalized_ds); if (!lb_vip_port && is_update_proto) { - ctl_fatal("Protocol is unnecessary when no port of vip " + ds_destroy(&lb_vip_normalized_ds); + ctl_error(ctx, "Protocol is unnecessary when no port of vip " "is given."); + return; } char *token = NULL, *save_ptr = NULL; @@ -2103,19 +2107,21 @@ nbctl_lb_add(struct ctl_context *ctx) if (lb_vip_port) { if (!inet_parse_active(token, -1, &ss_dst)) { - ctl_fatal("%s: should be an IP address and a port " + ctl_error(ctx, "%s: should be an IP address and a port " "number with : as a separator.", token); + goto out; } } else { if (!inet_parse_address(token, &ss_dst)) { - ctl_fatal("%s: should be an IP address.", token); + ctl_error(ctx, "%s: should be an IP address.", token); + goto out; } } if (ss_vip.ss_family != ss_dst.ss_family) { - ds_destroy(&lb_ips_new); - ctl_fatal("%s: IP address family is different from VIP %s.", - token, lb_vip_normalized); + ctl_error(ctx, "%s: IP address family is different from VIP %s.", + token, lb_vip_normalized); + goto out; } ds_put_format(&lb_ips_new, "%s%s", lb_ips_new.length ? "," : "", token); @@ -2125,14 +2131,15 @@ nbctl_lb_add(struct ctl_context *ctx) if (!add_duplicate) { char *error = lb_by_name_or_uuid(ctx, lb_name, false, &lb); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + goto out; } if (lb) { if (smap_get(&lb->vips, lb_vip_normalized)) { if (!may_exist) { - ds_destroy(&lb_ips_new); - ctl_fatal("%s: a load balancer with this vip (%s) " - "already exists", lb_name, lb_vip_normalized); + ctl_error(ctx, "%s: a load balancer with this vip (%s) " + "already exists", lb_name, lb_vip_normalized); + goto out; } /* Update the vips. */ smap_replace(CONST_CAST(struct smap *, &lb->vips), @@ -2150,9 +2157,7 @@ nbctl_lb_add(struct ctl_context *ctx) } nbrec_load_balancer_verify_vips(lb); nbrec_load_balancer_set_vips(lb, &lb->vips); - ds_destroy(&lb_ips_new); - ds_destroy(&lb_vip_normalized_ds); - return; + goto out; } } @@ -2163,6 +2168,7 @@ nbctl_lb_add(struct ctl_context *ctx) smap_add(CONST_CAST(struct smap *, &lb->vips), lb_vip_normalized, ds_cstr(&lb_ips_new)); nbrec_load_balancer_set_vips(lb, &lb->vips); +out: ds_destroy(&lb_ips_new); ds_destroy(&lb_vip_normalized_ds); From patchwork Sat Jul 7 11:09:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 940811 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 41N8Hr3Czxz9s0n for ; Sat, 7 Jul 2018 21:19:20 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 80586CFC; Sat, 7 Jul 2018 11:10: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 760DACAF for ; Sat, 7 Jul 2018 11:10:34 +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 D642C76A for ; Sat, 7 Jul 2018 11:10:33 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id j33-v6so6402011wrj.5 for ; Sat, 07 Jul 2018 04:10: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=spgQ1UtJorJ0oisM381GuYGtzUSdtax0rLa1BEj0AuQ=; b=uoYbtoZF8XeqIX+U9FOU4hdNRrfPYDz5ndJWlQ9uYBwzjQjsGmo5dwMVQBBrPBjE0b VDmhZDdiI9KKd9f/XSybSD8Ay4tjfkVoZlmf/Mb35AKqzueKQMwdfG8bmU0XTrSjOi8V r6Il6ocSdLegZVhPKHOJGStp+9TQ2ZtYGvo/vc9hs4O9fnE35v1aggqNTpA7E4kRdWdD D1YtTnv0QocrHNTryV6YHk/xBtqwaikcFnkHOj9qqct6w0umUq6kW6r7Oo03gGk9Syj6 /kbcNeyKuPJRSXsXaLeHPKpKqzv2PEAnxbTHWlt2+mVd0SFaLhn9Zzz6V2GzTR22aJ5M ICEg== X-Gm-Message-State: APt69E27p/3ditMDq5OduPLScB+gvSXvEjHBOZZhbH0S2oeCoouJGl/N CDaB8+wqWY5mcBMOBaL22jiXwblaje8= X-Google-Smtp-Source: AAOMgpfklKPYFCwUiSKsstRlxVW3IBj+FTlTHzwwozPhwcRhDhBXfQdnc6EmGO+9jUt8wZFxga5Diw== X-Received: by 2002:adf:8e89:: with SMTP id q9-v6mr10149667wrb.261.1530961832326; Sat, 07 Jul 2018 04:10: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 b6-v6sm15108524wru.66.2018.07.07.04.10.31 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 07 Jul 2018 04:10:31 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Sat, 7 Jul 2018 13:09:52 +0200 Message-Id: <20180707111004.8320-19-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180707111004.8320-1-jkbs@redhat.com> References: <20180707111004.8320-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 18/30] ovn-nbctl: Don't die in nbctl_lb_del() 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 Propagate the error via the context instead. Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 894c88689..56e47c1f0 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -2183,7 +2183,8 @@ nbctl_lb_del(struct ctl_context *ctx) char *error = lb_by_name_or_uuid(ctx, id, false, &lb); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } if (!lb) { return; @@ -2204,8 +2205,9 @@ nbctl_lb_del(struct ctl_context *ctx) return; } if (must_exist) { - ctl_fatal("vip %s is not part of the load balancer.", - lb_vip); + ctl_error(ctx, "vip %s is not part of the load balancer.", + lb_vip); + return; } return; } From patchwork Sat Jul 7 11:09:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 940812 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 41N8Jb69gpz9s0n for ; Sat, 7 Jul 2018 21:19:59 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 8AEE8CEC; Sat, 7 Jul 2018 11:10:38 +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 DBBECC0A for ; Sat, 7 Jul 2018 11:10:35 +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 6A50F76A for ; Sat, 7 Jul 2018 11:10:35 +0000 (UTC) Received: by mail-wm0-f65.google.com with SMTP id v25-v6so17006937wmc.0 for ; Sat, 07 Jul 2018 04:10: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=6JuweY1/UAhvwldKzdIXiRb/yepYTesSKp3Jd7e7Rfg=; b=V4mu8libvnRLzXMR1alivGcgadxsYO125SwoWu+X719ftqqctuaFfOwCMU/cJo90Xk VTtrVb1yntjZg78RnHaD+WVd20XPy0ZZcnJwDI2ILIcrVAKTrMZmy6AZ9FdKVl/8uJYz WG6t9kup/R305BZepedzooP6FQR2vlUtawO0Izva2OgE00XtYgVNUPAwtaRVu+/8+ABT w1ZuuNSDgvfCIkkEaK8Xzd7ZC8SL8qz0oqXGXTRegRGMki83hsjvt1ru0izihZXcgiZ2 NE25NTAIpItRXpCzpF+kbO+369lVpmMlcjGy7SWJgdtx49Gl8meu9qPyO+G2ABG7RDO/ ck8A== X-Gm-Message-State: APt69E0M/JfXISriqS2Pn3gYG5O35CjPohAtPGHFJagxMH1EnQUddEis iOxmFcBBR00WYlQ8tbcOHaYboCD5BE8= X-Google-Smtp-Source: AAOMgpeoVDI9DIA8v3VtkGbqzQP1ukSZV+GZEWq44egLBnjLOQ5PAujzbOegksqboQaCMP9Bj7Lsvw== X-Received: by 2002:a1c:e8c:: with SMTP id 134-v6mr8403763wmo.51.1530961833876; Sat, 07 Jul 2018 04:10: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 v25-v6sm7992692wmh.43.2018.07.07.04.10.32 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 07 Jul 2018 04:10:33 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Sat, 7 Jul 2018 13:09:53 +0200 Message-Id: <20180707111004.8320-20-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180707111004.8320-1-jkbs@redhat.com> References: <20180707111004.8320-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 19/30] ovn-nbctl: Don't die in nbctl_ls_lb_add(). 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 Propagate the error via the context instead. Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 56e47c1f0..16788cc43 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -2442,11 +2442,13 @@ nbctl_ls_lb_add(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; } error = lb_by_name_or_uuid(ctx, ctx->argv[2], true, &new_lb); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } bool may_exist = shash_find(&ctx->options, "--may-exist") != NULL; @@ -2458,8 +2460,9 @@ nbctl_ls_lb_add(struct ctl_context *ctx) if (may_exist) { return; } - ctl_fatal(UUID_FMT " : a load balancer with this UUID already " - "exists", UUID_ARGS(&lb->header_.uuid)); + ctl_error(ctx, UUID_FMT " : a load balancer with this UUID " + "already exists", UUID_ARGS(&lb->header_.uuid)); + return; } } From patchwork Sat Jul 7 11:09:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 940813 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 41N8K955DLz9s0n for ; Sat, 7 Jul 2018 21:20:29 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 4F991D02; Sat, 7 Jul 2018 11:10:39 +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 193F3CEC for ; Sat, 7 Jul 2018 11:10:38 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id D97D576E for ; Sat, 7 Jul 2018 11:10:36 +0000 (UTC) Received: by mail-wm0-f67.google.com with SMTP id v16-v6so16986263wmv.5 for ; Sat, 07 Jul 2018 04:10:36 -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=SVBsSF8c1PEyYJ83gxNNw1hoP66XhR0j0ye+QADRDAQ=; b=hsGsPmdnfbtklExQA2I78Xk7Z5A/I+mW4FXGHsfG0uwWxnfTPkDGckEOboHnxIFpTB i9TX7l9S8x60ycKiAERgs00TzCD6OQWdDZ5LiKzZDK0xAy7uj7LBpJlsSqG7oCisnAIj 7SC8xuDDd6JRNw2eO6jmU1rKKF7BPhdqKeUg5/jGul8jtqRgpvB8zYS9xbSz/LiYYNUw iiGeI6n78c/PkQR4VI1hI6/tjr4j8ni1Xo9ewJUdTSNgOMjYoHitUhriDH2EIa9sEPxj +RJnM74Exv/UupgAF8xusKH/LTFf7siWFIqg74bfr0uyQhsjFg1/9NW9yE08AUTLoreS xuFw== X-Gm-Message-State: APt69E3KD5CnuGP61cW0n5sRAz6VW6xaUitxEWMkfbYnLceHDHHTFqA5 /ColR4+iGpZN6lD6RrdvD+yAFOSx+Pc= X-Google-Smtp-Source: AAOMgpfgfHvH8yWK55A3ooXxl5vlRlsEn1K+b5Q2nKvP+EcD73xiuqHYEAgSmUKfYLpq8LDj7zl49A== X-Received: by 2002:a1c:7501:: with SMTP id o1-v6mr8997776wmc.133.1530961835345; Sat, 07 Jul 2018 04:10:35 -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 f190-v6sm20815491wmd.0.2018.07.07.04.10.34 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 07 Jul 2018 04:10:34 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Sat, 7 Jul 2018 13:09:54 +0200 Message-Id: <20180707111004.8320-21-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180707111004.8320-1-jkbs@redhat.com> References: <20180707111004.8320-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 20/30] ovn-nbctl: Don't die in nbctl_lr_lb_add(). 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 Propagate the error via the context instead. Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 16788cc43..989633120 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -2324,11 +2324,13 @@ nbctl_lr_lb_add(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; } error = lb_by_name_or_uuid(ctx, ctx->argv[2], true, &new_lb); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } bool may_exist = shash_find(&ctx->options, "--may-exist") != NULL; @@ -2340,8 +2342,9 @@ nbctl_lr_lb_add(struct ctl_context *ctx) if (may_exist) { return; } - ctl_fatal(UUID_FMT " : a load balancer with this UUID already " - "exists", UUID_ARGS(&lb->header_.uuid)); + ctl_error(ctx, UUID_FMT " : a load balancer with this UUID " + "already exists", UUID_ARGS(&lb->header_.uuid)); + return; } } From patchwork Sat Jul 7 11:09:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 940814 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 41N8Kj5F88z9s0n for ; Sat, 7 Jul 2018 21:20:57 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id F313ECFF; Sat, 7 Jul 2018 11:10:39 +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 43F2DD07 for ; Sat, 7 Jul 2018 11:10:39 +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 C199E76A for ; Sat, 7 Jul 2018 11:10:38 +0000 (UTC) Received: by mail-wm0-f66.google.com with SMTP id s12-v6so17005377wmc.1 for ; Sat, 07 Jul 2018 04:10:38 -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=iZJdTF74wcO4/eg2ol1WnFHNTAzDWLauhCOZM0Ac4+I=; b=ZHavl/rcgCt0afR2HCBAmO8Xh+Fx4XWRikblBbJCCwj+JttpRR9bqfcEANFI6yWNr9 cRirOdsQv4fDJHRLL9u4k/JWos1A6Srpn6751t01b0egNg4y4TVTI8UayWdP1k7L13bF MwSvoNQguinXkWIEKdeY+DQHDfKtndS2kayJje9t8b41lXyyzSEsZNMEygWlTAxqRDR4 TW225bgAC406C0zrfvHSxbeB7kJZqoj0Xz91JR70+8qBuWh8HZrgJH3KZgnM1ZjLtunD +PHT3DbzM7KrVKVdi8xHEOhM/FlFU/yu8tXWjPnJtqVuJLFbLKqCwYbXXTIiRH6R0bzj zl+w== X-Gm-Message-State: APt69E2TTexb4vKS0czgEADqNfyv3GVgJ1Ku8U+DIb2T/59mPhwTvrmu PSB82ZPmYQMygNwwjIaclVUDZWfjBLA= X-Google-Smtp-Source: AAOMgpfEwNMNGjkTYz67Y9Qfkd3MmsFah8YuxbIISHrbvEWssUmBX7eSQ+vhFYmda3DCKY/6Mmr9HQ== X-Received: by 2002:a7b:c0d5:: with SMTP id s21-v6mr7944178wmh.106.1530961837242; Sat, 07 Jul 2018 04:10:37 -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 p8-v6sm10177762wre.84.2018.07.07.04.10.36 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 07 Jul 2018 04:10:36 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Sat, 7 Jul 2018 13:09:55 +0200 Message-Id: <20180707111004.8320-22-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180707111004.8320-1-jkbs@redhat.com> References: <20180707111004.8320-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 21/30] ovn-nbctl: Don't die in nbctl_lr_add(). 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 Propagate the error via the context instead. Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 989633120..f97bfbb3e 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -2566,7 +2566,9 @@ nbctl_lr_add(struct ctl_context *ctx) bool may_exist = shash_find(&ctx->options, "--may-exist") != NULL; bool add_duplicate = shash_find(&ctx->options, "--add-duplicate") != NULL; if (may_exist && add_duplicate) { - ctl_fatal("--may-exist and --add-duplicate may not be used together"); + ctl_error(ctx, "--may-exist and --add-duplicate may not be used " + "together"); + return; } if (lr_name) { @@ -2577,15 +2579,18 @@ nbctl_lr_add(struct ctl_context *ctx) if (may_exist) { return; } - ctl_fatal("%s: a router with this name already exists", - lr_name); + ctl_error(ctx, "%s: a router with this name already " + "exists", lr_name); + return; } } } } else if (may_exist) { - ctl_fatal("--may-exist requires specifying a name"); + ctl_error(ctx, "--may-exist requires specifying a name"); + return; } else if (add_duplicate) { - ctl_fatal("--add-duplicate requires specifying a name"); + ctl_error(ctx, "--add-duplicate requires specifying a name"); + return; } struct nbrec_logical_router *lr; From patchwork Sat Jul 7 11:09:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 940815 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 41N8LG1V3Vz9s0n for ; Sat, 7 Jul 2018 21:21:25 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id A12D1D16; Sat, 7 Jul 2018 11:10:43 +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 0AB27D10 for ; Sat, 7 Jul 2018 11:10:42 +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 361BB318 for ; Sat, 7 Jul 2018 11:10:40 +0000 (UTC) Received: by mail-wm0-f66.google.com with SMTP id s14-v6so16548972wmc.1 for ; Sat, 07 Jul 2018 04:10:40 -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=kXzEtd4tVNMHLMhTJ4tR6eXQQXsV97CFh8WscyT9zu0=; b=ZvFRvxAcVmQCMU4vf60qTwkGFnJoZdq9/3oD9AvcjlVtUhDjU+Q4RVWRqr/JAlJpLw JoNq0MN2TCcn+XQIFxUi+3kI/eqMKb+ODvQZ8U9GgRYgBdz/mSAlTV1sagI6OQcwm3tl xV5Irs/GtnalFtpH84B7Qegxzaiuedtft0NPmLrhVV+CEwNP0OhstG9cvaf9vORVb9mS Y0DZZvrlMY1yuI6hiZTiroeZMg2Im7iXoQCG/T4WZ3OVacnmRWjJx3TFKgi0mnwwBnS0 0cN4Nd08ovtPXO5Pmn16RlfkO/GNqPJFpGZkb7No9AW09dSZXb4klO9pBsVrfxUkA0uc r2Sg== X-Gm-Message-State: APt69E2T9LUl9ZTcaJH3L3Cnzq92eAFMODCrzv1Z19OBfSzbenA6QVqn QRpMlNGMwDRxuIQqM+bqLXDXo79hcLI= X-Google-Smtp-Source: AAOMgpddDgnIUe4khx0tPfq9hNrpvhsIFNtA/HFAWGpOYxt4hRJFOZHJZ+9j8gzWgo4qXocQWebFVQ== X-Received: by 2002:a1c:c342:: with SMTP id t63-v6mr9045722wmf.123.1530961838697; Sat, 07 Jul 2018 04:10:38 -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 h1-v6sm14717255wri.90.2018.07.07.04.10.37 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 07 Jul 2018 04:10:38 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Sat, 7 Jul 2018 13:09:56 +0200 Message-Id: <20180707111004.8320-23-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180707111004.8320-1-jkbs@redhat.com> References: <20180707111004.8320-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 22/30] ovn-nbctl: Don't die in nbctl_lr_del(). 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 Propagate the error via the context instead. Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index f97bfbb3e..034eb3b74 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -2609,7 +2609,8 @@ nbctl_lr_del(struct ctl_context *ctx) char *error = lr_by_name_or_uuid(ctx, id, must_exist, &lr); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } if (!lr) { return; From patchwork Sat Jul 7 11:09:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 940816 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 41N8Lq18lZz9s0n for ; Sat, 7 Jul 2018 21:21:55 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 42204D1B; Sat, 7 Jul 2018 11:10:44 +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 26E06D16 for ; Sat, 7 Jul 2018 11:10:43 +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 AF7E776F for ; Sat, 7 Jul 2018 11:10:41 +0000 (UTC) Received: by mail-wr1-f42.google.com with SMTP id u7-v6so6403421wrn.12 for ; Sat, 07 Jul 2018 04:10:41 -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=hBUy5ojzuEbag7d0vkclbNZMIbyqXwdmvvySbDzjCqk=; b=WMw0xQgmr4DKeRpo4uBhSHZJeyF4G497aMvOLTWvDmKZguBCNBRsWxI/gCPYIwzqEf oR7cgVHm3j4HwgbfjqbwrZ7jABKm3NKpyeUDYhM7IakUsx8G1MWUy6FikvxvZppbfGNM ucL4eYNInUSxk1wt1SpRmG3BOkRqN2ycURoNjgfzbzaiEra2pBNCi5dXFpn9qK2HDuJN 9+zmBgdQ2wUEtemOcBSlVT5+0cq4VIJ62OdwAyh7j0uCxPLT5x5sFbIxkHM+doRHREXw 92XBojz56WoibrNAGnkkYyQHdCz8xA8Jdyvs6l0iJjDnIkpNzqypOGoL1vKlIx55D2Eq 3m8A== X-Gm-Message-State: APt69E1iDeeOUTaQrrKHBxCo1RbtpgAUuqTbuTA1hnsxTp1Chfez0qA+ fKdEcCvSGWLkPFW61bNkM6VuXbUVwbY= X-Google-Smtp-Source: AAOMgpcidGub8A5njD5g7STeF8n7EyMZ1HcAFE4aQE2biSYoz3cQeVbQOuwpFVmK0ybqrksPXfQy5Q== X-Received: by 2002:adf:be8d:: with SMTP id i13-v6mr9516360wrh.86.1530961840139; Sat, 07 Jul 2018 04:10:40 -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 b1-v6sm13938273wma.23.2018.07.07.04.10.39 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 07 Jul 2018 04:10:39 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Sat, 7 Jul 2018 13:09:57 +0200 Message-Id: <20180707111004.8320-24-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180707111004.8320-1-jkbs@redhat.com> References: <20180707111004.8320-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 23/30] ovn-nbctl: Don't die in nbctl_lrp_add(). 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 Propagate the error via the context instead. 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 034eb3b74..7a38cea92 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -3439,7 +3439,8 @@ nbctl_lrp_add(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; } const char *lrp_name = ctx->argv[2]; @@ -3455,7 +3456,9 @@ nbctl_lrp_add(struct ctl_context *ctx) } if (!n_networks) { - ctl_fatal("%s: router port requires specifying a network", lrp_name); + ctl_error(ctx, "%s: router port requires specifying a network", + lrp_name); + return; } char **settings = (char **) &ctx->argv[n_networks + 4]; @@ -3464,25 +3467,29 @@ nbctl_lrp_add(struct ctl_context *ctx) const struct nbrec_logical_router_port *lrp; error = lrp_by_name_or_uuid(ctx, lrp_name, false, &lrp); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } if (lrp) { if (!may_exist) { - ctl_fatal("%s: a port with this name already exists", + ctl_error(ctx, "%s: a port with this name already exists", lrp_name); + return; } const struct nbrec_logical_router *bound_lr; bound_lr = lrp_to_lr(ctx->idl, lrp); if (bound_lr != lr) { char uuid_s[UUID_LEN + 1]; - ctl_fatal("%s: port already exists but in router %s", lrp_name, - lr_get_name(bound_lr, uuid_s, sizeof uuid_s)); + ctl_error(ctx, "%s: port already exists but in router %s", + lrp_name, lr_get_name(bound_lr, uuid_s, sizeof uuid_s)); + return; } if (strcmp(mac, lrp->mac)) { - ctl_fatal("%s: port already exists with mac %s", lrp_name, + ctl_error(ctx, "%s: port already exists with mac %s", lrp_name, lrp->mac); + return; } struct sset new_networks = SSET_INITIALIZER(&new_networks); @@ -3497,8 +3504,9 @@ nbctl_lrp_add(struct ctl_context *ctx) sset_destroy(&orig_networks); sset_destroy(&new_networks); if (!same_networks) { - ctl_fatal("%s: port already exists with different network", + ctl_error(ctx, "%s: port already exists with different network", lrp_name); + return; } /* Special-case sanity-check of peer ports. */ @@ -3512,8 +3520,9 @@ nbctl_lrp_add(struct ctl_context *ctx) if ((!peer != !lrp->peer) || (lrp->peer && strcmp(peer, lrp->peer))) { - ctl_fatal("%s: port already exists with mismatching peer", + ctl_error(ctx, "%s: port already exists with mismatching peer", lrp_name); + return; } return; @@ -3521,7 +3530,8 @@ nbctl_lrp_add(struct ctl_context *ctx) struct eth_addr ea; if (!eth_addr_from_string(mac, &ea)) { - ctl_fatal("%s: invalid mac address %s", lrp_name, mac); + ctl_error(ctx, "%s: invalid mac address %s", lrp_name, mac); + return; } for (int i = 0; i < n_networks; i++) { @@ -3534,8 +3544,9 @@ nbctl_lrp_add(struct ctl_context *ctx) error = ipv6_parse_cidr(networks[i], &ipv6, &plen); if (error) { free(error); - ctl_fatal("%s: invalid network address: %s", lrp_name, + ctl_error(ctx, "%s: invalid network address: %s", lrp_name, networks[i]); + return; } } } @@ -3550,7 +3561,8 @@ nbctl_lrp_add(struct ctl_context *ctx) error = ctl_set_column("Logical_Router_Port", &lrp->header_, settings[i], ctx->symtab); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } } From patchwork Sat Jul 7 11:09:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 940817 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 41N8Mb3j60z9s0n for ; Sat, 7 Jul 2018 21:22:35 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id EBF56D15; Sat, 7 Jul 2018 11:10:45 +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 7F392D1F for ; Sat, 7 Jul 2018 11:10:44 +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 3727C76A for ; Sat, 7 Jul 2018 11:10:43 +0000 (UTC) Received: by mail-wr1-f68.google.com with SMTP id h10-v6so6413379wrq.8 for ; Sat, 07 Jul 2018 04:10:43 -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=wfiAQuyx5WVd0gmZPrkb4EBqJt1aZoIwxihhGvul3CE=; b=gemip3bAY/+nVaGidGgjjVj+gR0LAPfFdNUkPANPIGo5vWC3j+Qa24CFwrjmcekbmn r1nxiKNw6WouQeH6bK0rlVREFIqcAbsYV/aW5eLua+/zGwrCjnw3zybbO4WqN4W2ZVKQ Qg6XsA2QLkzU9GQ1Ymed4gfJKI713VNlA77F7GctjCddZgyJMijF6PJkU26yGw/g1qk+ BrY6m5ZT8o41ttAAFBSKwRz+v+lvHExYVYF2OFMF3Z+IfNbEWdYlEIlThh/W26ZoRynK yYfUq3QSIH3bHQ9X3AG9HdOK1CqMnfxWaRDSySrd4GdFQd5GK3TvCzIqa6CDRsa+vYJY f0PA== X-Gm-Message-State: APt69E3FrtYMcbe2DzcLGsw/AWK0lmpNwjK1VdWINZspifmxL2Shi0x7 /WK9+FTo1T4S1D1waO4DCsVU7RLhJko= X-Google-Smtp-Source: AAOMgpck7WheeDI9FYkLuxdj/nbPIJO8NaSw70pJikmsTZNA2LErA+hJnkPopceMw8supCIi21NO+Q== X-Received: by 2002:adf:83a6:: with SMTP id 35-v6mr9638751wre.13.1530961841653; Sat, 07 Jul 2018 04:10:41 -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 s41-v6sm18678814wrc.5.2018.07.07.04.10.40 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 07 Jul 2018 04:10:41 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Sat, 7 Jul 2018 13:09:58 +0200 Message-Id: <20180707111004.8320-25-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180707111004.8320-1-jkbs@redhat.com> References: <20180707111004.8320-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 24/30] ovn-nbctl: Don't die 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 Propagate the error via the context instead. Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 7a38cea92..032dcd414 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -3309,10 +3309,11 @@ nbctl_lrp_set_gateway_chassis(struct ctl_context *ctx) const struct nbrec_logical_router_port *lrp; char *error = lrp_by_name_or_uuid(ctx, lrp_name, true, &lrp); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } if (!lrp) { - ctl_fatal("router port %s is required", lrp_name); + ctl_error(ctx, "router port %s is required", lrp_name); return; } From patchwork Sat Jul 7 11:09:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 940818 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 41N8N556Q0z9s0n for ; Sat, 7 Jul 2018 21:23:01 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 8FCADD35; Sat, 7 Jul 2018 11:10:46 +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 45A8BD1F for ; Sat, 7 Jul 2018 11:10:45 +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 C03A2765 for ; Sat, 7 Jul 2018 11:10:44 +0000 (UTC) Received: by mail-wr1-f67.google.com with SMTP id h10-v6so6413427wrq.8 for ; Sat, 07 Jul 2018 04:10:44 -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=hAFCKiaZDZrJkourExEQOpVske/4Ql1qcR8PAY6bdSI=; b=rjJK7lbQ/ohdMG0+2f7kVomvc0MYAlOF5C+lwobzMzgZEVNwiOzOTHBiIZ3d9UW0mK tOM3ot8KVUjNI/x63CvDcH/dxBIYYZlTZgcl7YE4as8XsiHPlnaysJILQJK1X/cFqLjX Rytqi/dXxedauuUmxjELY67chiBwgwfZVqx4qSH1pJEtvUf6fK+TpEcPWXGN8ikXCvO8 OJy+fpXS0CfwnqLhmu3dvTkEZ2oNQgj6mCm5DAWeGBz0CZOVAaw/hnJNyy2OqC/2xnV1 vSlfobMaWc8UjIfoz2SFq297GaqdTVJS+Zu/g6sx0WQzc7JYCJxraZuIE7E2ToG8jeKa O9Qw== X-Gm-Message-State: APt69E1QZgN0P7tyCVBKkwIW4/hi+vvg25yXDbgUTzB7ykdvrpjVxJdr oBE4zdPTRDbtYcgNUjPy4H8Ms++MmkM= X-Google-Smtp-Source: AAOMgpdgNpExTO2+wGg152PgKHMd8Y43RJGRdQyhnS9WpjXaM52+ubbm9xeJN3bg11++phkcHs6xXQ== X-Received: by 2002:adf:e24d:: with SMTP id n13-v6mr10216332wri.205.1530961843190; Sat, 07 Jul 2018 04:10:43 -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 n16-v6sm18022403wrg.58.2018.07.07.04.10.42 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 07 Jul 2018 04:10:42 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Sat, 7 Jul 2018 13:09:59 +0200 Message-Id: <20180707111004.8320-26-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180707111004.8320-1-jkbs@redhat.com> References: <20180707111004.8320-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 25/30] ovn-nbctl: Don't die in nbctl_lrp_get_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 Propagate the error via the context instead. Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 032dcd414..aeb401962 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -3419,7 +3419,8 @@ nbctl_lrp_get_gateway_chassis(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; } gcs = get_ordered_gw_chassis_prio_list(lrp); From patchwork Sat Jul 7 11:10:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 940819 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 41N8Nq1qyNz9s0n for ; Sat, 7 Jul 2018 21:23:39 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 603EBCE3; Sat, 7 Jul 2018 11:10:48 +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 EADB8D33 for ; Sat, 7 Jul 2018 11:10:46 +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 7BD22765 for ; Sat, 7 Jul 2018 11:10:46 +0000 (UTC) Received: by mail-wr1-f68.google.com with SMTP id j33-v6so6402398wrj.5 for ; Sat, 07 Jul 2018 04:10:46 -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=LgGR5htqjOAMQPiTDp+Sb3pOEndwLXmiGMfV329vlhg=; b=NZurvm9aqTi6vJ7kpRTvXFRS8pA1gzKWcksbBL1JdPVhh3mBH7pxCOSkxUZyAOU31e t09MM41PVyeyHbaOsjxUFopRAAVm3pQrUw66GCrzoTbYETMZCks7622NE0zKllPv8bM3 vZbmK6CoDKv4q9DkE7pVlO6Q+Ebpo1Dr+OstJz4/ws3Xl069xXKkf1pL7CumQ/KxsvRo SzVtPcWfgQCjI1oJcG46kxGj6q+K8ODpA8zjl3wi8ck0LeAsvMICepFgW/BUYuawL9Z0 7s90R6YAhrUO3Lf5zceuXymoNjOyck/7pLhq+L61jmNe99IHOQ2aF8UeV70/5Kv5CDcn F7iw== X-Gm-Message-State: APt69E2SsrC6wqVPUTh/kaQIKvDBMqMOtIL68RGp24CQWhCDqtW+ZayK whvV8Rtcy4W7Wl+HQzyXqtVWNJcN+yI= X-Google-Smtp-Source: AAOMgpcFR+bSjP6OWpnq1D2Z7iwNuPT1J5GyYKJzRnwINS9YAcmsbp/CASdAajeO9fb7CNxzUeQTWA== X-Received: by 2002:adf:f002:: with SMTP id j2-v6mr9151834wro.260.1530961844944; Sat, 07 Jul 2018 04:10:44 -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 a17-v6sm8181268wrr.81.2018.07.07.04.10.44 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 07 Jul 2018 04:10:44 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Sat, 7 Jul 2018 13:10:00 +0200 Message-Id: <20180707111004.8320-27-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180707111004.8320-1-jkbs@redhat.com> References: <20180707111004.8320-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 26/30] ovn-nbctl: Don't die in nbctl_lrp_del_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 Propagate the error via the context instead. Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index aeb401962..1591ce47d 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -3387,7 +3387,8 @@ nbctl_lrp_del_gateway_chassis(struct ctl_context *ctx) const struct nbrec_logical_router_port *lrp; char *error = lrp_by_name_or_uuid(ctx, ctx->argv[1], true, &lrp); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } if (!lrp) { return; @@ -3404,7 +3405,7 @@ nbctl_lrp_del_gateway_chassis(struct ctl_context *ctx) } /* Can't happen because of the database schema. */ - ctl_fatal("chassis %s is not added to logical port %s", + ctl_error(ctx, "chassis %s is not added to logical port %s", chassis_name, ctx->argv[1]); } From patchwork Sat Jul 7 11:10:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 940820 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 41N8PL0ClMz9s0n for ; Sat, 7 Jul 2018 21:24:06 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 0ADFED37; Sat, 7 Jul 2018 11:10:50 +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 B37D2D37 for ; Sat, 7 Jul 2018 11:10:48 +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 447E2776 for ; Sat, 7 Jul 2018 11:10:48 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id q10-v6so6405631wrd.4 for ; Sat, 07 Jul 2018 04:10:48 -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=g4hz+7zOqf4njhRiTdUFC1S546YkDV9lWR1C70KYAJE=; b=Ccz+IGuuzWWUmipkAtOz+bDa76dW7akqyHIMLrcWkzeoX68i6/RRrldw7sm5nqm+KZ UM+W3pKsc+T7/GntcQYJK++paEOkKWcHSPBKH4ahymca4LJnmHN9QTnDCsOXuRJ8hpsa /Ni66TRtdKgC+z9Faja5V5kwksdww47XEywRRys6a/cxbWdHrP8/hzY2Tq6LTptRGe+0 3Q2BN+qqdnebFEbOmdmaF6yLcG+kPCGXDQVpn06GBr/K/0RUMylo3DdOLeVcrly3x5YA FTFx3h2AD+FabHFIaC0sGUcVtxuPE+OyfpUr6PGjCqzHfgD5vwrJH1gkzFX0PM8nNJF5 aqDQ== X-Gm-Message-State: APt69E0HUQr4DcIIRO0GP1aMBV5E48de+81mplmgrJSHpzQTQcD+5p7w tye0BP/Ywgk2QEHPSYh6z7wzlGaNZ9k= X-Google-Smtp-Source: AAOMgpeY5aqLDOmnyWyHY6mItAz/fVHTZtaFFUyzI3Sn5EvqsXFczEaaOF5EX08iI4zrbFiZpYZGIw== X-Received: by 2002:a5d:46c6:: with SMTP id g6-v6mr9218585wrs.76.1530961846786; Sat, 07 Jul 2018 04:10:46 -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 k36-v6sm9004754wrk.93.2018.07.07.04.10.45 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 07 Jul 2018 04:10:46 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Sat, 7 Jul 2018 13:10:01 +0200 Message-Id: <20180707111004.8320-28-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180707111004.8320-1-jkbs@redhat.com> References: <20180707111004.8320-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 27/30] ovn-nbctl: Don't die in nbctl_lrp_set_enabled(). 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 Propagate the error via the context instead. Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 1591ce47d..a64df51a0 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -3672,7 +3672,8 @@ nbctl_lrp_set_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; @@ -3681,7 +3682,8 @@ nbctl_lrp_set_enabled(struct ctl_context *ctx) bool enabled; error = parse_enabled(state, &enabled); if (error) { - ctl_fatal("%s", error); + ctx->error = error; + return; } nbrec_logical_router_port_set_enabled(lrp, &enabled, 1); } From patchwork Sat Jul 7 11:10:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 940821 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 41N8Ps1XVJz9s0n for ; Sat, 7 Jul 2018 21:24:33 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id A05F6D38; Sat, 7 Jul 2018 11:10:51 +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 2C607C96 for ; Sat, 7 Jul 2018 11:10:50 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 9F09876A for ; Sat, 7 Jul 2018 11:10:49 +0000 (UTC) Received: by mail-wm0-f67.google.com with SMTP id v3-v6so12937518wmh.0 for ; Sat, 07 Jul 2018 04:10:49 -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=G9+GZCUWGXr7AcFXXqvs1CWb7KfxeT+JotMb4B145d4=; b=djD4c6kWH56IvXxmaQNM09ymWXRYd6Ym/mSkqIJXE0v2sWiHHxm6cbl92rRVpwyq1R FVm0uhy2mTvm9LWIeplwwdo6/dPNrvD+lV+zTj4pKoVPB7BEIonMfCno+EFcNk0pArb4 4A5TWUTpgCHF+h2R4Eu5BwXQzPUsvWhbdonJy1CtzZE2PJQb2tlVLnL7BpVSHeMZg91O 5EvwBaiuC5VDYu7JtSCwFJf+/+Um59tWj8AuxsRQf9fYJ78STYO2D3Vwjd5lrZIRfWeA B1rUQM6gAs3xoSaEbLWZZavK2X/SuUeIvZzI7y4tynpVdopFYUfRBUxCYR9LJhm+9WXm pIbw== X-Gm-Message-State: APt69E39+HvnQY2rQl36ST+UnJ9O3T+opXb81GcW3ZvNuVZ54lZift7q jITz7v7xpUcFyaEqvTKebba3ypm/4eM= X-Google-Smtp-Source: AAOMgpcvoI82QI3b3myyWqVm6hbJFAIyqyyYa4ceui80uz98VGvleaHgwhT5fpsarFon+JUX/o+YEQ== X-Received: by 2002:a1c:9788:: with SMTP id z130-v6mr9021313wmd.88.1530961848113; Sat, 07 Jul 2018 04:10:48 -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 y203-v6sm7731510wme.42.2018.07.07.04.10.47 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 07 Jul 2018 04:10:47 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Sat, 7 Jul 2018 13:10:02 +0200 Message-Id: <20180707111004.8320-29-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180707111004.8320-1-jkbs@redhat.com> References: <20180707111004.8320-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 28/30] ovn-nbctl: Don't die in nbctl_lr_route_add(). 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 Propagate the error via the context instead. Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index a64df51a0..cdf6ae8c9 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -2817,24 +2817,28 @@ nbctl_lr_route_add(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; } char *prefix, *next_hop; const char *policy = shash_find_data(&ctx->options, "--policy"); if (policy && strcmp(policy, "src-ip") && strcmp(policy, "dst-ip")) { - ctl_fatal("bad policy: %s", policy); + ctl_error(ctx, "bad policy: %s", policy); + return; } prefix = normalize_prefix_str(ctx->argv[2]); if (!prefix) { - ctl_fatal("bad prefix argument: %s", ctx->argv[2]); + ctl_error(ctx, "bad prefix argument: %s", ctx->argv[2]); + return; } next_hop = normalize_prefix_str(ctx->argv[3]); if (!next_hop) { free(prefix); - ctl_fatal("bad next hop argument: %s", ctx->argv[3]); + ctl_error(ctx, "bad next hop argument: %s", ctx->argv[3]); + return; } if (strchr(prefix, '.')) { @@ -2842,14 +2846,16 @@ nbctl_lr_route_add(struct ctl_context *ctx) if (!ip_parse(ctx->argv[3], &hop_ipv4)) { free(prefix); free(next_hop); - ctl_fatal("bad IPv4 nexthop argument: %s", ctx->argv[3]); + ctl_error(ctx, "bad IPv4 nexthop argument: %s", ctx->argv[3]); + return; } } else { struct in6_addr hop_ipv6; if (!ipv6_parse(ctx->argv[3], &hop_ipv6)) { free(prefix); free(next_hop); - ctl_fatal("bad IPv6 nexthop argument: %s", ctx->argv[3]); + ctl_error(ctx, "bad IPv6 nexthop argument: %s", ctx->argv[3]); + return; } } @@ -2871,9 +2877,11 @@ nbctl_lr_route_add(struct ctl_context *ctx) } if (!may_exist) { + ctl_error(ctx, "duplicate prefix: %s", prefix); free(next_hop); free(rt_prefix); - ctl_fatal("duplicate prefix: %s", prefix); + free(prefix); + return; } /* Update the next hop for an existing route. */ From patchwork Sat Jul 7 11:10:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 940822 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 41N8QK6yfPz9s0n for ; Sat, 7 Jul 2018 21:24:57 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 4E1D3D4D; Sat, 7 Jul 2018 11:10:53 +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 D1AA9D48 for ; Sat, 7 Jul 2018 11:10:51 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 487AF318 for ; Sat, 7 Jul 2018 11:10:51 +0000 (UTC) Received: by mail-wm0-f67.google.com with SMTP id s12-v6so17005615wmc.1 for ; Sat, 07 Jul 2018 04:10:51 -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=Mzaoa9hvNxsOJnWNaZb1pFN4ErHRfNxUR2fWeOannsA=; b=a35kSzPcZE/Ee5rmravxeIABcZBRnU7cV3UDr0IrikakvH0E60HsrrisSD5oZ0eD0Z 971YEm2STp9AkfI656O5zMWyokXZT+LjtM4j+XE29PEiDRtCV2mlhcQqmg4DR40275bn YfaFLvqQ8KmQPJOZSBMvFChvZUlYaad80lfwUEj5cAMSzi1sruEpYXsC6xeClMpt/X0d 4cqsrDDu3AT+KrRi1+rGnbPpesfK5Qc863U7XEzcIWYnjvCOmKDocomV3Pn1Xgt095Fu wxkBIIr598RIFZPWRkP/CZCDfAkcytlLrkchKDvKgSxMsmeBXBoKvt8tWeRPM79q4i8T 0ejA== X-Gm-Message-State: APt69E2DTF6vi8qEoCNOX+2tugCyxkFaGZbHxvxgHWKC5D6y8cozfz6J D8JXIIZiZKd87HGJYQzGA8jKKbC/6Vo= X-Google-Smtp-Source: AAOMgpeGV2t5mBT5+weA0qYyjFR4rTH2ULBX4PxXQGxBdFg7SChEHvLUlQAqwivHE4mtNqBysL1whw== X-Received: by 2002:a1c:d6cf:: with SMTP id n198-v6mr3416678wmg.61.1530961849843; Sat, 07 Jul 2018 04:10:49 -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 k18-v6sm8011348wrn.61.2018.07.07.04.10.49 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 07 Jul 2018 04:10:49 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Sat, 7 Jul 2018 13:10:03 +0200 Message-Id: <20180707111004.8320-30-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180707111004.8320-1-jkbs@redhat.com> References: <20180707111004.8320-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 29/30] ovn-nbctl: Don't die in nbctl_lr_route_del(). 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 Propagate the error via the context instead. Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index cdf6ae8c9..1781bf1f8 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -2933,7 +2933,8 @@ nbctl_lr_route_del(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; } if (ctx->argc == 2) { @@ -2944,7 +2945,8 @@ nbctl_lr_route_del(struct ctl_context *ctx) char *prefix = normalize_prefix_str(ctx->argv[2]); if (!prefix) { - ctl_fatal("bad prefix argument: %s", ctx->argv[2]); + ctl_error(ctx, "bad prefix argument: %s", ctx->argv[2]); + return; } for (int i = 0; i < lr->n_static_routes; i++) { @@ -2972,7 +2974,7 @@ nbctl_lr_route_del(struct ctl_context *ctx) } if (!shash_find(&ctx->options, "--if-exists")) { - ctl_fatal("no matching prefix: %s", prefix); + ctl_error(ctx, "no matching prefix: %s", prefix); } free(prefix); } From patchwork Sat Jul 7 11:10:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 940823 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 41N8Qs08hBz9s0w for ; Sat, 7 Jul 2018 21:25:25 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id E3988D3D; Sat, 7 Jul 2018 11:10:55 +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 29B7FD3D for ; Sat, 7 Jul 2018 11:10:54 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id ABAA776F for ; Sat, 7 Jul 2018 11:10:52 +0000 (UTC) Received: by mail-wm0-f68.google.com with SMTP id v3-v6so12937579wmh.0 for ; Sat, 07 Jul 2018 04:10:52 -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=Hzerj2Pi+GkIk+wO9tVollILsPKkPhhGvbvZCdRAiHE=; b=RrZTQcXgrZq7kchNMZR9uRBB9v0KKGkKoCNUGjsg95WduvNWMYtmqP5ccLsMFldh1l LnYwAR/LNntuLuex3J8sOhMjf7roQh9SivD0dc1bC4f+8ND0JeBXaTrTBRCREnz84vIk 4lukDBlL+Mx9OFJ8LZ5oICAfAng5z7njEYCcdIlzbUjO7A4aGYMgbZ31/OdD/3ckg4Bs Pi3d/3eBoyGXRMDJqg3EZF5V5jyzbR4JpjZsLuvxqQfqoF9Aw9g0B+ZEhp0wRLRrs9oa dUUBt92LyfhF2132RBYLmVmcVj0DPeNAxWZhGUoSIKdUmKDI9rF1pfr6+OEhN7vFFC5F 6+fA== X-Gm-Message-State: APt69E05JEobUYIjjTGFLjYXoIs+BEnfNTTPvVqdZJ9xCZxPefZ52hgW lvGVF2+gbk1x7oiNH+VzKObvNJVRItU= X-Google-Smtp-Source: AAOMgpeFi0APnC+RpO9gTDrSl+tFrSKBBwZz8KkjFmOV8nt9N1Rqf4apGs+OLX+F+yLDI4QpVl4jtg== X-Received: by 2002:a1c:ea17:: with SMTP id i23-v6mr7354478wmh.29.1530961851218; Sat, 07 Jul 2018 04:10:51 -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 o17-v6sm9677174wrp.62.2018.07.07.04.10.50 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 07 Jul 2018 04:10:50 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Sat, 7 Jul 2018 13:10:04 +0200 Message-Id: <20180707111004.8320-31-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180707111004.8320-1-jkbs@redhat.com> References: <20180707111004.8320-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 30/30] ovn-nbctl: Don't die in nbctl_lsp_set_type(). 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 Propagate the error via the context instead. Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 1781bf1f8..1181cdfba 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -1360,13 +1360,15 @@ nbctl_lsp_set_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; } if (ovn_is_known_nb_lsp_type(type)) { nbrec_logical_switch_port_set_type(lsp, type); } else { - ctl_fatal("Logical switch port type '%s' is unrecognized. " + ctl_error(ctx, "Logical switch port type '%s' is unrecognized. " "Not setting type.", type); + return; } }