Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1514543ybf; Sun, 1 Mar 2020 11:16:32 -0800 (PST) X-Google-Smtp-Source: APXvYqyovaWip9hIYaxBXlFrxlNNo3SQYPCETZuCfnvzL1zVlCj7WOxCI56ctx5vWZ6KjaOlyQpI X-Received: by 2002:a05:6808:4c2:: with SMTP id a2mr8960577oie.118.1583090192849; Sun, 01 Mar 2020 11:16:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583090192; cv=none; d=google.com; s=arc-20160816; b=OUWWQNcr+cvmygjuPWeDh/IfdOyI9E0ycb76v8cjBgV8JlcwOZxj9NKKDGDllcenaj s7UObtCOsFQnk17nAGu+f5MLIL0Nbj1ZptXVRggSeH0dqWDLzC5autrJZiuOGLsEiSi+ Xd9edCey15SUJKmaiPYB3U+2jPT+xgRtENBgqBAlH3cuzayvZHqNfChMxvb0ZUZ9lZG+ Mmqh3Di9a8G4ik5pt+UfV058RaM9ByixN7yaR2EIteVRusqheO08FCM+1CmIrPArCjSg korFclU2w53BUh/z7hsW3R4szSH+P96SBLbKNs2A13gQ7dT9xW5BnFvv29r1C86y6cWU kEZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=7BtwWmGqlMfLRFx10LsAlrYvxOig9qCTrlkBwPALNEY=; b=NNla64jDCzQUvEWotUm66gAmtxU5mEDtZS1jpRKkVjvu14JvmJ+rW2NEw5fGGftDAC Ev1rQkaju86Z0j6CZ842OXJ7tAd9mTyti9SzQDILkiCcjknfWTTqHNXpe5SQW/T/qT3e 41hQN2GJvRQx7wz3nYpCBIVWAebZou9JQi6GHTJyu6nxjMNv8SamZL+gArjTsRQsB+8P b+pLcR/Af1/xislmmgvU+QErpU5fxR9gKmFtciEuL8oVPnz3Yul1BV287j6IwKEguBog 4D4Bc4LgLz1upv4sa1fXADFGfXJjXLgwosVFVgGzIN1wOce8cBLdjYd1dyu5Ad5KD6Js oo/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dlBuD5no; 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 u6si1095330otg.73.2020.03.01.11.16.21; Sun, 01 Mar 2020 11:16:32 -0800 (PST) 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=dlBuD5no; 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 S1726579AbgCATQQ (ORCPT + 99 others); Sun, 1 Mar 2020 14:16:16 -0500 Received: from mail-ot1-f52.google.com ([209.85.210.52]:33680 "EHLO mail-ot1-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726188AbgCATQQ (ORCPT ); Sun, 1 Mar 2020 14:16:16 -0500 Received: by mail-ot1-f52.google.com with SMTP id w6so7593294otk.0 for ; Sun, 01 Mar 2020 11:16:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=7BtwWmGqlMfLRFx10LsAlrYvxOig9qCTrlkBwPALNEY=; b=dlBuD5norKFYCrB+04LYP78AFoST6eVnBdxrdKubyUVyVbOhXVuDe6PEejoyZwvFiC Gx+nPF5vRlUF8EEQmlhK7L4l/YhYuW682brNWDcDeyDfkhYP6g5526o+ygBjpM9oyI3N 8yEpGdVIduQW9MEIRUVjHgSfR9MwR+4Zge1Xbax3gG3nDcapkRzmVP4ZaXT9tesnqB+O BQlOMOziaRCwHRYCBNehYpJNbR2qhjtNXJwM+Y2Tjz/6MMifV1G/u19p9ZiOo1wG3Itk LjoHaY/Cc4gEeia2aoYjF/fK+751kNH1mwObiJ3dfW70hohT/xXWG3ABfyWwpxv7Z3Qf EhbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=7BtwWmGqlMfLRFx10LsAlrYvxOig9qCTrlkBwPALNEY=; b=r26Convy7T+nc8jdF/IKNrkkP56z0iyzwg3ABpCNPhHuQ0LbPAZucfus1SFZBHNo73 ncP4BYAx3k8bfKcUU6EFckUNuoH2q6kMrdrtzV6N8VImt9SyxdSFPLrILgC7H+KSu9lk JlcHBPTidVHqj/TC8ZwqTuDKep9zQd/Os9VN5FDFZpDO5avOrfWcL2if+pbiry7Q0jzv xQtfB9qWbcfN9DyyBVBF6b4aVVN3lYiD7clgmd7iWfOpHaa0DoWfx/hJYmjOmKtEAYJ0 F1JtCJqLTsVQlWk9GzDJRMp5GTEUHHgrGD6G0OYa2ZTBRQlsJ/YHxd/Ndvsh3xxwRdUY /bxA== X-Gm-Message-State: APjAAAWhr+nJIz9Al17NG16Q7U2cv1/49y4DRDsdrKIEytHviVWskPbb SvPcu6FHCKkIHL+Aty03OmPejArC+p1mbpYW8qVegJ08 X-Received: by 2002:a9d:6c01:: with SMTP id f1mr10289689otq.133.1583090175538; Sun, 01 Mar 2020 11:16:15 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Emil Lenngren Date: Sun, 1 Mar 2020 20:16:04 +0100 Message-ID: Subject: Re: Get negotiated ATT MTU? To: Luiz Augusto von Dentz Cc: Bluez mailing list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Luiz, Den s=C3=B6n 1 mars 2020 kl 07:46 skrev Luiz Augusto von Dentz : > > Hi Emil, > > On Sat, Feb 29, 2020 at 2:13 AM Emil Lenngren w= rote: > > > > Hi. I have a feature request that the negotiated ATT MTU should be > > exposed as a property in the org.bluez.Device1 interface. > > > > For some applications it's good to know or required how much data that > > can be written / read / notified in each packet, and it's not always > > desired or possible to use AcquireNotify / AcquireWrite. > > We already negotiate a fairly big MTU maximum by default, and you can > just use AcquireWrite/AcquireNotify just to discover it and the close > the fd immediately, so I suppose we cover much of what the feature is, I was considering having a solution implementable by for example Web-Bluetooth. This "workaround" wouldn't always work since it's not guaranteed to exist a characteristic with the 'write-without-response' or 'notify' property. I think there could also be a "race condition" here if two apps do the same thing (although the time window is pretty small): one app might get that the acquire operation returned "busy". And is it even possible to use AcquireNotify/AcquiceWrite if the d-bus runs over tcp or the programming language doesn't support d-bus file descriptors? An ATT MTU property would be so much simpler and straight-forward. > except perhaps if the application requires something bellow the > default MTU bluetoothd but that can be a problem if other application > would start requiring their own MTU as well, so even if we introduce a > Property that would have to be read-only Yes! The idea was to have it read-only. It's sane to let the BT stack negotiate (a big value on non-embedded systems like Linux/BlueZ) immediately after the connection has been established. There should be no reason for an application using BlueZ to negotiate a smaller MTU than a "big" one, which BlueZ already selects. > but there may be races if the > application start writing/reading too fast or the remote end do > trigger its own exchange for some reason. It's already not possible to write anything after "Connected" has become true but before "ServicesResolved" becomes true (I get "org.bluez.Error.Failed: Not connected" in that case). I assume MTU is guaranteed to have been exchanged at this point, so there shouldn't be any problem for this case. Another possibility would also be to add a boolean "ATT MTU exchanged" property which is set to true when the MTU property becomes valid, if waiting for "ServicesResolved" wouldn't be enough. It should be fine also if the remote end sends an Exchange MTU request at the beginning of the connection since we can then immediately send a response and assign the MTU property without waiting for the Exchange MTU response (that corresponds to our request). In the case when the remote end sends a notification before it receives our Exchange MTU request, then the MTU property would correctly be 23 since the MTU Exchange hasn't finished yet. The list of five rules in Bluetooth Core specification Vol 3 Part F 3.4.2.2 (ATT_EXCHANGE_MTU_RSP) should also prevent most "race conditions". Let me know if you think I've missed some edge case... /Emil