Bug 959693 - ip -6 route add ::/0 results in File exists error
Summary: ip -6 route add ::/0 results in File exists error
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: kernel
Version: 18
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Kernel Maintainer List
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-05-04 20:44 UTC by Gene Czarcinski
Modified: 2013-05-06 17:59 UTC (History)
10 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2013-05-06 16:17:20 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Gene Czarcinski 2013-05-04 20:44:51 UTC
Description of problem:
I am attempting to add the capability for a user to specify static routes being added to libvirt virtual (bridge) devices for both IPv4 and IPv6.  I am constructing and then executing the equivalent of a command line.  For IPv4 everything works fine including specifying 0.0.0.0/0.0.0.0 or 0.0.0.0/0 for a default route.  For IPv6, everything works except when ::/0 is specified.  Then I get the error message:
   RTNETLINK answers: File exist

I do not know if this is a bug or a "feature" but I cannot find any documentation that says this is invalid.

/sbin/ip -6 route and /sbin/route -A inet6 do not show any existing ::/0 allocations on the virtual bridge being specified.

Since I am effectively just issuing a command as root, this can be debugged from a terminal window.

Version-Release number of selected component (if applicable):
Fedora 18, kernel-3.8.9-200.fc18.x86_64, iproute-3.6.0-8.fc18.x86_64

How reproducible:
every time

Steps to Reproduce:

Command entered:

ip -6 route add ::/0 via fd00:beef:10:8::2:6 dev virbr4 proto static metric 1

Actual results:
RTNETLINK answers: File exist

Expected results:
::/0 via fd00:beef:10:8::2:6 dev virbr4  proto static  metric 1

Additional info:

Leaving the prefix off naturally results in ::/128.  Specifying anything else also works.  It is only ::/0 that is troublesome.

If this is some limitation, fine, but the error message leaves a lot to be desired.

Comment 1 Gene Czarcinski 2013-05-05 16:46:39 UTC
After looking into some of the source for iproute, ::/0 (or default for IPv6) appears to be a valid address.  Therefore, this is an error.

Comment 2 Petr Šabata 2013-05-06 11:50:12 UTC
This should indeed work and I cannot reproduce your issue with a dummy interface.
Given the netlink answer, I'm assigning this to kernel.

Comment 3 Neil Horman 2013-05-06 13:16:46 UTC
Well, the fact that you're getting -EEXIST suggests that you already have a default route set that matches that.  What does the route table on this system look like prior to your route add command?

Comment 4 Gene Czarcinski 2013-05-06 14:25:50 UTC
Since you are not specifying something else, I am assuming that you mean the output from executing "sbin/ip -6 route show".  If it is anything else such as specifying a tableid for the above command, you will need to tell me.

Note:  This is occurring with libvirt network bridge devices and the problem may lie there.  I have not explored that possibility.

Since the code just runs command-line commands, I will do the tests with command line commands with show before, add, and then show after.  For completeness, I will be doing both IPv4 and IPv6 and I will first start the virtual network so that I have the virtual bridge device to work with.
----------------------------------------------------------------------------
[root@falcon:~]#ip -4 route show
default via 192.168.18.91 dev p33p1  proto static 
192.168.18.0/24 dev p33p1  proto kernel  scope link  src 192.168.18.2 
[root@falcon:~]#ip -6 route
fd00:dead:beef:18:1::2 dev p33p1  proto kernel  metric 256 
fd00:dead:beef:18:1::6 via fd00:dead:beef:18:1::6 dev p33p1  metric 0 
    cache  expires -4618625sec
fd00:dead:beef:18::/64 dev p33p1  proto kernel  metric 256  expires 42807sec
fe80::/64 dev p33p1  proto kernel  metric 256 
default via fe80::2a0:ccff:fea2:4fad dev p33p1  proto static  metric 1 
default via fe80::2a0:ccff:fea2:4fad dev p33p1  proto ra  metric 1024  expires 1407sec
[root@falcon:~]#virsh net-start net8
Network net8 started

[root@falcon:~]#ip -4 route show
default via 192.168.18.91 dev p33p1  proto static 
192.168.8.0/24 dev virbr4  proto kernel  scope link  src 192.168.8.1 
192.168.18.0/24 dev p33p1  proto kernel  scope link  src 192.168.18.2 
192.168.81.0/24 via 192.168.8.2 dev virbr4  proto static  metric 1 
[root@falcon:~]#ip route add 0.0.0.0/0 via 192.168.8.3 dev virbr4 proto static metric 1
[root@falcon:~]#ip -4 route show
default via 192.168.18.91 dev p33p1  proto static 
default via 192.168.8.3 dev virbr4  proto static  metric 1 
192.168.8.0/24 dev virbr4  proto kernel  scope link  src 192.168.8.1 
192.168.18.0/24 dev p33p1  proto kernel  scope link  src 192.168.18.2 
192.168.81.0/24 via 192.168.8.2 dev virbr4  proto static  metric 1 
[root@falcon:~]#ip -6 route show
fd00:beef:10:8::/64 dev virbr4  proto kernel  metric 256 
fd00:beef:13:1::/64 via fd00:beef:10:8::2:5 dev virbr4  proto static  metric 1 
fd00:dead:beef:18:1::2 dev p33p1  proto kernel  metric 256 
fd00:dead:beef:18:1::6 via fd00:dead:beef:18:1::6 dev p33p1  metric 0 
    cache  expires -4618791sec
fd00:dead:beef:18::/64 dev p33p1  proto kernel  metric 256  expires 43187sec
fe80::/64 dev p33p1  proto kernel  metric 256 
fe80::/64 dev virbr4  proto kernel  metric 256 
default via fe80::2a0:ccff:fea2:4fad dev p33p1  proto static  metric 1 
default via fe80::2a0:ccff:fea2:4fad dev p33p1  proto ra  metric 1024  expires 1787sec
[root@falcon:~]#ip route add ::/0 via fd00:beef:10:8::2:6 dev virbr4 proto static metric 1
RTNETLINK answers: File exists
[root@falcon:~]#ip -6 route show
fd00:beef:10:8::/64 dev virbr4  proto kernel  metric 256 
fd00:beef:13:1::/64 via fd00:beef:10:8::2:5 dev virbr4  proto static  metric 1 
fd00:dead:beef:18:1::2 dev p33p1  proto kernel  metric 256 
fd00:dead:beef:18:1::6 via fd00:dead:beef:18:1::6 dev p33p1  metric 0 
    cache  expires -4618912sec
fd00:dead:beef:18::/64 dev p33p1  proto kernel  metric 256  expires 43066sec
fe80::/64 dev p33p1  proto kernel  metric 256 
fe80::/64 dev virbr4  proto kernel  metric 256 
default via fe80::2a0:ccff:fea2:4fad dev p33p1  proto static  metric 1 
default via fe80::2a0:ccff:fea2:4fad dev p33p1  proto ra  metric 1024  expires 1666sec
[root@falcon:~]#
----------------------------------------------------------------------------
Note:
Both the 192.168.81.0/24 and fd00:beef:13:1::/64 static routes were created
by the modified libvirt code.
----------------------------------------------------------------------------

It appears to me that whatever is doing the checking for IPv6 is only checking for the address+prefix match and ignoring other factors such as the device, etc.

What do these extra default routes mean and how will thinks actual work, I have no idea.  However, it this should not work for IPv6, then it is probably a bad idea for IPv4 also.  The thing is, I can see multiple default (address=0, prefix=0) definitions but each one has something uniquely different about it.
------------------------------------------------------------------------------
And here is the output from /sbin/route -A inet6"
------------------------------------------------------------------------------
[root@falcon:~]#route -A inet6
Kernel IPv6 routing table
Destination                    Next Hop                   Flag Met Ref Use If
localhost/128                  [::]                       U    256 0     0 lo
fd00:beef:10:8::/64            [::]                       U    256 0     2 virbr4
fd00:beef:13:1::/64            fd00:beef:10:8::2:5        UG   1   0     0 virbr4
falcon.lcl/128                 [::]                       U    256 0     0 p33p1
fd00:dead:beef:18::/64         [::]                       UAe  256 0     0 p33p1
fe80::/64                      [::]                       U    256 0     0 p33p1
fe80::/64                      [::]                       U    256 0     0 virbr4
[::]/0                         fe80::2a0:ccff:fea2:4fad   UG   1   0     0 p33p1
[::]/0                         fe80::2a0:ccff:fea2:4fad   UGDAe 1024 0     0 p33p1
[::]/0                         [::]                       !n   -1  1 56907 lo
localhost/128                  [::]                       Un   0   1   248 lo
fd00:beef:10:8::/128           [::]                       Un   0   1     0 lo
fd00:beef:10:8::1/128          [::]                       Un   0   1     0 lo
falcon.lcl/128                 [::]                       Un   0   3 16431 lo
fe80::/128                     [::]                       Un   0   1     0 lo
fe80::/128                     [::]                       Un   0   1     0 lo
fe80::3285:a9ff:fe8f:e982/128  [::]                       Un   0   1   576 lo
fe80::5054:ff:fe68:be31/128    [::]                       Un   0   1     0 lo
ff00::/8                       [::]                       U    256 0     0 p33p1
ff00::/8                       [::]                       U    256 0     0 virbr4
[::]/0                         [::]                       !n   -1  1 56907 lo
[root@falcon:~]#
--------------------------------------------------------------------------------

Comment 5 Neil Horman 2013-05-06 16:17:20 UTC
yeah, this isn't a bug as far as I can see.  The magic that your looking for is in fib6_add_rt2node().  When adding a new route, we search for duplicate routes, and should we find one, we compare them to ensure that when the ipv6 stack does a route lookup, they have some way to select which route should be used.  To do that they use the metric/preference number (I admit that use of the term metric in the iproute2 tool is a bit misleading, but if you check the ip-route(8) man page, you'll see its a synonym for preference).  At any rate, since you already have a default gateway (which the stack sees as a duplicate for the one your adding), and the existing route has the same metric/preference as the one you are adding, you get the EXIST error.

Ways to work around this:

1) Use the src option in the ip route add command to differentiate and prevent the existing default gw from being used (might be useful if you want different virt guests to use different default gw).

2) instead of using ip route add, use ip route replace, which will overwrite the existing default gw.

3) Use a different metric value than the existing default gw.  Both routes will be added, but only the higest priority route will be used.

Comment 6 Gene Czarcinski 2013-05-06 17:59:09 UTC
Thank you for promptly addressing this!


Note You need to log in before you can comment on or make changes to this bug.