Commit d989188f authored by Håvard Reierstad's avatar Håvard Reierstad Committed by Anas Nashif
Browse files

Bluetooth: Host: l2cap: Fix MPS/MTU confusion

The implementation used BT_L2CAP_ECRED_MIN_MTU to check the lower limits
of both MTU and MPS, instead of BT_L2CAP_ECRED_MIN_MPS for MPS. While
these are the same here, confusion may arise. This commit fixes the
confusion.

Signed-off-by: default avatarHåvard Reierstad <haavard.reierstad@nordicsemi.no>
parent bad11090
Loading
Loading
Loading
Loading
+4 −3
Changes for subsys/bluetooth/host/l2cap.c: 4 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ LOG_MODULE_REGISTER(bt_l2cap, CONFIG_BT_L2CAP_LOG_LEVEL);
#define CHAN_RX(_w) CONTAINER_OF(_w, struct bt_l2cap_le_chan, rx_work)

#define L2CAP_LE_MIN_MTU		23
#define L2CAP_LE_MIN_MPS		23

#define L2CAP_LE_MAX_CREDITS		(BT_BUF_ACL_RX_COUNT - 1)

@@ -1474,7 +1475,7 @@ static void le_conn_req(struct bt_l2cap *l2cap, uint8_t ident,

	LOG_DBG("psm 0x%02x scid 0x%04x mtu %u mps %u credits %u", psm, scid, mtu, mps, credits);

	if (mtu < L2CAP_LE_MIN_MTU || mps < L2CAP_LE_MIN_MTU) {
	if (mtu < L2CAP_LE_MIN_MTU || mps < L2CAP_LE_MIN_MPS) {
		LOG_ERR("Invalid LE-Conn Req params: mtu %u mps %u", mtu, mps);
		return;
	}
@@ -1573,7 +1574,7 @@ static void le_ecred_conn_req(struct bt_l2cap *l2cap, uint8_t ident,

	LOG_DBG("psm 0x%02x mtu %u mps %u credits %u", psm, mtu, mps, credits);

	if (mtu < BT_L2CAP_ECRED_MIN_MTU || mps < BT_L2CAP_ECRED_MIN_MTU) {
	if (mtu < BT_L2CAP_ECRED_MIN_MTU || mps < BT_L2CAP_ECRED_MIN_MPS) {
		LOG_ERR("Invalid ecred conn req params. mtu %u mps %u", mtu, mps);
		result = BT_L2CAP_LE_ERR_INVALID_PARAMS;
		goto response;
@@ -1681,7 +1682,7 @@ static void le_ecred_reconf_req(struct bt_l2cap *l2cap, uint8_t ident,
	mtu = sys_le16_to_cpu(req->mtu);
	mps = sys_le16_to_cpu(req->mps);

	if (mps < BT_L2CAP_ECRED_MIN_MTU) {
	if (mps < BT_L2CAP_ECRED_MIN_MPS) {
		result = BT_L2CAP_RECONF_OTHER_UNACCEPT;
		goto response;
	}