ipv4: fib_rules: Switch to using a for loop in fib_empty_table
Subsystems (3)
PATCH 1/1 ipv4: fib_rules: Switch to using a for loop in fib_empty_table
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
--- net/ipv4/fib_rules.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
net/ipv4/fib_rules.c +1 -7
@@ -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 ; }
Signature · 1 line
2.56.0
Quoted 6 lines · 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 in58075ff523af("ipv4:fib_rules: Fix possible infinite loop infib_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
Quoted 8 lines · Ido Schimmel
Quoted 6 lines · 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 in58075ff523af("ipv4:fib_rules: Fix possible infinite loop infib_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.
Quoted 5 lines
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