ofproto-dpif-rid: Use array instead of ofpbuf for recirc_state stack.
[cascardo/ovs.git] / ofproto / ofproto-dpif-rid.c
index d142933..c61b007 100644 (file)
@@ -135,25 +135,22 @@ recirc_metadata_hash(const struct recirc_state *state)
     if (flow_tnl_dst_is_set(state->metadata.tunnel)) {
         /* We may leave remainder bytes unhashed, but that is unlikely as
          * the tunnel is not in the datapath format. */
-        hash = hash_words64((const uint64_t *) state->metadata.tunnel,
-                            flow_tnl_size(state->metadata.tunnel)
-                            / sizeof(uint64_t), hash);
+        hash = hash_bytes64((const uint64_t *) state->metadata.tunnel,
+                            flow_tnl_size(state->metadata.tunnel), hash);
     }
     hash = hash_boolean(state->conntracked, hash);
-    hash = hash_words64((const uint64_t *) &state->metadata.metadata,
-                        (sizeof state->metadata - sizeof state->metadata.tunnel)
-                        / sizeof(uint64_t),
+    hash = hash_bytes64((const uint64_t *) &state->metadata.metadata,
+                        sizeof state->metadata - sizeof state->metadata.tunnel,
                         hash);
-    if (state->stack && state->stack->size != 0) {
-        hash = hash_words64((const uint64_t *) state->stack->data,
-                            state->stack->size / sizeof(uint64_t), hash);
+    if (state->stack && state->n_stack) {
+        hash = hash_bytes64((const uint64_t *) state->stack,
+                            state->n_stack * sizeof *state->stack, hash);
     }
     hash = hash_int(state->mirrors, hash);
     hash = hash_int(state->action_set_len, hash);
     if (state->ofpacts_len) {
-        hash = hash_words64(ALIGNED_CAST(const uint64_t *, state->ofpacts),
-                            state->ofpacts_len / sizeof(uint64_t),
-                            hash);
+        hash = hash_bytes64(ALIGNED_CAST(const uint64_t *, state->ofpacts),
+                            state->ofpacts_len, hash);
     }
     return hash;
 }
@@ -167,9 +164,8 @@ recirc_metadata_equal(const struct recirc_state *a,
             && flow_tnl_equal(a->metadata.tunnel, b->metadata.tunnel)
             && !memcmp(&a->metadata.metadata, &b->metadata.metadata,
                        sizeof a->metadata - sizeof a->metadata.tunnel)
-            && (((!a->stack || !a->stack->size) &&
-                 (!b->stack || !b->stack->size))
-                || (a->stack && b->stack && ofpbuf_equal(a->stack, b->stack)))
+            && a->n_stack == b->n_stack
+            && !memcmp(a->stack, b->stack, a->n_stack * sizeof *a->stack)
             && a->mirrors == b->mirrors
             && a->conntracked == b->conntracked
             && a->action_set_len == b->action_set_len
@@ -214,20 +210,18 @@ recirc_state_clone(struct recirc_state *new, const struct recirc_state *old,
     flow_tnl_copy__(tunnel, old->metadata.tunnel);
     new->metadata.tunnel = tunnel;
 
-    if (new->stack) {
-        new->stack = new->stack->size ? ofpbuf_clone(new->stack) : NULL;
-    }
-    if (new->ofpacts) {
-        new->ofpacts = (new->ofpacts_len
-                        ? xmemdup(new->ofpacts, new->ofpacts_len)
-                        : NULL);
-    }
+    new->stack = (new->n_stack
+                  ? xmemdup(new->stack, new->n_stack * sizeof *new->stack)
+                  : NULL);
+    new->ofpacts = (new->ofpacts_len
+                    ? xmemdup(new->ofpacts, new->ofpacts_len)
+                    : NULL);
 }
 
 static void
 recirc_state_free(struct recirc_state *state)
 {
-    ofpbuf_delete(state->stack);
+    free(state->stack);
     free(state->ofpacts);
 }