]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
netfilter: xt_rateest: fix u64 truncation in xt_rateest_mt()
authorFeng Wu <wufengwufengwufeng@gmail.com>
Thu, 25 Jun 2026 08:44:25 +0000 (08:44 +0000)
committerFlorian Westphal <fw@strlen.de>
Fri, 3 Jul 2026 12:45:21 +0000 (14:45 +0200)
On links faster than ~34 Gbps, where byte rate may exceed 2^32-1
(~ 4.3 GBps), the comparison result becomes incorrect because the
truncated value no longer reflects the actual estimator rate.

Fix by changing the local variables to u64.

Fixes: 1c0d32fde5bd ("net_sched: gen_estimator: complete rewrite of rate estimators")
Signed-off-by: Feng Wu <wufengwufengwufeng@gmail.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
net/netfilter/xt_rateest.c

index b1d736c15fcbe5e22ae9077feb8e1f11c8afa8bb..7c05b63425784e9933243fa19365abcd89b1c3a5 100644 (file)
@@ -16,7 +16,7 @@ xt_rateest_mt(const struct sk_buff *skb, struct xt_action_param *par)
 {
        const struct xt_rateest_match_info *info = par->matchinfo;
        struct gnet_stats_rate_est64 sample = {0};
-       u_int32_t bps1, bps2, pps1, pps2;
+       u64 bps1, bps2, pps1, pps2;
        bool ret = true;
 
        gen_estimator_read(&info->est1->rate_est, &sample);