All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] bridge: ebtables: Avoid resetting limit rule state
@ 2017-11-25  7:44 ` Linus Lüssing
  0 siblings, 0 replies; 17+ messages in thread
From: Linus Lüssing @ 2017-11-25  7:44 UTC (permalink / raw)
  To: netfilter-devel
  Cc: Pablo Neira Ayuso, Jozsef Kadlecsik, Florian Westphal,
	Stephen Hemminger, David S . Miller, coreteam, bridge, netdev,
	linux-kernel, Linus Lüssing

So far any changes with ebtables will reset the state of limit rules,
leading to spikes in traffic. This is especially noticeable if changes
are done frequently, for instance via a daemon.

This patch fixes this by bailing out from (re)setting if the limit
rule was initialized before.

When sending packets every 250ms for 600s, with a
"--limit 1/sec --limit-burst 50" rule and a command like this
in the background:

$ ebtables -N VOIDCHAIN
$ while true; do ebtables -F VOIDCHAIN; sleep 30; done

The results are:

Before: ~1600 packets
After: 650 packets

Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
---
 net/bridge/netfilter/ebt_limit.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/bridge/netfilter/ebt_limit.c b/net/bridge/netfilter/ebt_limit.c
index 61a9f1be1263..f74b48633feb 100644
--- a/net/bridge/netfilter/ebt_limit.c
+++ b/net/bridge/netfilter/ebt_limit.c
@@ -69,6 +69,10 @@ static int ebt_limit_mt_check(const struct xt_mtchk_param *par)
 {
 	struct ebt_limit_info *info = par->matchinfo;
 
+	/* Do not reset state on unrelated table changes */
+	if (info->prev)
+		return 0;
+
 	/* Check for overflow. */
 	if (info->burst == 0 ||
 	    user2credits(info->avg * info->burst) < user2credits(info->avg)) {
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2017-12-08  5:49 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-25  7:44 [PATCH net-next] bridge: ebtables: Avoid resetting limit rule state Linus Lüssing
2017-11-25  7:44 ` [Bridge] " Linus Lüssing
2017-11-27 23:30 ` Pablo Neira Ayuso
2017-11-27 23:30   ` [Bridge] " Pablo Neira Ayuso
2017-12-04  4:53   ` Linus Lüssing
2017-12-04  4:53     ` [Bridge] " Linus Lüssing
2017-12-04  4:53     ` Linus Lüssing
2017-12-04  5:20     ` [Bridge] " Linus Lüssing
2017-12-04 10:13       ` Pablo Neira Ayuso
2017-12-07  0:26     ` Pablo Neira Ayuso
2017-12-07  0:26       ` [Bridge] " Pablo Neira Ayuso
2017-12-07  0:26       ` Pablo Neira Ayuso
2017-12-08  5:46       ` Linus Lüssing
2017-12-08  5:46         ` [Bridge] " Linus Lüssing
2017-12-08  5:49         ` Linus Lüssing
2017-12-08  5:49           ` [Bridge] " Linus Lüssing
2017-12-08  5:49           ` Linus Lüssing

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.