From: Florian Westphal <fw@strlen.de>
To: <netfilter-devel@vger.kernel.org>
Cc: Florian Westphal <fw@strlen.de>
Subject: [PATCH nftables 5/9] src: add host byte order integer type
Date: Fri, 3 Feb 2017 13:35:52 +0100 [thread overview]
Message-ID: <20170203123556.17357-6-fw@strlen.de> (raw)
In-Reply-To: <20170203123556.17357-1-fw@strlen.de>
This is needed once we add support to set a zone, as in
ct zone set 42
Using integer_type makes nft use big-endian representation of the zone id
instead of the required host byte order.
When using 'ct zone 1', things will work because the (implicit) relational
operation makes sure that the left and right sides have same byte order.
In the statement case the lack of relop means we either need to convert
ourselves (the ct template contains endianess info), or use a dedicated type
(the latter is the reason why setting a mark will 'just work' since the
mark type takes care of it).
The dedicated type has the advantage that it also works when maps are used:
ct zone set mark map { 1 : 10, 2 : 20, 3 : 30 }
... which is not easy to do with current map/set code, its endianess
settings rely on dtype->byteorder (i.e., it will always set BIG_ENDIAN
when we'd use integer_type for the zone).
Using evaluation context seems like a nightmare because several
places during eval steps can re-set this information, and propagating
the template info means to pollute generic code with something specific
to ct.
It seems like a future removal of all .byteorder members in the templates
in favor of using appropriate types might be a good idea.
Signed-off-by: Florian Westphal <fw@strlen.de>
---
include/datatype.h | 2 ++
src/datatype.c | 10 ++++++++++
2 files changed, 12 insertions(+)
diff --git a/include/datatype.h b/include/datatype.h
index 9f127f2954e3..8c1c827253be 100644
--- a/include/datatype.h
+++ b/include/datatype.h
@@ -82,6 +82,7 @@ enum datatypes {
TYPE_DSCP,
TYPE_ECN,
TYPE_FIB_ADDR,
+ TYPE_U32,
__TYPE_MAX
};
#define TYPE_MAX (__TYPE_MAX - 1)
@@ -231,6 +232,7 @@ extern const struct datatype icmp_code_type;
extern const struct datatype icmpv6_code_type;
extern const struct datatype icmpx_code_type;
extern const struct datatype time_type;
+extern const struct datatype u32_type;
extern const struct datatype *concat_type_alloc(uint32_t type);
extern void concat_type_destroy(const struct datatype *dtype);
diff --git a/src/datatype.c b/src/datatype.c
index 1518606a3f89..cab42d47f0f0 100644
--- a/src/datatype.c
+++ b/src/datatype.c
@@ -48,6 +48,7 @@ static const struct datatype *datatypes[TYPE_MAX + 1] = {
[TYPE_ICMP_CODE] = &icmp_code_type,
[TYPE_ICMPV6_CODE] = &icmpv6_code_type,
[TYPE_ICMPX_CODE] = &icmpx_code_type,
+ [TYPE_U32] = &u32_type,
};
void datatype_register(const struct datatype *dtype)
@@ -1057,3 +1058,12 @@ struct error_record *rate_parse(const struct location *loc, const char *str,
return NULL;
}
+
+const struct datatype u32_type = {
+ .type = TYPE_U32,
+ .name = "u32",
+ .desc = "32bit host endian integer",
+ .size = 4 * BITS_PER_BYTE,
+ .byteorder = BYTEORDER_HOST_ENDIAN,
+ .basetype = &integer_type,
+};
--
2.10.2
next prev parent reply other threads:[~2017-02-03 12:35 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-03 12:35 [PATCH -next 0/9] nftables: add zone support to ct statement Florian Westphal
2017-02-03 12:35 ` [PATCH nf-next 1/9] netfilter: nft_ct: add zone id get support Florian Westphal
2017-02-08 9:28 ` Pablo Neira Ayuso
2017-02-03 12:35 ` [PATCH nf-next 2/9] netfilter: nft_ct: prepare for key-dependent error unwind Florian Westphal
2017-02-08 9:29 ` Pablo Neira Ayuso
2017-02-03 12:35 ` [PATCH nf-next 3/9] netfilter: nft_ct: add zone id set support Florian Westphal
2017-02-08 9:29 ` Pablo Neira Ayuso
2017-02-03 12:35 ` [PATCH libnftnl 4/9] src: ct: add zone support Florian Westphal
2017-02-19 19:22 ` Pablo Neira Ayuso
2017-02-03 12:35 ` Florian Westphal [this message]
2017-02-06 17:31 ` [PATCH nftables 5/9] src: add host byte order integer type Pablo Neira Ayuso
2017-02-06 18:17 ` Pablo Neira Ayuso
2017-02-06 22:33 ` Florian Westphal
2017-02-07 11:58 ` Pablo Neira Ayuso
2017-02-07 12:29 ` Pablo Neira Ayuso
2017-02-03 12:35 ` [PATCH nftables 6/9] src: add conntrack zone support Florian Westphal
2017-02-03 12:35 ` [PATCH nftables 7/9] ct: refactor print function so it can be re-used for ct statement Florian Westphal
2017-02-03 12:35 ` [PATCH nftables 8/9] src: support zone set statement with optional direction Florian Westphal
2017-02-03 12:35 ` [PATCH nftables 9/9] tests: add test entries for conntrack zones Florian Westphal
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=20170203123556.17357-6-fw@strlen.de \
--to=fw@strlen.de \
--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).