ofp-actions: New function ovs_instruction_type_from_inst_type().
[sliver-openvswitch.git] / lib / flow.c
index 82d6729..00e66a4 100644 (file)
@@ -393,9 +393,7 @@ flow_extract(struct ofpbuf *packet, const struct pkt_metadata *md,
 
     if (md) {
         flow->tunnel = md->tunnel;
-        if (md->in_port.odp_port != ODPP_NONE) {
-            flow->in_port = md->in_port;
-        };
+        flow->in_port = md->in_port;
         flow->skb_priority = md->skb_priority;
         flow->pkt_mark = md->pkt_mark;
     }
@@ -820,6 +818,25 @@ flow_wildcards_set_reg_mask(struct flow_wildcards *wc, int idx, uint32_t mask)
     wc->masks.regs[idx] = mask;
 }
 
+/* Calculates the 5-tuple hash from the given flow. */
+uint32_t
+flow_hash_5tuple(const struct flow *flow, uint32_t basis)
+{
+    uint32_t hash = 0;
+
+    if (!flow) {
+        return 0;
+    }
+
+    hash = mhash_add(hash, (OVS_FORCE unsigned int) flow->nw_src);
+    hash = mhash_add(basis, (OVS_FORCE unsigned int) flow->nw_dst);
+    hash = mhash_add(hash, ((OVS_FORCE unsigned int) flow->tp_src << 16)
+                           | (OVS_FORCE unsigned int) flow->tp_dst);
+    hash = mhash_add(hash, flow->nw_proto);
+
+    return mhash_finish(hash, 13);
+}
+
 /* Hashes 'flow' based on its L2 through L4 protocol information. */
 uint32_t
 flow_hash_symmetric_l4(const struct flow *flow, uint32_t basis)