From patchwork Tue Dec 22 15:41:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dumitru Ceara X-Patchwork-Id: 1419437 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.133; helo=hemlock.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=iPXhRknu; dkim-atps=neutral Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4D0gYs6Mzsz9sVk for ; Wed, 23 Dec 2020 02:41:53 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 85C6E872A6; Tue, 22 Dec 2020 15:41:49 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6nkvb7raGDzF; Tue, 22 Dec 2020 15:41:48 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id 33F8987262; Tue, 22 Dec 2020 15:41:48 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 20FA7C1787; Tue, 22 Dec 2020 15:41:48 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id A1B24C0893 for ; Tue, 22 Dec 2020 15:41:46 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 95D2986135 for ; Tue, 22 Dec 2020 15:41:46 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Y9C94DZigHFv for ; Tue, 22 Dec 2020 15:41:45 +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 [63.128.21.124]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 9E65A8612B for ; Tue, 22 Dec 2020 15:41:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608651704; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:content-type:content-type; bh=DK4QZiK3OTuX8gDm0/gAfFUST926uRFYdUgF04NLzeI=; b=iPXhRknuYXbSTTW58egvfp3+3wHfFzVYr6kfl3h3QX5CwgipUPnKRzizdZooctJNlF06TH qDZeJ0gBoZC99AwIXNV5LtAvPWlkT+9RmHioPSE7p5Mgr66bmw5r3mNm9u+AA0pZJNt3Ne 5EpATMWnCMxSBMUxBZW8kKiJ5Mth9Fo= 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-262-b2Sv5Kb-Pae839nQI-B2mg-1; Tue, 22 Dec 2020 10:41:42 -0500 X-MC-Unique: b2Sv5Kb-Pae839nQI-B2mg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5DDB91005513 for ; Tue, 22 Dec 2020 15:41:41 +0000 (UTC) Received: from dceara.remote.csb (ovpn-114-158.ams2.redhat.com [10.36.114.158]) by smtp.corp.redhat.com (Postfix) with ESMTP id ADA0C5F708 for ; Tue, 22 Dec 2020 15:41:40 +0000 (UTC) From: Dumitru Ceara To: dev@openvswitch.org Date: Tue, 22 Dec 2020 16:41:37 +0100 Message-Id: <1608651697-25226-1-git-send-email-dceara@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 ovn] pinctrl: Fix race condition when explicitly clearing IGMP groups. 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" When a user flushes the IGMP Groups ("ovn-sbctl ip-multicast-flush") there's no guarantee that the ovn-controller main thread runs soon after the pinctrl thread has flushed the in-memory IGMP groups, in ip_mcast_snoop_flush(). To avoid unnecessarily waking the main thread just clear the local IGMP_Group records in the main thread. This scenario is quite hard to encounter in real deployments but every now and then we hit it in CI. Fixes: 70ff8243040f ("OVN: Add IGMP SB definitions and ovn-controller support") Signed-off-by: Dumitru Ceara --- controller/pinctrl.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/controller/pinctrl.c b/controller/pinctrl.c index 7e3abf0..e957b75 100644 --- a/controller/pinctrl.c +++ b/controller/pinctrl.c @@ -4507,9 +4507,16 @@ ip_mcast_snoop_state_find(int64_t dp_key) return NULL; } +/* Updates the ip_mcast_snoop_cfg for a logical datapath specified by + * 'dp_key'. Also sets 'needs_flush' to 'true' if the config change should + * to trigger flushing of the existing IGMP_Groups. + * + * Returns 'true' if any changes happened to the configuration. + */ static bool ip_mcast_snoop_state_update(int64_t dp_key, - const struct ip_mcast_snoop_cfg *cfg) + const struct ip_mcast_snoop_cfg *cfg, + bool *needs_flush) OVS_REQUIRES(pinctrl_mutex) { bool notify = false; @@ -4519,6 +4526,9 @@ ip_mcast_snoop_state_update(int64_t dp_key, ms_state = ip_mcast_snoop_state_add(dp_key); notify = true; } else if (memcmp(cfg, &ms_state->cfg, sizeof *cfg)) { + if (ms_state->cfg.seq_no != cfg->seq_no) { + *needs_flush = true; + } notify = true; } @@ -4738,6 +4748,25 @@ ip_mcast_snoop_run(void) } } +/* Flushes all IGMP_Groups installed by the local chassis for the logical + * datapath specified by 'dp_key'. + */ +static void +ip_mcast_flush_groups(int64_t dp_key, const struct sbrec_chassis *chassis, + struct ovsdb_idl_index *sbrec_igmp_groups) +{ + const struct sbrec_igmp_group *sbrec_igmp; + + SBREC_IGMP_GROUP_FOR_EACH_BYINDEX (sbrec_igmp, sbrec_igmp_groups) { + if (!sbrec_igmp->datapath || + sbrec_igmp->datapath->tunnel_key != dp_key || + sbrec_igmp->chassis != chassis) { + continue; + } + igmp_group_delete(sbrec_igmp); + } +} + /* * This runs in the pinctrl main thread, so it has access to the southbound * database. It reads the IP_Multicast table and updates the local multicast @@ -4770,11 +4799,15 @@ ip_mcast_sync(struct ovsdb_idl_txn *ovnsb_idl_txn, int64_t dp_key = ip_mcast->datapath->tunnel_key; struct ip_mcast_snoop_cfg cfg; + bool flush_groups = false; ip_mcast_snoop_cfg_load(&cfg, ip_mcast); - if (ip_mcast_snoop_state_update(dp_key, &cfg)) { + if (ip_mcast_snoop_state_update(dp_key, &cfg, &flush_groups)) { notify = true; } + if (flush_groups) { + ip_mcast_flush_groups(dp_key, chassis, sbrec_igmp_groups); + } } /* Then delete the old entries. */