]> git.baikalelectronics.ru Git - kernel.git/commit
ipv6: set rt6i_protocol properly in the route when it is installed
authorXin Long <lucien.xin@gmail.com>
Thu, 3 Aug 2017 06:13:46 +0000 (14:13 +0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 3 Aug 2017 22:10:18 +0000 (15:10 -0700)
commitc35eecb08e75eeb542f8b1eadb2e4b506a1f001d
treee569db3ef34e64ed7ec7912c6f6a9cc966613f32
parente2c4fdd5ea6cd5f17d0c960f8816c2f885a21c8f
ipv6: set rt6i_protocol properly in the route when it is installed

After commit 3eadd3374c1b ("net: ipv6: check route protocol when
deleting routes"), ipv6 route checks rt protocol when trying to
remove a rt entry.

It introduced a side effect causing 'ip -6 route flush cache' not
to work well. When flushing caches with iproute, all route caches
get dumped from kernel then removed one by one by sending DELROUTE
requests to kernel for each cache.

The thing is iproute sends the request with the cache whose proto
is set with RTPROT_REDIRECT by rt6_fill_node() when kernel dumps
it. But in kernel the rt_cache protocol is still 0, which causes
the cache not to be matched and removed.

So the real reason is rt6i_protocol in the route is not set when
it is allocated. As David Ahern's suggestion, this patch is to
set rt6i_protocol properly in the route when it is installed and
remove the codes setting rtm_protocol according to rt6i_flags in
rt6_fill_node.

This is also an improvement to keep rt6i_protocol consistent with
rtm_protocol.

Fixes: 3eadd3374c1b ("net: ipv6: check route protocol when deleting routes")
Reported-by: Jianlin Shi <jishi@redhat.com>
Suggested-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv6/route.c