Received: by 10.213.65.68 with SMTP id h4csp1799192imn; Mon, 19 Mar 2018 13:35:25 -0700 (PDT) X-Google-Smtp-Source: AG47ELu2LQJ0LPXCOGVFkl17O1XhRzWRQsKMT/x2jDfQZ9mJsma+kc07HQknbpyDCeRAVkAWuRZK X-Received: by 10.98.201.194 with SMTP id l63mr11318038pfk.126.1521491725018; Mon, 19 Mar 2018 13:35:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521491724; cv=none; d=google.com; s=arc-20160816; b=h38c2kmi+awMh3wB4PButMlUOUaQ3tLW/IbBgZgLb5yiJTF+R78bHkYz1+ExMAwal0 yWvsPDGIr0IeS3+4rZdqlwVvVT5tSRVqxs67a3TX6ey4CHxC6q05MORJP5o6uwkSSqpH VDuHLy6wNABpBL6pUMQc16Aeg7xJKPq7mumr72UfERSUGEas9YcoFyEGJQsfGubdgabE qAN/CsUWKO8+l9uDf9zElb5eLMuLGV/C8zaIh/P0oxXnwcRiMsZWnnNK1769V88S1QO8 UsJK+gmuDQBYg0o4NT1MRV9ElqOMvzMGss9nSOE24qd1SYhvhdGxI4myW1WsLUhyjDqh Af6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=m/tWwmcNfihDA+YIYx6JkzrGh0bVX4acZ52kTPrHO/U=; b=f3AzHSx35vCDHWOOE0iu6urzFVX0A/l7z7aQc4I6H1JZOs7JrboIk0WWV1XHUEnP07 JTbJ7wfdhSjqLJBuq8P6LccfzOXxoCZfBA2STtHDQmpCtbfcvearRAswoxz/MYLoMy+R wFzOXprLjAVOwthGI0Iu5rNvso6uOQTTAtRDqvMyR4lPdmYsCfKrwJvn4cWAHnV04Ly/ q4Pd/H9N0EUslIOboXiM3NVci0qYeoIpHaPGdpIjtkEX8YrzS/++/RfTyBfZXOYuFpOZ H+hmUlTnu0yG3cp8+tyvq6Y6FZ770sUdf3XMiJKKxGNCwWMkhcQrrazMzjYs2DEy5sxp fAhA== ARC-Authentication-Results: i=1; mx.google.com; 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 3-v6si29533pll.585.2018.03.19.13.34.41; Mon, 19 Mar 2018 13:35:24 -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; 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 S1030533AbeCSUbL (ORCPT + 99 others); Mon, 19 Mar 2018 16:31:11 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:42880 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935629AbeCSSMo (ORCPT ); Mon, 19 Mar 2018 14:12:44 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 4CFB911B4; Mon, 19 Mar 2018 18:12:43 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Simon Wunderlich , Andreas Pape , Sven Eckelmann , Sasha Levin Subject: [PATCH 4.4 022/134] batman-adv: handle race condition for claims between gateways Date: Mon, 19 Mar 2018 19:05:05 +0100 Message-Id: <20180319171852.398262408@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319171849.024066323@linuxfoundation.org> References: <20180319171849.024066323@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Andreas Pape [ Upstream commit a3a5129e122709306cfa6409781716c2933df99b ] Consider the following situation which has been found in a test setup: Gateway B has claimed client C and gateway A has the same backbone network as B. C sends a broad- or multicast to B and directly after this packet decides to send another packet to A due to a better TQ value. B will forward the broad-/multicast into the backbone as it is the responsible gw and after that A will claim C as it has been chosen by C as the best gateway. If it now happens that A claims C before it has received the broad-/multicast forwarded by B (due to backbone topology or due to some delay in B when forwarding the packet) we get a critical situation: in the current code A will immediately unclaim C when receiving the multicast due to the roaming client scenario although the position of C has not changed in the mesh. If this happens the multi-/broadcast forwarded by B will be sent back into the mesh by A and we have looping packets until one of the gateways claims C again. In order to prevent this, unclaiming of a client due to the roaming client scenario is only done after a certain time is expired after the last claim of the client. 100 ms are used here, which should be slow enough for big backbones and slow gateways but fast enough not to break the roaming client use case. Acked-by: Simon Wunderlich Signed-off-by: Andreas Pape [sven@narfation.org: fix conflicts with current version] Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- net/batman-adv/bridge_loop_avoidance.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) --- a/net/batman-adv/bridge_loop_avoidance.c +++ b/net/batman-adv/bridge_loop_avoidance.c @@ -1603,10 +1603,22 @@ int batadv_bla_tx(struct batadv_priv *ba /* if yes, the client has roamed and we have * to unclaim it. */ - batadv_handle_unclaim(bat_priv, primary_if, - primary_if->net_dev->dev_addr, - ethhdr->h_source, vid); - goto allow; + if (batadv_has_timed_out(claim->lasttime, 100)) { + /* only unclaim if the last claim entry is + * older than 100 ms to make sure we really + * have a roaming client here. + */ + batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla_tx(): Roaming client %pM detected. Unclaim it.\n", + ethhdr->h_source); + batadv_handle_unclaim(bat_priv, primary_if, + primary_if->net_dev->dev_addr, + ethhdr->h_source, vid); + goto allow; + } else { + batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla_tx(): Race for claim %pM detected. Drop packet.\n", + ethhdr->h_source); + goto handled; + } } /* check if it is a multicast/broadcast frame */