Skip to content

Commit e659803

Browse files
jori-nordicnashif
authored andcommitted
Bluetooth: L2CAP: Downgrade user_data API error to a warning
When user_data is not zeroed-out, the API returns an error. Downgrade the API error to a warning log instead. Introducing this check (zephyrproject-rtos#76489) broke a few PTS tests, as user_data is not initialized by `net_buf_alloc()`. Doing so is in discussion: zephyrproject-rtos#77088 Signed-off-by: Jonathan Rico <[email protected]> (cherry picked from commit 6fa6c4c)
1 parent 6a519f6 commit e659803

File tree

6 files changed

+4
-46
lines changed

6 files changed

+4
-46
lines changed

subsys/bluetooth/host/l2cap.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3117,9 +3117,9 @@ static int bt_l2cap_dyn_chan_send(struct bt_l2cap_le_chan *le_chan, struct net_b
31173117
return -EINVAL;
31183118
}
31193119

3120-
CHECKIF(user_data_not_empty(buf)) {
3121-
LOG_DBG("Please clear user_data first");
3122-
return -EINVAL;
3120+
if (user_data_not_empty(buf)) {
3121+
/* There may be issues if user_data is not empty. */
3122+
LOG_WRN("user_data is not empty");
31233123
}
31243124

31253125
/* Prepend SDU length.

tests/bsim/bluetooth/host/l2cap/compile.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ source ${ZEPHYR_BASE}/tests/bsim/compile.source
1313
app=tests/bsim/bluetooth/host/l2cap/many_conns compile
1414
app=tests/bsim/bluetooth/host/l2cap/general compile
1515
app=tests/bsim/bluetooth/host/l2cap/userdata compile
16-
app=tests/bsim/bluetooth/host/l2cap/userdata conf_file=prj_no_checks.conf compile
1716
app=tests/bsim/bluetooth/host/l2cap/stress compile
1817
app=tests/bsim/bluetooth/host/l2cap/stress conf_file=prj_nofrag.conf compile
1918
app=tests/bsim/bluetooth/host/l2cap/stress conf_file=prj_syswq.conf compile

tests/bsim/bluetooth/host/l2cap/userdata/prj_no_checks.conf

Lines changed: 0 additions & 16 deletions
This file was deleted.

tests/bsim/bluetooth/host/l2cap/userdata/src/main_l2cap_userdata.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -258,20 +258,7 @@ static void test_central_main(void)
258258
*/
259259
err = bt_l2cap_chan_send(&channel.chan, buf);
260260

261-
if (has_checks) {
262-
/* The stack is supposed to reject `buf` if it has non-null
263-
* user_data.
264-
*/
265-
if (err == -EINVAL) {
266-
PASS("(Enabled-checks) Test passed\n");
267-
return;
268-
}
269-
270-
FAIL("Expected EINVAL (%d) got %d\n", -EINVAL, err);
271-
}
272-
273-
/* We have bypassed runtime checks of user_data. L2CAP will take our
274-
* `buf` with non-null user_data. We verify that:
261+
/* L2CAP will take our `buf` with non-null user_data. We verify that:
275262
* - it is cleared
276263
* - we don't segfault later (e.g. in `tx_notify`)
277264
*/

tests/bsim/bluetooth/host/l2cap/userdata/tests_scripts/_compile.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@ INCR_BUILD=1
88
source ${ZEPHYR_BASE}/tests/bsim/compile.source
99

1010
app="$(guess_test_relpath)" compile
11-
app="$(guess_test_relpath)" conf_file=prj_no_checks.conf compile
1211

1312
wait_for_background_jobs

tests/bsim/bluetooth/host/l2cap/userdata/tests_scripts/l2cap.sh

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,3 @@ Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \
2020
-D=2 -sim_length=5e6 $@
2121

2222
wait_for_background_jobs
23-
24-
Execute ./bs_${BOARD_TS}_tests_bsim_bluetooth_host_l2cap_userdata_prj_no_checks_conf \
25-
-v=${verbosity_level} -s=${simulation_id} -d=0 -testid=central
26-
27-
Execute ./bs_${BOARD_TS}_tests_bsim_bluetooth_host_l2cap_userdata_prj_no_checks_conf \
28-
-v=${verbosity_level} -s=${simulation_id} -d=1 -testid=peripheral
29-
30-
Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \
31-
-D=2 -sim_length=5e6 $@
32-
33-
wait_for_background_jobs

0 commit comments

Comments
 (0)