host/l2cap: send command reject in L2CAP disc req for invalid CID#1001
host/l2cap: send command reject in L2CAP disc req for invalid CID#1001KKopyscinski merged 2 commits intoapache:masterfrom
Conversation
| if (!chan || (le16toh(req->scid) != chan->dcid)) { | ||
| os_mbuf_free_chain(txom); | ||
| ble_hs_unlock(); | ||
| ble_l2cap_sig_reject_invalid_cid_tx(conn_handle, hdr->identifier, req->dcid, req->scid); |
There was a problem hiding this comment.
actually we are doing here wrong.
as per Bluetooth specification "If the DCID is not recognized by the
receiver of this message, an L2CAP_COMMAND_REJECT_RSP
packet with ‘invalid CID’ result code shall be sent in response. If the
receiver finds a DCID match but the SCID fails to find the same match, the
request should be silently discarded"
That means - if (!chan) { we should send REJECT}
if ((le16toh(req->scid) != chan->dcid)) -> we should silently discard a message
There was a problem hiding this comment.
I pushed the change but I checked it out again and turns out that this requires another one PTS issue ticket: TS says that lower tester should send invalid DCID, but PTS sends invalid SCID and valid DCID and expects disconnection. Of course what we got here is OK, it just allowed test to pass when it was wrong (before the push)
If ble_hs_conn_chan_find_by_scid fails to find channel, it means that destination CID in L2CAP Disconnection Request is invalid. Send L2CAP_COMMAND_REJECT_RSP with BLE_L2CAP_SIG_ERR_INVALID_CID reason. This is affecting L2CAP/LE/CFC/BV-23-C
f5b1628 to
bc16aef
Compare
rymanluk
left a comment
There was a problem hiding this comment.
can we have unit test for that?
rymanluk
left a comment
There was a problem hiding this comment.
looks good to me. Having unit test for that would also be good.
|
Added requested unit test |
If ble_hs_conn_chan_find_by_scid fails to find channel, it means
that destination CID in L2CAP Disconnection Request is invalid.
Send L2CAP_COMMAND_REJECT_RSP with BLE_L2CAP_SIG_ERR_INVALID_CID
reason.
This is affecting L2CAP/LE/CFC/BV-23-C