[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEA6p_BdnBB71eQJ7LGWDiZpkymQKJ_TcFJ78xZ8-vB94QHXyA@mail.gmail.com>
Date: Fri, 6 Oct 2017 19:06:01 -0700
From: Wei Wang <weiwan@...gle.com>
To: 吉藤英明 <hideaki.yoshifuji@...aclelinux.com>
Cc: David Miller <davem@...emloft.net>,
network dev <netdev@...r.kernel.org>,
Eric Dumazet <edumazet@...gle.com>,
Martin KaFai Lau <kafai@...com>,
YOSHIFUJI Hideaki <yoshfuji@...ux-ipv6.org>
Subject: Re: [PATCH net-next 11/16] ipv6: replace dst_hold() with
dst_hold_safe() in routing code
On Fri, Oct 6, 2017 at 4:57 PM, 吉藤英明 <hideaki.yoshifuji@...aclelinux.com> wrote:
> Hi,
>
> 2017-10-07 4:06 GMT+09:00 Wei Wang <weiwan@...gle.com>:
>> 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
Powered by blists - more mailing lists