* Low-Cost IP TOS bit won't clear.
@ 2001-08-13 5:25 Ben Greear
2001-08-13 14:15 ` David S. Miller
0 siblings, 1 reply; 2+ messages in thread
From: Ben Greear @ 2001-08-13 5:25 UTC (permalink / raw)
To: linux-kernel
I'm doing some experimenting with setting the various values of
the IP TOS byte. First (as I already mentioned on the linux-net
mailing list) the IPTOS_* values in netinet/ip.h do not seem
correct, they should be shifted left by 2 bits each, if I understand
correctly...
However, even if that is a bug, it is easily fixable in user space
by just passing our own values to the setsockopt() method.
There does seem to be a bug with setsockopt and/or IP itself.
If I ever set the Cost TOS bit (0x80), then I cannot clear it,
even by setting the TOS byte to zero. If I do attempt to set
the byte to zero, getsockopt shows that it was really set to 2.
(I'm beginning to think I should be using htonl or something
like that, but I don't think that explains the failure to set
to zero....)
My method to set/get is:
int BtbitsIpEndpoint::doSetTos() {
// Set IP ToS
if (dev_socket >= 0) {
int val = tos;
VLOG_DBG(VLOG << "Setting TOS to: " << val << endl);
if (setsockopt(dev_socket, SOL_IP, IP_TOS, (char*)&val, sizeof(int)) < 0) {
VLOG_ERR(VLOG << "ERROR: tcp-start, setsockopt TOS: " << strerror(errno) << endl);
return -1;
}//if
int new_val = 0;
socklen_t slt = sizeof(int);
if (getsockopt(dev_socket, SOL_IP, IP_TOS, (void*)(&new_val), &slt) < 0) {
VLOG_ERR(VLOG << "ERROR: tcp-start, getsockopt TOS: " << strerror(errno) << endl);
return -1;
}//if
else {
if (val != new_val) {
VLOG_WRN(VLOG << "Didn't set TOS as desired, requested: " << tos << " current is: "
<< new_val << endl);
tos = new_val;
real_tos = new_val;
}
}
}
return 0;
}//doSetTos
Any ideas will be appreciated...
Ben
--
Ben Greear <greearb@candelatech.com> <Ben_Greear@excite.com>
President of Candela Technologies Inc http://www.candelatech.com
ScryMUD: http://scry.wanfear.com http://scry.wanfear.com/~greear
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Low-Cost IP TOS bit won't clear.
2001-08-13 5:25 Low-Cost IP TOS bit won't clear Ben Greear
@ 2001-08-13 14:15 ` David S. Miller
0 siblings, 0 replies; 2+ messages in thread
From: David S. Miller @ 2001-08-13 14:15 UTC (permalink / raw)
To: greearb; +Cc: linux-kernel
From: Ben Greear <greearb@candelatech.com>
Date: Sun, 12 Aug 2001 22:25:51 -0700
I'm doing some experimenting with setting the various values of
the IP TOS byte. First (as I already mentioned on the linux-net
mailing list) the IPTOS_* values in netinet/ip.h do not seem
correct, they should be shifted left by 2 bits each, if I understand
correctly...
You do not understand the bit layout correctly :-), and also see what
I mentioned about ECN if you are getting "stuck bits".
Later,
David S. Miller
davem@redhat.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2001-08-13 14:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-08-13 5:25 Low-Cost IP TOS bit won't clear Ben Greear
2001-08-13 14:15 ` David S. Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox