Received: by 2002:a25:d783:0:0:0:0:0 with SMTP id o125csp645774ybg; Thu, 19 Mar 2020 06:20:42 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtUUpLe7RREv2FtfCWKI2PMz3CK2thRj6YFOFDdvfqQYGG9ql3N/Sn8/Aheth+1baHMeeeF X-Received: by 2002:aca:47c8:: with SMTP id u191mr2316783oia.17.1584624041787; Thu, 19 Mar 2020 06:20:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584624041; cv=none; d=google.com; s=arc-20160816; b=AfqXwciDiln8h38mczmc/WTcDSlEX5nJ49vJcplrI6zcYpzOX8r7E31nvdrRwnkz0F F/kPFgM6knLsZ75eoEV/TrvmHSkfgg6E++HrAh5hywnZzDZAJNbeBbmYNsKwWq44hN+Q 88Ik2EejaEgQNyOreU6aSgXKrkWqYEfBKgDp64/KP0IJwMh49QUHZqdUrEmpYXLupQx+ Yb/tJUJye8moZRd85+nxQ3hi8Dn0qqZx4YuD338dRj5kJUsczZlIH34qxEeD058r1TfT Xm9NTOF5rFyiqgCKqSGjcDnUAMT/YHXbJHnhTGzAIGagIGUdlAE9QZDv5iRtVgpVSBeW BsZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rUy5C4rI3oCAHG7kKs0qRZdj7bVMopsVkmd9EKR9bIA=; b=RfP8k6Z8zF/P2AHQ2FagcLM919453I0Qu/utu2zX6n9w8L3m/rzLFtv8CukchD2+a2 PbkeqStBgr1wN0h/M7wUOR6Fs0fN8I/HUVA+7nj+dOwtxpJ8mqAgtwchhbm8tBsBpfsl A40iUXbqb3emd6F4sk9lVGMnFCdRGgKBsgSqIuWTdVX1YuWVFbltkRN2+YewEjGmDwHJ kYlBu0sCFAEBelDxCXU+DCAV8eJrHhVudtHHEDkRpgdmDKlGRwBhFMReKlVft2XpwP8A Mqw9MX004OZafHIFBY7IqwsiGl/GCPd1xTxLzigFjYX+c3tfbgYfPSUmdCR0Cxyda7W/ c4JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qduhFeHI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r1si1132130oti.200.2020.03.19.06.20.28; Thu, 19 Mar 2020 06:20:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qduhFeHI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728930AbgCSNS4 (ORCPT + 99 others); Thu, 19 Mar 2020 09:18:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:41642 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728696AbgCSNSw (ORCPT ); Thu, 19 Mar 2020 09:18:52 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 19D2C214D8; Thu, 19 Mar 2020 13:18:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584623931; bh=UVIq3kfmmMt4OxRi/iwoPRHANQQVObbhqUMTpEQTYOo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qduhFeHIhiUHTwo1frGI8+IRuQM/eBYQaiW2bNUUMLRKi0jl9UCaKo/EI8jYsOv7k +xvOq1iENFlIkyE6TDNr7pZbQiM6zuREMh76WI1ZYPYExPYyoQmgZ8PsqQ7yEYpgnE Oqz1XIrChCfrJvd1oTa3V9eUm8v2jxwetXeFvvsw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Marek Lindner , Sven Eckelmann , Simon Wunderlich Subject: [PATCH 4.14 75/99] batman-adv: prevent TT request storms by not sending inconsistent TT TLVLs Date: Thu, 19 Mar 2020 14:03:53 +0100 Message-Id: <20200319124003.828460399@linuxfoundation.org> X-Mailer: git-send-email 2.25.2 In-Reply-To: <20200319123941.630731708@linuxfoundation.org> References: <20200319123941.630731708@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marek Lindner commit 16116dac23396e73c01eeee97b102e4833a4b205 upstream. A translation table TVLV changset sent with an OGM consists of a number of headers (one per VLAN) plus the changeset itself (addition and/or deletion of entries). The per-VLAN headers are used by OGM recipients for consistency checks. Said consistency check might determine that a full translation table request is needed to restore consistency. If the TT sender adds per-VLAN headers of empty VLANs into the OGM, recipients are led to believe to have reached an inconsistent state and thus request a full table update. The full table does not contain empty VLANs (due to missing entries) the cycle restarts when the next OGM is issued. Consequently, when the translation table TVLV headers are composed, empty VLANs are to be excluded. Fixes: 21a57f6e7a3b ("batman-adv: make the TT CRC logic VLAN specific") Signed-off-by: Marek Lindner Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich Signed-off-by: Greg Kroah-Hartman --- net/batman-adv/translation-table.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -941,15 +941,20 @@ batadv_tt_prepare_tvlv_local_data(struct struct batadv_tvlv_tt_vlan_data *tt_vlan; struct batadv_softif_vlan *vlan; u16 num_vlan = 0; - u16 num_entries = 0; + u16 vlan_entries = 0; + u16 total_entries = 0; u16 tvlv_len; u8 *tt_change_ptr; int change_offset; spin_lock_bh(&bat_priv->softif_vlan_list_lock); hlist_for_each_entry_rcu(vlan, &bat_priv->softif_vlan_list, list) { + vlan_entries = atomic_read(&vlan->tt.num_entries); + if (vlan_entries < 1) + continue; + num_vlan++; - num_entries += atomic_read(&vlan->tt.num_entries); + total_entries += vlan_entries; } change_offset = sizeof(**tt_data); @@ -957,7 +962,7 @@ batadv_tt_prepare_tvlv_local_data(struct /* if tt_len is negative, allocate the space needed by the full table */ if (*tt_len < 0) - *tt_len = batadv_tt_len(num_entries); + *tt_len = batadv_tt_len(total_entries); tvlv_len = *tt_len; tvlv_len += change_offset; @@ -974,6 +979,10 @@ batadv_tt_prepare_tvlv_local_data(struct tt_vlan = (struct batadv_tvlv_tt_vlan_data *)(*tt_data + 1); hlist_for_each_entry_rcu(vlan, &bat_priv->softif_vlan_list, list) { + vlan_entries = atomic_read(&vlan->tt.num_entries); + if (vlan_entries < 1) + continue; + tt_vlan->vid = htons(vlan->vid); tt_vlan->crc = htonl(vlan->tt.crc);