Received: by 10.213.65.68 with SMTP id h4csp1771935imn; Mon, 19 Mar 2018 12:50:57 -0700 (PDT) X-Google-Smtp-Source: AG47ELviFzpBZEUsxL65uOGHTcVuH+R9bfLI+Xuq5DSnPpLVWh/xsBizJY56Jwqer0fbVZf5mbAV X-Received: by 10.99.177.7 with SMTP id r7mr9972363pgf.76.1521489057196; Mon, 19 Mar 2018 12:50:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521489057; cv=none; d=google.com; s=arc-20160816; b=s444fU6tZbE0RusGnnYsBNQC5XjZpM0USGsC4eT3bMxn0gT+BOJHko5cvrQZUaY4wy oOzXH4z2iQqp2pBUblC/3d4KnDVlWtsJMDIyFFNVvsVZLtnSdrkurIG7sMDlC5+KPaY/ iGy+NkA6hvHU4uuPqbu2J0zSyqPuG0rWrjGw1rXaTpN/12j9y80faqGild1k6ry87tJB DyDCb8YuEoDB4DBHH6fWT6lt81/gVwXWmlo/lCEHqDhYhYLr44S3ZBo3FuNj8lDyM4P8 I33yv5moMQ9XPp6zv/Bsdwe2T5vGd2l+6MzQIeGrUHsbUpYM4S9oWWpgtSbSPcjjy8uY mRxQ== 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=wTYOY/im2wLdK3Ivc5DkdMYyyq7X8PlFFl34t0wkqe0=; b=dcP+vDco85q0gUDqEX68wtgAGq9rXPImw0NYr5tBamQbBAVIT5C5TDaix33MA0JslZ 0Y7mDyP1/xjr9PaNguYen+V76S/jnwcwzW+bDtZX7oNTPB5ofEI7F8TENyWCtYGzuRRs eylGqneIF5k8aZbyQBKlox+tZt/GONjRjIaaEQDnoyniT/kG5WYVb5TTZXI6hPzwVzkS eXEvZMsJef8xTCsaec1mKvphh6MQ14MEMpa0JkAokh42GJgP88ypf8x8ZfV5+7JWv4Dt p+u/EPaFn8nmcCvmRDvBjkVvR6sSyMoU3/ZIxsd/gPeM/lZqSznsppCScEBrEW5qWp+L RH5Q== 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 b8-v6si553991plz.31.2018.03.19.12.50.43; Mon, 19 Mar 2018 12:50:57 -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 S1030977AbeCSSUI (ORCPT + 99 others); Mon, 19 Mar 2018 14:20:08 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:47500 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030937AbeCSSUF (ORCPT ); Mon, 19 Mar 2018 14:20:05 -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 9971A2F; Mon, 19 Mar 2018 18:20:04 +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.9 049/241] batman-adv: handle race condition for claims between gateways Date: Mon, 19 Mar 2018 19:05:14 +0100 Message-Id: <20180319180753.240133786@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319180751.172155436@linuxfoundation.org> References: <20180319180751.172155436@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.9-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 @@ -1964,10 +1964,22 @@ bool batadv_bla_tx(struct batadv_priv *b /* 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 */