[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87y0xah1ol.fsf@toke.dk>
Date: Wed, 12 Mar 2025 13:29:46 +0100
From: Toke Høiland-Jørgensen <toke@...hat.com>
To: Justin Iurman <justin.iurman@...ege.be>, 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
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
Powered by blists - more mailing lists