summaryrefslogtreecommitdiff
path: root/include/openflow/nicira-ext.h
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2014-06-05 21:53:34 -0700
committerBen Pfaff <blp@nicira.com>2014-06-12 14:47:22 -0700
commit35f48b8bd9b3b3491d79418878ef70dc54b0a8f0 (patch)
tree423a72ba1b6efbf159afb6356d0c15fb6a66cd63 /include/openflow/nicira-ext.h
parent9ca4a86fffcda89098588cbdd9ba0c21aa60a9c8 (diff)
downloadopenvswitch-35f48b8bd9b3b3491d79418878ef70dc54b0a8f0.tar.gz
Implement learned flow deletion.
When a flow with a "learn" action is deleted, one often wants the flows that it created (the "learned flows") to be deleted as well. This commit makes that possible. I am aware of a race condition that could lead to a learned flow not being properly deleted. Suppose thread A deletes a flow with a "learn" action. Meanwhile, thread B obtains the actions for this flow and translates and executes them. Thread B could obtain the actions for the flow before it is deleted, but execute them after the "learn" flow and its learned flows are deleted. The result is that the flow created by thread B persists despite its "learn" flow having been deleted. This race can and should be fixed, but I think that this commit is worth reviewing without it. VMware-BZ: #1254021 Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Thomas Graf <tgraf@suug.ch> Acked-by: Ethan Jackson <ethan@nicira.com>
Diffstat (limited to 'include/openflow/nicira-ext.h')
-rw-r--r--include/openflow/nicira-ext.h36
1 files changed, 34 insertions, 2 deletions
diff --git a/include/openflow/nicira-ext.h b/include/openflow/nicira-ext.h
index 767b98b0a..cb3413a8d 100644
--- a/include/openflow/nicira-ext.h
+++ b/include/openflow/nicira-ext.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -927,7 +927,7 @@ struct nx_action_learn {
ovs_be16 hard_timeout; /* Max time before discarding (seconds). */
ovs_be16 priority; /* Priority level of flow entry. */
ovs_be64 cookie; /* Cookie for new flow. */
- ovs_be16 flags; /* Either 0 or OFPFF_SEND_FLOW_REM. */
+ ovs_be16 flags; /* NX_LEARN_F_*. */
uint8_t table_id; /* Table to insert flow entry. */
uint8_t pad; /* Must be zero. */
ovs_be16 fin_idle_timeout; /* Idle timeout after FIN, if nonzero. */
@@ -937,6 +937,38 @@ struct nx_action_learn {
};
OFP_ASSERT(sizeof(struct nx_action_learn) == 32);
+/* Bits for 'flags' in struct nx_action_learn.
+ *
+ * If NX_LEARN_F_SEND_FLOW_REM is set, then the learned flows will have their
+ * OFPFF_SEND_FLOW_REM flag set.
+ *
+ * If NX_LEARN_F_DELETE_LEARNED is set, then removing this action will delete
+ * all the flows from the learn action's 'table_id' that have the learn
+ * action's 'cookie'. Important points:
+ *
+ * - The deleted flows include those created by this action, those created
+ * by other learn actions with the same 'table_id' and 'cookie', those
+ * created by flow_mod requests by a controller in the specified table
+ * with the specified cookie, and those created through any other
+ * means.
+ *
+ * - If multiple flows specify "learn" actions with
+ * NX_LEARN_F_DELETE_LEARNED with the same 'table_id' and 'cookie', then
+ * no deletion occurs until all of those "learn" actions are deleted.
+ *
+ * - Deleting a flow that contains a learn action is the most obvious way
+ * to delete a learn action. Modifying a flow's actions, or replacing it
+ * by a new flow, can also delete a learn action. Finally, replacing a
+ * learn action with NX_LEARN_F_DELETE_LEARNED with a learn action
+ * without that flag also effectively deletes the learn action and can
+ * trigger flow deletion.
+ *
+ * NX_LEARN_F_DELETE_LEARNED was added in Open vSwitch 2.4. */
+enum nx_learn_flags {
+ NX_LEARN_F_SEND_FLOW_REM = 1 << 0,
+ NX_LEARN_F_DELETE_LEARNED = 1 << 1,
+};
+
#define NX_LEARN_N_BITS_MASK 0x3ff
#define NX_LEARN_SRC_FIELD (0 << 13) /* Copy from field. */