Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2978723ybl; Mon, 19 Aug 2019 10:11:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqyp2k6uYeV5tbq1Vsi0DoaZBan5SuLEAVGDovKEth43p/n7ObXthZxy8qL8iP13B+q3gLgK X-Received: by 2002:a63:1045:: with SMTP id 5mr20706453pgq.165.1566234702487; Mon, 19 Aug 2019 10:11:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566234702; cv=none; d=google.com; s=arc-20160816; b=L7uufHKrBXrbik1PakLdNFfU6FMPHlWjeudFROZa8jGF7T9EoIAMC5jV3wwF2872rg iNe+u2CYrk7XZpMcstAdnVgLPQxFhR6WPyu0hxqf38d4RBw93DmOkHuljL8p8T3hHQev i2CzqeJSiOefVBIaRz6JwBQzUg9okN02bGHamUxLGPdFmw3MVxX5lsZ2Dnpn0lI2kMR2 OhAfUiPmFRg5gERg91obdsVZpAxoyGLyl+HXRKA5h2ziL+SCD4YB9puAtt7U3TkmAj7I z2xDaUuhR6PZlYWOs2sWaBQrSkV1OFDY30oba3c54mD1KpBH0VD252eRitDaNHhyC7cs B/Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:reply-to:dkim-signature; bh=6vsdPHMc2yAtS4wTo18vV6fkZPfCs+gH5x+BhCkFg68=; b=eFLL6gJlWaiw+6OR82xrmxq1INTJSoQnOtYUuty1H3vbhuxQpVN9JflqH/pDUijSZI a/Us4CrtNQzYVZ0qtD2Fxa59aumo+HA12/MuiC/I/5OHp/ukHSrRYDcWFfClR5FdUZT4 w6GkOWXYtLo4nAc+6lzBtDmLR9yCMrrFO1MX5k6vb1xfzwz2Rzhwjw3/k33bQo8n9Avz pqNJdrO6Eo1dtofUtr77NMplNcO+Y0PiENN98Aw7GeuxXjlzLH9SbbrOgXERVO9D4+U3 Q3+zjkKlxAYGnbCKyJNDKBxiiEtF0VOh9PqZU1fRpj4LyOnuVk6f13+t5pZjWUbYOipV On+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jQ2I1Qcx; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g4si9347758pjt.70.2019.08.19.10.11.27; Mon, 19 Aug 2019 10:11:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-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=@gmail.com header.s=20161025 header.b=jQ2I1Qcx; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727653AbfHSRKw (ORCPT + 99 others); Mon, 19 Aug 2019 13:10:52 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:34609 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726627AbfHSRKv (ORCPT ); Mon, 19 Aug 2019 13:10:51 -0400 Received: by mail-io1-f67.google.com with SMTP id s21so5930282ioa.1 for ; Mon, 19 Aug 2019 10:10:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=reply-to:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=6vsdPHMc2yAtS4wTo18vV6fkZPfCs+gH5x+BhCkFg68=; b=jQ2I1QcxId45JVLbg9s2h5Q7QvskvoLkNg1IAPIGwqH0gr1+jpuNKWFvFRFmx8FZlU PWZeL9Y1lokEh7Gu7FKCnDp+l64coL16QSMttgaFrMYuWMJHW8nbH05tfqtusBk2kzxa Gk8PUp5Z+ChSNGZxVBnMKDbXkqcGIbwYjrwtlBBcIAstsRPqJsqVLNNeU6DiK7QvGyEB nAXnVbq4sUXOjbKV2uuz0lZWJ0312vVXdHzqCuTUYbpc9+ZWABey4sQDba7WKODxYHdd vQkfm5Fug0uTe/ai3ilBC4/HtyG2f7YNv199tQF2u/kILPCzQ0BKmbfRUQzJqwlbhqmH afwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:subject:to:cc:references:from :message-id:date:user-agent:mime-version:in-reply-to :content-transfer-encoding:content-language; bh=6vsdPHMc2yAtS4wTo18vV6fkZPfCs+gH5x+BhCkFg68=; b=HfU/fynmlCkuksPlaF2P+dPun8pvwL4AUZY9Pw++zO00Rm0IgAczifNYfHkmoO7GOZ EA57sy1KFxi1t04b3UFVczNsoRd6etx6P17vWWvGUC4RawPf97aQWfFR9C9rK3GR0brI i9pkMYtrtbps7SPTS7YUlrJqtHHNBaSVE3dS1pC5w5cdHtzRr3vYuD5WaThh9k+k7iCf wriVznoDYbchzdhf0uL68GJsCZuyzBLCHNV1nNTda3bqo+BwHCsg1E8wYq+7UDsBWKFI tdmVj3BH3J0yfzu7TnVIHu96Y7n+MhLCIZUKNU/z7R5Mjyq2kh6tbEigH6Q1jWI21Bf5 OiHQ== X-Gm-Message-State: APjAAAXE0NHMI61Juy8lAmlcXPEWtWB60wAqvUm8cpVy7lJq/07U05P7 5ZQhaiEk2OnFLLuUAWaCauE= X-Received: by 2002:a6b:ed09:: with SMTP id n9mr478208iog.153.1566234650738; Mon, 19 Aug 2019 10:10:50 -0700 (PDT) Received: from [10.1.1.187] ([8.39.228.178]) by smtp.gmail.com with ESMTPSA id k3sm22063326ioq.18.2019.08.19.10.10.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Aug 2019 10:10:49 -0700 (PDT) Reply-To: csonsino@gmail.com Subject: Re: [PATCH 1/1] bluetooth: validate BLE connection interval updates To: Andreas Kemnade Cc: Marcel Holtmann , Johan Hedberg , linux-bluetooth@vger.kernel.org, Sasha Levin References: <138296C5-49FA-475D-9618-FC8D241B8823@holtmann.org> <20190815104419.161177fa@kemnade.info> <0cda8242-304e-a073-90d8-63e656e3600c@gmail.com> <20190819180813.04a8e771@kemnade.info> From: Carey Sonsino Message-ID: <624153c1-d462-1d6d-ddb2-ac7c03575a2c@gmail.com> Date: Mon, 19 Aug 2019 11:10:48 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190819180813.04a8e771@kemnade.info> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Andreas, Considering that this patch has already made it's way into stable trees, and the only options are to back it out or to patch it again, I would obviously prefer to keep it in and patch it again.  I think that it would be fairly quick and painless to just set the default min/max to 6/3200, or add an additional flag as you suggested, which should resolve any problems in the near term. Longer term, I think that there are several ways to allow the system admin to configure the allowable min/max, but it only matters if the system will check requests against the configured min/max and respond appropriately, which is what the patch in question does.  The best current way that I'm aware of to control the system-wide connection interval is through the existing debugfs mechanism, and in my opinion it didn't work correctly without this patch. Regarding power consumption, I have not done any power measurement testing to determine the effect of connection interval on power consumption, so perhaps that was not the best use case.  Here is the exact real world use case that caused me to write the patch in the first place: I was writing a Linux-based test system for an embedded BLE-communication based product.  The product embedded code was written to attempt to renegotiate the connection interval to a fairly low number after the initial connection was established. My test system had a requirement to be able to perform the tests using various pre-defined connection intervals so that I could gather data throughput and product performance metrics.  Every time my test system attempted to perform a test a the desired connection interval, the device would immediately request to renegiate to a lower value.  Linux would accept that request and return a successful response, and I had no way to stop it.  Let's not go down the "Why didn't you just change the embedded code?" / "Why doesn't Linux reject values outside of the configured bounds?" rabbit hole...  :) Carey On 8/19/19 10:08 AM, Andreas Kemnade wrote: > Hi Carey, > > On Mon, 19 Aug 2019 07:58:19 -0600 > Carey Sonsino wrote: > >> This seems like the exact "downside" situation that I described in the >> patch writeup. >> >> I would still claim that as a Linux system administrator, I should have >> control over my system.  If I am operating in a low power environment, I >> do not want to allow a remote device to apply a setting which causes me >> to use more power without any say in the matter. >> > In principle I agree here. High connection interval has its downsides, > low connection interval also. Just curios: What are the numbers about > power consumption here? A few mA? I have only compared these values on > peripherals running on low-power SoCs like e.g. the nrf stuff from nordic. > I see around 1 mA difference there with a power consumption besides of that > usually measured in the µA range. Never tested these things on a linux machine. > > The point here is that with this patch there is insufficient control > about this. Yes, there is the debugfs interface. > > But if you want to provide a driver to a gatt service living on top of > bluetoothd dbus api? Ask people to not use distribution kernels? > What options do you have? > using the monitor interface to sniff the connection handle and then > call hci_le_conn_update() to set things? > >> The connection min/max interval settings are configuration options that >> control how my bluetooth device operates.  Why are these down in debugfs >> anyway?  I think that a much more appropriate fix would be to migrate >> some of the BLE configuration options to sysconfdir (some place like >> /etc/bluetooth/ble.conf).  That would also help in the persistence of >> these configuration settings, which is kind of a pain with the debugfs >> mechanism that gets wiped out and recreated on bootup. >> > I think that these things should be part of the dbus api provided > by bluetoothd so that a driver could decide and having defaults outside > of such a dark corner like the debug fs. > >> A quicker fix would be to simply set the default connection min interval >> and connection max interval values to the full range (6, 3200). > Or just maybe a flag allowing such behavior? > >> *think* that this could be done by simply updating the values in >> hci_core.c, the hci_alloc_dev() function: >> >>     hdev->le_conn_min_interval = 0x0018; >>     hdev->le_conn_max_interval = 0x0028; >> >> would become: >> >>     hdev->le_conn_min_interval = 0x0006; >>     hdev->le_conn_max_interval = 0x0c80; >> >> This should allow all devices to negotiate whatever connection interval >> they want by default.  If I'm running on a device with debugfs (which I >> happen to be most of the time), then I can still override these defaults >> to control my system. >> >> Please let me know if you would like me to do any further work towards >> resolving this issue.  I'd be happy to test and submit a patch that >> changes the default connection min/max interval values- I could probably >> get that done in the next day or two.  If you would like me to >> investigate migrating configuration settings to /etc then I'd be happy >> to do that as well, but it might take a bit more effort and time. >> > Well, all these things are important, but are new features but there is a > problem: > The kernel patch has gone into the stable trees and from there into distributions, > so how can these new features flow down the same path. > > Regards, > Andreas >