TOS value restrictions in iptables and 'ip rule'

raf raf@comdyn.com.au
Tue, 15 May 2001 16:29:45 +1000


Mark Frazer wrote:

> I'd like to be able to select a routing table based on any possible TOS
> setting.  The system I'm building is to be able to route an arbitrary
> TOS setting as we're looking at the IPv4 TOS byte as a diffserv DSCP.
> What is the reasoning behind restricting the valid TOS matches to 0x00,
> 0x02, 0x04, 0x08 and 0x10?
> 
> I basically have a truckload of point-to-point links and would like to
> route particular traffic types of different links.  I've been trying to
> use 'ip rule add tos 0xc0 table link1' which didn't work, so then I was
> going to pick routes based on a fwmark, but 'iptables -I PREROUTING -t
> mangle -m tos --tos -0xc0 j MARK --set-mark 1' also doesn't like anything
> other than the 5 TOS values mentioned above.
> 
> I'm a bit new to wandering through the kernel, but I think the
> functions I'm having grief with are the checkentry function in
> net/ipv4/netfilter/ipt_TOS.c for iptables.  I'd expect to find a similar
> test for the net/netlink or net/core/rtnetlink.c but I cannot, although
> I assume the ip command is trying to use the routing netlink to set
> its routes.
> 
> If one of the routing types could point me at some starting documentation,
> I'd be happy to come up with some sort of an intelligent patch.
> 
> cheers
> -mark

according to rfc1349, setting multiple tos bits is not supported.

from the summary:

    The ability to request that transmission be
   optimized along multiple axes (previously accomplished by setting
   multiple TOS bits simultaneously) is removed.  Thus, for example, a
   single datagram can no longer request that the network simultaneously
   minimize delay and maximize throughput.

raf