Added OFPFC_MODIFY_STRICT flow mod command.
[openvswitch] / switch / table-hash.c
index 34cba7ad564e69f05ada0bf8cde9a8e495b5230f..0960082b3cc2cfb8642247925cb75349412df1e9 100644 (file)
@@ -82,12 +82,6 @@ static int table_hash_insert(struct sw_table *swt, struct sw_flow *flow)
     } else {
         struct sw_flow *old_flow = *bucket;
         if (!flow_compare(&old_flow->key.flow, &flow->key.flow)) {
-            /* Keep stats from the original flow */
-            flow->used = old_flow->used;
-            flow->created = old_flow->created;
-            flow->packet_count = old_flow->packet_count;
-            flow->byte_count = old_flow->byte_count;
-
             *bucket = flow;
             flow_free(old_flow);
             retval = 1;
@@ -99,7 +93,7 @@ static int table_hash_insert(struct sw_table *swt, struct sw_flow *flow)
 }
 
 static int table_hash_modify(struct sw_table *swt, 
-        const struct sw_flow_key *key,
+        const struct sw_flow_key *key, uint16_t priority, int strict,
         const struct ofp_action *actions, int n_actions) 
 {
     struct sw_table_hash *th = (struct sw_table_hash *) swt;
@@ -108,7 +102,8 @@ static int table_hash_modify(struct sw_table *swt,
     if (key->wildcards == 0) {
         struct sw_flow **bucket = find_bucket(swt, key);
         struct sw_flow *flow = *bucket;
-        if (flow && flow_matches_1wild(&flow->key, key)) {
+        if (flow && flow_matches_desc(&flow->key, key, strict)
+                && (!strict || (flow->priority == priority))) {
             flow_replace_acts(flow, actions, n_actions);
             count = 1;
         }
@@ -118,7 +113,8 @@ static int table_hash_modify(struct sw_table *swt,
         for (i = 0; i <= th->bucket_mask; i++) {
             struct sw_flow **bucket = &th->buckets[i];
             struct sw_flow *flow = *bucket;
-            if (flow && flow_matches_1wild(&flow->key, key)) {
+            if (flow && flow_matches_desc(&flow->key, key, strict)
+                    && (!strict || (flow->priority == priority))) {
                 flow_replace_acts(flow, actions, n_actions);
                 count++;
             }
@@ -158,7 +154,7 @@ static int table_hash_delete(struct sw_table *swt,
         for (i = 0; i <= th->bucket_mask; i++) {
             struct sw_flow **bucket = &th->buckets[i];
             struct sw_flow *flow = *bucket;
-            if (flow && flow_del_matches(&flow->key, key, strict)) {
+            if (flow && flow_matches_desc(&flow->key, key, strict)) {
                 do_delete(bucket);
                 count++;
             }
@@ -307,12 +303,14 @@ static int table_hash2_insert(struct sw_table *swt, struct sw_flow *flow)
 }
 
 static int table_hash2_modify(struct sw_table *swt, 
-        const struct sw_flow_key *key,
+        const struct sw_flow_key *key, uint16_t priority, int strict,
         const struct ofp_action *actions, int n_actions) 
 {
     struct sw_table_hash2 *t2 = (struct sw_table_hash2 *) swt;
-    return (table_hash_modify(t2->subtable[0], key, actions, n_actions)
-            + table_hash_modify(t2->subtable[1], key, actions, n_actions));
+    return (table_hash_modify(t2->subtable[0], key, priority, strict,
+                    actions, n_actions)
+            + table_hash_modify(t2->subtable[1], key, priority, strict,
+                    actions, n_actions));
 }
 
 static int table_hash2_delete(struct sw_table *swt,