[ovs-dev] [PATCH 2/3] openvswitch/types.h: New macros OVS_BE16_MAX, OVS_BE32_MAX, OVS_BE64_MAX.

Ben Pfaff blp at nicira.com
Wed Mar 27 04:32:35 UTC 2013


These seem slightly nicer than e.g. htons(UINT16_MAX).

Signed-off-by: Ben Pfaff <blp at nicira.com>
---
 include/openvswitch/types.h |    6 +++++-
 lib/match.c                 |   30 +++++++++++++++---------------
 lib/meta-flow.c             |   11 +++++------
 lib/nx-match.c              |   10 +++++-----
 lib/ofp-actions.c           |    2 +-
 lib/ofp-parse.c             |    8 ++++----
 lib/ofp-print.c             |    2 +-
 lib/ofp-util.c              |   16 ++++++++--------
 lib/packets.c               |    2 +-
 ofproto/ofproto.c           |    8 ++++----
 tests/test-classifier.c     |   18 +++++++++---------
 tests/test-util.c           |    4 ++--
 12 files changed, 60 insertions(+), 57 deletions(-)

diff --git a/include/openvswitch/types.h b/include/openvswitch/types.h
index 72caa5c..d2fcf89 100644
--- a/include/openvswitch/types.h
+++ b/include/openvswitch/types.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011 Nicira, Inc.
+ * Copyright (c) 2010, 2011, 2013 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -38,6 +38,10 @@
 typedef __be16 ovs_be16;
 typedef __be32 ovs_be32;
 typedef __be64 ovs_be64;
+
+#define OVS_BE16_MAX ((OVS_FORCE ovs_be16) 0xffff)
+#define OVS_BE32_MAX ((OVS_FORCE ovs_be32) 0xffffffff)
+#define OVS_BE64_MAX ((OVS_FORCE ovs_be64) 0xffffffffffffffffULL)
 
 /* Netlink and OpenFlow both contain 64-bit values that are only guaranteed to
  * be aligned on 32-bit boundaries.  These types help.
diff --git a/lib/match.c b/lib/match.c
index 76c23cf..f89d772 100644
--- a/lib/match.c
+++ b/lib/match.c
@@ -183,7 +183,7 @@ match_set_reg_masked(struct match *match, unsigned int reg_idx,
 void
 match_set_metadata(struct match *match, ovs_be64 metadata)
 {
-    match_set_metadata_masked(match, metadata, htonll(UINT64_MAX));
+    match_set_metadata_masked(match, metadata, OVS_BE64_MAX);
 }
 
 void
@@ -197,7 +197,7 @@ match_set_metadata_masked(struct match *match,
 void
 match_set_tun_id(struct match *match, ovs_be64 tun_id)
 {
-    match_set_tun_id_masked(match, tun_id, htonll(UINT64_MAX));
+    match_set_tun_id_masked(match, tun_id, OVS_BE64_MAX);
 }
 
 void
@@ -210,7 +210,7 @@ match_set_tun_id_masked(struct match *match, ovs_be64 tun_id, ovs_be64 mask)
 void
 match_set_tun_src(struct match *match, ovs_be32 src)
 {
-    match_set_tun_src_masked(match, src, htonl(UINT32_MAX));
+    match_set_tun_src_masked(match, src, OVS_BE32_MAX);
 }
 
 void
@@ -223,7 +223,7 @@ match_set_tun_src_masked(struct match *match, ovs_be32 src, ovs_be32 mask)
 void
 match_set_tun_dst(struct match *match, ovs_be32 dst)
 {
-    match_set_tun_dst_masked(match, dst, htonl(UINT32_MAX));
+    match_set_tun_dst_masked(match, dst, OVS_BE32_MAX);
 }
 
 void
@@ -296,7 +296,7 @@ match_set_skb_mark(struct match *match, uint32_t skb_mark)
 void
 match_set_dl_type(struct match *match, ovs_be16 dl_type)
 {
-    match->wc.masks.dl_type = htons(UINT16_MAX);
+    match->wc.masks.dl_type = OVS_BE16_MAX;
     match->flow.dl_type = dl_type;
 }
 
@@ -407,7 +407,7 @@ match_set_dl_vlan(struct match *match, ovs_be16 dl_vlan)
 {
     flow_set_dl_vlan(&match->flow, dl_vlan);
     if (dl_vlan == htons(OFP10_VLAN_NONE)) {
-        match->wc.masks.vlan_tci = htons(UINT16_MAX);
+        match->wc.masks.vlan_tci = OVS_BE16_MAX;
     } else {
         match->wc.masks.vlan_tci |= htons(VLAN_VID_MASK | VLAN_CFI);
     }
@@ -514,7 +514,7 @@ match_set_mpls_bos(struct match *match, uint8_t mpls_bos)
 void
 match_set_tp_src(struct match *match, ovs_be16 tp_src)
 {
-    match_set_tp_src_masked(match, tp_src, htons(UINT16_MAX));
+    match_set_tp_src_masked(match, tp_src, OVS_BE16_MAX);
 }
 
 void
@@ -527,7 +527,7 @@ match_set_tp_src_masked(struct match *match, ovs_be16 port, ovs_be16 mask)
 void
 match_set_tp_dst(struct match *match, ovs_be16 tp_dst)
 {
-    match_set_tp_dst_masked(match, tp_dst, htons(UINT16_MAX));
+    match_set_tp_dst_masked(match, tp_dst, OVS_BE16_MAX);
 }
 
 void
@@ -548,7 +548,7 @@ void
 match_set_nw_src(struct match *match, ovs_be32 nw_src)
 {
     match->flow.nw_src = nw_src;
-    match->wc.masks.nw_src = htonl(UINT32_MAX);
+    match->wc.masks.nw_src = OVS_BE32_MAX;
 }
 
 void
@@ -563,7 +563,7 @@ void
 match_set_nw_dst(struct match *match, ovs_be32 nw_dst)
 {
     match->flow.nw_dst = nw_dst;
-    match->wc.masks.nw_dst = htonl(UINT32_MAX);
+    match->wc.masks.nw_dst = OVS_BE32_MAX;
 }
 
 void
@@ -688,7 +688,7 @@ match_set_ipv6_dst_masked(struct match *match, const struct in6_addr *dst,
 void
 match_set_ipv6_label(struct match *match, ovs_be32 ipv6_label)
 {
-    match->wc.masks.ipv6_label = htonl(UINT32_MAX);
+    match->wc.masks.ipv6_label = OVS_BE32_MAX;
     match->flow.ipv6_label = ipv6_label;
 }
 
@@ -775,7 +775,7 @@ format_be16_masked(struct ds *s, const char *name,
 {
     if (mask != htons(0)) {
         ds_put_format(s, "%s=", name);
-        if (mask == htons(UINT16_MAX)) {
+        if (mask == OVS_BE16_MAX) {
             ds_put_format(s, "%"PRIu16, ntohs(value));
         } else {
             ds_put_format(s, "0x%"PRIx16"/0x%"PRIx16,
@@ -794,7 +794,7 @@ format_flow_tunnel(struct ds *s, const struct match *match)
     switch (wc->masks.tunnel.tun_id) {
     case 0:
         break;
-    case CONSTANT_HTONLL(UINT64_MAX):
+    case OVS_BE64_MAX:
         ds_put_format(s, "tun_id=%#"PRIx64",", ntohll(tnl->tun_id));
         break;
     default:
@@ -926,7 +926,7 @@ match_format(const struct match *match, struct ds *s, unsigned int priority)
     switch (wc->masks.metadata) {
     case 0:
         break;
-    case CONSTANT_HTONLL(UINT64_MAX):
+    case OVS_BE64_MAX:
         ds_put_format(s, "metadata=%#"PRIx64",", ntohll(f->metadata));
         break;
     default:
@@ -972,7 +972,7 @@ match_format(const struct match *match, struct ds *s, unsigned int priority)
         format_ipv6_netmask(s, "ipv6_src", &f->ipv6_src, &wc->masks.ipv6_src);
         format_ipv6_netmask(s, "ipv6_dst", &f->ipv6_dst, &wc->masks.ipv6_dst);
         if (wc->masks.ipv6_label) {
-            if (wc->masks.ipv6_label == htonl(UINT32_MAX)) {
+            if (wc->masks.ipv6_label == OVS_BE32_MAX) {
                 ds_put_format(s, "ipv6_label=0x%05"PRIx32",",
                               ntohl(f->ipv6_label));
             } else {
diff --git a/lib/meta-flow.c b/lib/meta-flow.c
index 6f7a3aa..b2d244c 100644
--- a/lib/meta-flow.c
+++ b/lib/meta-flow.c
@@ -2075,12 +2075,12 @@ mf_from_ipv4_string(const struct mf_field *mf, const char *s,
             return xasprintf("%s: network prefix bits not between 1 and "
                              "32", s);
         } else if (prefix == 32) {
-            *mask = htonl(UINT32_MAX);
+            *mask = OVS_BE32_MAX;
         } else {
             *mask = htonl(((1u << prefix) - 1) << (32 - prefix));
         }
     } else if (sscanf(s, IP_SCAN_FMT, IP_SCAN_ARGS(ip)) == IP_SCAN_COUNT) {
-        *mask = htonl(UINT32_MAX);
+        *mask = OVS_BE32_MAX;
     } else {
         return xasprintf("%s: invalid IP address", s);
     }
@@ -2140,7 +2140,7 @@ mf_from_ofp_port_string(const struct mf_field *mf, const char *s,
                          s, mf->name);
     } else if (ofputil_port_from_string(s, &port)) {
         *valuep = htons(port);
-        *maskp = htons(UINT16_MAX);
+        *maskp = OVS_BE16_MAX;
         return NULL;
     } else {
         return mf_from_integer_string(mf, s,
@@ -2247,7 +2247,7 @@ static char *
 mf_from_tun_flags_string(const char *s, ovs_be16 *valuep, ovs_be16 *maskp)
 {
     if (!parse_flow_tun_flags(s, flow_tun_flag_to_string, valuep)) {
-        *maskp = htons(UINT16_MAX);
+        *maskp = OVS_BE16_MAX;
         return NULL;
     }
 
@@ -2404,8 +2404,7 @@ mf_format(const struct mf_field *mf,
         break;
 
     case MFS_IPV4:
-        ip_format_masked(value->be32, mask ? mask->be32 : htonl(UINT32_MAX),
-                         s);
+        ip_format_masked(value->be32, mask ? mask->be32 : OVS_BE32_MAX, s);
         break;
 
     case MFS_IPV6:
diff --git a/lib/nx-match.c b/lib/nx-match.c
index bfead68..5c73bcd 100644
--- a/lib/nx-match.c
+++ b/lib/nx-match.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, 2012 Nicira, Inc.
+ * Copyright (c) 2010, 2011, 2012, 2013 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -194,7 +194,7 @@ nx_pull_raw(const uint8_t *p, unsigned int match_len, bool strict,
                 if (NXM_HASMASK(header)) {
                     memcpy(cookie_mask, p + 4 + width, width);
                 } else {
-                    *cookie_mask = htonll(UINT64_MAX);
+                    *cookie_mask = OVS_BE64_MAX;
                 }
                 error = 0;
             }
@@ -372,7 +372,7 @@ nxm_put_16m(struct ofpbuf *b, uint32_t header, ovs_be16 value, ovs_be16 mask)
     case 0:
         break;
 
-    case CONSTANT_HTONS(UINT16_MAX):
+    case OVS_BE16_MAX:
         nxm_put_16(b, header, value);
         break;
 
@@ -404,7 +404,7 @@ nxm_put_32m(struct ofpbuf *b, uint32_t header, ovs_be32 value, ovs_be32 mask)
     case 0:
         break;
 
-    case CONSTANT_HTONL(UINT32_MAX):
+    case OVS_BE32_MAX:
         nxm_put_32(b, header, value);
         break;
 
@@ -436,7 +436,7 @@ nxm_put_64m(struct ofpbuf *b, uint32_t header, ovs_be64 value, ovs_be64 mask)
     case 0:
         break;
 
-    case CONSTANT_HTONLL(UINT64_MAX):
+    case OVS_BE64_MAX:
         nxm_put_64(b, header, value);
         break;
 
diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c
index d405d2d..226f0c4 100644
--- a/lib/ofp-actions.c
+++ b/lib/ofp-actions.c
@@ -2216,7 +2216,7 @@ ofpact_format(const struct ofpact *a, struct ds *s)
                       ofpact_instruction_name_from_type(
                           OVSINST_OFPIT11_WRITE_METADATA),
                       ntohll(metadata->metadata));
-        if (metadata->mask != htonll(UINT64_MAX)) {
+        if (metadata->mask != OVS_BE64_MAX) {
             ds_put_format(s, "/%#"PRIx64, ntohll(metadata->mask));
         }
         break;
diff --git a/lib/ofp-parse.c b/lib/ofp-parse.c
index e8abc9f..a93b27e 100644
--- a/lib/ofp-parse.c
+++ b/lib/ofp-parse.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, 2012 Nicira, Inc.
+ * Copyright (c) 2010, 2011, 2012, 2013 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -383,7 +383,7 @@ parse_metadata(struct ofpbuf *b, char *arg)
         *mask = '\0';
         om->mask = htonll(str_to_u64(mask + 1));
     } else {
-        om->mask = htonll(UINT64_MAX);
+        om->mask = OVS_BE64_MAX;
     }
 
     om->metadata = htonll(str_to_u64(arg));
@@ -862,7 +862,7 @@ parse_ofp_str(struct ofputil_flow_mod *fm, int command, const char *str_,
     fm->cookie_mask = htonll(0);
     if (command == OFPFC_MODIFY || command == OFPFC_MODIFY_STRICT) {
         /* For modify, by default, don't update the cookie. */
