History

Bluetooth: Limit duration of Remote Name Resolve

When doing remote name request, we cannot scan. In the normal case it's OK since we can expect it to finish within a short amount of time. However, there is a possibility to scan lots of devices that (1) requires Remote Name Resolve (2) is unresponsive to Remote Name Resolve When this happens, we are stuck to do Remote Name Resolve until all is done before continue scanning. This patch adds a time limit to stop us spending too long on remote name request.

Archie Pusaka committed 4 years ago

Commit dbf68111 parent ea13aed2 files · +10 −0Browse files

Unified · Split

2 files
  1. include/net/bluetooth/hci_core.h +3 −0
  2. net/bluetooth/hci_event.c +7 −0
include/net/bluetooth/hci_core.h+3−0
@@ -88,6 +88,7 @@ struct discovery_state { · 87 unmodified lines
8888 u8 (*uuids)[16];
8989 unsigned long scan_start;
9090 unsigned long scan_duration;
91+ unsigned long name_resolve_timeout;
9192 };
9293
9394 #define SUSPEND_NOTIFIER_TIMEOUT msecs_to_jiffies(2000) /* 2 seconds */
@@ -1759,6 +1760,8 @@ void hci_mgmt_chan_unregister(struct hci_mgmt_chan *c); · 1665 unmodified lines
17591760 #define DISCOV_LE_FAST_ADV_INT_MIN 0x00A0 /* 100 msec */
17601761 #define DISCOV_LE_FAST_ADV_INT_MAX 0x00F0 /* 150 msec */
17611762
1763+#define NAME_RESOLVE_DURATION msecs_to_jiffies(10240) /* 10.24 sec */
1764+
17621765 void mgmt_fill_version_info(void *ver);
17631766 int mgmt_new_settings(struct hci_dev *hdev);
17641767 void mgmt_index_added(struct hci_dev *hdev);
net/bluetooth/hci_event.c+7−0
@@ -2129,6 +2129,12 @@ static bool hci_resolve_next_name(struct hci_dev *hdev) · 2128 unmodified lines
21292129 if (list_empty(&discov->resolve))
21302130 return false;
21312131
2132+ /* We should stop if we already spent too much time resolving names. */
2133+ if (time_after(jiffies, discov->name_resolve_timeout)) {
2134+ bt_dev_warn_ratelimited(hdev, "Name resolve takes too long.");
2135+ return false;
2136+ }
2137+
21322138 e = hci_inquiry_cache_lookup_resolve(hdev, BDADDR_ANY, NAME_NEEDED);
21332139 if (!e)
21342140 return false;
@@ -2716,6 +2722,7 @@ static void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) · 581 unmodified lines
27162722 if (e && hci_resolve_name(hdev, e) == 0) {
27172723 e->name_state = NAME_PENDING;
27182724 hci_discovery_set_state(hdev, DISCOVERY_RESOLVING);
2725+ discov->name_resolve_timeout = jiffies + NAME_RESOLVE_DURATION;
27192726 } else {
27202727 /* When BR/EDR inquiry is active and no LE scanning is in
27212728 * progress, then change discovery state to indicate completion.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t