Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1455882pxf; Fri, 2 Apr 2021 10:56:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpYerdUhvpa8Qi0+H8Yj3yitkC7/qPuQqrB/qo8aWeqFm9Lenx3DuohpJ6qApulmH0R5MI X-Received: by 2002:aa7:cd54:: with SMTP id v20mr16871875edw.80.1617386167292; Fri, 02 Apr 2021 10:56:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617386167; cv=none; d=google.com; s=arc-20160816; b=DcYmV8OD3Hm+mkQptyFpNqXGPjVllgWoQhkiigCBBTBLPBEyr4ICI0rtMK23mcVdZ5 1H+IQY8xIFkOyLvdjN4q1ifW1h9EDXk8zf9F4Tl2gNlWs4Fc7yDaYGer7gYcxRcQUNa3 mcu/zEMmsaw3M/s19j8kNUt+YQ8/CGKmtWANFEnxZ2KqmkECD2I1SRiizF9Qt4wFQ3g6 eGkvLjmbhz6Kbv2E0CeI0Flvd8QFz9UHvH2OoAHu72qp95IiZfDNiqA2O70PYuPp+XLB v5iponec/jqUg5ScXuqflK8sBjN1SanbFQxuNVWne0z7MMKE4lsn3FzxbNQnEuWs+z5L wTSw== 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 :dkim-signature; bh=H/QN+XLAOQblK5KA0ufolQMfBhTIuBh3TpbLAoLglYU=; b=Uoqvpjr8SpNvM66Qk4OA48E9LWKrnGrw5UGP0iUvGY3Ux3emo7zVbe7WP8LpIncOVg Fe3jkYsiT25eDo2H0l9rFS/aPCeUabFRusv7VwFVWJVYgxC+aFJIjQ7oUbJwwcgupQXv uHTOyVLZqRqboTFsqS7e77P7ZqVKgoFTpkpf8+xExGuMfvfCCUGOAbfKRVDWXH2UUSxO aW04HsFbDsCstfe5XySbJMDvpEev84yDZUqUAcq3K2SYDl6LYY+bC69/plMGygretDS5 r3ckjjDplr63FjdGuee5VkkeBmlO9cMIGTszarcOap95EnjPmmL0S2/eEMTbfzLE/NBX 4wOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=YVISu5OC; 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; 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 h12si7830494ejx.570.2021.04.02.10.55.44; Fri, 02 Apr 2021 10:56:07 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=YVISu5OC; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235113AbhDBRyv (ORCPT + 99 others); Fri, 2 Apr 2021 13:54:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234207AbhDBRyv (ORCPT ); Fri, 2 Apr 2021 13:54:51 -0400 Received: from mail-qk1-x74a.google.com (mail-qk1-x74a.google.com [IPv6:2607:f8b0:4864:20::74a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92271C0613E6 for ; Fri, 2 Apr 2021 10:54:49 -0700 (PDT) Received: by mail-qk1-x74a.google.com with SMTP id p133so6124697qka.17 for ; Fri, 02 Apr 2021 10:54:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=H/QN+XLAOQblK5KA0ufolQMfBhTIuBh3TpbLAoLglYU=; b=YVISu5OC169fQpXC59PG7UjpCT2nVConTKQq7BlmNxFw1NwTbpa8+Dx45CDJmkBANz Cwyb4qWFklymIw3FoLDpQdNCpfOP8zE7zeZq2BGCpbdBnxnJ4+J1CPiU5FEqoJRnSTDp nH++68MoadOxp9NDhN4HJPPtmEAnXJ62EQdEiEhGtH9Z/g538baHVzV1vO6cjBdBA2xS drA7pZWdLHSsN3tju9dfz1bOfitw+vdP0HGHg1GFjQt4WYXnAoKnFXVM9KvfW/ilPvwm Vx97iVt4M/HUF4Q+b12qjqje+btT0wl+5TxpZoowhk3ttOIjm93yvmgG0soCO7XJ0uAU lx1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=H/QN+XLAOQblK5KA0ufolQMfBhTIuBh3TpbLAoLglYU=; b=ZsENOH1/zekAuic5hDVm3uCZIPQor188t57+hT3V+VsS2Y2MtkQ39yBWV5asjZBLMx 1LKeFnAuCNX+YptcYwUZ2vKVLn/bXgQpvNbeCyE4zWqyAg9Sm+5uzjUCPcKSK9tWmAcT 2HNtsXBU9XWyFQ9oAOrmXSwKNb8EqD+ikpwjT/Xttox3eH34suaBRejVc5StZTV3bOX8 DF0bCcJPYinEe95jiLE0sNSOEsfSMCZxbFSGIR8abSwaBazD6nff1lSQEVtNOLP9CmWb aLw7adkSUogbSpEMvjWAn27casJqbpmlCW2v32XfWpVSNhKyqPaNfm3Nd6wV8osNHfLN mdVA== X-Gm-Message-State: AOAM531tHBMoExrVsJ/HtcciSiFcPEa/dqbwKG8yVnxGlIpnurE6tFrT kBXyQDHwb7sKRWEdtb1frJYxm5edkZMF X-Received: from yudiliu.mtv.corp.google.com ([2620:15c:202:201:a4ba:ce38:21e0:52a5]) (user=yudiliu job=sendgmr) by 2002:a05:6214:2507:: with SMTP id gf7mr13843817qvb.40.1617386088760; Fri, 02 Apr 2021 10:54:48 -0700 (PDT) Date: Fri, 2 Apr 2021 10:54:44 -0700 Message-Id: <20210402105437.v1.1.Id5ee0a2edda8f0902498aaeb1b6c78d062579b75@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.31.0.208.g409f899ff0-goog Subject: [PATCH v1] Bluetooth: Return whether a connection is outbound From: Yu Liu To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, chromeos-bluetooth-upstreaming@chromium.org Cc: Yu Liu , 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-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 + #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); + if (conn->out) + flags |= MGMT_DEV_CONN_INITIATED_CONNECTION; + else + flags &= ~MGMT_DEV_CONN_INITIATED_CONNECTION; + ev->flags = __cpu_to_le32(flags); /* We must ensure that the EIR Data fields are ordered and -- 2.31.0.208.g409f899ff0-goog