0067-kernel-bridge-ebtables-Avoid-resetting-limit-rule-state.patch 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. From: Linus Lüssing <linus.luessing@c0d3.blue>
  2. Date: Sun, 26 Nov 2017 05:19:21 +0100
  3. Subject: kernel: bridge: ebtables: Avoid resetting limit rule state
  4. Link: https://patchwork.ozlabs.org/patch/841210/
  5. Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
  6. diff --git a/target/linux/generic/patches-4.4/121-bridge-ebtables-Avoid-resetting-limit-rule-state.patch b/target/linux/generic/patches-4.4/121-bridge-ebtables-Avoid-resetting-limit-rule-state.patch
  7. new file mode 100644
  8. index 0000000000000000000000000000000000000000..417fdd75e543ebb6a3fdd56cb97fc83324eeb104
  9. --- /dev/null
  10. +++ b/target/linux/generic/patches-4.4/121-bridge-ebtables-Avoid-resetting-limit-rule-state.patch
  11. @@ -0,0 +1,50 @@
  12. +From 535097827e437bfa1906ed3210e6504750f4342b Mon Sep 17 00:00:00 2001
  13. +From: =?UTF-8?q?Linus=20L=C3=BCssing?= <linus.luessing@c0d3.blue>
  14. +Date: Sat, 25 Nov 2017 00:36:13 +0100
  15. +Subject: [PATCH] bridge: ebtables: Avoid resetting limit rule state
  16. +MIME-Version: 1.0
  17. +Content-Type: text/plain; charset=UTF-8
  18. +Content-Transfer-Encoding: 8bit
  19. +
  20. +So far any changes with ebtables will reset the state of limit rules,
  21. +leading to spikes in traffic. This is especially noticeable if changes
  22. +are done frequently, for instance via a daemon.
  23. +
  24. +This patch fixes this by bailing out from (re)setting if the limit
  25. +rule was initialized before.
  26. +
  27. +When sending packets every 250ms for 600s, with a
  28. +"--limit 1/sec --limit-burst 50" rule and a command like this
  29. +in the background:
  30. +
  31. +$ ebtables -N VOIDCHAIN
  32. +$ while true; do ebtables -F VOIDCHAIN; sleep 30; done
  33. +
  34. +The results are:
  35. +
  36. +Before: ~1600 packets
  37. +After: 650 packets
  38. +
  39. +Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
  40. +---
  41. + net/bridge/netfilter/ebt_limit.c | 4 ++++
  42. + 1 file changed, 4 insertions(+)
  43. +
  44. +diff --git a/net/bridge/netfilter/ebt_limit.c b/net/bridge/netfilter/ebt_limit.c
  45. +index 61a9f1be1263..f74b48633feb 100644
  46. +--- a/net/bridge/netfilter/ebt_limit.c
  47. ++++ b/net/bridge/netfilter/ebt_limit.c
  48. +@@ -69,6 +69,10 @@ static int ebt_limit_mt_check(const struct xt_mtchk_param *par)
  49. + {
  50. + struct ebt_limit_info *info = par->matchinfo;
  51. +
  52. ++ /* Do not reset state on unrelated table changes */
  53. ++ if (info->prev)
  54. ++ return 0;
  55. ++
  56. + /* Check for overflow. */
  57. + if (info->burst == 0 ||
  58. + user2credits(info->avg * info->burst) < user2credits(info->avg)) {
  59. +--
  60. +2.11.0
  61. +