From: Kui-Feng Lee <sinquersw@gmail.com>
To: Eric Dumazet <edumazet@google.com>
Cc: David Ahern <dsahern@kernel.org>,
patchwork-bot+netdevbpf@kernel.org,
Kui-Feng Lee <thinker.li@gmail.com>,
davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
netdev@vger.kernel.org, eric.dumazet@gmail.com
Subject: Re: [PATCH net-next] ipv6: add debug checks in fib6_info_release()
Date: Thu, 7 Dec 2023 11:08:22 -0800 [thread overview]
Message-ID: <dd9aefd4-b436-4ef7-8d1f-e966bccb2a14@gmail.com> (raw)
In-Reply-To: <CANn89iJo6i67tf=k8_KHYNFXy1DyPoOZKLB2NbyY4xqmp_qWgw@mail.gmail.com>
On 12/7/23 11:05, Eric Dumazet wrote:
> On Thu, Dec 7, 2023 at 8:00 PM Kui-Feng Lee <sinquersw@gmail.com> wrote:
>>
>>
>>
>> On 12/7/23 10:40, Kui-Feng Lee wrote:
>>>
>>>
>>> On 12/7/23 10:36, Kui-Feng Lee wrote:
>>>>
>>>>
>>>> On 12/7/23 10:25, David Ahern wrote:
>>>>> On 12/7/23 11:22 AM, Eric Dumazet wrote:
>>>>>> Feel free to amend the patch, but the issue is that we insert a fib
>>>>>> gc_link to a list, then free the fi6 object without removing it first
>>>>>> from the external list.
>>>>>
>>>>> yes, move the insert down:
>>>>>
>>>>> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
>>>>> index b132feae3393..7257ba0e72b7 100644
>>>>> --- a/net/ipv6/route.c
>>>>> +++ b/net/ipv6/route.c
>>>>> @@ -3762,12 +3762,6 @@ static struct fib6_info
>>>>> *ip6_route_info_create(struct fib6_config *cfg,
>>>>> if (cfg->fc_flags & RTF_ADDRCONF)
>>>>> rt->dst_nocount = true;
>>>>>
>>>>> - if (cfg->fc_flags & RTF_EXPIRES)
>>>>> - fib6_set_expires_locked(rt, jiffies +
>>>>> -
>>>>> clock_t_to_jiffies(cfg->fc_expires));
>>>>> - else
>>>>> - fib6_clean_expires_locked(rt);
>>>>> -
>>>>
>>>> fib6_set_expires_locked() here actually doesn't insert a fib gc_link
>>>> since rt->fib6_table is not assigned yet. The gc_link will
>>>> be inserted by fib6_add() being called later.
>>>>
>>>>
>>>>> if (cfg->fc_protocol == RTPROT_UNSPEC)
>>>>> cfg->fc_protocol = RTPROT_BOOT;
>>>>> rt->fib6_protocol = cfg->fc_protocol;
>>>>> @@ -3824,6 +3818,12 @@ static struct fib6_info
>>>>> *ip6_route_info_create(struct fib6_config *cfg,
>>>>> } else
>>>>> rt->fib6_prefsrc.plen = 0;
>>>>>
>>>>> +
>>>>> + if (cfg->fc_flags & RTF_EXPIRES)
>>>>> + fib6_set_expires_locked(rt, jiffies +
>>>>> +
>>>>> clock_t_to_jiffies(cfg->fc_expires));
>>>>> + else
>>>>> + fib6_clean_expires_locked(rt);
>>>>> return rt;
>>>>> out:
>>>>> fib6_info_release(rt);
>>>>
>>>> However, this should fix the warning messages.
>>> Just realize this cause inserting the gc_link twice. fib6_add()
>>> will try to add it again!
>>
>> I made a minor change to the patch that fix warning messages
>> provided by David Ahern. Will send an official patch later.
>>
>> --- a/net/ipv6/route.c
>> +++ b/net/ipv6/route.c
>> @@ -3762,17 +3762,10 @@ static struct fib6_info
>> *ip6_route_info_create(struct fib6_config *cfg,
>> if (cfg->fc_flags & RTF_ADDRCONF)
>> rt->dst_nocount = true;
>>
>> - if (cfg->fc_flags & RTF_EXPIRES)
>> - fib6_set_expires_locked(rt, jiffies +
>> -
>> clock_t_to_jiffies(cfg->fc_expires));
>> - else
>> - fib6_clean_expires_locked(rt);
>> -
>> if (cfg->fc_protocol == RTPROT_UNSPEC)
>> cfg->fc_protocol = RTPROT_BOOT;
>> rt->fib6_protocol = cfg->fc_protocol;
>>
>> - rt->fib6_table = table;
>> rt->fib6_metric = cfg->fc_metric;
>> rt->fib6_type = cfg->fc_type ? : RTN_UNICAST;
>> rt->fib6_flags = cfg->fc_flags & ~RTF_GATEWAY;
>> @@ -3824,6 +3817,17 @@ static struct fib6_info
>> *ip6_route_info_create(struct fib6_config *cfg,
>> } else
>> rt->fib6_prefsrc.plen = 0;
>>
>> + if (cfg->fc_flags & RTF_EXPIRES)
>> + fib6_set_expires_locked(rt, jiffies +
>> +
>> clock_t_to_jiffies(cfg->fc_expires));
>> + else
>> + fib6_clean_expires_locked(rt);
>
> Note that I do not see why we call fib6_clean_expires_locked() on a
> freshly allocated object.
>
> f6i->expires should already be zero...
>
Agree! I will remove it as well.
>> + /* Set fib6_table after fib6_set_expires_locked() to ensure the
>> + * gc_link is not inserted until fib6_add() is called to insert the
>> + * fib6_info to the fib.
>> + */
>> + rt->fib6_table = table;
>> +
>> return rt;
>> out:
next prev parent reply other threads:[~2023-12-07 19:08 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-05 17:32 [PATCH net-next] ipv6: add debug checks in fib6_info_release() Eric Dumazet
2023-12-06 3:41 ` David Ahern
2023-12-07 3:10 ` patchwork-bot+netdevbpf
2023-12-07 13:29 ` Eric Dumazet
2023-12-07 16:43 ` Kui-Feng Lee
2023-12-07 18:06 ` Kui-Feng Lee
2023-12-07 18:10 ` Eric Dumazet
2023-12-07 18:19 ` Kui-Feng Lee
2023-12-07 18:22 ` Eric Dumazet
2023-12-07 18:25 ` David Ahern
2023-12-07 18:26 ` David Ahern
2023-12-07 18:36 ` Kui-Feng Lee
2023-12-07 18:40 ` Kui-Feng Lee
2023-12-07 19:00 ` Kui-Feng Lee
2023-12-07 19:05 ` Eric Dumazet
2023-12-07 19:08 ` Kui-Feng Lee [this message]
2023-12-07 19:14 ` Eric Dumazet
2023-12-07 18:46 ` Kui-Feng Lee
2023-12-07 18:55 ` Eric Dumazet
2023-12-07 23:02 ` Kui-Feng Lee
2023-12-08 9:18 ` Eric Dumazet
2023-12-08 18:20 ` Kui-Feng Lee
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dd9aefd4-b436-4ef7-8d1f-e966bccb2a14@gmail.com \
--to=sinquersw@gmail.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=eric.dumazet@gmail.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=patchwork-bot+netdevbpf@kernel.org \
--cc=thinker.li@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.