From patchwork Thu Feb 25 06:31:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andreas Pape X-Patchwork-Id: 15845 X-Patchwork-Delegate: mareklindner@neomailbox.ch Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from open-mesh.org (localhost [127.0.0.1]) by open-mesh.org (Postfix) with ESMTP id EDB9D818F6; Thu, 25 Feb 2016 07:31:16 +0100 (CET) Received-SPF: None (no SPF record) identity=mailfrom; client-ip=62.157.123.121; helo=mail2.phoenixcontact.com; envelope-from=apape@phoenixcontact.com; receiver=b.a.t.m.a.n@lists.open-mesh.org Authentication-Results: open-mesh.org; dmarc=none header.from=phoenixcontact.com Received: from mail2.phoenixcontact.com (mail2.phoenixcontact.com [62.157.123.121]) by open-mesh.org (Postfix) with ESMTPS id 50D0A818FA for ; Thu, 25 Feb 2016 07:31:14 +0100 (CET) Received: from localhost.localdomain ([149.208.237.66]) by de-nice01.de.phoenixcontact.com with ESMTP id 2016022507311301-8451 ; Thu, 25 Feb 2016 07:31:13 +0100 From: Andreas Pape To: b.a.t.m.a.n@lists.open-mesh.org X-Mailer: git-send-email 1.7.0.4 X-MIMETrack: Itemize by SMTP Server on DE-NICE01/Hub/SRV/DE/Phoenix Contact at 25.02.2016 07:31:13, Serialize by ntm_grab.EXE on nemex02/spoke/SRV/DE/Phoenix Contact at 25.02.2016 07:31:07, Serialize complete at 25.02.2016 07:31:07, Itemize by ntm_grab.EXE on nemex02/spoke/SRV/DE/Phoenix Contact at 25.02.2016 07:31:07, Serialize by Router on nemex02/spoke/SRV/DE/Phoenix Contact at 25.02.2016 07:31:08, Serialize complete at 25.02.2016 07:31:08 X-TNEFEvaluated: 1 Message-ID: <1456381870-29872-1-git-send-email-apape@phoenixcontact.com> Date: Thu, 25 Feb 2016 07:31:10 +0100 content-transfer-encoding: quoted-printable content-type: text/plain; charset="utf-8" Subject: [B.A.T.M.A.N.] [PATCH 7/7] batman-adv: handle race condition for claims between gateways X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking Errors-To: b.a.t.m.a.n-bounces@lists.open-mesh.org Sender: "B.A.T.M.A.N" This patch is crucial for prevention of looping broadcast or multicast packets in a bla setup. Consider the following situation: 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 multicast into the backbone as it is the responsible gw and 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 multicast forwarded by B (due to backbone topology or some delay in B) we get a critical situation: in the current code A will immediately unclaim C if the multicast is received due to the roaming client scenario although the position of C has not changed in the mesh. If this happens the broadcast will be sent back into the mesh and we have a loop 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. Signed-off-by: Andreas Pape --- net/batman-adv/bridge_loop_avoidance.c | 20 ++++++++++++++++---- 1 files changed, 16 insertions(+), 4 deletions(-) -- 1.7.0.4 .................................................................. PHOENIX CONTACT ELECTRONICS GmbH Sitz der Gesellschaft / registered office of the company: 31812 Bad Pyrmont USt-Id-Nr.: DE811742156 Amtsgericht Hannover HRB 100528 / district court Hannover HRB 100528 Geschäftsführer / Executive Board: Roland Bent, Dr. Martin Heubeck diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c index 6311ca2..7afddd9 100644 --- a/net/batman-adv/bridge_loop_avoidance.c +++ b/net/batman-adv/bridge_loop_avoidance.c @@ -1761,10 +1761,22 @@ int batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb, /* 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 */