-        fm->new_cookie = htonll(UINT64_MAX);
+        fm->new_cookie = OVS_BE64_MAX;
     } else{
         fm->new_cookie = htonll(0);
     }
@@ -962,7 +962,7 @@ parse_ofp_str(struct ofputil_flow_mod *fm, int command, const char *str_,
             }
         }
     }
-    if (!fm->cookie_mask && fm->new_cookie == htonll(UINT64_MAX)
+    if (!fm->cookie_mask && fm->new_cookie == OVS_BE64_MAX
             && (command == OFPFC_MODIFY || command == OFPFC_MODIFY_STRICT)) {
         /* On modifies without a mask, we are supposed to add a flow if
          * one does not exist.  If a cookie wasn't been specified, use a
diff --git a/lib/ofp-print.c b/lib/ofp-print.c
index 95d9b73..a84e4ec 100644
--- a/lib/ofp-print.c
+++ b/lib/ofp-print.c
@@ -799,7 +799,7 @@ ofp_print_flow_mod(struct ds *s, const struct ofp_header *oh, int verbosity)
     if (ds_last(s) != ' ') {
         ds_put_char(s, ' ');
     }
-    if (fm.new_cookie != htonll(0) && fm.new_cookie != htonll(UINT64_MAX)) {
+    if (fm.new_cookie != htonll(0) && fm.new_cookie != OVS_BE64_MAX) {
         ds_put_format(s, "cookie:0x%"PRIx64" ", ntohll(fm.new_cookie));
     }
     if (fm.cookie_mask != htonll(0)) {
diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index 6b78f84..9af9fc1 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -106,10 +106,10 @@ ofputil_wildcard_from_ofpfw10(uint32_t ofpfw, struct flow_wildcards *wc)
                                                  >> OFPFW10_NW_DST_SHIFT);
 
     if (!(ofpfw & OFPFW10_TP_SRC)) {
-        wc->masks.tp_src = htons(UINT16_MAX);
+        wc->masks.tp_src = OVS_BE16_MAX;
     }
     if (!(ofpfw & OFPFW10_TP_DST)) {
-        wc->masks.tp_dst = htons(UINT16_MAX);
+        wc->masks.tp_dst = OVS_BE16_MAX;
     }
 
     if (!(ofpfw & OFPFW10_DL_SRC)) {
@@ -119,7 +119,7 @@ ofputil_wildcard_from_ofpfw10(uint32_t ofpfw, struct flow_wildcards *wc)
         memset(wc->masks.dl_dst, 0xff, ETH_ADDR_LEN);
     }
     if (!(ofpfw & OFPFW10_DL_TYPE)) {
-        wc->masks.dl_type = htons(UINT16_MAX);
+        wc->masks.dl_type = OVS_BE16_MAX;
     }
 
     /* VLAN TCI mask. */
@@ -335,7 +335,7 @@ ofputil_match_from_ofp11_match(const struct ofp11_match *ofmatch,
         if (ofmatch->dl_vlan == htons(OFPVID11_NONE)) {
             /* Match only packets without a VLAN tag. */
             match->flow.vlan_tci = htons(0);
-            match->wc.masks.vlan_tci = htons(UINT16_MAX);
+            match->wc.masks.vlan_tci = OVS_BE16_MAX;
         } else {
             if (ofmatch->dl_vlan == htons(OFPVID11_ANY)) {
                 /* Match any packet with a VLAN tag regardless of VID. */
@@ -1144,8 +1144,8 @@ ofputil_usable_protocols(const struct match *match)
     }
 
     /* NXM and OXM support bitwise matching on transport port. */
-    if ((wc->masks.tp_src && wc->masks.tp_src != htons(UINT16_MAX)) ||
-        (wc->masks.tp_dst && wc->masks.tp_dst != htons(UINT16_MAX))) {
+    if ((wc->masks.tp_src && wc->masks.tp_src != OVS_BE16_MAX) ||
+        (wc->masks.tp_dst && wc->masks.tp_dst != OVS_BE16_MAX)) {
         return OFPUTIL_P_OF10_NXM_ANY | OFPUTIL_P_OF12_OXM
             | OFPUTIL_P_OF13_OXM;
     }
@@ -1523,7 +1523,7 @@ ofputil_decode_flow_mod(struct ofputil_flow_mod *fm,
         } else {
             fm->cookie = ofm->cookie;
             fm->cookie_mask = ofm->cookie_mask;
-            fm->new_cookie = htonll(UINT64_MAX);
+            fm->new_cookie = OVS_BE64_MAX;
         }
         fm->command = ofm->command;
         fm->table_id = ofm->table_id;
@@ -3403,7 +3403,7 @@ ofputil_decode_role_message(const struct ofp_header *oh,
         rr->role = ntohl(orr->role);
         if (raw == OFPRAW_OFPT12_ROLE_REQUEST
             ? orr->role == htonl(OFPCR12_ROLE_NOCHANGE)
-            : orr->generation_id == htonll(UINT64_MAX)) {
+            : orr->generation_id == OVS_BE64_MAX) {
             rr->have_generation_id = false;
             rr->generation_id = 0;
         } else {
diff --git a/lib/packets.c b/lib/packets.c
index 77aa7d3..492924c 100644
--- a/lib/packets.c
+++ b/lib/packets.c
@@ -450,7 +450,7 @@ void
 ip_format_masked(ovs_be32 ip, ovs_be32 mask, struct ds *s)
 {
     ds_put_format(s, IP_FMT, IP_ARGS(ip));
-    if (mask != htonl(UINT32_MAX)) {
+    if (mask != OVS_BE32_MAX) {
         if (ip_is_cidr(mask)) {
             ds_put_format(s, "/%d", ip_count_cidr_bits(mask));
         } else {
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 03ca59b..30fdb38 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -2449,8 +2449,8 @@ handle_table_stats_request(struct ofconn *ofconn,
         ots[i].apply_actions = htonl(OFPAT11_OUTPUT);
         ots[i].write_setfields = htonll(OFPXMT12_MASK);
         ots[i].apply_setfields = htonll(OFPXMT12_MASK);
-        ots[i].metadata_match = htonll(UINT64_MAX);
-        ots[i].metadata_write = htonll(UINT64_MAX);
+        ots[i].metadata_match = OVS_BE64_MAX;
+        ots[i].metadata_write = OVS_BE64_MAX;
         ots[i].instructions = htonl(OFPIT11_ALL);
         ots[i].config = htonl(OFPTC11_TABLE_MISS_MASK);
         ots[i].max_entries = htonl(1000000); /* An arbitrary big number. */
@@ -3217,7 +3217,7 @@ modify_flows__(struct ofproto *ofproto, struct ofconn *ofconn,
 
         actions_changed = !ofpacts_equal(fm->ofpacts, fm->ofpacts_len,
                                          rule->ofpacts, rule->ofpacts_len);
-        new_cookie = (fm->new_cookie != htonll(UINT64_MAX)
+        new_cookie = (fm->new_cookie != OVS_BE64_MAX
                       ? fm->new_cookie
                       : rule->flow_cookie);
 
@@ -3243,7 +3243,7 @@ modify_flows_add(struct ofproto *ofproto, struct ofconn *ofconn,
                  const struct ofputil_flow_mod *fm,
                  const struct ofp_header *request)
 {
-    if (fm->cookie_mask != htonll(0) || fm->new_cookie == htonll(UINT64_MAX)) {
+    if (fm->cookie_mask != htonll(0) || fm->new_cookie == OVS_BE64_MAX) {
         return 0;
     }
     return add_flow(ofproto, ofconn, fm, request);
diff --git a/tests/test-classifier.c b/tests/test-classifier.c
index 18dee86..8e86211 100644
--- a/tests/test-classifier.c
+++ b/tests/test-classifier.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc.
+ * Copyright (c) 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -522,29 +522,29 @@ make_rule(int wc_fields, unsigned int priority, int value_pat)
                values[f_idx][value_idx], f->len);
 
         if (f_idx == CLS_F_IDX_NW_SRC) {
-            match.wc.masks.nw_src = htonl(UINT32_MAX);
+            match.wc.masks.nw_src = OVS_BE32_MAX;
         } else if (f_idx == CLS_F_IDX_NW_DST) {
-            match.wc.masks.nw_dst = htonl(UINT32_MAX);
+            match.wc.masks.nw_dst = OVS_BE32_MAX;
         } else if (f_idx == CLS_F_IDX_TP_SRC) {
-            match.wc.masks.tp_src = htons(UINT16_MAX);
+            match.wc.masks.tp_src = OVS_BE16_MAX;
         } else if (f_idx == CLS_F_IDX_TP_DST) {
-            match.wc.masks.tp_dst = htons(UINT16_MAX);
+            match.wc.masks.tp_dst = OVS_BE16_MAX;
         } else if (f_idx == CLS_F_IDX_DL_SRC) {
             memset(match.wc.masks.dl_src, 0xff, ETH_ADDR_LEN);
         } else if (f_idx == CLS_F_IDX_DL_DST) {
             memset(match.wc.masks.dl_dst, 0xff, ETH_ADDR_LEN);
         } else if (f_idx == CLS_F_IDX_VLAN_TCI) {
-            match.wc.masks.vlan_tci = htons(UINT16_MAX);
+            match.wc.masks.vlan_tci = OVS_BE16_MAX;
         } else if (f_idx == CLS_F_IDX_TUN_ID) {
-            match.wc.masks.tunnel.tun_id = htonll(UINT64_MAX);
+            match.wc.masks.tunnel.tun_id = OVS_BE64_MAX;
         } else if (f_idx == CLS_F_IDX_METADATA) {
-            match.wc.masks.metadata = htonll(UINT64_MAX);
+            match.wc.masks.metadata = OVS_BE64_MAX;
         } else if (f_idx == CLS_F_IDX_NW_DSCP) {
             match.wc.masks.nw_tos |= IP_DSCP_MASK;
         } else if (f_idx == CLS_F_IDX_NW_PROTO) {
             match.wc.masks.nw_proto = UINT8_MAX;
         } else if (f_idx == CLS_F_IDX_DL_TYPE) {
-            match.wc.masks.dl_type = htons(UINT16_MAX);
+            match.wc.masks.dl_type = OVS_BE16_MAX;
         } else if (f_idx == CLS_F_IDX_IN_PORT) {
             match.wc.masks.in_port = UINT16_MAX;
         } else {
diff --git a/tests/test-util.c b/tests/test-util.c
index 3eecc7a..e1f2756 100644
--- a/tests/test-util.c
+++ b/tests/test-util.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012 Nicira, Inc.
+ * Copyright (c) 2011, 2012, 2013 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -256,7 +256,7 @@ test_bitwise_one(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
             ovs_be64 expect;
 
             if (n_bits == 64) {
-                expect = htonll(UINT64_MAX);
+                expect = OVS_BE64_MAX;
             } else {
                 uint64_t mask = (UINT64_C(1) << n_bits) - 1;
                 expect = orig_dst | htonll(mask << dst_ofs);
-- 
1.7.10.4




More information about the dev mailing list