diff options
author | Florian Westphal <fw@strlen.de> | 2022-12-01 11:13:17 +0100 |
---|---|---|
committer | Florian Westphal <fw@strlen.de> | 2022-12-01 15:18:29 +0100 |
commit | 1b1eb7e784a66882d6d4b0440b716b6aba8c99da (patch) | |
tree | 81ac8ac0fc1c1bad99914cdcc6d3b12ed2636336 /extensions/libxt_statistic.c | |
parent | 7f9a0204683f292f05577cd8b4dfc689cdd8e660 (diff) |
extensions: add xt_statistics random mode translation
Use meta random and bitops to replicate what xt_statistics
is doing.
Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'extensions/libxt_statistic.c')
-rw-r--r-- | extensions/libxt_statistic.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/extensions/libxt_statistic.c b/extensions/libxt_statistic.c index 4f3341a3..37915adc 100644 --- a/extensions/libxt_statistic.c +++ b/extensions/libxt_statistic.c @@ -141,13 +141,19 @@ static int statistic_xlate(struct xt_xlate *xl, switch (info->mode) { case XT_STATISTIC_MODE_RANDOM: - return 0; + xt_xlate_add(xl, "meta random & %u %s %u", + INT_MAX, + info->flags & XT_STATISTIC_INVERT ? ">=" : "<", + info->u.random.probability); + break; case XT_STATISTIC_MODE_NTH: xt_xlate_add(xl, "numgen inc mod %u %s%u", info->u.nth.every + 1, info->flags & XT_STATISTIC_INVERT ? "!= " : "", info->u.nth.packet); break; + default: + return 0; } return 1; |