Stopgap fix for bug #478, where kernel panics on SNAT to input port.
[sliver-openvswitch.git] / datapath / chain.c
index 87b8b79..cd3b6e5 100644 (file)
@@ -72,6 +72,7 @@ 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);
+               t->n_lookup++;
                if (flow) {
                        t->n_matched++;
                        return flow;
@@ -101,8 +102,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_header *actions, size_t actions_len)
+{
+       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, actions_len);
+       }
+
+       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