From patchwork Mon Nov 9 11:09:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dumitru Ceara X-Patchwork-Id: 1396692 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=HH/0nA5S; dkim-atps=neutral Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CV7Z64KgYz9sS8 for ; Mon, 9 Nov 2020 22:10:03 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id DB86D8654D; Mon, 9 Nov 2020 11:10:00 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nbUhDP1NH2RG; Mon, 9 Nov 2020 11:09:59 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id 9E50984C2A; Mon, 9 Nov 2020 11:09:59 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 7410EC0889; Mon, 9 Nov 2020 11:09:59 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 34472C016F for ; Mon, 9 Nov 2020 11:09:58 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 2F98686382 for ; Mon, 9 Nov 2020 11:09:58 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xQ-6bwLVpUIR for ; Mon, 9 Nov 2020 11:09:57 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by whitealder.osuosl.org (Postfix) with ESMTPS id 3279B84C2A for ; Mon, 9 Nov 2020 11:09:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604920195; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type; bh=zO0ZBvjCB2gCCfJpgdH/9mBpvuxve1ZSNN+NI6nvYmA=; b=HH/0nA5S4ldEU7K2yYL1kRyggLsQtN4JKqCOUIEnEh6+7KURVCrfIz1o9OTxGZRnsCawBi KdN94po5gk59/eeiOYsX2HXW0Z16eQ92ZChd8tk1Jsodfq6rrNhRc2CfAzse7bwIrb3vii XaLdI//gG2MwhYyMzQH309kAgt/MFQk= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-533-mIycbBsRPuKOX6v5Wf-mTA-1; Mon, 09 Nov 2020 06:09:53 -0500 X-MC-Unique: mIycbBsRPuKOX6v5Wf-mTA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6315C6D258; Mon, 9 Nov 2020 11:09:52 +0000 (UTC) Received: from dceara.remote.csb (ovpn-113-208.ams2.redhat.com [10.36.113.208]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5927010013BD; Mon, 9 Nov 2020 11:09:51 +0000 (UTC) From: Dumitru Ceara To: dev@openvswitch.org Date: Mon, 9 Nov 2020 12:09:41 +0100 Message-Id: <1604920181-23904-1-git-send-email-dceara@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dceara@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH] ovsdb-idl: Add ovsdb_idl_monitor_condition_pending(). X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" IDL clients had no way of checking whether monitor_cond_change requests were pending (either local or in flight). This commit introduces a new API to check for the state of the conditional monitoring clauses. Signed-off-by: Dumitru Ceara --- lib/ovsdb-idl.c | 40 ++++++++++++++++++++++++++++++++-------- lib/ovsdb-idl.h | 1 + 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c index fdb9d85..8c0f86c 100644 --- a/lib/ovsdb-idl.c +++ b/lib/ovsdb-idl.c @@ -188,6 +188,17 @@ enum ovsdb_idl_monitoring { outstanding. */ }; +enum ovsdb_idl_monitor_cond_state { + OVSDB_IDL_MONITOR_COND_ACKED, /* Local conditional monitoring clauses + * have been acked by the server. */ + OVSDB_IDL_MONITOR_COND_LOCAL, /* Local conditional monitoring clause + * changes have not yet been sent to the + * server. */ + OVSDB_IDL_MONITOR_COND_REQUESTED, /* Local conditional monitoring clause + * changes have been sent to the server + * but have not yet been acked. */ +}; + struct ovsdb_idl_db { struct ovsdb_idl *idl; @@ -203,8 +214,8 @@ struct ovsdb_idl_db { struct json *schema; enum ovsdb_idl_monitoring monitoring; - /* True if any of the tables' monitoring conditions has changed. */ - bool cond_changed; + /* Current state of the conditional monitoring clauses. */ + enum ovsdb_idl_monitor_cond_state cond_state; unsigned int cond_seqno; /* Keep track of condition clauses changes over a single conditional monitoring session. @@ -1580,7 +1591,7 @@ ovsdb_idl_db_set_condition(struct ovsdb_idl_db *db, if (!ovsdb_idl_condition_equals(condition, table_cond)) { ovsdb_idl_condition_clone(&table->new_cond, condition); - db->cond_changed = true; + db->cond_state = OVSDB_IDL_MONITOR_COND_LOCAL; poll_immediate_wake(); return seqno + 1; } @@ -1638,7 +1649,7 @@ ovsdb_idl_create_cond_change_req(const struct ovsdb_idl_condition *cond) static struct jsonrpc_msg * ovsdb_idl_db_compose_cond_change(struct ovsdb_idl_db *db) { - if (!db->cond_changed) { + if (db->cond_state != OVSDB_IDL_MONITOR_COND_LOCAL) { return NULL; } @@ -1672,7 +1683,7 @@ ovsdb_idl_db_compose_cond_change(struct ovsdb_idl_db *db) return NULL; } - db->cond_changed = false; + db->cond_state = OVSDB_IDL_MONITOR_COND_REQUESTED; struct json *params = json_array_create_3(json_clone(db->monitor_id), json_clone(db->monitor_id), monitor_cond_change_requests); @@ -1693,6 +1704,19 @@ ovsdb_idl_db_ack_condition(struct ovsdb_idl_db *db) ovsdb_idl_condition_move(&table->ack_cond, &table->req_cond); } } + + /* Ack the last monitor condition change if no local changes happened in + * the meantime. + */ + if (db->cond_state == OVSDB_IDL_MONITOR_COND_REQUESTED) { + db->cond_state = OVSDB_IDL_MONITOR_COND_ACKED; + } +} + +bool +ovsdb_idl_monitor_condition_pending(struct ovsdb_idl *idl) +{ + return idl->data.cond_state != OVSDB_IDL_MONITOR_COND_ACKED; } /* Should be called when the IDL fsm is restarted and resyncs table conditions @@ -1712,7 +1736,7 @@ ovsdb_idl_db_sync_condition(struct ovsdb_idl_db *db) { bool ack_all = uuid_is_zero(&db->last_id); - db->cond_changed = false; + db->cond_state = OVSDB_IDL_MONITOR_COND_ACKED; for (size_t i = 0; i < db->class_->n_tables; i++) { struct ovsdb_idl_table *table = &db->tables[i]; @@ -1731,7 +1755,7 @@ ovsdb_idl_db_sync_condition(struct ovsdb_idl_db *db) } else { /* If there was no "unsent" condition but instead a * monitor_cond_change request was in flight, move table->req_cond - * to table->new_cond and set db->cond_changed to trigger a new + * to table->new_cond and set db->cond_state to trigger a new * monitor_cond_change request. * * However, if a new condition has been set by the IDL client, @@ -1740,7 +1764,7 @@ ovsdb_idl_db_sync_condition(struct ovsdb_idl_db *db) */ if (table->req_cond && !table->new_cond) { ovsdb_idl_condition_move(&table->new_cond, &table->req_cond); - db->cond_changed = true; + db->cond_state = OVSDB_IDL_MONITOR_COND_LOCAL; } } } diff --git a/lib/ovsdb-idl.h b/lib/ovsdb-idl.h index a1a5776..3f19d40 100644 --- a/lib/ovsdb-idl.h +++ b/lib/ovsdb-idl.h @@ -421,6 +421,7 @@ unsigned int ovsdb_idl_set_condition(struct ovsdb_idl *, const struct ovsdb_idl_condition *); unsigned int ovsdb_idl_get_condition_seqno(const struct ovsdb_idl *); +bool ovsdb_idl_monitor_condition_pending(struct ovsdb_idl *); /* Indexes over one or more columns in the IDL, to retrieve rows matching * particular search criteria and to iterate over a subset of rows in a defined