Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1387907pxf; Fri, 9 Apr 2021 07:15:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx12f070SgWJHkRJgn2lKIkGaMh1Xi/7n7yXqwrPxVZtSKdX30Qj6xCeXJlHQN87OFSb8He X-Received: by 2002:a17:906:dfcc:: with SMTP id jt12mr16414284ejc.31.1617977758319; Fri, 09 Apr 2021 07:15:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617977758; cv=none; d=google.com; s=arc-20160816; b=SRPFV4sJvK94i50r3DLDoTvF3Qr2nptlI66cvMFmjwaq+ThRez6OPcPLVepUqk9jQ9 FZM3zBCrE3Sp91AcuHqzr5jxlWy3rBLP2Z+NjxAgaHI1nB4Q9BPxhsxfN8OGcrSDn1xx IK2RIEc5LSeTXl7ZCbpXLjUrQS5zP2nG1GoT/MX3te0Opl2rDzBnPpDCSK9BSD82Subv dS8D+xNyV+1PaiWxSt9PKpK5qfmND+y9p7f4M6XUnlfkA41eYEbI5VVNoTmLGE7KityQ 8k3z6lT1yUs2/dt4mH1Cz8kvoMywiv5k/ZIeFfucY2jQHSvqC3YnO0PGdF35wzi3LmWp XXug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=EQpZqQplSJ8D2lhpOMUYSQSvdp7jKaAU8wekNNJB5jQ=; b=0IKHiHczwLYLCkphQM0l6ZbjxKbl05V1IO6UiLOphVoVCzZJ3EOgAoyp4elix91l0g VUX87+u9vpZCBLqaE5NT+KLTvKVYaaKRxCSJ0j/C4UnuKCMyfvVRLci1qq62RRX3MjDW 4Zmzx/Oxqh+vAi8QLuGVfOFTBxttIboAQ484CHm7Y1hV7REdO2eG8nfboQ0ts2kibuy5 QfLe0s0hLvSyTnG8C/9QEIDDd3VPy7c2QDpPgyBLIikEvFIMHtM/dPMqrP0U2K/1+IYE PuELtK1lGsVYHUx2Yq/12Jvs9RLUVDW9EvgV5EPm/A8DvNHBuDj28H5kqZrXh5VJKS5K 7fEA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s18si2237479edr.441.2021.04.09.07.15.32; Fri, 09 Apr 2021 07:15:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233071AbhDIOO1 convert rfc822-to-8bit (ORCPT + 99 others); Fri, 9 Apr 2021 10:14:27 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:45734 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232286AbhDIOO0 (ORCPT ); Fri, 9 Apr 2021 10:14:26 -0400 Received: from marcel-macbook.holtmann.net (p5b3d235a.dip0.t-ipconnect.de [91.61.35.90]) by mail.holtmann.org (Postfix) with ESMTPSA id 316B2CECC3; Fri, 9 Apr 2021 16:21:53 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\)) Subject: Re: [PATCH v1] Bluetooth: Return whether a connection is outbound From: Marcel Holtmann In-Reply-To: <20210402105437.v1.1.Id5ee0a2edda8f0902498aaeb1b6c78d062579b75@changeid> Date: Fri, 9 Apr 2021 16:14:09 +0200 Cc: linux-bluetooth , CrosBT Upstreaming , Miao-chen Chou , Alain Michaud , "David S. Miller" , Jakub Kicinski , Johan Hedberg , Luiz Augusto von Dentz , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <4E147FE8-F1B6-4EE9-9D7F-FE5656EAB2BE@holtmann.org> References: <20210402105437.v1.1.Id5ee0a2edda8f0902498aaeb1b6c78d062579b75@changeid> To: Yu Liu X-Mailer: Apple Mail (2.3654.60.0.2.21) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Yu, > When an MGMT_EV_DEVICE_CONNECTED event is reported back to the user > space we will set the flags to tell if the established connection is > outbound or not. This is useful for the user space to log better metrics > and error messages. > > Reviewed-by: Miao-chen Chou > Reviewed-by: Alain Michaud > Signed-off-by: Yu Liu > --- > > Changes in v1: > - Initial change > > include/net/bluetooth/mgmt.h | 2 ++ > net/bluetooth/mgmt.c | 5 +++++ > 2 files changed, 7 insertions(+) > > diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h > index a7cffb069565..7cc724386b00 100644 > --- a/include/net/bluetooth/mgmt.h > +++ b/include/net/bluetooth/mgmt.h > @@ -885,6 +885,8 @@ struct mgmt_ev_new_long_term_key { > struct mgmt_ltk_info key; > } __packed; > > +#define MGMT_DEV_CONN_INITIATED_CONNECTION 0x08 > + I would just add this to MGMT_DEV_FOUND_INITIATED_CONN 0x08. And yes, I realize that this is a bit weird, but then all values are in one place. > #define MGMT_EV_DEVICE_CONNECTED 0x000B > struct mgmt_ev_device_connected { > struct mgmt_addr_info addr; > diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c > index 09e099c419f2..77213e67e8e4 100644 > --- a/net/bluetooth/mgmt.c > +++ b/net/bluetooth/mgmt.c > @@ -8774,6 +8774,11 @@ void mgmt_device_connected(struct hci_dev *hdev, struct hci_conn *conn, > bacpy(&ev->addr.bdaddr, &conn->dst); > ev->addr.type = link_to_bdaddr(conn->type, conn->dst_type); So the prototype of mgmt_device_connected needs to be changed to remove the flags parameter. It is not used at all. > > + if (conn->out) > + flags |= MGMT_DEV_CONN_INITIATED_CONNECTION; > + else > + flags &= ~MGMT_DEV_CONN_INITIATED_CONNECTION; > + And then this should be just this: if (conn->out) flags |= MGMT_DEV_CONN_INITIATED_CONNECTION; > ev->flags = __cpu_to_le32(flags); > > /* We must ensure that the EIR Data fields are ordered and Regards Marcel