From patchwork Thu Jul 12 13:40: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: 943045 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 41RHCM4WpGz9rxx for ; Thu, 12 Jul 2018 23:41:19 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id ADBACCD8; Thu, 12 Jul 2018 13:40: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 DD6A8CB9 for ; Thu, 12 Jul 2018 13:40:22 +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 62BB576A for ; Thu, 12 Jul 2018 13:40:22 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id h9-v6so21769209wro.3 for ; Thu, 12 Jul 2018 06:40:22 -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:cc:subject:date:message-id:in-reply-to :references; bh=wuT3+IW4vYRIuBgOmE2eoHhtP2E6vL8N5bb7cDqebec=; b=LsBH8ERKMVICq2EhMToGCPr4T9FGy7BQFZceKJmIoauvygiDJdNOmjrm7nLdC5WJh1 f6sT7/obcYOFOmkaoygRj3P6Fmpul9Ilk0LTHRaUlfWws9ay2crcR7WsbOQ5iBDTWO72 UFoVD5tFaA6i1Uhs1YdLDGi4A/pZ6IH7UbWymVs1Yzqt2wyAhk3EUJ+70zqj5qlj6qby 5FpwrjyYSQMOV5ICwhinSV8KjoJbLaHkkf2/P73VfnrhCAHjIIlKJIMcmA9QBsEMcYke vrik7/uaJMdd4xLlZkY8St95Md7ZMUZHuA3qd9t9coi3/jYuAVyBTewGwbnSafpFgnxR 5G0g== X-Gm-Message-State: AOUpUlHNqptAsNVDvDcLSe01eETxLpN5u6g8t+O2QxCMzC2yVwGw8s5b AMpCskqeRCj+ikEvnlxc1TjHh1EKkDM= X-Google-Smtp-Source: AAOMgpdbpzxGd4lxIHdcNc43XxVwVEfFKlRUf/xn6dOXbEDr/FcYvboGHfFqowXTXY8tIbVv6xHyLA== X-Received: by 2002:adf:ef03:: with SMTP id e3-v6mr1722981wro.182.1531402820780; Thu, 12 Jul 2018 06:40:20 -0700 (PDT) Received: from redhat.com (red-hat-inc.vlan404.asr1.mad1.gblx.net. [64.215.113.190]) by smtp.gmail.com with ESMTPSA id w135-v6sm11844237wme.7.2018.07.12.06.40.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Jul 2018 06:40:20 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Thu, 12 Jul 2018 15:40:03 +0200 Message-Id: <20180712134016.14336-3-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180712134016.14336-1-jkbs@redhat.com> References: <20180712134016.14336-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 v2 02/15] ovsdb-idl: Allow monitoring columns that are already monitored. 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 If IDL was created with monitoring and alerts turned on by default for all columns, then there is no harm in allowing the API users to ask again for monitoring and alerts to be enabled for any given column. This allows us to run prerequisites handlers for db-ctl and ovn-nbctl commands once the IDL has already ran once. Signed-off-by: Jakub Sitnicki --- lib/ovsdb-idl.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c index 9ab5d6723..ae0a55c3a 100644 --- a/lib/ovsdb-idl.c +++ b/lib/ovsdb-idl.c @@ -1116,6 +1116,20 @@ ovsdb_idl_db_get_mode(struct ovsdb_idl_db *db, return &table->modes[column - table->class_->columns]; } +static void +ovsdb_idl_db_set_mode(struct ovsdb_idl_db *db, + const struct ovsdb_idl_column *column, + unsigned char mode) +{ + const struct ovsdb_idl_table *table = ovsdb_idl_table_from_column(db, + column); + size_t column_idx = column - table->class_->columns; + + if (table->modes[column_idx] != mode) { + *ovsdb_idl_db_get_mode(db, column) = mode; + } +} + static void add_ref_table(struct ovsdb_idl_db *db, const struct ovsdb_base_type *base) { @@ -1136,7 +1150,7 @@ static void ovsdb_idl_db_add_column(struct ovsdb_idl_db *db, const struct ovsdb_idl_column *column) { - *ovsdb_idl_db_get_mode(db, column) = OVSDB_IDL_MONITOR | OVSDB_IDL_ALERT; + ovsdb_idl_db_set_mode(db, column, OVSDB_IDL_MONITOR | OVSDB_IDL_ALERT); add_ref_table(db, &column->type.key); add_ref_table(db, &column->type.value); }