From: Patrick McHardy <kaber@trash.net>
To: pablo@netfilter.org
Cc: alvaroneay@gmail.com, netfilter-devel@vger.kernel.org
Subject: [PATCH 3/3] proto: fix byteorder of ETH_P_* values
Date: Tue, 19 Aug 2014 00:27:31 +0100 [thread overview]
Message-ID: <1408404451-9075-4-git-send-email-kaber@trash.net> (raw)
In-Reply-To: <1408404451-9075-1-git-send-email-kaber@trash.net>
The ethernet header type is in big endian byte order, the ETH_P_* values
are in host byte order however. Fix this using __constant_htons().
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
src/proto.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/src/proto.c b/src/proto.c
index e5f49cb..15a456a 100644
--- a/src/proto.c
+++ b/src/proto.c
@@ -712,10 +712,10 @@ const struct proto_desc proto_vlan = {
.base = PROTO_BASE_LL_HDR,
.protocol_key = VLANHDR_TYPE,
.protocols = {
- PROTO_LINK(ETH_P_IP, &proto_ip),
- PROTO_LINK(ETH_P_ARP, &proto_arp),
- PROTO_LINK(ETH_P_IPV6, &proto_ip6),
- PROTO_LINK(ETH_P_8021Q, &proto_vlan),
+ PROTO_LINK(__constant_htons(ETH_P_IP), &proto_ip),
+ PROTO_LINK(__constant_htons(ETH_P_ARP), &proto_arp),
+ PROTO_LINK(__constant_htons(ETH_P_IPV6), &proto_ip6),
+ PROTO_LINK(__constant_htons(ETH_P_8021Q), &proto_vlan),
},
.templates = {
@@ -741,10 +741,10 @@ const struct datatype etheraddr_type = {
static const struct symbol_table ethertype_tbl = {
.symbols = {
- SYMBOL("ip", ETH_P_IP),
- SYMBOL("arp", ETH_P_ARP),
- SYMBOL("ip6", ETH_P_IPV6),
- SYMBOL("vlan", ETH_P_8021Q),
+ SYMBOL("ip", __constant_htons(ETH_P_IP)),
+ SYMBOL("arp", __constant_htons(ETH_P_ARP)),
+ SYMBOL("ip6", __constant_htons(ETH_P_IPV6)),
+ SYMBOL("vlan", __constant_htons(ETH_P_8021Q)),
SYMBOL_LIST_END
},
};
@@ -792,10 +792,10 @@ const struct proto_desc proto_eth = {
.base = PROTO_BASE_LL_HDR,
.protocol_key = ETHHDR_TYPE,
.protocols = {
- PROTO_LINK(ETH_P_IP, &proto_ip),
- PROTO_LINK(ETH_P_ARP, &proto_arp),
- PROTO_LINK(ETH_P_IPV6, &proto_ip6),
- PROTO_LINK(ETH_P_8021Q, &proto_vlan),
+ PROTO_LINK(__constant_htons(ETH_P_IP), &proto_ip),
+ PROTO_LINK(__constant_htons(ETH_P_ARP), &proto_arp),
+ PROTO_LINK(__constant_htons(ETH_P_IPV6), &proto_ip6),
+ PROTO_LINK(__constant_htons(ETH_P_8021Q), &proto_vlan),
},
.templates = {
[ETHHDR_DADDR] = ETHHDR_ADDR("daddr", ether_dhost),
--
1.9.3
next prev parent reply other threads:[~2014-08-18 23:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-18 23:27 [PATCH 0/3] nftables: fix some endian issues Patrick McHardy
2014-08-18 23:27 ` [PATCH 1/3] payload: take endianess into account when updating the payload context Patrick McHardy
2014-08-18 23:27 ` [PATCH 2/3] datatype: take endianess into account in symbolic_constant_print() Patrick McHardy
2014-08-18 23:27 ` Patrick McHardy [this message]
2014-08-19 17:22 ` [PATCH 0/3] nftables: fix some endian issues Álvaro 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=1408404451-9075-4-git-send-email-kaber@trash.net \
--to=kaber@trash.net \
--cc=alvaroneay@gmail.com \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.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).