UPSTREAM: Bluetooth: L2CAP: add support for waiting disconnection resp

Whenever we disconnect a L2CAP connection, we would immediately
report a disconnection event (EPOLLHUP) to the upper layer, without
waiting for the response of the other device.

This patch offers an option to wait until we receive a disconnection
response before reporting disconnection event, by using the "how"
parameter in l2cap_sock_shutdown(). Therefore, upper layer can opt
to wait for disconnection response by shutdown(sock, SHUT_WR).

This can be used to enforce proper disconnection order in HID,
where the disconnection of the interrupt channel must be complete
before attempting to disconnect the control channel.

Signed-off-by: Archie Pusaka <apusaka@chromium.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
(cherry picked from commit 5b440676c15bbe1a40f2546ec92db83ed66d9e22)

BUG=b:149887300
TEST=Run tools/l2cap-tester

Change-Id: I2ca8b706a02b94cb0fe17a348c2f243cfa2a544b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/2232303
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Reviewed-by: Yun-Hao Chung <howardchung@google.com>
Commit-Queue: Archie Pusaka <apusaka@chromium.org>
Tested-by: Archie Pusaka <apusaka@chromium.org>
1 file changed