From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: kaber@trash.net
Subject: [PATCH nft 2/3] netlink_delinearize: fix listing of set members in host byteorder using integer_type
Date: Mon, 8 Dec 2014 23:24:33 +0100 [thread overview]
Message-ID: <1418077474-6431-2-git-send-email-pablo@netfilter.org> (raw)
In-Reply-To: <1418077474-6431-1-git-send-email-pablo@netfilter.org>
nft list table filter
...
cpu { 50331648, 33554432, 0, 16777216} counter packets 8 bytes 344
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
src/netlink_delinearize.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/src/netlink_delinearize.c b/src/netlink_delinearize.c
index c809bb6..e9a04dd 100644
--- a/src/netlink_delinearize.c
+++ b/src/netlink_delinearize.c
@@ -742,6 +742,29 @@ static void payload_dependency_store(struct rule_pp_ctx *ctx,
ctx->pdep = stmt;
}
+static void integer_type_postprocess(struct expr *expr)
+{
+ struct expr *i;
+
+ switch (expr->ops->type) {
+ case EXPR_VALUE:
+ if (expr->byteorder == BYTEORDER_HOST_ENDIAN) {
+ uint32_t len = div_round_up(expr->len, BITS_PER_BYTE);
+
+ mpz_switch_byteorder(expr->value, len);
+ }
+ break;
+ case EXPR_SET_REF:
+ list_for_each_entry(i, &expr->set->init->expressions, list) {
+ expr_set_type(i, expr->dtype, expr->byteorder);
+ integer_type_postprocess(i);
+ }
+ break;
+ default:
+ break;
+ }
+}
+
static void payload_match_postprocess(struct rule_pp_ctx *ctx,
struct stmt *stmt, struct expr *expr)
{
@@ -805,6 +828,12 @@ static void meta_match_postprocess(struct rule_pp_ctx *ctx,
left->flags & EXPR_F_PROTOCOL)
payload_dependency_store(ctx, stmt, left->meta.base);
break;
+ case OP_LOOKUP:
+ expr_set_type(expr->right, expr->left->dtype,
+ expr->left->byteorder);
+ if (expr->right->dtype == &integer_type)
+ integer_type_postprocess(expr->right);
+ break;
default:
break;
}
--
1.7.10.4
next prev parent reply other threads:[~2014-12-08 22:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-08 22:24 [PATCH nft 1/3] src: generate set members using integer_type in the appropriate byteorder Pablo Neira Ayuso
2014-12-08 22:24 ` Pablo Neira Ayuso [this message]
2014-12-09 7:53 ` [PATCH nft 2/3] netlink_delinearize: fix listing of set members in host byteorder using integer_type Patrick McHardy
2014-12-09 14:19 ` Pablo Neira Ayuso
2014-12-09 14:25 ` Patrick McHardy
2014-12-08 22:24 ` [PATCH nft 3/3] netlink: fix listing of range set elements in host byteorder Pablo Neira Ayuso
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=1418077474-6431-2-git-send-email-pablo@netfilter.org \
--to=pablo@netfilter.org \
--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 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.