3

If I have two routes with the same destination, shouldn't the system choose the route that matches it's source address? I'm trying to use the from keyword to add source address constrained routes to the routing table.

For example, I have a host with an address of 2001:db9:1::2 in interface e1. If I add a normal route to 2001:db9:1::3 like below, ping6 works fine:

root@pc:/# ip -6 route add 2001:db9:1::3 dev e1
root@pc:/# ip -6 route
2001:db9:1::3 dev e1  metric 1024

Next I add a source constrained route with the from keyword, using some source address not assigned to any of my interfaces:

root@pc:/# ip -6 route add 2001:db9:1::3 from 2001:db9:a::2 dev e1
root@pc:/# ip -6 route
2001:db9:1::3 from 2001:db9:a::2 dev e1  metric 1024
2001:db9:1::3 dev e1  metric 1024

If I try to ping now, I get a network unreachable message. When the system sees that the first source constrained entry doesn't work, shouldn't it try the second entry and succeed?

Interestingly, if I add a route with a from specifier but with the correct source address, the correct route is selected and the ping is successful.

root@pc:/# ip -6 route add 2001:db9:1::3 from 2001:db9:1::2 dev e1
root@pc:/# ip -6 route
2001:db9:1::3 from 2001:db9:1::2 dev e1  metric 1024
2001:db9:1::3 from 2001:db9:a::2 dev e1  metric 1024
2001:db9:1::3 dev e1  metric 1024

(I also tried using 2001:db9:1::1 as source, and the result is still successful, so lexicographical order doesn't matter). So it seems non-source constrained routes are ignored if a source constrained route exists for a destination.

I already checked the kernel configuration (version 4.9.13) and IPV6_SUBTREES are enabled. Any ideas?

0

It seems that mixing both normal and source specific routes in the same routing table leads to unintended behavior. This is mentioned in net/ipv6/Kconfig in the linux kernel source:

config IPV6_SUBTREES
    bool "IPv6: source address based routing"
    depends on IPV6_MULTIPLE_TABLES
    ---help---
      Enable routing by source address or prefix.

      The destination address is still the primary routing key, so mixing
      normal and source prefix specific routes in the same routing table
      may sometimes lead to unintended routing behavior.  This can be
      avoided by defining different routing tables for the normal and
      source prefix specific routes.

      If unsure, say N.

Putting source constrained routes in a separate routing table gives the correct behavior.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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