Skip to contentSkip to conversation

IP_TOS setsockopt filters away MinCost

DISCUSSION Fredrik Tolf 2 participants 3 messages Mar 7, 2004

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw
Quoted 4 lines · 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.

#2 lore raw
Quoted 10 lines · David S. Miller
Quoted 4 lines · 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