* [PATCH] ipv4: fib_rules: Switch to using a for loop in fib_empty_table
@ 2026-11-20 8:12 Nikolay Borisov
2026-11-24 11:03 ` Ido Schimmel
0 siblings, 1 reply; 3+ messages in thread
From: Nikolay Borisov @ 2026-11-20 8:12 UTC (permalink / raw)
To: davem; +Cc: kuba, dsahern, netdev, Nikolay Borisov
Since commit efdfb1e27a33 ("ipv4: fib: bound automatic table ID allocation")
added a sane bound to the loop looking for a table id the concerns in
58075ff523af ("ipv4: fib_rules: Fix possible infinite loop in fib_empty_table")
are rendered moot. Just revert the code back to a "for" loop, using the
new bound. This makes the code's flow and terminating condition a
lot clearer.
No functional changes
Signed-off-by: Nikolay Borisov <nik.borisov@suse.com>
---
net/ipv4/fib_rules.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c
index 060501b376a8..7fe3ec07618a 100644
--- a/net/ipv4/fib_rules.c
+++ b/net/ipv4/fib_rules.c
@@ -218,15 +218,9 @@ INDIRECT_CALLABLE_SCOPE int fib4_rule_match(struct fib_rule *rule,
static struct fib_table *fib_empty_table(struct net *net)
{
- u32 id = 1;
-
- while (1) {
+ for (int id = 1; id <= FIB_MAX_AUTO_TABLE_ID; id++)
if (!fib_get_table(net, id))
return fib_new_table(net, id);
-
- if (id++ == FIB_MAX_AUTO_TABLE_ID)
- break;
- }
return NULL;
}
--
2.56.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] ipv4: fib_rules: Switch to using a for loop in fib_empty_table
2026-11-20 8:12 [PATCH] ipv4: fib_rules: Switch to using a for loop in fib_empty_table Nikolay Borisov
@ 2026-11-24 11:03 ` Ido Schimmel
2026-11-24 11:11 ` Nikolay Borisov
0 siblings, 1 reply; 3+ messages in thread
From: Ido Schimmel @ 2026-11-24 11:03 UTC (permalink / raw)
To: Nikolay Borisov; +Cc: davem, kuba, dsahern, netdev
On Fri, Nov 20, 2026 at 10:12:42AM +0200, Nikolay Borisov wrote:
> Since commit efdfb1e27a33 ("ipv4: fib: bound automatic table ID allocation")
> added a sane bound to the loop looking for a table id the concerns in
> 58075ff523af ("ipv4: fib_rules: Fix possible infinite loop in fib_empty_table")
> are rendered moot. Just revert the code back to a "for" loop, using the
> new bound. This makes the code's flow and terminating condition a
> lot clearer.
I disagree with "a lot clearer". The function is tiny.
Please read:
https://docs.kernel.org/next/process/maintainer-netdev.html#clean-up-patches
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] ipv4: fib_rules: Switch to using a for loop in fib_empty_table
2026-11-24 11:03 ` Ido Schimmel
@ 2026-11-24 11:11 ` Nikolay Borisov
0 siblings, 0 replies; 3+ messages in thread
From: Nikolay Borisov @ 2026-11-24 11:11 UTC (permalink / raw)
To: Ido Schimmel; +Cc: davem, kuba, dsahern, netdev
On 24.11.26 г. 13:03 ч., Ido Schimmel wrote:
> On Fri, Nov 20, 2026 at 10:12:42AM +0200, Nikolay Borisov wrote:
>> Since commit efdfb1e27a33 ("ipv4: fib: bound automatic table ID allocation")
>> added a sane bound to the loop looking for a table id the concerns in
>> 58075ff523af ("ipv4: fib_rules: Fix possible infinite loop in fib_empty_table")
>> are rendered moot. Just revert the code back to a "for" loop, using the
>> new bound. This makes the code's flow and terminating condition a
>> lot clearer.
>
> I disagree with "a lot clearer". The function is tiny.
>
> Please read:
>
> https://docs.kernel.org/next/process/maintainer-netdev.html#clean-up-patches
You are the maintainer, it's your say. However, I disagree that this
patch falls within the "cleanup patches" described in the aforementioned
link.
That function is a linear scan in a [1-4096] space. I see no reason why
a linear scan should be implemented via an infinite while(1) loop with a
terminating condition in the body, when a 'for' loop construct is the
right tool for the job. Anyway, as I said it's up to the maintainers.
Regards,
Nikolay
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-24 11:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20 8:12 [PATCH] ipv4: fib_rules: Switch to using a for loop in fib_empty_table Nikolay Borisov
2026-11-24 11:03 ` Ido Schimmel
2026-11-24 11:11 ` Nikolay Borisov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox