Low-Cost IP TOS bit won't clear.

From: Ben Greear (greearb@candelatech.com)
Date: Mon Aug 13 2001 - 00:25:51 EST


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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed Aug 15 2001 - 21:00:44 EST