Bug 13535 - possibly wrong logic in xt_rateest.c
Summary: possibly wrong logic in xt_rateest.c
Status: RESOLVED CODE_FIX
Alias: None
Product: Networking
Classification: Unclassified
Component: Netfilter/Iptables (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: networking_netfilter-iptables@kernel-bugs.osdl.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-14 09:44 UTC by Török Edwin
Modified: 2013-12-10 16:37 UTC (History)
2 users (show)

See Also:
Kernel Version: 2.6.30
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Török Edwin 2009-06-14 09:44:27 UTC
Compiling the kernel with clang has shown this warning:

net/netfilter/xt_rateest.c:69:16: warning: self-comparison always results in a constant value
                        ret &= pps2 == pps2;
                                    ^
Looking at the code:
if (info->flags & XT_RATEEST_MATCH_BPS)
			ret &= bps1 == bps2;
		if (info->flags & XT_RATEEST_MATCH_PPS)
			ret &= pps2 == pps2;

Judging from the MATCH_BPS case it seems to be a typo, with the intention of comparing pps1 with pps2.

If my intepretation is correct, then the following patch should fix this:

diff --git a/net/netfilter/xt_rateest.c b/net/netfilter/xt_rateest.c
index 220a1d5..4fc6a91 100644
--- a/net/netfilter/xt_rateest.c
+++ b/net/netfilter/xt_rateest.c
@@ -66,7 +66,7 @@ xt_rateest_mt(const struct sk_buff *skb, const struct xt_match_param *par)
                if (info->flags & XT_RATEEST_MATCH_BPS)
                        ret &= bps1 == bps2;
                if (info->flags & XT_RATEEST_MATCH_PPS)
-                       ret &= pps2 == pps2;
+                       ret &= pps1 == pps2;
                break;
        }
Comment 1 Patrick McHardy 2009-06-19 12:26:11 UTC
Good catch, thanks. I've queued your patch for upstream submission.

Note You need to log in before you can comment on or make changes to this bug.