ipvs: Fix clamp() order in ip_vs_conn_init()
Subsystems (4)
PATCH v2 1/1 ipvs: Fix clamp() order in ip_vs_conn_init()
We recently added some build time asserts to detect incorrect calls to clamp and it detected this bug which breaks the build. The variable in this clamp is "max_avail" and it should be the first argument. The code currently is the equivalent to max = min(max_avail, max).
There probably aren't very many systems out there where we actually can hit the minimum value so this doesn't affect runtime for most people.
---
v2: In the commit message, I said max() but it should have been min().
I added a note that this bug probably doesn't affect too many people in real life. I also added David Laight as a Suggested-by because he did all the work root causing this bug and he already sent a similar patch last week.
Added Bartosz's tested by tags.
net/netfilter/ipvs/ip_vs_conn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/ipvs/ip_vs_conn.c +1 -1
@@ -1495,7 +1495,7 @@ int __init ip_vs_conn_init(void) max_avail -=2 ;/* ~4 in hash row */ max_avail -=1 ;/* IPVS up to 1/2 of mem */ max_avail -=order_base_2 (sizeof (struct ip_vs_conn )); - max =clamp (max, min, max_avail); + max =clamp (max_avail, min, max); ip_vs_conn_tab_bits =clamp_val (ip_vs_conn_tab_bits, min, max); ip_vs_conn_tab_size =1 << ip_vs_conn_tab_bits; ip_vs_conn_tab_mask = ip_vs_conn_tab_size -1 ;
Signature · 1 line
2.45.2