Bug 138652 - [tcp] TCP window scaling value calculated incorrectly?
Summary: [tcp] TCP window scaling value calculated incorrectly?
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 1.0-CURRENT
Hardware: Any Any
: Normal Affects Only Me
Assignee: Andre Oppermann
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-09-09 07:10 UTC by Gaurav Goel
Modified: 2010-08-18 21:05 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gaurav Goel 2009-09-09 07:10:01 UTC
I found in file "tcp_input.c-orig" located at location "usr/src/sys/netinet" at line number 511, "tp->request_r_scale" is incremented depending on condition. 16 bits are reserved for window and its value could be MAX 30 bits.
In your if condition "TCP_MAXWIN << tp->request_r_scale < so->so_rcv.sb_hiwat", if I have "so->so_rcv.sb_hiwat" value to be 524286, then "tp->request_r_scale" is incremented four times but its value should be 3.

Reason being, while shifting TCP_MAXWIN,
1st iteration 1111111111111111 < 1111111111111111110 [TRUE]
increment once
2nd iteration 11111111111111110 < 1111111111111111110 [TRUE]
increment again
3rd iteration 111111111111111100 < 1111111111111111110 [TRUE]
increment once
4th iteration 1111111111111111000 < 1111111111111111110 [TRUE]
increment again
5th iteration 11111111111111110000 < 1111111111111111110 [FALSE]

The LSB are zeros, which should be one.

Please tell me if I am wrong.
Comment 1 Gavin Atkinson freebsd_committer freebsd_triage 2009-09-09 13:38:16 UTC
State Changed
From-To: open->feedback

To submitter: Firstly, tcp_input.c-orig is not a file distributed with 
FreeBSD.  I suspect this is left over from a failed patch attempt to 
src/sys/netinet/tcp_input.c.  Can you confirm that the problem exists 
in that file?  Can you also please give the version number of the copy 
you are looking at, and the line numbers where the problem occurs? 
Thanks! 


Comment 2 Gavin Atkinson freebsd_committer freebsd_triage 2009-09-09 13:38:16 UTC
Responsible Changed
From-To: freebsd-bugs->gavin

Track
Comment 3 Gaurav Goel 2009-09-09 14:49:58 UTC
Dear Gavin,

