From: Florian Westphal <fw@strlen.de>
To: <netfilter-devel@vger.kernel.org>
Cc: Florian Westphal <fw@strlen.de>
Subject: [PATCH nft 1/3] datatype: ll: use big endian byte ordering
Date: Fri, 9 Sep 2016 14:43:14 +0200 [thread overview]
Message-ID: <1473424996-26957-2-git-send-email-fw@strlen.de> (raw)
In-Reply-To: <1473424996-26957-1-git-send-email-fw@strlen.de>
ether daddr set 00:03:2d:2b:74:ec is listed as:
ether daddr set ec:74:2b:2d:03:00
(it was fine without 'set' keyword). Reason is that
ether address was listed as being HOST endian.
The payload expression (unlike statement) path contains
a few conversion call sites for this, i.e.:
if (tmp->byteorder == BYTEORDER_HOST_ENDIAN)
mpz_switch_byteorder(tmp->value, tmp->len / BITS_PER_BYTE);
... it might make sense to remove those in a followup patch.
Reported-by: Laura Garcia Liebana <nevola@gmail.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
---
src/datatype.c | 7 ++++---
src/proto.c | 4 ++--
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/datatype.c b/src/datatype.c
index 2b1619a..1e40287 100644
--- a/src/datatype.c
+++ b/src/datatype.c
@@ -348,7 +348,8 @@ static void lladdr_type_print(const struct expr *expr)
uint8_t data[len];
unsigned int i;
- mpz_export_data(data, expr->value, BYTEORDER_HOST_ENDIAN, len);
+ mpz_export_data(data, expr->value, BYTEORDER_BIG_ENDIAN, len);
+
for (i = 0; i < len; i++) {
printf("%s%.2x", delim, data[i]);
delim = ":";
@@ -374,7 +375,7 @@ static struct error_record *lladdr_type_parse(const struct expr *sym,
}
*res = constant_expr_alloc(&sym->location, sym->dtype,
- BYTEORDER_HOST_ENDIAN, len * BITS_PER_BYTE,
+ BYTEORDER_BIG_ENDIAN, len * BITS_PER_BYTE,
buf);
return NULL;
}
@@ -383,7 +384,7 @@ const struct datatype lladdr_type = {
.type = TYPE_LLADDR,
.name = "ll_addr",
.desc = "link layer address",
- .byteorder = BYTEORDER_HOST_ENDIAN,
+ .byteorder = BYTEORDER_BIG_ENDIAN,
.basetype = &integer_type,
.print = lladdr_type_print,
.parse = lladdr_type_parse,
diff --git a/src/proto.c b/src/proto.c
index 94995f1..df5439c 100644
--- a/src/proto.c
+++ b/src/proto.c
@@ -854,7 +854,7 @@ const struct datatype etheraddr_type = {
.type = TYPE_ETHERADDR,
.name = "ether_addr",
.desc = "Ethernet address",
- .byteorder = BYTEORDER_HOST_ENDIAN,
+ .byteorder = BYTEORDER_BIG_ENDIAN,
.size = ETH_ALEN * BITS_PER_BYTE,
.basetype = &lladdr_type,
};
@@ -892,7 +892,7 @@ const struct datatype ethertype_type = {
ETHHDR_TEMPLATE(__name, ðertype_type, __member)
#define ETHHDR_ADDR(__name, __member) \
PROTO_HDR_TEMPLATE(__name, ðeraddr_type, \
- BYTEORDER_HOST_ENDIAN, \
+ BYTEORDER_BIG_ENDIAN, \
offsetof(struct ether_header, __member) * 8, \
field_sizeof(struct ether_header, __member) * 8)
--
2.7.3
next prev parent reply other threads:[~2016-09-09 12:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-09 12:43 [PATCH nft 0/3] fix ether address formatting Florian Westphal
2016-09-09 12:43 ` Florian Westphal [this message]
2016-09-09 13:33 ` [PATCH nft 1/3] datatype: ll: use big endian byte ordering Pablo Neira Ayuso
2016-09-09 12:43 ` [PATCH nft 2/3] tests: catch ordering issue w. ether set Florian Westphal
2016-09-09 13:33 ` Pablo Neira Ayuso
2016-09-09 12:43 ` [PATCH nft 3/3] payload: remove byteorder conversion Florian Westphal
2016-09-09 13:34 ` 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=1473424996-26957-2-git-send-email-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).