[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1c585bdf-ebcc-40db-bd36-81d008cf6827@uliege.be>
Date: Wed, 12 Mar 2025 13:32:11 +0100
From: Justin Iurman <justin.iurman@...ege.be>
To: Toke Høiland-Jørgensen <toke@...hat.com>,
netdev@...r.kernel.org
Cc: davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
pabeni@...hat.com, horms@...nel.org, Roopa Prabhu <roopa@...dia.com>,
Andrea Mayer <andrea.mayer@...roma2.it>,
Stefano Salsano <stefano.salsano@...roma2.it>,
Ahmed Abdelsalam <ahabdels.dev@...il.com>, Ido Schimmel <idosch@...dia.com>
Subject: Re: [PATCH net] net: lwtunnel: fix recursion loops
On 3/12/25 13:29, Toke Høiland-Jørgensen wrote:
> Justin Iurman <justin.iurman@...ege.be> writes:
>
>>> --- /dev/null
>>> +++ b/net/core/lwtunnel.h
>>> @@ -0,0 +1,42 @@
>>> +/* SPDX-License-Identifier: GPL-2.0+ */
>>> +#ifndef _NET_CORE_LWTUNNEL_H
>>> +#define _NET_CORE_LWTUNNEL_H
>>> +
>>> +#include <linux/netdevice.h>
>>> +
>>> +#define LWTUNNEL_RECURSION_LIMIT 8
>>> +
>>> +#ifndef CONFIG_PREEMPT_RT
>>> +static inline bool lwtunnel_recursion(void)
>>> +{
>>> + return unlikely(__this_cpu_read(softnet_data.xmit.recursion) >
>>> + LWTUNNEL_RECURSION_LIMIT);
>>> +}
>>> +
>>> +static inline void lwtunnel_recursion_inc(void)
>>> +{
>>> + __this_cpu_inc(softnet_data.xmit.recursion);
>>> +}
>>> +
>>> +static inline void lwtunnel_recursion_dec(void)
>>> +{
>>> + __this_cpu_dec(softnet_data.xmit.recursion);
>>> +}
>>> +#else
>>> +static inline bool lwtunnel_recursion(void)
>>> +{
>>> + return unlikely(current->net_xmit.recursion > LWTUNNEL_RECURSION_LIMIT);
>>> +}
>>> +
>>> +static inline void lwtunnel_recursion_inc(void)
>>> +{
>>> + current->net_xmit.recursion++;
>>> +}
>>> +
>>> +static inline void lwtunnel_recursion_dec(void)
>>> +{
>>> + current->net_xmit.recursion--;
>>> +}
>>> +#endif
>>> +
>>> +#endif /* _NET_CORE_LWTUNNEL_H */
>>
>> Wondering what folks think about the above idea to reuse fields that
>> dev_xmit_recursion() currently uses. IMO, it seems OK considering the
>> use case and context. If not, I guess we'd need to add a new field to
>> both softnet_data and task_struct.
>
> Why not just reuse the dev_xmit_recursion*() helpers directly?
>
> -Toke
>
It was my initial idea, but I'm not sure I can. Looks like they're not
exposed (it's a local .h in net/core/).
Powered by blists - more mailing lists