[PATCH 1/2] Bluetooth: set sk_sndbuf and sk_rcvbuf properly in ERTM

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Setting both this value to MPS * TxWin * 1.2 guarantees that we are
reserving space to fit the whole txwindow in the memory, and that
sendmsg() will block when the transmission window is full avoid
overloading the system memory.
I don't have a strong reason about the 1.2 constant in the account, we
can do another tests in the future and change that value.

Signed-off-by: Gustavo F. Padovan <padovan@xxxxxxxxxxxxxx>
---
 net/bluetooth/l2cap_core.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 44aa034..1e2ab05 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -3129,9 +3129,17 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr
 		l2cap_pi(sk)->next_tx_seq = 0;
 		l2cap_pi(sk)->expected_tx_seq = 0;
 		__skb_queue_head_init(TX_QUEUE(sk));
-		if (l2cap_pi(sk)->mode ==  L2CAP_MODE_ERTM)
+		if (l2cap_pi(sk)->mode ==  L2CAP_MODE_ERTM) {
 			l2cap_ertm_init(sk);
 
+			sk->sk_sndbuf = (l2cap_pi(sk)->remote_tx_win * 1.2 *
+						(sizeof(struct l2cap_pinfo) +
+						l2cap_pi(sk)->mps));
+			sk->sk_rcvbuf = (l2cap_pi(sk)->tx_win * 1.2 *
+						(sizeof(struct l2cap_pinfo) +
+						l2cap_pi(sk)->remote_mps));
+		}
+
 		l2cap_chan_ready(sk);
 	}
 
-- 
1.7.3

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux