Skip to content

Commit

Permalink
Bluetooth: L2CAP: Downgrade user_data API error to a warning
Browse files Browse the repository at this point in the history
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 <jonathan.rico@nordicsemi.no>
  • Loading branch information
jori-nordic committed Aug 15, 2024
1 parent 0533473 commit 0e1c346
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 46 deletions.
6 changes: 3 additions & 3 deletions subsys/bluetooth/host/l2cap.c
Original file line number Diff line number Diff line change
Expand Up @@ -3135,9 +3135,9 @@ static int bt_l2cap_dyn_chan_send(struct bt_l2cap_le_chan *le_chan, struct net_b
return -EINVAL;
}

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

/* Prepend SDU length.
Expand Down
1 change: 0 additions & 1 deletion tests/bsim/bluetooth/host/l2cap/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ app=tests/bsim/bluetooth/host/l2cap/many_conns compile
app=tests/bsim/bluetooth/host/l2cap/multilink_peripheral compile
app=tests/bsim/bluetooth/host/l2cap/general compile
app=tests/bsim/bluetooth/host/l2cap/userdata compile
app=tests/bsim/bluetooth/host/l2cap/userdata conf_file=prj_no_checks.conf compile
app=tests/bsim/bluetooth/host/l2cap/stress compile
app=tests/bsim/bluetooth/host/l2cap/stress conf_file=prj_nofrag.conf compile
app=tests/bsim/bluetooth/host/l2cap/stress conf_file=prj_syswq.conf compile
Expand Down
16 changes: 0 additions & 16 deletions tests/bsim/bluetooth/host/l2cap/userdata/prj_no_checks.conf

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -258,20 +258,7 @@ static void test_central_main(void)
*/
err = bt_l2cap_chan_send(&channel.chan, buf);

if (has_checks) {
/* The stack is supposed to reject `buf` if it has non-null
* user_data.
*/
if (err == -EINVAL) {
PASS("(Enabled-checks) Test passed\n");
return;
}

FAIL("Expected EINVAL (%d) got %d\n", -EINVAL, err);
}

/* We have bypassed runtime checks of user_data. L2CAP will take our
* `buf` with non-null user_data. We verify that:
/* L2CAP will take our `buf` with non-null user_data. We verify that:
* - it is cleared
* - we don't segfault later (e.g. in `tx_notify`)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ INCR_BUILD=1
source ${ZEPHYR_BASE}/tests/bsim/compile.source

app="$(guess_test_relpath)" compile
app="$(guess_test_relpath)" conf_file=prj_no_checks.conf compile

wait_for_background_jobs
11 changes: 0 additions & 11 deletions tests/bsim/bluetooth/host/l2cap/userdata/tests_scripts/l2cap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,3 @@ Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \
-D=2 -sim_length=5e6 $@

wait_for_background_jobs

Execute ./bs_${BOARD_TS}_tests_bsim_bluetooth_host_l2cap_userdata_prj_no_checks_conf \
-v=${verbosity_level} -s=${simulation_id} -d=0 -testid=central

Execute ./bs_${BOARD_TS}_tests_bsim_bluetooth_host_l2cap_userdata_prj_no_checks_conf \
-v=${verbosity_level} -s=${simulation_id} -d=1 -testid=peripheral

Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \
-D=2 -sim_length=5e6 $@

wait_for_background_jobs

0 comments on commit 0e1c346

Please sign in to comment.