Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4494356pxf; Tue, 23 Mar 2021 11:59:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzeAnDHMP2RQftH1lzCnbFAvPfT8fNHLLrxnkcmxTPi1V81IjROIWEAdp4IniTziryH93eQ X-Received: by 2002:aa7:cb0a:: with SMTP id s10mr6012865edt.36.1616525965551; Tue, 23 Mar 2021 11:59:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616525965; cv=none; d=google.com; s=arc-20160816; b=NlcQId0UjRY19wcdNSPFKa+AfcTb+/NFYTb8vZd0rIB+x2mV/xr0mu67Rj7tygzTxE uLwTDCJiU6obBECYzp3P6oGGxL8PTMgZCPCtBHAZzjsIcmM5M+RiDmutxeG5aPoxRU/L s53o+ZY2MdzNr096uIygjBLA+U2wxDU1PA0KMETLXFdAcA4UxspUI3WCfYmW0EozMMMz 8sXcP7dMJ7L2nbJJV/uDC5x2HgZ+NOs2kdwIDwBgZJW7nbwtKse+tAzipIpJOEk4GgSJ M49p8/S9OEVZspM4GY+1xWlbAp95z/yng7kvGWX6nLrByuoagzHPiDJJWJS+fVzB3J0T UDhg== 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=RYIeg+FAZo3N58AkdDKWG73SSjjPsdnT5WfpGKmyRWc=; b=ZJAY7g/6zPQBoEdacxPk4hXfUL3FQV5DzNQjl2+ZvSqaxDl3k7AKoIFwMqUicQDVjA in4w2NT5z8Pl9C28z20H0UnmFfIFoxgB4vH8aHf01v3nrFAlZAwCbZzSIsipXo9fZ1mU 5POhCNV+/ssh4YMsTZqYTpT7gYjt5PNfQCoiedRzpGQ54edwpyKIVWV+xduw4VTetw76 /tkXEWavIHaMLaU2+eizlRcATErBOsBRjanDIbV413Aq+kugqW1XkyAtrquJiUTIQase z5TqY+ZL/Awq1vU1vYbWlubeOHTCyCZE6d/NMbMoNNCvdaaqu2C7BTWdJgmVNe6Rt5nD J7Ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=MenOAbW8; 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 ay5si14570882ejb.692.2021.03.23.11.59.00; Tue, 23 Mar 2021 11:59:25 -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=MenOAbW8; 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 S231837AbhCWSz2 (ORCPT + 99 others); Tue, 23 Mar 2021 14:55:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232562AbhCWSzH (ORCPT ); Tue, 23 Mar 2021 14:55:07 -0400 Received: from mail-qk1-x749.google.com (mail-qk1-x749.google.com [IPv6:2607:f8b0:4864:20::749]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CB5FC061574 for ; Tue, 23 Mar 2021 11:55:06 -0700 (PDT) Received: by mail-qk1-x749.google.com with SMTP id c1so2674900qke.8 for ; Tue, 23 Mar 2021 11:55:06 -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=RYIeg+FAZo3N58AkdDKWG73SSjjPsdnT5WfpGKmyRWc=; b=MenOAbW8u/FEj1QE4zVvDCRZ3GxvMYxHAqW/vQq1Otd/70qUmEd+Epa4Fr/Dul15+M EdpQqtmL3TaqapOrXmNEUDv2bxPuNniHwyodHkRl05h94uYjYIaMz/gpUfzCS5XEXqKo Is1CoCpXx0H11blhGVhdIAxQLJPMsPvgB47eKtnzVFguZPC3aHgC9VgEko/q96AEzF+A IvfQ6Af5wUoN5ctwn+F3LrI4Map1O26i3DAwxU6GazWtPDMp3mhMlMIEm4xJxQDYZ+02 JAMtyR3mz9fAi0rz7ALfg6YGlcP7RtmATbMU5wSgpg+TW1ISXRWUSa7y7qqBEiyx8dIs BCdw== 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=RYIeg+FAZo3N58AkdDKWG73SSjjPsdnT5WfpGKmyRWc=; b=D4zK6RUblDtjnvFSEK9awalS6RFXFwjZuZOUaWQ4cwsAKwU6wbdCusLxWltOBmA3Ml bxzXOysUnC7phDtdHamTxOC9thVNyJslsWaYtjc12wT8DisV534YteOTC91g7wtm1oFf 7e6QDJaUZAh7Hs/kBvCXhRhwR2REyYf/SqnD+Yv9BoF9UXz/+wzjeCd+PcakeeDQxJdE TvNWLoTUGYtEaHW2eEHarlU1hHpm/VW/GKrADgR+3g52DAyi6N6NRe7dkVsnMyQq3FaR /eRmN450vKGXTlWFr38oztAXmrn3vSex09oCe2lwWS2NKpFDgAsdJgfbs2Q01YlbO4tH wBHA== X-Gm-Message-State: AOAM532JcALyiDJsGXplCCiiumaP71EBUMYoCVeM4OaNx47xVo9lf491 w+ADEdP3dWrUgmYXrpEBnsqhfMbIRQmm X-Received: from yudiliu.mtv.corp.google.com ([2620:15c:202:201:a916:b584:a08a:3fcd]) (user=yudiliu job=sendgmr) by 2002:a05:6214:12a1:: with SMTP id w1mr6227626qvu.57.1616525705227; Tue, 23 Mar 2021 11:55:05 -0700 (PDT) Date: Tue, 23 Mar 2021 11:55:01 -0700 Message-Id: <20210323115459.v1.1.I3f19b22d6eaaa182123e373a9fa1fa85105aba07@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.31.0.291.g576ba9dcdaf-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..d66bc6938b58 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_DIRECTION_OUT 0x01 + #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 90334ac4a135..fc0ff6dc7ebf 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -8772,6 +8772,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_DIRECTION_OUT; + else + flags &= ~MGMT_DEV_CONN_DIRECTION_OUT; + ev->flags = __cpu_to_le32(flags); /* We must ensure that the EIR Data fields are ordered and -- 2.31.0.291.g576ba9dcdaf-goog