From patchwork Wed Dec 7 07:28:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 703471 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 3tYVVK0v0tz9t0p for ; Wed, 7 Dec 2016 18:28:56 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id D7B83B94; Wed, 7 Dec 2016 07:28:52 +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 527608A5 for ; Wed, 7 Dec 2016 07:28:52 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 9C60E137 for ; Wed, 7 Dec 2016 07:28:51 +0000 (UTC) Received: from mfilter10-d.gandi.net (mfilter10-d.gandi.net [217.70.178.139]) by relay3-d.mail.gandi.net (Postfix) with ESMTP id 17FABA80DB; Wed, 7 Dec 2016 08:28:50 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mfilter10-d.gandi.net Received: from relay3-d.mail.gandi.net ([IPv6:::ffff:217.70.183.195]) by mfilter10-d.gandi.net (mfilter10-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id 4mfxtpcnn_t6; Wed, 7 Dec 2016 08:28:48 +0100 (CET) X-Originating-IP: 173.228.112.229 Received: from sigabrt.gateway.sonic.net (173-228-112-229.dsl.dynamic.fusionbroadband.com [173.228.112.229]) (Authenticated sender: blp@ovn.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id EF0B7A80CF; Wed, 7 Dec 2016 08:28:47 +0100 (CET) From: Ben Pfaff To: dev@openvswitch.org Date: Tue, 6 Dec 2016 23:28:40 -0800 Message-Id: <20161207072843.27022-1-blp@ovn.org> X-Mailer: git-send-email 2.10.2 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ben Pfaff Subject: [ovs-dev] [PATCH 1/4] ofproto: Update access rules for 'flow_cookie'. 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 The 'flow_cookie' member of struct rule is read during flow translation without holding a mutex, breaking the documented OVS_GUARDED access rule. However, the flow_cookie member is actually never modified after a rule is initialized, so this commit changes the access rules to reflect that. Signed-off-by: Ben Pfaff --- ofproto/ofproto-provider.h | 4 ++-- ofproto/ofproto.c | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ofproto/ofproto-provider.h b/ofproto/ofproto-provider.h index c515779..3739ebc 100644 --- a/ofproto/ofproto-provider.h +++ b/ofproto/ofproto-provider.h @@ -365,8 +365,8 @@ struct rule { struct ovs_refcount ref_count; /* A "flow cookie" is the OpenFlow name for a 64-bit value associated with - * a flow.. */ - ovs_be64 flow_cookie OVS_GUARDED; + * a flow. */ + const ovs_be64 flow_cookie; /* Immutable once rule is constructed. */ struct hindex_node cookie_node OVS_GUARDED_BY(ofproto_mutex); enum ofputil_flow_mod_flags flags OVS_GUARDED; diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 4f43c45..58295a1 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -4859,7 +4859,7 @@ ofproto_rule_create(struct ofproto *ofproto, struct cls_rule *cr, ovs_mutex_init(&rule->mutex); ovs_mutex_lock(&rule->mutex); - rule->flow_cookie = new_cookie; + *CONST_CAST(ovs_be64 *, &rule->flow_cookie) = new_cookie; rule->created = rule->modified = time_msec(); rule->idle_timeout = idle_timeout; rule->hard_timeout = hard_timeout; @@ -5098,7 +5098,8 @@ replace_rule_start(struct ofproto *ofproto, struct ofproto_flow_mod *ofm, new_rule->created = old_rule->created; } if (!change_cookie) { - new_rule->flow_cookie = old_rule->flow_cookie; + *CONST_CAST(ovs_be64 *, &new_rule->flow_cookie) + = old_rule->flow_cookie; } ovs_mutex_unlock(&old_rule->mutex); ovs_mutex_unlock(&new_rule->mutex);