Added OFPFC_MODIFY_STRICT flow mod command.
[openvswitch] / datapath / chain.c
index 71e00ee6fca7bbcbac6ae839ee9ff520553328cb..865f908d7d00cf468cc52861b5427b2e3049d9bb 100644 (file)
@@ -72,8 +72,10 @@ struct sw_flow *chain_lookup(struct sw_chain *chain,
        for (i = 0; i < chain->n_tables; i++) {
                struct sw_table *t = chain->tables[i];
                struct sw_flow *flow = t->lookup(t, key);
-               if (flow)
+               if (flow) {
+                       t->n_matched++;
                        return flow;
+               }
        }
        return NULL;
 }
@@ -99,8 +101,31 @@ int chain_insert(struct sw_chain *chain, struct sw_flow *flow)
        return -ENOBUFS;
 }
 
-/* Deletes from 'chain' any and all flows that match 'key'.  Returns the number
- * of flows that were deleted.
+/* Modifies actions in 'chain' that match 'key'.  If 'strict' set, wildcards 
+ * and priority must match.  Returns the number of flows that were modified.
+ *
+ * Expensive in the general case as currently implemented, since it requires
+ * iterating through the entire contents of each table for keys that contain
+ * wildcards.  Relatively cheap for fully specified keys. */
+int
+chain_modify(struct sw_chain *chain, const struct sw_flow_key *key, 
+               uint16_t priority, int strict,
+               const struct ofp_action *actions, int n_actions)
+{
+       int count = 0;
+       int i;
+
+       for (i = 0; i < chain->n_tables; i++) {
+               struct sw_table *t = chain->tables[i];
+               count += t->modify(t, key, priority, strict, actions, n_actions);
+       }
+
+       return count;
+}
+
+/* Deletes from 'chain' any and all flows that match 'key'.  If 'strict' set, 
+ * wildcards and priority must match.  Returns the number of flows that were 
+ * deleted.
  *
  * Expensive in the general case as currently implemented, since it requires
  * iterating through the entire contents of each table for keys that contain
@@ -158,22 +183,6 @@ void chain_destroy(struct sw_chain *chain)
        kfree(chain);
 }
 
-/* Prints statistics for each of the tables in 'chain'. */
-void chain_print_stats(struct sw_chain *chain)
-{
-       int i;
-
-       printk("\n");
-       for (i = 0; i < chain->n_tables; i++) {
-               struct sw_table *t = chain->tables[i];
-               struct sw_table_stats stats;
-               t->stats(t, &stats);
-               printk("%s: %lu/%lu flows\n",
-                                       stats.name, stats.n_flows, stats.max_flows);
-       }
-}
-
-
 int chain_set_hw_hook(struct sw_table *(*create_hw_table)(void),
                      struct module *owner)
 {