Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp731248pxx; Wed, 28 Oct 2020 15:51:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxgiLET7eP4aTmFPvpIoBADHMWgAlEj1CtHFxmfNBULlJTUdiM6VYfVK47wW8RAue3EX/Q X-Received: by 2002:a17:906:34c3:: with SMTP id h3mr1344000ejb.132.1603925494075; Wed, 28 Oct 2020 15:51:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603925494; cv=none; d=google.com; s=arc-20160816; b=NvIG6JUn3QQlfc2xoVzg8mrBcFnAVEhfrZG/GY7WWs5maog2h4K/4Zra9orHPnaddW 1/WAiwGSl8VY66/6EOYxFulef2sWwG6DdyM+SNfk7bEsCycck7J/fXH8HHSD6rpcxfj1 Ga5VvtXyqeXc00PiJmsVZsQWTVNX6i3pcePEVZrWNdv1i52isPT42Qn5Qxcc/fKlB7Rw VM4XsS5iZ5YDCH9C10ScIH3deajH4G0b5AmCh8TwAcKxoHwob0Q7cXi7s3U1Z7kYYxQ2 LHDNe++Tjl8/VyhZmfJ56KbESbvBFktIKJCsPv0valXFy2O8iyHwnj4pHUi6Yl5eVI2h 9sQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :sender:dkim-signature; bh=j9PRoCK9JmS5PHro2aXk4eIPqO/Hcdx6BXy0bDJAfRw=; b=SD6BgJq82Rx9RYo5+YugnUv0egPkYS5ZkTXiYsvqoFJpg+yxyH1agn/urrA9MZTdKg OOsn57SHWnPaNQWFs8ZgJn6RPiGg7oXbOBNzuPyvalVbvpVi41cNKh4IAvxnE+xaXSdC 6QhDh8NbvwWMVhXDn4a3S8y7P7z5+mgYCFe53q1BDxjjy+pjrKgx5JN3iynNE6CBeGfa /QuDa1GaNsizdNJYnnsb8RE77cIdMr8HHc+Ixg13bQB5d10OegjzZ4Rjcxk7LvfIGGlb 0aTOep41fojgDa4h48+0bTwaooTahKo+JI6/zeJxf6xq0jfg5MTX+0wUujNG/YJyVh8o ocIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ku5BbWZP; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bs11si733267edb.24.2020.10.28.15.51.00; Wed, 28 Oct 2020 15:51:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ku5BbWZP; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730232AbgJ1Wuf (ORCPT + 99 others); Wed, 28 Oct 2020 18:50:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389556AbgJ1Wud (ORCPT ); Wed, 28 Oct 2020 18:50:33 -0400 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D02CC0613CF for ; Wed, 28 Oct 2020 15:50:33 -0700 (PDT) Received: by mail-pf1-x44a.google.com with SMTP id s12so579169pfu.11 for ; Wed, 28 Oct 2020 15:50:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=j9PRoCK9JmS5PHro2aXk4eIPqO/Hcdx6BXy0bDJAfRw=; b=ku5BbWZP8UwJEoyy2Tb91sFXbjQSlaT1x7nuWb4QgVtbJSfqABqnpzFi7sHW1exI7U Pki1mUrq5Tp38JPg5LkaHFOB08txL5BHyivV8dg4hiVzEov7MPku8BKo29VQRl/XhOgx xexnDHRxyknCTAVJtN9PYNYd3gsEb47cxXtfavNxiZv0VxRjNGeYb2TmfE/krXP7YXdJ Ju2EC82wisifEnxKa8KAr6JX+rrjRDscyMj2QwF0lEy0HTonFkykwSFvDpuLJrLoFqJ3 U1EFkvuVjhx94fJhW5rRog+b/pYMGrLmuKMdKel+Nu2LQoqOZukwudBsL7Kxk1aoMsbh NtRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=j9PRoCK9JmS5PHro2aXk4eIPqO/Hcdx6BXy0bDJAfRw=; b=HOQA2wxM6t2Inpm7zKSvpwmZjI9YCKyFmnA5XZMfJl3mWcbg/HD2lKughl0o/IFSOC Ncl41fCo3J57oIsWi93Uv9uDkC3Jpn5yvhH0tw1oApKgVB9aZGj2njOM64n+kKrHlB2R rAJqYGmY5QFwGYLWTQZ8vBSuKzF8ouHeC+Z0UZwhCiTF/3nDn2KwnhZvqhtIe3qqOU35 yQwl3vv1Z2LNE9DGg/7kMB/F1Un1cxql4+OHkj674tao63F0RrujVxi8TW6/l4Vc3Nz+ /zuUYG0peQdhcBKj9DrU6FMnZObTcozt9JqnKedpXdv3ZSzfTo6mbON1O/qmXzVgF7GF zjOQ== X-Gm-Message-State: AOAM533wZHUu8yjgI8ZbLmG9uXH6MtZHspyvgISqJbmt4RRq1Lrb5+rK J4cSWD21pqS6iM3vLRbREk2jqxl7lv8SBBfDcFz2 Sender: "danielwinkler via sendgmr" X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a17:90a:d713:: with SMTP id y19mr274822pju.87.1603925433054; Wed, 28 Oct 2020 15:50:33 -0700 (PDT) Date: Wed, 28 Oct 2020 15:50:13 -0700 Message-Id: <20201028154914.Bluez.1.I8216fab388e34d8a1373efc71a252c2c5a085564@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog Subject: [Bluez PATCH] adapter: Use initial temporary status to decide device removal From: Daniel Winkler To: luiz.von.dentz@intel.com Cc: linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler , Abhishek Pandit-Subedi Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org When a connection fails, the temporary attribute of the device is used to decide if the device should be removed altogether. However, a recent change to device_bonding_complete resets the temporary attribute so that it will be treated as a new device which will eventually time out. A side effect, though, is that the device will now always be removed in connect_failed_callback immediately, regardless of whether the device was marked as temporary to begin with. This change stores the device's temporary attribute before device_bonding_complete is called to ensure it is only removed if the device was temporary to begin with. Otherwise it will timeout, as I think the author intended. Reviewed-by: Abhishek Pandit-Subedi --- src/adapter.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index c0053000a..9eb60ba03 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -8877,6 +8877,7 @@ static void connect_failed_callback(uint16_t index, uint16_t length, struct btd_adapter *adapter = user_data; struct btd_device *device; char addr[18]; + bool initially_temporary = true; if (length < sizeof(*ev)) { btd_error(adapter->dev_id, "Too small connect failed event"); @@ -8897,6 +8898,11 @@ static void connect_failed_callback(uint16_t index, uint16_t length, * request structure. */ if (device_is_bonding(device, NULL)) device_cancel_authentication(device, FALSE); + + /* Store whether device is temporary before the attribute is + * cleared in bonding_attempt_complete + */ + initially_temporary = device_is_temporary(device); } /* In the case of security mode 3 devices */ @@ -8914,8 +8920,7 @@ static void connect_failed_callback(uint16_t index, uint16_t length, /* In the case the bonding was canceled or did exists, remove the device * when it is temporary. */ - if (device && !device_is_bonding(device, NULL) - && device_is_temporary(device)) + if (device && !device_is_bonding(device, NULL) && initially_temporary) btd_adapter_remove_device(adapter, device); } -- 2.29.1.341.ge80a0c044ae-goog