Version- Revision *1.192.2.1 *(check it on link "
http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/netinet/tcp_usrreq.c")
File- "src/sys/netinet/tcp_usrreq.c"
Line No- 1101

Problem described as above

Thanks,
Gaurav Goel

On Wed, Sep 9, 2009 at 6:13 PM, <gavin@freebsd.org> wrote:

> Synopsis: TCP window scaling value
>
> State-Changed-From-To: open->feedback
> State-Changed-By: gavin
> State-Changed-When: Wed Sep 9 12:38:16 UTC 2009
> State-Changed-Why:
> To submitter: Firstly, tcp_input.c-orig is not a file distributed with
> FreeBSD.  I suspect this is left over from a failed patch attempt to
> src/sys/netinet/tcp_input.c.  Can you confirm that the problem exists
> in that file?  Can you also please give the version number of the copy
> you are looking at, and the line numbers where the problem occurs?
> Thanks!
>
>
> Responsible-Changed-From-To: freebsd-bugs->gavin
> Responsible-Changed-By: gavin
> Responsible-Changed-When: Wed Sep 9 12:38:16 UTC 2009
> Responsible-Changed-Why:
> Track
>
> http://www.freebsd.org/cgi/query-pr.cgi?pr=138652
>



-- 
Gaurav Goel
Comment 4 Gaurav Goel 2009-09-09 15:06:48 UTC
Hello,

I was having the older version. Now the same code segment is available in
file "src/sys/netinet/tcp_usrreq.c"

Thanks,
Gaurav Goel

On Wed, Sep 9, 2009 at 7:19 PM, Gaurav Goel <gaurav0287@gmail.com> wrote:

> Dear Gavin,
>
> Version- Revision *1.192.2.1 *(check it on link "
> http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/netinet/tcp_usrreq.c")
> File- "src/sys/netinet/tcp_usrreq.c"
> Line No- 1101
>
> Problem described as above
>
> Thanks,
> Gaurav Goel
>


-- 
Gaurav Goel
Comment 5 Gavin Atkinson freebsd_committer freebsd_triage 2009-09-09 15:24:24 UTC
State Changed
From-To: feedback->open

Over to maintainer(s) for investigation 


Comment 6 Gavin Atkinson freebsd_committer freebsd_triage 2009-09-09 15:24:24 UTC
Responsible Changed
From-To: gavin->freebsd-net

Feedback was received, thanks!
Comment 7 Gaurav Goel 2009-09-10 14:30:37 UTC
Dear Gavin,

Please find the fix for the problem:

*Replace*
*    while (tp->request_r_scale < TCP_MAX_WINSHIFT &&
        (TCP_MAXWIN << tp->request_r_scale) < sb_max)
        tp->request_r_scale++;*

*With*
*unsigned int new_TCP_MAXWIN = TCP_MAXWIN;
while (tp->request_r_scale < TCP_MAX_WINSHIFT)
{
    if(new_TCP_MAXWIN < sb_max)
        tp->request_r_scale++;
    else
        break;**
**    new_TCP_MAXWIN <<=1;**
**    new_TCP_MAXWIN |=1;**
**}*

Please inform me if I am right/wrong.

Thanks,
Gaurav Goel

On Wed, Sep 9, 2009 at 7:59 PM, <gavin@freebsd.org> wrote:

> Old Synopsis: TCP window scaling value
> New Synopsis: TCP window scaling value calculated incorrectly?
>
> State-Changed-From-To: feedback->open
> State-Changed-By: gavin
> State-Changed-When: Wed Sep 9 14:24:24 UTC 2009
> State-Changed-Why:
> Over to maintainer(s) for investigation
>
>
> Responsible-Changed-From-To: gavin->freebsd-net
> Responsible-Changed-By: gavin
> Responsible-Changed-When: Wed Sep 9 14:24:24 UTC 2009
> Responsible-Changed-Why:
> Feedback was received, thanks!
>
> http://www.freebsd.org/cgi/query-pr.cgi?pr=138652
>



-- 
Gaurav Goel
Comment 8 Gaurav Goel 2009-10-06 10:17:52 UTC
Hi,

May I know if someone is working on the bug. I have provided the solution
too, but didn't get any response.

Thanks,
Gaurav Goel

On Thu, Sep 10, 2009 at 7:00 PM, Gaurav Goel <gaurav0287@gmail.com> wrote:

> Dear Gavin,
>
> Please find the fix for the problem:
>
> *Replace*
> *    while (tp->request_r_scale < TCP_MAX_WINSHIFT &&
>         (TCP_MAXWIN << tp->request_r_scale) < sb_max)
>         tp->request_r_scale++;*
>
> *With*
> *unsigned int new_TCP_MAXWIN = TCP_MAXWIN;
> while (tp->request_r_scale < TCP_MAX_WINSHIFT)
> {
>     if(new_TCP_MAXWIN < sb_max)
>         tp->request_r_scale++;
>     else
>         break;**
> **    new_TCP_MAXWIN <<=1;**
> **    new_TCP_MAXWIN |=1;**
> **}*
>
> Please inform me if I am right/wrong.
>
> Thanks,
> Gaurav Goel
>
>
> On Wed, Sep 9, 2009 at 7:59 PM, <gavin@freebsd.org> wrote:
>
>> Old Synopsis: TCP window scaling value
>> New Synopsis: TCP window scaling value calculated incorrectly?
>>
>> State-Changed-From-To: feedback->open
>> State-Changed-By: gavin
>> State-Changed-When: Wed Sep 9 14:24:24 UTC 2009
>> State-Changed-Why:
>> Over to maintainer(s) for investigation
>>
>>
>> Responsible-Changed-From-To: gavin->freebsd-net
>> Responsible-Changed-By: gavin
>> Responsible-Changed-When: Wed Sep 9 14:24:24 UTC 2009
>> Responsible-Changed-Why:
>> Feedback was received, thanks!
>>
>> http://www.freebsd.org/cgi/query-pr.cgi?pr=138652
>>
>
>
>
> --
> Gaurav Goel
>



-- 
Gaurav Goel
Comment 9 Andre Oppermann freebsd_committer freebsd_triage 2010-08-10 23:17:20 UTC
Responsible Changed
From-To: freebsd-net->andre

Take over.
Comment 10 Andre Oppermann freebsd_committer freebsd_triage 2010-08-18 20:40:33 UTC
Gaurav

The window scale computation as found in FreeBSD is indeed correct.
The LSB have to be zero as the window is shiftet.  The values of
these bits are lost to the TCP window.  We can't represent the LSB
in the downshifted window field in the TCP header.

-- 
Andre
Comment 11 Andre Oppermann freebsd_committer freebsd_triage 2010-08-18 21:05:09 UTC
State Changed
From-To: open->closed

Not a bug but correct behavior.