vswitchd: Delete DP_MAX_PORTS.
[openvswitch] / lib / nx-match.c
index bcb6482aafe7a02845ec308f118a4b7160d73d57..c1d8fa84e1bd265a7d3cae9a60db69e82f7c64a1 100644 (file)
@@ -318,7 +318,7 @@ parse_nxm_entry(struct cls_rule *rule, const struct nxm_field *f,
 
         /* Tunnel ID. */
     case NFI_NXM_NX_TUN_ID:
-        flow->tun_id = htonl(ntohll(get_unaligned_be64(value)));
+        flow->tun_id = get_unaligned_be64(value);
         return 0;
 
         /* Registers. */
@@ -395,7 +395,7 @@ nx_pull_match(struct ofpbuf *b, unsigned int match_len, uint16_t priority,
 
     p = ofpbuf_try_pull(b, ROUND_UP(match_len, 8));
     if (!p) {
-        VLOG_DBG_RL(&rl, "nx_match length %zu, rounded up to a "
+        VLOG_DBG_RL(&rl, "nx_match length %u, rounded up to a "
                     "multiple of 8, is longer than space in message (max "
                     "length %zu)", match_len, b->size);
         return ofp_mkerr(OFPET_BAD_REQUEST, OFPBRC_BAD_LEN);
@@ -646,7 +646,7 @@ nx_put_match(struct ofpbuf *b, const struct cls_rule *cr)
 
     /* Tunnel ID. */
     if (!(wc & FWW_TUN_ID)) {
-        nxm_put_64(b, NXM_NX_TUN_ID, htonll(ntohl(flow->tun_id)));
+        nxm_put_64(b, NXM_NX_TUN_ID, flow->tun_id);
     }
 
     /* Registers. */
@@ -749,25 +749,6 @@ parse_nxm_field_name(const char *name, int name_len)
 
     return 0;
 }
-
-static const char *
-parse_hex_bytes(struct ofpbuf *b, const char *s, unsigned int n)
-{
-    while (n--) {
-        uint8_t byte;
-        bool ok;
-
-        s += strspn(s, " ");
-        byte = hexits_value(s, 2, &ok);
-        if (!ok) {
-            ovs_fatal(0, "%.2s: hex digits expected", s);
-        }
-
-        ofpbuf_put(b, &byte, 1);
-        s += 2;
-    }
-    return s;
-}
 \f
 /* nx_match_from_string(). */
 
@@ -788,6 +769,7 @@ nx_match_from_string(const char *s, struct ofpbuf *b)
         const char *name;
         uint32_t header;
         int name_len;
+        size_t n;
 
         name = s;
         name_len = strcspn(s, "(");
@@ -803,14 +785,20 @@ nx_match_from_string(const char *s, struct ofpbuf *b)
         s += name_len + 1;
 
         nxm_put_header(b, header);
-        s = parse_hex_bytes(b, s, nxm_field_bytes(header));
+        s = ofpbuf_put_hex(b, s, &n);
+        if (n != nxm_field_bytes(header)) {
+            ovs_fatal(0, "%.2s: hex digits expected", s);
+        }
         if (NXM_HASMASK(header)) {
             s += strspn(s, " ");
             if (*s != '/') {
                 ovs_fatal(0, "%s: missing / in masked field %.*s",
                           full_s, name_len, name);
             }
-            s = parse_hex_bytes(b, s + 1, nxm_field_bytes(header));
+            s = ofpbuf_put_hex(b, s + 1, &n);
+            if (n != nxm_field_bytes(header)) {
+                ovs_fatal(0, "%.2s: hex digits expected", s);
+            }
         }
 
         s += strspn(s, " ");
@@ -933,7 +921,7 @@ nxm_parse_reg_load(struct nx_action_reg_load *load, const char *s)
     }
 
     if (n_bits < 64 && (value >> n_bits) != 0) {
-        ovs_fatal(0, "%s: value %llu does not fit into %d bits",
+        ovs_fatal(0, "%s: value %"PRIu64" does not fit into %d bits",
                   full_s, value, n_bits);
     }
 
@@ -1104,7 +1092,7 @@ nxm_read_field(const struct nxm_field *src, const struct flow *flow)
         return ntohs(flow->tp_dst) & 0xff;
 
     case NFI_NXM_NX_TUN_ID:
-        return ntohl(flow->tun_id);
+        return ntohll(flow->tun_id);
 
 #define NXM_READ_REGISTER(IDX)                  \
     case NFI_NXM_NX_REG##IDX:                   \
@@ -1166,7 +1154,7 @@ nxm_execute_reg_move(const struct nx_action_reg_move *action,
     } else if (dst->header == NXM_OF_VLAN_TCI) {
         flow->vlan_tci = htons(new_data);
     } else if (dst->header == NXM_NX_TUN_ID) {
-        flow->tun_id = htonl(new_data);
+        flow->tun_id = htonll(new_data);
     } else {
         NOT_REACHED();
     }