On Fri, Oct 6, 2017 at 4:57 PM, 吉藤英明 <[email protected]> wrote:
> Hi,
>
> 2017-10-07 4:06 GMT+09:00 Wei Wang <[email protected]>:
>> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
>> index 941c062389d2..aeb349aea429 100644
>> --- a/net/ipv6/route.c
>> +++ b/net/ipv6/route.c
> :
>> @@ -1625,12 +1643,17 @@ struct rt6_info *ip6_pol_route(struct net *net,
>> struct fib6_table *table,
>> if (rt_cache)
>> rt = rt_cache;
>>
>> - if (rt == net->ipv6.ip6_null_entry || (rt->rt6i_flags & RTF_CACHE)) {
>> - dst_use(&rt->dst, jiffies);
>> + if (rt == net->ipv6.ip6_null_entry) {
>> + read_unlock_bh(&table->tb6_lock);
>> + dst_hold(&rt->dst);
>> + trace_fib6_table_lookup(net, rt, table->tb6_id, fl6);
>> + return rt;
>> + } else if (rt->rt6i_flags & RTF_CACHE) {
>> + if (ip6_hold_safe(net, &rt, true)) {
>> + dst_use_noref(&rt->dst, jiffies);
>> + rt6_dst_from_metrics_check(rt);
>> + }
>> read_unlock_bh(&table->tb6_lock);
>> -
>> - rt6_dst_from_metrics_check(rt);
>> -
>> trace_fib6_table_lookup(net, rt, table->tb6_id, fl6);
>> return rt;
>> } else if (unlikely((fl6->flowi6_flags & FLOWI_FLAG_KNOWN_NH) &&
>
> Is it intended to move rt6_dst_from_metrics_check() inside the table lock?
>
I think it doesn't really matter whether rt6_dst_from_metrics_check()
is inside the table lock or not. The code looks cleaner if we put it
inside the if (ip6_hold_safe()) {} block because we don't want to do
rt6_dst_from_metrics_check() if ip6_hold_safe() returns false.
> --yoshfuji