]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
proto: fix byteorder of ETH_P_* values
authorPatrick McHardy <kaber@trash.net>
Mon, 18 Aug 2014 23:21:59 +0000 (00:21 +0100)
committerPatrick McHardy <kaber@trash.net>
Mon, 18 Aug 2014 23:21:59 +0000 (00:21 +0100)
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

index e5f49cb2b0ce4f788c996c4db71b110635a824d3..15a456a768bfb59b844ca5e3f1ba93f90917503c 100644 (file)
@@ -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),