From patchwork Tue Dec 20 09:47:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Zhou X-Patchwork-Id: 707398 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3tjXzs2Wf0z9t5m for ; Tue, 20 Dec 2016 20:48:57 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 2AE4BB1F; Tue, 20 Dec 2016 09:48:28 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 20C982C for ; Tue, 20 Dec 2016 09:48:27 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f67.google.com (mail-pg0-f67.google.com [74.125.83.67]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id CD60BE5 for ; Tue, 20 Dec 2016 09:48:26 +0000 (UTC) Received: by mail-pg0-f67.google.com with SMTP id i5so1729847pgh.2 for ; Tue, 20 Dec 2016 01:48:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YOa4C/kTvX8EhT07cVASB+iOBdjdzdSYT2xkLwEKzH8=; b=Qf3pJS3JfiV/IcfGQlsI0/8KIGWhoPly4ZBtECWfMST86UoOXoiGNBMQ4YEYzkkeCr +JLVgehD9ASUcB+cEyzGObPZO95HuLBaWiKvuXEGPjlyWXk6vczcXadXZdnK3D4rUH5k FDpuKVVGBXtVWW/a+FhhIhmqJvZ1AZFq8nvpBxH//NzQay7I5zpgQph9iUEyr42og0Ct Z4NFpehz76Q3KVXOoN+MAGeEncniKBk9+Nc8Fb/squNtsthHQZ9eha9VbtG/eXVotsim hWstseo/2US0Z36Aw2Az9ATEEa0Yzc2t9MzaJKMqVMO3euilGrU4MxhuqWd6WkV8symr bv9g== X-Gm-Message-State: AKaTC00sRe6+Sq4ULr5By8HrQ5RzrcZb6/qXwT47ck5hBHKU8wHEh60mE4kCB3SK0TXp3A== X-Received: by 10.99.245.21 with SMTP id w21mr35099389pgh.5.1482227306249; Tue, 20 Dec 2016 01:48:26 -0800 (PST) Received: from localhost.localdomain (c-73-202-55-235.hsd1.ca.comcast.net. [73.202.55.235]) by smtp.gmail.com with ESMTPSA id x2sm37540191pfx.65.2016.12.20.01.48.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Dec 2016 01:48:25 -0800 (PST) From: Andy Zhou To: dev@openvswitch.org Date: Tue, 20 Dec 2016 01:47:16 -0800 Message-Id: <1482227237-61638-2-git-send-email-azhou@ovn.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1482227237-61638-1-git-send-email-azhou@ovn.org> References: <1482227237-61638-1-git-send-email-azhou@ovn.org> X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 2/3] ovsdb-idl: Properly handle conditional monitor update 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 From: andy zhou When generating conditional monitoring update request, current code failed to update idl's 'request-id'. This bug causes the reply message of the update request, regardless an ACK or a NACK, be logged as an unexpected message at the debug level and ignored by the core idl logic. In addition, the idl should not generate another conditional monitoring update request when there is an outstanding request. So that the requests and their reply are properly serialized. When the conditional monitoring is nacked by the server, drop idl into a client visible error state. Signed-off-by: Andy Zhou --- lib/ovsdb-idl.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c index 218b6b3..341951d 100644 --- a/lib/ovsdb-idl.c +++ b/lib/ovsdb-idl.c @@ -456,8 +456,11 @@ ovsdb_idl_run(struct ovsdb_idl *idl) idl->schema = NULL; break; - case IDL_S_MONITORING: case IDL_S_MONITORING_COND: + /* Conditional monitor clauses were updated. */ + break; + + case IDL_S_MONITORING: case IDL_S_NO_SCHEMA: default: OVS_NOT_REACHED(); @@ -496,14 +499,23 @@ ovsdb_idl_run(struct ovsdb_idl *idl) idl->state = IDL_S_MONITOR_REQUESTED; } } else if (msg->type == JSONRPC_ERROR + && idl->state == IDL_S_MONITORING_COND + && idl->request_id + && json_equal(idl->request_id, msg->id)) { + json_destroy(idl->request_id); + idl->request_id = NULL; + VLOG_ERR("%s: conditional monitor update failed", + jsonrpc_session_get_name(idl->session)); + idl->state = IDL_S_NO_SCHEMA; + } else if (msg->type == JSONRPC_ERROR && idl->state == IDL_S_SCHEMA_REQUESTED && idl->request_id && json_equal(idl->request_id, msg->id)) { - json_destroy(idl->request_id); - idl->request_id = NULL; - VLOG_ERR("%s: requested schema not found", - jsonrpc_session_get_name(idl->session)); - idl->state = IDL_S_NO_SCHEMA; + json_destroy(idl->request_id); + idl->request_id = NULL; + VLOG_ERR("%s: requested schema not found", + jsonrpc_session_get_name(idl->session)); + idl->state = IDL_S_NO_SCHEMA; } else if ((msg->type == JSONRPC_ERROR || msg->type == JSONRPC_REPLY) && ovsdb_idl_txn_process_reply(idl, msg)) { @@ -1091,8 +1103,11 @@ ovsdb_idl_send_cond_change(struct ovsdb_idl *idl) struct json *params, *json_uuid; struct jsonrpc_msg *request; + /* When 'idl-request_id' is not NULL, there is an outstanding + * conditional monitoring update request that we have not heard + * from the server yet. Don't generate another request in this case. */ if (!idl->cond_changed || !jsonrpc_session_is_connected(idl->session) || - idl->state != IDL_S_MONITORING_COND) { + idl->state != IDL_S_MONITORING_COND || idl->request_id) { return; } @@ -1128,7 +1143,8 @@ ovsdb_idl_send_cond_change(struct ovsdb_idl *idl) params = json_array_create_3(json_uuid, json_string_create(uuid), monitor_cond_change_requests); - request = jsonrpc_create_request("monitor_cond_change", params, NULL); + request = jsonrpc_create_request("monitor_cond_change", params, + &idl->request_id); jsonrpc_session_send(idl->session, request); } idl->cond_changed = false;