From: Jan Engelhardt <jengelh@medozas.de>
To: kaber@trash.net
Cc: netfilter-devel@vger.kernel.org
Subject: [PATCH 11/13] libxt_rateest: fix rateest save operation
Date: Mon, 23 May 2011 16:39:21 +0200 [thread overview]
Message-ID: <1306161564-4370-12-git-send-email-jengelh@medozas.de> (raw)
In-Reply-To: <1306161564-4370-1-git-send-email-jengelh@medozas.de>
rateest's save operation was pretty much busted.
References: http://marc.info/?l=netfilter&m=130332436408107&w=2
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
---
extensions/libxt_rateest.c | 73 +++++++++++++++++++++++++++++++++-----------
1 files changed, 55 insertions(+), 18 deletions(-)
diff --git a/extensions/libxt_rateest.c b/extensions/libxt_rateest.c
index 62d6033..2244558 100644
--- a/extensions/libxt_rateest.c
+++ b/extensions/libxt_rateest.c
@@ -399,27 +399,64 @@ rateest_save(const void *ip, const struct xt_entry_match *match)
{
const struct xt_rateest_match_info *info = (const void *)match->data;
+ if (info->flags & XT_RATEEST_MATCH_DELTA)
+ printf(" --rateest-delta");
+
if (info->flags & XT_RATEEST_MATCH_REL) {
- printf(" --rateest1 %s", info->name1);
- if (info->flags & XT_RATEEST_MATCH_BPS)
- printf(" --rateest-bps");
- if (info->flags & XT_RATEEST_MATCH_PPS)
- printf(" --rateest-pps");
- rateest_print_mode(info, " --rateest-");
- printf(" --rateest2 %s", info->name2);
- } else {
- printf(" --rateest %s", info->name1);
- if (info->flags & XT_RATEEST_MATCH_BPS) {
- printf(" --rateest-bps1");
- rateest_print_rate(info->bps1, 0);
- printf(" --rateest-bps2");
- rateest_print_rate(info->bps2, 0);
+ printf(" --rateest1");
+ xtables_save_string(info->name1);
+ if (info->flags & XT_RATEEST_MATCH_DELTA) {
+ if (info->flags & XT_RATEEST_MATCH_BPS) {
+ printf(" --rateest-bps1");
+ rateest_print_rate(info->bps1, 0);
+ } else {
+ printf(" --rateest-pps1 %u", info->pps1);
+ }
rateest_print_mode(info, "--rateest-");
- }
- if (info->flags & XT_RATEEST_MATCH_PPS) {
- printf(" --rateest-pps");
+ printf(" --rateest2");
+ xtables_save_string(info->name2);
+ if (info->flags & XT_RATEEST_MATCH_BPS) {
+ printf(" --rateest-bps2");
+ rateest_print_rate(info->bps2, 0);
+ } else {
+ printf(" --rateest-pps2 %u", info->pps2);
+ }
+ } else {
rateest_print_mode(info, "--rateest-");
- printf(" %u", info->pps2);
+ printf(" --rateest2");
+ xtables_save_string(info->name2);
+ printf(info->flags & XT_RATEEST_MATCH_BPS ?
+ " --bytes" : " --packets");
+ }
+ } else {
+ printf(" --rateest");
+ xtables_save_string(info->name1);
+ if (info->flags & XT_RATEEST_MATCH_DELTA) {
+ if (info->flags & XT_RATEEST_MATCH_BPS) {
+ printf(" --rateest-bps1");
+ rateest_print_rate(info->bps1, 0);
+ } else {
+ printf(" --rateest-pps1 %u",
+ (unsigned int)info->pps1);
+ }
+ }
+ rateest_print_mode(info, "--rateest-");
+ if (info->flags & XT_RATEEST_MATCH_DELTA) {
+ if (info->flags & XT_RATEEST_MATCH_BPS) {
+ printf(" --rateest-bps2");
+ rateest_print_rate(info->bps2, 0);
+ } else {
+ printf(" --rateest-pps2 %u",
+ (unsigned int)info->pps2);
+ }
+ } else {
+ if (info->flags & XT_RATEEST_MATCH_BPS) {
+ printf(" --rateest-bps");
+ rateest_print_rate(info->bps2, 0);
+ } else {
+ printf(" --rateest-pps %u",
+ (unsigned int)info->pps2);
+ }
}
}
}
--
1.7.3.4
next prev parent reply other threads:[~2011-05-23 14:39 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-23 14:39 option parsing, run 9 Jan Engelhardt
2011-05-23 14:39 ` [PATCH 01/13] libxtables: retract _NE types and use a flag instead Jan Engelhardt
2011-05-23 14:39 ` [PATCH 02/13] libipt_REDIRECT: "--to-ports" is not mandatory Jan Engelhardt
2011-05-23 14:39 ` [PATCH 03/13] libxt_quota: readd missing XTOPT_PUT request Jan Engelhardt
2011-05-23 14:39 ` [PATCH 04/13] libxt_quota: make sure uint64 is not truncated Jan Engelhardt
2011-05-23 14:39 ` [PATCH 05/13] libxtables: check for negative numbers in xtables_strtou* Jan Engelhardt
2011-05-23 14:39 ` [PATCH 06/13] libxt_rateest: streamline case display of units Jan Engelhardt
2011-05-23 14:39 ` [PATCH 07/13] doc: add some coded option examples to libxt_hashlimit Jan Engelhardt
2011-05-23 14:39 ` [PATCH 08/13] doc: make usage of libxt_rateest more obvious Jan Engelhardt
2011-05-23 14:39 ` [PATCH 09/13] doc: clarify that -p all is a special keyword only Jan Engelhardt
2011-05-23 14:39 ` [PATCH 10/13] libxt_rateest: avoid optional arguments Jan Engelhardt
2011-05-24 6:46 ` Patrick McHardy
2011-05-24 8:03 ` Jan Engelhardt
2011-05-24 8:14 ` Patrick McHardy
2011-05-24 8:51 ` Jan Engelhardt
2011-05-24 12:49 ` Patrick McHardy
2011-05-23 14:39 ` Jan Engelhardt [this message]
2011-05-23 14:39 ` [PATCH 12/13] libxt_rateest: use guided option parser Jan Engelhardt
2011-05-23 14:39 ` [PATCH 13/13] libxt_ipvs: restore network-byte order Jan Engelhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1306161564-4370-12-git-send-email-jengelh@medozas.de \
--to=jengelh@medozas.de \
--cc=kaber@trash.net \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).