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;
}
return -ENOBUFS;
}
+/* Modifies actions in 'chain' that match 'key'. 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,
+ 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, actions, n_actions);
+ }
+
+ return count;
+}
+
/* Deletes from 'chain' any and all flows that match 'key'. Returns the number
* of flows that were deleted.
*
}
free(chain);
}
-
-/* Prints statistics for each of the tables in 'chain'. */
-void
-chain_print_stats(struct sw_chain *chain)
-{
- int i;
-
- printf("\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);
- printf("%s: %lu/%lu flows\n",
- stats.name, stats.n_flows, stats.max_flows);
- }
-}