Skip to content

Commit e5af67a

Browse files
ceggers-arriVudentz
authored andcommitted
Bluetooth: MGMT: set_mesh: update LE scan interval and window
According to the message of commit b338d91 ("Bluetooth: Implement support for Mesh"), MGMT_OP_SET_MESH_RECEIVER should set the passive scan parameters. Currently the scan interval and window parameters are silently ignored, although user space (bluetooth-meshd) expects that they can be used [1] [1] https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/mesh/mesh-io-mgmt.c#n344 Fixes: b338d91 ("Bluetooth: Implement support for Mesh") Cc: [email protected] Signed-off-by: Christian Eggers <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent 46c0d94 commit e5af67a

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

net/bluetooth/mgmt.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2153,6 +2153,9 @@ static int set_mesh_sync(struct hci_dev *hdev, void *data)
21532153
else
21542154
hci_dev_clear_flag(hdev, HCI_MESH);
21552155

2156+
hdev->le_scan_interval = __le16_to_cpu(cp->period);
2157+
hdev->le_scan_window = __le16_to_cpu(cp->window);
2158+
21562159
len -= sizeof(*cp);
21572160

21582161
/* If filters don't fit, forward all adv pkts */
@@ -2167,6 +2170,7 @@ static int set_mesh(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
21672170
{
21682171
struct mgmt_cp_set_mesh *cp = data;
21692172
struct mgmt_pending_cmd *cmd;
2173+
__u16 period, window;
21702174
int err = 0;
21712175

21722176
bt_dev_dbg(hdev, "sock %p", sk);
@@ -2180,6 +2184,23 @@ static int set_mesh(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
21802184
return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_MESH_RECEIVER,
21812185
MGMT_STATUS_INVALID_PARAMS);
21822186

2187+
/* Keep allowed ranges in sync with set_scan_params() */
2188+
period = __le16_to_cpu(cp->period);
2189+
2190+
if (period < 0x0004 || period > 0x4000)
2191+
return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_MESH_RECEIVER,
2192+
MGMT_STATUS_INVALID_PARAMS);
2193+
2194+
window = __le16_to_cpu(cp->window);
2195+
2196+
if (window < 0x0004 || window > 0x4000)
2197+
return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_MESH_RECEIVER,
2198+
MGMT_STATUS_INVALID_PARAMS);
2199+
2200+
if (window > period)
2201+
return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_MESH_RECEIVER,
2202+
MGMT_STATUS_INVALID_PARAMS);
2203+
21832204
hci_dev_lock(hdev);
21842205

21852206
cmd = mgmt_pending_add(sk, MGMT_OP_SET_MESH_RECEIVER, hdev, data, len);
@@ -6432,6 +6453,7 @@ static int set_scan_params(struct sock *sk, struct hci_dev *hdev,
64326453
return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_SCAN_PARAMS,
64336454
MGMT_STATUS_NOT_SUPPORTED);
64346455

6456+
/* Keep allowed ranges in sync with set_mesh() */
64356457
interval = __le16_to_cpu(cp->interval);
64366458

64376459
if (interval < 0x0004 || interval > 0x4000)

0 commit comments

Comments
 (0)