Received: by 10.223.185.116 with SMTP id b49csp1112635wrg; Sat, 3 Mar 2018 15:57:38 -0800 (PST) X-Google-Smtp-Source: AG47ELu4jaxEfxIrtTP80kRHX3XY4bJAQO2dOnNqLx5mzusyTcShabU4QiZY9/rrg61t/dAain8q X-Received: by 10.101.97.67 with SMTP id o3mr8621573pgv.251.1520121458405; Sat, 03 Mar 2018 15:57:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520121458; cv=none; d=google.com; s=arc-20160816; b=rGn3UoKKSijQbUsXerQ2oBQ7ZfMCScw60sJ4gYX8bDZgmzFsbjTnr+NeRHgoCDcSCi mZVb2g382I+oycCmvr1qqalXLcjgC3tn1WRnc4QrTcvtNeyGhjpk8R9Ef+eRKfc2Stsb lzp+zCGlu44UhLFyedtsAy1AtMdu4S9BsljPUR7J1XH84lQbAPbpPUSZWRZGwURnG5js 3kD1KT8xorXmJ2BGRWCDkNalV1IV5NjjxvlYZ8kDwwKiD2vg7+oGmxVTLBPI7+bTJnwf 2mfBnU+YdPNPEUcCqFnoJpZ46/Tyt+Ak1SmHSHf4PypHkKWBS1eS23CTHjaBF/I5/gkx da5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=C7PeYwCmAenLW+yr8QXC2DQS52devIvkrp0tSSJjS0k=; b=ZxxbxSIGLDJSgn98LfOgL4P73AT6fCBLUS76ROkf6LdeFwI18Vtm0CMskOlafGQHus FCLpE+lWJrDlDxUdoOju/9eB7bOdROKEFZn7p/unzswSG5pgaTA5Mc18VXlbUBeTixOb IbVZH7HrYGxjEiG/4RhCVncByjtHNY1eGUPvcIEpfPNkzCJIEXrdpoiSsQriKh0LJJE8 XDkq7DEvTqGxqVANoWTiSVaC+EVcI4CcVMFPmRJRDex6bz1QpBr54zMmsM892Y2wC3rE mXfabOLa2XkjKkxSJOmkhSW+MwevGjMQXIetOGlpW3jd4EklGaRutCXM0kRc5xAMooSl kHXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=MnglLN1g; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u29si6169548pgn.770.2018.03.03.15.57.24; Sat, 03 Mar 2018 15:57:38 -0800 (PST) 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=@microsoft.com header.s=selector1 header.b=MnglLN1g; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933852AbeCCWc2 (ORCPT + 99 others); Sat, 3 Mar 2018 17:32:28 -0500 Received: from mail-by2nam01on0120.outbound.protection.outlook.com ([104.47.34.120]:24496 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933793AbeCCWcT (ORCPT ); Sat, 3 Mar 2018 17:32:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=C7PeYwCmAenLW+yr8QXC2DQS52devIvkrp0tSSJjS0k=; b=MnglLN1gOAy2PFUs2IaVeQG1JpGzGIfzZBsPupTq7muCIB13LaCgG/0TqoBMOGznO7k38dL2+9205z50LlelKL2Hy/foExyJdAa12GTUR/fDnCXmp9LAwY2flXqLjSudbtl0MYDtmJvpVnWyVmRBzT1+pP+TAefm11+ga86j6vQ= Received: from MW2PR2101MB1034.namprd21.prod.outlook.com (52.132.149.10) by MW2PR2101MB1036.namprd21.prod.outlook.com (52.132.149.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.567.3; Sat, 3 Mar 2018 22:32:13 +0000 Received: from MW2PR2101MB1034.namprd21.prod.outlook.com ([fe80::1d56:338f:e2b:cec0]) by MW2PR2101MB1034.namprd21.prod.outlook.com ([fe80::1d56:338f:e2b:cec0%3]) with mapi id 15.20.0567.006; Sat, 3 Mar 2018 22:32:13 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Andreas Pape , Andreas Pape , Sven Eckelmann , Simon Wunderlich , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 051/219] batman-adv: handle race condition for claims between gateways Thread-Topic: [PATCH AUTOSEL for 4.9 051/219] batman-adv: handle race condition for claims between gateways Thread-Index: AQHTsz7yzkqxCZGark+/717K2s0ryw== Date: Sat, 3 Mar 2018 22:28:25 +0000 Message-ID: <20180303222716.26640-51-alexander.levin@microsoft.com> References: <20180303222716.26640-1-alexander.levin@microsoft.com> In-Reply-To: <20180303222716.26640-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MW2PR2101MB1036;7:Wgvv3qmBbdLjezW7c2AM6gLgfPWPF5H6xrmTVYFipLunmVgkAjkFUK3yE/8HfwDVSFezdVC+SYh/W1nWRqxUWbyrSDf3bklkVsZLZrQGVnubpT6xRe7eIAAlVx2VTxf66e1OKb8BmcAguL45GcXk8c92JfjVVp9+DyXG0NyGdbQQlrtLs/Vzybhs6CBlgWfBozq9UaxcW891pRVTd2xHkiX0bZawOg632Z/K/TViT39RhQ2ONaD9t5ZGWZivIfd3 x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: df868126-5dee-4c19-1692-08d581569c6f x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(3008032)(2017052603307)(7193020);SRVR:MW2PR2101MB1036; x-ms-traffictypediagnostic: MW2PR2101MB1036: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040501)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231220)(944501244)(52105095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041288)(20161123562045)(20161123564045)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:MW2PR2101MB1036;BCL:0;PCL:0;RULEID:;SRVR:MW2PR2101MB1036; x-forefront-prvs: 0600F93FE1 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(396003)(366004)(39380400002)(346002)(376002)(39860400002)(199004)(189003)(10290500003)(81166006)(5660300001)(107886003)(8936002)(81156014)(3846002)(6506007)(2906002)(8676002)(3280700002)(59450400001)(72206003)(76176011)(4326008)(478600001)(6116002)(6486002)(53936002)(1076002)(68736007)(6512007)(102836004)(2501003)(66066001)(3660700001)(5250100002)(6436002)(105586002)(86612001)(36756003)(316002)(7736002)(97736004)(26005)(186003)(110136005)(305945005)(22452003)(86362001)(99286004)(6666003)(25786009)(106356001)(2900100001)(14454004)(54906003)(10090500001)(2950100002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:MW2PR2101MB1036;H:MW2PR2101MB1034.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: h3klCQqfyNW185BLQZf6jUVbmXYvuMqjJCz66f7hjJgdjJvOTZz0MLAZv33bQQsp6chjvah54LVWfmROUGbNi1MdfPyB3tMMHJNCJ0OHdz97Phy3ABr+b33i4iG+EA8FA5PZbHy6G6HQwyyx/+tGMRAqPFPEDTlqmfcdnwkkzQk= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: df868126-5dee-4c19-1692-08d581569c6f X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Mar 2018 22:28:25.5412 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR2101MB1036 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- net/batman-adv/bridge_loop_avoidance.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge= _loop_avoidance.c index e7f690b571ea..5419b1214abd 100644 --- 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 *bat_priv, st= ruct 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 dete= cted. 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 dete= cted. Drop packet.\n", + ethhdr->h_source); + goto handled; + } } =20 /* check if it is a multicast/broadcast frame */ --=20 2.14.1