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. */