net: wget: Take in account tcp sequence number wrap around
Subsystems (2)
RFC PATCH v2 1/1 net: wget: Take in account tcp sequence number wrap around
Coming from some discussion on mailing about wget unconsistent. It's just and idea to play around
Signed-off-by Michael Trimarchi <[email protected]>
---
RFC V1 -> RFC V2:
- drop random train change in unsigned difference
--- include/net/tcp.h | 10 ++++++++++ net/wget.c | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-)
include/net/tcp.h +10 -0
@@ -88,6 +88,16 @@ struct ip_tcp_hdr {#define TCP_MSS 1460/* Max segment size */ #define TCP_SCALE 0x01/* Scale */ +/* +* The next routines deal with comparing 32 bit unsigned ints +* and worry about wraparound (automatic with unsigned arithmetic). +*/ +static inline bool before (__u32 seq1,__u32 seq2) +{ +return (__s32)(seq1-seq2) <0 ; +} +#define after (seq2, seq1) before(seq1, seq2) +/** * struct tcp_mss - TCP option structure for MSS (Max segment size) * @kind: Field ID
net/wget.c +1 -1
@@ -333,7 +333,7 @@ static void wget_handler(uchar *pkt, u16 dport,"wget: Transferring, seq=%x, ack=%x,len=%x\n" , tcp_seq_num, tcp_ack_num, len); -if (tcp_seq_num >= initial_data_seq_num && +if (!before (initial_data_seq_num, tcp_seq_num) &&store_block (pkt, tcp_seq_num - initial_data_seq_num, len) !=0 ) { wget_fail("wget: store error\n",
Signature · 1 line
2.40.1
Quoted 8 lines · Michael Trimarchi
Coming from some discussion on mailing about wget unconsistent. It's just and idea to play around
Signed-off-by Michael Trimarchi <[email protected]>---
RFC V1 -> RFC V2:
- drop random train change in unsigned difference
Same behavior: I always get Bytes transferred = 1448 (5a8 hex), no matter the file size.
Please try to reproduce the original error when you get a chance.