Le blog de Olivier Crête

Categories

Me

My Planets

Projects

Archives

July 2009
M T W T F S S
« Nov   May »
 12345
6789101112
13141516171819
20212223242526
2728293031  

RSS 2.0


Log in

When a man page lies

The part of the socket(7) man page about setsockopt(.., SOL_SOCKET, SO_PRIORITY…)  says:

“For ip(7), this also sets the  IP  type-of- service  (TOS)  field  for outgoing packets.”

I wanted to know how exactly it mapped the socket priority to the ToS field, so I looked in the kernel code for a while, and it turns out that in recent Linux 2.6 kernel, this is a lie. The ToS field is never set when the application selects the socket priority, only the internal priority of the packet is set. That said, the reverse is true, setting setsockopt(.., IPPROTO_IP, IP_TOS…)  sets both the ToS header field and the internal priority of the packet.

So the question here is: Who is wrong, is the kernel buggy? Or is the man page incorrect?

Also, dear lazyweb, is there any support for applications to set the DiffServ field? Or are they only settable through iptables?

3 answers to “When a man page lies”

No avatar

The man page would be in the wrong here. The man page usually reflects the current operating state of the program in question. If the program does not implement a feature or that feature has been removed the man page should usually be updated.

The man page does not describe some standard, it describes the program. Now if the kernel is supposed to set the ToS when the application selects the socket priority, that would be a poor implementation of the feature against whatever standard or published process one is comparing to. However, the man page is not the place for reiterating standards only references to standards that may apply to the given program.

For example, a program may be required to transmit a request via XXX.XXX.XXX.XXX address per a given standard. The man page may note that the program transmits via the given address per (RFC XXXX). However, the man page may in turn say: If transmission fails a second request is sent via YYY.YYY.YYY.YYY. The standard may not say anything about transmitting on YYY… but the man page reflects what the program will do, not what it is supposed to do.

Of course that’s my two cents. Have you asked the LKML? I am not properly introduced to this so I am not sure if the is normal per se, and I would hate to start asking uneducated questions on the LKML, but I would not mind it.

No avatar

I can’t answer for sure, but you may want to have a look at Asterisk’s code. It has some options to set the tos flags and they definitely work (I was testing that this week). At least in 1.4.XX they did.

The relevant code from svn-trunk seems to be:

int ast_netsock_set_qos(int netsocket, int tos, int cos, const char *desc)
{
int res;

if ((res = setsockopt(netsocket, IPPROTO_IP, IP_TOS, &tos, sizeof(tos))))
ast_log(LOG_WARNING, “Unable to set %s TOS to %d, may be you have no root privilegesn”, desc, tos);
else if (tos)
ast_verb(2, “Using %s TOS bits %dn”, desc, tos);

#if defined(linux)
if (setsockopt(netsocket, SOL_SOCKET, SO_PRIORITY, &cos, sizeof(cos)))
ast_log(LOG_WARNING, “Unable to set %s CoS to %dn”, desc, cos);
else if (cos)
ast_verb(2, “Using %s CoS mark %dn”, desc, cos);
#endif

return res;
}

No avatar
ariveira dit:

Send an email with your concerns to netdev@vger.kernel.org CC’ing linux-man@vger.kernel.org (the man pages mailing list). Either your doubt will be cleared or the man page updated. A win-win situation ;)

 

This page is XHTML 1.0 Strict and CSS level 3