]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
Bluetooth: Return whether a connection is outbound
authorYu Liu <yudiliu@google.com>
Fri, 9 Apr 2021 22:04:06 +0000 (15:04 -0700)
committerMarcel Holtmann <marcel@holtmann.org>
Sat, 26 Jun 2021 05:12:23 +0000 (07:12 +0200)
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 <mcchou@chromium.org>
Reviewed-by: Alain Michaud <alainm@chromium.org>
Signed-off-by: Yu Liu <yudiliu@google.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
include/net/bluetooth/hci_core.h
include/net/bluetooth/mgmt.h
net/bluetooth/hci_event.c
net/bluetooth/l2cap_core.c
net/bluetooth/mgmt.c

index c73ac52af186946c635cb3bf7678935c9ef6a531..8f5f390363f54107c39e9e1e93f537425e279660 100644 (file)
@@ -1768,7 +1768,7 @@ void __mgmt_power_off(struct hci_dev *hdev);
 void mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key,
                       bool persistent);
 void mgmt_device_connected(struct hci_dev *hdev, struct hci_conn *conn,
-                          u32 flags, u8 *name, u8 name_len);
+                          u8 *name, u8 name_len);
 void mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr,
                              u8 link_type, u8 addr_type, u8 reason,
                              bool mgmt_connected);
index a7cffb069565174eb4be22d7c530f10a2b316e52..a03c62b1dc2fbd66ec1cd158dd68f81e03f73710 100644 (file)
@@ -939,6 +939,7 @@ struct mgmt_ev_auth_failed {
 #define MGMT_DEV_FOUND_CONFIRM_NAME    0x01
 #define MGMT_DEV_FOUND_LEGACY_PAIRING  0x02
 #define MGMT_DEV_FOUND_NOT_CONNECTABLE 0x04
+#define MGMT_DEV_FOUND_INITIATED_CONN  0x08
 
 #define MGMT_EV_DEVICE_FOUND           0x0012
 struct mgmt_ev_device_found {
index ea06b010ccad76659ee3ff4892add9f2e54ab3c1..59c5329354e122d6d66809c0e0e390e284961713 100644 (file)
@@ -2069,7 +2069,7 @@ static void hci_check_pending_name(struct hci_dev *hdev, struct hci_conn *conn,
        if (conn &&
            (conn->state == BT_CONFIG || conn->state == BT_CONNECTED) &&
            !test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags))
-               mgmt_device_connected(hdev, conn, 0, name, name_len);
+               mgmt_device_connected(hdev, conn, name, name_len);
 
        if (discov->state == DISCOVERY_STOPPED)
                return;
@@ -3256,7 +3256,7 @@ static void hci_remote_features_evt(struct hci_dev *hdev,
                cp.pscan_rep_mode = 0x02;
                hci_send_cmd(hdev, HCI_OP_REMOTE_NAME_REQ, sizeof(cp), &cp);
        } else if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags))
-               mgmt_device_connected(hdev, conn, 0, NULL, 0);
+               mgmt_device_connected(hdev, conn, NULL, 0);
 
        if (!hci_outgoing_auth_needed(hdev, conn)) {
                conn->state = BT_CONNECTED;
@@ -4330,7 +4330,7 @@ static void hci_remote_ext_features_evt(struct hci_dev *hdev,
                cp.pscan_rep_mode = 0x02;
                hci_send_cmd(hdev, HCI_OP_REMOTE_NAME_REQ, sizeof(cp), &cp);
        } else if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags))
-               mgmt_device_connected(hdev, conn, 0, NULL, 0);
+               mgmt_device_connected(hdev, conn, NULL, 0);
 
        if (!hci_outgoing_auth_needed(hdev, conn)) {
                conn->state = BT_CONNECTED;
@@ -5204,7 +5204,7 @@ static void le_conn_complete_evt(struct hci_dev *hdev, u8 status,
        }
 
        if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags))
-               mgmt_device_connected(hdev, conn, 0, NULL, 0);
+               mgmt_device_connected(hdev, conn, NULL, 0);
 
        conn->sec_level = BT_SECURITY_LOW;
        conn->handle = handle;
index b6a88b8256c7763035c1cf8d789dd06672c3d8b6..7d975cf98c2086d1dda4d1b64b868d78033f0866 100644 (file)
@@ -4237,7 +4237,7 @@ static int l2cap_connect_req(struct l2cap_conn *conn,
        hci_dev_lock(hdev);
        if (hci_dev_test_flag(hdev, HCI_MGMT) &&
            !test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &hcon->flags))
-               mgmt_device_connected(hdev, hcon, 0, NULL, 0);
+               mgmt_device_connected(hdev, hcon, NULL, 0);
        hci_dev_unlock(hdev);
 
        l2cap_connect(conn, cmd, data, L2CAP_CONN_RSP, 0);
index f290d0c54d3215c1e49e986f9d3ea1f6af867a1c..f6e510d06becb0f19abd973c7bac79735b2ba710 100644 (file)
@@ -8767,15 +8767,19 @@ void mgmt_new_conn_param(struct hci_dev *hdev, bdaddr_t *bdaddr,
 }
 
 void mgmt_device_connected(struct hci_dev *hdev, struct hci_conn *conn,
-                          u32 flags, u8 *name, u8 name_len)
+                          u8 *name, u8 name_len)
 {
        char buf[512];
        struct mgmt_ev_device_connected *ev = (void *) buf;
        u16 eir_len = 0;
+       u32 flags = 0;
 
        bacpy(&ev->addr.bdaddr, &conn->dst);
        ev->addr.type = link_to_bdaddr(conn->type, conn->dst_type);
 
+       if (conn->out)
+               flags |= MGMT_DEV_FOUND_INITIATED_CONN;
+
        ev->flags = __cpu_to_le32(flags);
 
        /* We must ensure that the EIR Data fields are ordered and