From patchwork Mon Mar 20 21:08:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Stringer X-Patchwork-Id: 741190 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 3vn7pT1qCsz9s0m for ; Tue, 21 Mar 2017 08:08:33 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id A0543B5A; Mon, 20 Mar 2017 21:08:30 +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 53148B50 for ; Mon, 20 Mar 2017 21:08:29 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id D2A9D25E for ; Mon, 20 Mar 2017 21:08:28 +0000 (UTC) Received: from mfilter11-d.gandi.net (mfilter11-d.gandi.net [217.70.178.131]) by relay2-d.mail.gandi.net (Postfix) with ESMTP id 9C26FC5A6F for ; Mon, 20 Mar 2017 22:08:27 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mfilter11-d.gandi.net Received: from relay2-d.mail.gandi.net ([IPv6:::ffff:217.70.183.194]) by mfilter11-d.gandi.net (mfilter11-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id AT-Otjy13hWa for ; Mon, 20 Mar 2017 22:08:26 +0100 (CET) X-Originating-IP: 208.91.1.34 Received: from carno.eng.vmware.com (unknown [208.91.1.34]) (Authenticated sender: joe@ovn.org) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id B3201C5A44 for ; Mon, 20 Mar 2017 22:08:25 +0100 (CET) From: Joe Stringer To: dev@openvswitch.org Date: Mon, 20 Mar 2017 14:08:19 -0700 Message-Id: <20170320210819.1069-1-joe@ovn.org> X-Mailer: git-send-email 2.11.1 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 Subject: [ovs-dev] [PATCH] ofproto-dpif-upcall: Fix flow setup/delete race. 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 a handler thread takes a long time to set up a set of flows, it is possible for one of the installed flows to be dumped and scheduled for deletion by a revalidator thread before the handler is able to transition the ukey into an operational state---Between the dpif_operate() above this function and the ukey lock / transition logic modified by this patch. Only transition the ukey for the flow if it wasn't already transitioned to a later state by a revalidator thread. Fixes: 54ebeff4c03d ("upcall: Track ukey states.") Reported-by: Paul Blakey Signed-off-by: Joe Stringer Tested-by: Paul Blakey --- ofproto/ofproto-dpif-upcall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c index 07086ee385cc..0854807e4482 100644 --- a/ofproto/ofproto-dpif-upcall.c +++ b/ofproto/ofproto-dpif-upcall.c @@ -1404,7 +1404,7 @@ handle_upcalls(struct udpif *udpif, struct upcall *upcalls, ovs_mutex_lock(&ukey->mutex); if (ops[i].dop.error) { transition_ukey(ukey, UKEY_EVICTED); - } else { + } else if (ukey->state < UKEY_OPERATIONAL) { transition_ukey(ukey, UKEY_OPERATIONAL); } ovs_mutex_unlock(&ukey->mutex);