Received: by 10.223.185.116 with SMTP id b49csp1074390wrg; Sat, 3 Mar 2018 14:50:52 -0800 (PST) X-Google-Smtp-Source: AG47ELt0UMPMVnnEPgmBslkwp+JbovX83M56K1yTieZr5swrjkQwM79o5zGYLNPO3Kw8ExgNPv7l X-Received: by 2002:a17:902:6c41:: with SMTP id h1-v6mr8788064pln.25.1520117452711; Sat, 03 Mar 2018 14:50:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520117452; cv=none; d=google.com; s=arc-20160816; b=lZ/lD4vvOR0/bL51VJQgynUQtILAiHni1jT4cKN8M8aqOi1oSc1x45xOP9QEuh1k4A enwo0WMyLnnwGH39b+ozPpce5tSQ2WcT2zhnBRM5TMX3lRjU7YkI0C1MpL0R3yFbkTEf v/t3Fa0wxGuTryNVwffLQyn4GYVcfQDHCn3Sroh7cTW/UubX0fMVMLXvFhUsBNIlt+qA Q+omA/8DgTlkNYoUShMBlxqdRkN64EoA4KIQmLrPePiE3UaMqLi+wQ9uIaLWBjvuAJ0D 9Xi7SKVPi+Phhpks/o6zgJzSViMSnY6TkcxmfAdMvYqY5PewR4wyrXXsfssJZyzLG1St W/SA== 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=lCFmITn4jzgVRBhec6c2W4mnespfi0pd0vdn+lpjm1w=; b=I4sGY1WrGdWJP/Od6nIbNkRt7A44Yh6n4zjh1lZNIoibl5B9ryv2GXFv8tw0YXSc4n WjdH9P+QZH6GlGHxl/mHYKNI4s5xqfVOR6HVDcKcTCewHiWHjjSfoIit4GmVTQe+GrNj VDUTNNMkdcSrlEe8zOi64jtbqtYYNMTgsAbdAST1fEIpsclW3bff9yOmhW3mUM2UXYwl iu9cPkeNAahbsECMJC6YP3WiZaUeZxxNCLuDfJku0u5R+NGG+lvdmTHVHu6hKFwysDqr +y0cSxyX7cZttWM029goIDgKLBu5OP+CRfyFCnIl9MlXBFVRq5lab89N5Ze+T3JD0US3 aHrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=Xkt6jvbS; 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 c18si7392322pfe.335.2018.03.03.14.50.38; Sat, 03 Mar 2018 14:50:52 -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=Xkt6jvbS; 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 S935482AbeCCWlQ (ORCPT + 99 others); Sat, 3 Mar 2018 17:41:16 -0500 Received: from mail-by2nam01on0095.outbound.protection.outlook.com ([104.47.34.95]:48488 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S935391AbeCCWlD (ORCPT ); Sat, 3 Mar 2018 17:41:03 -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=lCFmITn4jzgVRBhec6c2W4mnespfi0pd0vdn+lpjm1w=; b=Xkt6jvbSMSL4urlgopqxwm6LmuhWDXqvHI3fOAqZsTCJ8t1ncXVFquVHUMcB2LMTCiF8xH8d7J8niYqddZcDza+wnwCVkmobaDQtuxMfO7zt8gNmk8JxXFILhlTZwdPmXScY9ANsQKn/QE1c8x68BJVzlNDysMuzBV9ZQDDuXjc= Received: from MW2PR2101MB1034.namprd21.prod.outlook.com (52.132.149.10) by MW2PR2101MB0940.namprd21.prod.outlook.com (52.132.146.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.567.5; Sat, 3 Mar 2018 22:41:00 +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:41:00 +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 3.18 13/63] batman-adv: handle race condition for claims between gateways Thread-Topic: [PATCH AUTOSEL for 3.18 13/63] batman-adv: handle race condition for claims between gateways Thread-Index: AQHTsz+fhla13OONNk+XVwrKVe6Jfg== Date: Sat, 3 Mar 2018 22:33:16 +0000 Message-ID: <20180303223228.27323-13-alexander.levin@microsoft.com> References: <20180303223228.27323-1-alexander.levin@microsoft.com> In-Reply-To: <20180303223228.27323-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;MW2PR2101MB0940;7:OVCavPsplDNlR6wxvwOx0PPQYrqSt9RKF+OzOTP7fwcclTx8f7Dct5QMVY2cr/RH88fVJuFoilW2RcWzznqzpIF/D710v2WKZs2SviuXJyyQq9rX4QfQOj6GTnz4hgf5pYF6/pQVhyNYb6E3BrJViHuFHsKbfyNQz0lDdQXiXN4NLvvrjRGG2bR7lRgfbIboNpQMldjEWTxpb5LXGN8fYWae/ncEmIY9hpbV1mOXp5vIo8k9DHU/Ri4YfV5pnWiA x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 98f8fce1-d233-4632-a43f-08d58157d6a8 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603307)(7193020);SRVR:MW2PR2101MB0940; x-ms-traffictypediagnostic: MW2PR2101MB0940: 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)(5005006)(8121501046)(93006095)(93001095)(3002001)(10201501046)(3231220)(944501244)(52105095)(6055026)(61426038)(61427038)(6041288)(20161123558120)(20161123564045)(20161123560045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:MW2PR2101MB0940;BCL:0;PCL:0;RULEID:;SRVR:MW2PR2101MB0940; x-forefront-prvs: 0600F93FE1 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(376002)(39380400002)(346002)(366004)(39860400002)(396003)(199004)(189003)(106356001)(68736007)(6486002)(25786009)(22452003)(6436002)(186003)(2906002)(81156014)(81166006)(10090500001)(66066001)(8676002)(36756003)(6512007)(2900100001)(316002)(97736004)(59450400001)(102836004)(53936002)(6506007)(3280700002)(26005)(4326008)(5250100002)(305945005)(2501003)(76176011)(2950100002)(86362001)(99286004)(3846002)(72206003)(14454004)(3660700001)(478600001)(1076002)(5660300001)(10290500003)(6666003)(6116002)(7736002)(86612001)(107886003)(110136005)(54906003)(105586002)(8936002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:MW2PR2101MB0940;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: xHzr4roT6ZZXboZZoaRQ2ihv0qXo3EkCa57wVclavn3malmwg3FENxA3Q4Z97lSF3F002VGS+VoWDnnDf0YtAf67zsUy4Dj0Hl4tmzE5q23IE13/+BoZ940IuWWqwOkKNeA69iAs2+rTZbssbw8ZIxFhFcVbbA+9JKGLEcyFbh4= 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: 98f8fce1-d233-4632-a43f-08d58157d6a8 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Mar 2018 22:33:16.5441 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR2101MB0940 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 a957c8140721..9906e177131c 100644 --- a/net/batman-adv/bridge_loop_avoidance.c +++ b/net/batman-adv/bridge_loop_avoidance.c @@ -1596,10 +1596,22 @@ int batadv_bla_tx(struct batadv_priv *bat_priv, str= uct 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