Bluetooth: Fix l2cap_tx_window_full
Subsystems (2)
Luiz Augusto von Dentz
maintainerPATCH v2 1/1 Bluetooth: Fix l2cap_tx_window_full
From: Luiz Augusto von Dentz <[email protected]>
l2cap_tx_window_full is not checking the window limit properly, first it computes based on sequence numbers which doesn't take into account the ReqSeq and always assume 64 not the real window size.
To fix this now it just checks if the number of unacked frames is >= of tx window which is much simpler.
---
Add debug
include/net/bluetooth/l2cap.h | 10 +++------- 1 files changed, 3 insertions(+), 7 deletions(-)
include/net/bluetooth/l2cap.h +3 -7
@@ -661,14 +661,10 @@ static inline __u16 __next_seq(struct l2cap_chan *chan, __u16 seq)static inline int l2cap_tx_window_full (struct l2cap_chan *ch) { -int sub; +BT_DBG ("chan %p unacked %d tx_win %d" , ch, ch->unacked_frames, + ch->remote_tx_win); - sub = (ch->next_tx_seq - ch->expected_ack_seq) %64 ; - -if (sub <0 ) - sub +=64 ; - -return sub == ch->remote_tx_win; +return ch->unacked_frames >= ch->remote_tx_win; }static inline __u16 __get_reqseq (struct l2cap_chan *chan,__u32 ctrl)
Signature · 1 line
1.7.7.6
Hi Luiz,
Quoted 39 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
l2cap_tx_window_fullis not checking the window limit properly, first it computes based on sequence numbers which doesn't take into account the ReqSeq and always assume 64 not the real window size.To fix this now it just checks if the number of unacked frames is >= of tx window which is much simpler.
Signed-off-by Luiz Augusto von Dentz <[email protected]>---
Add debuginclude/net/bluetooth/l2cap.h | 10 +++-------
1 files changed, 3 insertions(+), 7 deletions(-)include/net/bluetooth/l2cap.h +3
-8@@ -661,14 +661,10 @@ static inline __u16 __next_seq(struct l2cap_chan *chan, __u16 seq) static inline int l2cap_tx_window_full(struct l2cap_chan *ch) { - int sub; + BT_DBG("chan %p unacked %d tx_win %d", ch, ch->unacked_frames, + ch->remote_tx_win); - sub = (ch->next_tx_seq - ch->expected_ack_seq) % 64; - - if (sub < 0) - sub += 64; - - return sub == ch->remote_tx_win; + return ch->unacked_frames >= ch->remote_tx_win; } static inline __u16 __get_reqseq(struct l2cap_chan *chan, __u32 ctrl) --
Quoted 1 line
1.7.7.6
Looks good to me.
Regards,
Signature · 5 lines
Ulisses Furquim ProFUSION embedded systems http://profusion.mobi Mobile: +55 19 9250 0942 Skype: ulissesffs
Hi all,
Quoted 41 lines · Ulisses Furquim
Hi Luiz,
Quoted 37 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
l2cap_tx_window_fullis not checking the window limit properly, first it computes based on sequence numbers which doesn't take into account the ReqSeq and always assume 64 not the real window size.To fix this now it just checks if the number of unacked frames is >= of tx window which is much simpler.
Signed-off-by Luiz Augusto von Dentz <[email protected]>---
Add debuginclude/net/bluetooth/l2cap.h | 10 +++-------
1 files changed, 3 insertions(+), 7 deletions(-)include/net/bluetooth/l2cap.h +3
-7@@ -661,14 +661,10 @@ static inline __u16 __next_seq(struct l2cap_chan *chan, __u16 seq) static inline int l2cap_tx_window_full(struct l2cap_chan *ch) { - int sub; + BT_DBG("chan %p unacked %d tx_win %d", ch, ch->unacked_frames, + ch->remote_tx_win); - sub = (ch->next_tx_seq - ch->expected_ack_seq) % 64; - - if (sub < 0) - sub += 64; - - return sub == ch->remote_tx_win; + return ch->unacked_frames >= ch->remote_tx_win; }
Quoted 5 lines
Quoted 3 lines
include/net/bluetooth/l2cap.h +0
-1static inline __u16 __get_reqseq(struct l2cap_chan *chan, __u32 ctrl) --1.7.7.6
Looks good to me.
Same here, I am wondering why it was done in a such complex way? Maybe there is some logic behind?
Best regards
Andrei Emeltchenko
Gustavo Padovan
Acked-byHi Andrei,
Quoted 44 lines · Andrei Emeltchenko
Hi all,
Quoted 41 lines · Ulisses Furquim
Hi Luiz,
Quoted 37 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
l2cap_tx_window_fullis not checking the window limit properly, first it computes based on sequence numbers which doesn't take into account the ReqSeq and always assume 64 not the real window size.To fix this now it just checks if the number of unacked frames is >= of tx window which is much simpler.
Signed-off-by Luiz Augusto von Dentz <[email protected]>---
Add debuginclude/net/bluetooth/l2cap.h | 10 +++-------
1 files changed, 3 insertions(+), 7 deletions(-)include/net/bluetooth/l2cap.h +3
-7@@ -661,14 +661,10 @@ static inline __u16 __next_seq(struct l2cap_chan *chan, __u16 seq) static inline int l2cap_tx_window_full(struct l2cap_chan *ch) { - int sub; + BT_DBG("chan %p unacked %d tx_win %d", ch, ch->unacked_frames, + ch->remote_tx_win); - sub = (ch->next_tx_seq - ch->expected_ack_seq) % 64; - - if (sub < 0) - sub += 64; - - return sub == ch->remote_tx_win; + return ch->unacked_frames >= ch->remote_tx_win; }
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
include/net/bluetooth/l2cap.h +0
-1static inline __u16 __get_reqseq(struct l2cap_chan *chan, __u32 ctrl) --1.7.7.6
Looks good to me.
Same here, I am wondering why it was done in a such complex way? Maybe there is some logic behind?
I followed the specification, next_tx_seq minus expecpted_ack_seq is the definition of the current size of the tx_window.
Anyway,
Gustavo
Luiz Augusto von Dentz
maintainerHi Gustavo,
Quoted 7 lines · Gustavo Padovan
I followed the specification,
next_tx_seqminusexpecpted_ack_seqis the definition of the current size of thetx_window.Anyway,
I notice it, It was actually possible to fix this by using __seq_offset but then I notice in Mat's patch he just use unacked_frames which is way simpler to read/use. Btw, there is still something else preventing me to use bigger MTU with OBEX, I can use up to 32k in kvm but only 16k if I boot it directly, at some point it just stall in the transmitter even though the receiver acks and the window is not full.
Signature · 1 line
Luiz Augusto von Dentz
Quoted 8 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
l2cap_tx_window_fullis not checking the window limit properly, first it computes based on sequence numbers which doesn't take into account the ReqSeq and always assume 64 not the real window size.To fix this now it just checks if the number of unacked frames is >= of tx window which is much simpler.
So what is the status with this patch?
Best regards
Andrei Emeltchenko
Quoted 37 lines
Signed-off-by Luiz Augusto von Dentz <[email protected]>---
Add debuginclude/net/bluetooth/l2cap.h | 10 +++------- 1 files changed, 3 insertions(+), 7 deletions(-)include/net/bluetooth/l2cap.h +3
-7@@ -661,14 +661,10 @@ static inline __u16 __next_seq(struct l2cap_chan *chan, __u16 seq)static inline int l2cap_tx_window_full (struct l2cap_chan *ch) { -int sub; +BT_DBG ("chan %p unacked %d tx_win %d" , ch, ch->unacked_frames, + ch->remote_tx_win); - sub = (ch->next_tx_seq - ch->expected_ack_seq) %64 ; - -if (sub <0 ) - sub +=64 ; - -return sub == ch->remote_tx_win; +return ch->unacked_frames >= ch->remote_tx_win; }static inline __u16 __get_reqseq (struct l2cap_chan *chan,__u32 ctrl)Signature · 6 lines
1.7.7.6 -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html