public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ben Greear <greearb@candelatech.com>
To: linux-kernel <linux-kernel@vger.kernel.org>
Subject: Low-Cost IP TOS bit won't clear.
Date: Sun, 12 Aug 2001 22:25:51 -0700	[thread overview]
Message-ID: <3B7764DF.BF58692D@candelatech.com> (raw)

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

             reply	other threads:[~2001-08-13  5:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-13  5:25 Ben Greear [this message]
2001-08-13 14:15 ` Low-Cost IP TOS bit won't clear David S. Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3B7764DF.BF58692D@candelatech.com \
    --to=greearb@candelatech.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox