Q: Does kernel IPv6 route support route cache ?
yes. but it is very different with IPv4.
It should be ‘clone’ strictly speaking.
For simple let us only focus on ip6_pol_route, and variable struct rt6_info *nrt.
When a route is matched, a
nrtwill be created byrt6_alloc_coworrt6_alloc_clone.the
nrtwill be set with flagRTF_CACHE;ip6_ins_rtinsert the newnrtto fib tree.kernel starts fib6 gc for
nrt.
so there will be a new cache route, and after a period it will disappear.
Data structure
1 | 89 struct rt6_info { |
call trace
Fox exmaple: forwarding a IPv6 packet.
1 | > ip6_rcv_finish |
methods
1 | 830 int ip6_ins_rt(struct rt6_info *rt) |
1 | 817 static int __ip6_ins_rt(struct rt6_info *rt, struct nl_info *info) |
1 | 809 int fib6_add(struct fib6_node *root, struct rt6_info *rt, struct nl_info *info) |
test log
add IPv6 address to a interface.
1 | ➜ ~ sudo ip addr add dev eth0 3ffe::1/64 |
check the related IPv6 route
1 | ➜ ~ sudo ip -6 route |
try to a ping6 test(expect failed).
1 | ➜ ~ ping6 3ffe::2 |
check the route again.
1 | ➜ ~ sudo ip -6 route show cache |
A cache route is inserted, while common route unchanged.
1 | ➜ ~ sudo ip -6 route show |
after a period, check again. cache route disappear.
1 | ➜ ~ sudo ip -6 route show cache |
Serveral questions:
Q1: What kernel will do with subnet route vs route cache?
ex:
1. add route 3ffe::1/64
2. ping route 3ffe::2 a route cache will be insert to fib tree.
3. add roue 3ffe::1/96
What kernel will do with it? the cache route will be deleted?
See following line in function fib6_add, kernel will prune all clone/cache route.
1 | 903 err = fib6_add_rt2node(fn, rt, info); |