2004-03-07 05:00:52

by Fredrik Tolf

[permalink] [raw]
Subject: IP_TOS setsockopt filters away MinCost

Hi!

I found some code in net/ipv4/ip_sockglue.c that I failed to make
sense of. In the setsockopt code for setting IP_TOS, it erases the two
lowest bits (I dunno what bit 0 in the TOS is - last I looked it was
reserved, but bit 1 is for minimal cost), and replaces them with what
was already set for the socket (only for SOCK_STREAM sockets,
though). That means that one cannot set minimal cost TOS on stream
sockets.

This didn't make sense to me. Is there some reason behind this, and
would someone like to explain it to me in that case? I just spent an
hour trying to debug my program to find it why it didn't want to set
minimal cost, while the other three TOS options worked.

Fredrik Tolf


2004-03-07 06:34:56

by David Miller

[permalink] [raw]
Subject: Re: IP_TOS setsockopt filters away MinCost

On Sun, 7 Mar 2004 06:00:48 +0100
Fredrik Tolf <[email protected]> wrote:

> This didn't make sense to me. Is there some reason behind this, and
> would someone like to explain it to me in that case? I just spent an
> hour trying to debug my program to find it why it didn't want to set
> minimal cost, while the other three TOS options worked.

Please read the diffserv RFCs for the current meanins of the TOS
bits.

2004-03-07 13:14:57

by Fredrik Tolf

[permalink] [raw]
Subject: Re: IP_TOS setsockopt filters away MinCost

David S. Miller writes:
> On Sun, 7 Mar 2004 06:00:48 +0100
> Fredrik Tolf <[email protected]> wrote:
>
> > This didn't make sense to me. Is there some reason behind this, and
> > would someone like to explain it to me in that case? I just spent an
> > hour trying to debug my program to find it why it didn't want to set
> > minimal cost, while the other three TOS options worked.
>
> Please read the diffserv RFCs for the current meanins of the TOS
> bits.

Well, I was thinking that it might be diffserv, but on the next line
in that code, it checks the TOS precedence value, so I thought it
can't be. Also, it only resets these bits for SOCK_STREAM sockets - it
doesn't touch SOCK_DGRAMs. Is diffserv still somehow the reason behind
it?

Fredrik Tolf