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
88 u8 (*uuids)[16];88 u8 (*uuids)[16];
89 unsigned long scan_start;89 unsigned long scan_start;
90 unsigned long scan_duration;90 unsigned long scan_duration;
91 unsigned long name_resolve_timeout;
91};92};
92 93
93#define SUSPEND_NOTIFIER_TIMEOUT msecs_to_jiffies(2000) /* 2 seconds */94#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
1759#define DISCOV_LE_FAST_ADV_INT_MIN 0x00A0 /* 100 msec */1760#define DISCOV_LE_FAST_ADV_INT_MIN 0x00A0 /* 100 msec */
1760#define DISCOV_LE_FAST_ADV_INT_MAX 0x00F0 /* 150 msec */1761#define DISCOV_LE_FAST_ADV_INT_MAX 0x00F0 /* 150 msec */
1761 1762
1763#define NAME_RESOLVE_DURATION msecs_to_jiffies(10240) /* 10.24 sec */
1764
1762void mgmt_fill_version_info(void *ver);1765void mgmt_fill_version_info(void *ver);
1763int mgmt_new_settings(struct hci_dev *hdev);1766int mgmt_new_settings(struct hci_dev *hdev);
1764void mgmt_index_added(struct hci_dev *hdev);1767void 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
2129 if (list_empty(&discov->resolve))2129 if (list_empty(&discov->resolve))
2130 return false;2130 return false;
2131 2131
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
2132 e = hci_inquiry_cache_lookup_resolve(hdev, BDADDR_ANY, NAME_NEEDED);2138 e = hci_inquiry_cache_lookup_resolve(hdev, BDADDR_ANY, NAME_NEEDED);
2133 if (!e)2139 if (!e)
2134 return false;2140 return false;
@@ -2716,6 +2722,7 @@ static void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) · 581 unmodified lines
2716 if (e && hci_resolve_name(hdev, e) == 0) {2722 if (e && hci_resolve_name(hdev, e) == 0) {
2717 e->name_state = NAME_PENDING;2723 e->name_state = NAME_PENDING;
2718 hci_discovery_set_state(hdev, DISCOVERY_RESOLVING);2724 hci_discovery_set_state(hdev, DISCOVERY_RESOLVING);
2725 discov->name_resolve_timeout = jiffies + NAME_RESOLVE_DURATION;
2719 } else {2726 } else {
2720 /* When BR/EDR inquiry is active and no LE scanning is in2727 /* When BR/EDR inquiry is active and no LE scanning is in
2721 * progress, then change discovery state to indicate completion.2728 * 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