I've been working with custom route tables on Linux, and I'm a bit confused by some of the documentation and behavior of the "ip route" command. It seems that the only valid values should be 0-255 plus the names defined in /etc/iproute2/rt_tables:

255 local
254 main
253 default
0   unspec

This would leave 1-252 for custom tables. Attempting to use an undefined table name gives an error:

$ ip route show table kermit
Error: argument "kermit" is wrong: table id value is invalid

However, it seems that I can use numbers far higher than 255 without error:

$ ip route show table 1000
[no output]
$ ip route add 10.10.10.0/24 dev eth0 table 1000
[no output]
$ ip route show table 1000
10.10.10.0/24 dev eth0  scope link

At some point, things get even weirder. Right at maxint (2^31), it "overflows" into the local table (255):

$ ip route show table 2147483647
[no output]
$ ip route show table 2147483648
[exact output of table 255 (local)]

Can anyone explain what is happening? Are there actually maxint custom routing tables that can be used?

link|improve this question
feedback

1 Answer

up vote 1 down vote accepted

As far as the 2.6 kernel is concerned, the max table is 0xFFFFFFFF (from rtnetlink.h). However, iproute2 uses a signed integer in it's filter to do the lookup so at 2^31 it thinks you specified an invalid table and defaults to showing you table 255.

link|improve this answer
So, an invalid name gives you an error, but an invalid integer gives you 255? Also, I assume that 255 was the previous max (in 2.4 maybe?) but was increased to a 32-bit number in kernel 2.6? – Bob Sep 27 '11 at 18:07
Yes, the max in 2.4 and 2.2 was 255. – Ciclamino Sep 27 '11 at 19:36
Also, always showing table 255 for values with the 32nd bit doesn't appear to be any sort of planned behaviour, just a bug. With a one line patch to iproute I was able to create and show a table with number 4294967290. However, it may not be as simple as that, there may other pieces that still don't deal with 2^32 tables. – Ciclamino Sep 27 '11 at 20:02
Accepted, thanks. Maybe you should submit your patch :) – Bob Oct 6 '11 at 11:41
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.