[ovs-dev] [nxm 34/42] nicira-ext: Shuffle comments around.

Ben Pfaff blp at nicira.com
Thu Oct 28 17:28:05 UTC 2010


It seemed to me that the descriptions of what actions do should be just
above the action structures, where the reader can see the arguments,
instead of just above the enumeration name, so I rearranged the code
this way.

A few actions didn't have their own structures, so to do this I had to give
them some.
---
 include/openflow/nicira-ext.h |  132 +++++++++++++++++++++++-----------------
 1 files changed, 76 insertions(+), 56 deletions(-)

diff --git a/include/openflow/nicira-ext.h b/include/openflow/nicira-ext.h
index e563b40..a329fb2 100644
--- a/include/openflow/nicira-ext.h
+++ b/include/openflow/nicira-ext.h
@@ -172,59 +172,50 @@ enum nx_role {
 /* Nicira vendor flow actions. */
 
 enum nx_action_subtype {
-    NXAST_SNAT__OBSOLETE,           /* No longer used. */
-
-    /* Searches the flow table again, using a flow that is slightly modified
-     * from the original lookup:
-     *
-     *    - The 'in_port' member of struct nx_action_resubmit is used as the
-     *      flow's in_port.
-     *
-     *    - If NXAST_RESUBMIT is preceded by actions that affect the flow
-     *      (e.g. OFPAT_SET_VLAN_VID), then the flow is updated with the new
-     *      values.
-     *
-     * Following the lookup, the original in_port is restored.
-     *
-     * If the modified flow matched in the flow table, then the corresponding
-     * actions are executed.  Afterward, actions following NXAST_RESUBMIT in
-     * the original set of actions, if any, are executed; any changes made to
-     * the packet (e.g. changes to VLAN) by secondary actions persist when
-     * those actions are executed, although the original in_port is restored.
-     *
-     * NXAST_RESUBMIT may be used any number of times within a set of actions.
-     *
-     * NXAST_RESUBMIT may nest to an implementation-defined depth.  Beyond this
-     * implementation-defined depth, further NXAST_RESUBMIT actions are simply
-     * ignored.  (Open vSwitch 1.0.1 and earlier did not support recursion.)
-     */
-    NXAST_RESUBMIT,
-
-    /* Set encapsulating tunnel ID. */
-    NXAST_SET_TUNNEL,
-
-    /* Stops processing further actions, if the packet being processed is an
-     * Ethernet+IPv4 ARP packet for which the source Ethernet address inside
-     * the ARP packet differs from the source Ethernet address in the Ethernet
-     * header.
-     *
-     * This is useful because OpenFlow does not provide a way to match on the
-     * Ethernet addresses inside ARP packets, so there is no other way to drop
-     * spoofed ARPs other than sending every ARP packet to a controller. */
-    NXAST_DROP_SPOOFED_ARP,
-
-    /* Set the queue that should be used when packets are output.  This
-     * is similar to the OpenFlow OFPAT_ENQUEUE action, but does not
-     * take the output port as an argument.  This allows the queue
-     * to be defined before the port is known. */
-    NXAST_SET_QUEUE,
+    NXAST_SNAT__OBSOLETE,       /* No longer used. */
+    NXAST_RESUBMIT,             /* struct nx_action_resubmit */
+    NXAST_SET_TUNNEL,           /* struct nx_action_set_tunnel */
+    NXAST_DROP_SPOOFED_ARP,     /* struct nx_action_drop_spoofed_arp */
+    NXAST_SET_QUEUE,            /* struct nx_action_set_queue */
+    NXAST_POP_QUEUE             /* struct nx_action_pop_queue */
+};
 
-    /* Restore the queue to the value it was before any NXAST_SET_QUEUE
-     * actions were used. */
-    NXAST_POP_QUEUE
+/* Header for Nicira-defined actions. */
+struct nx_action_header {
+    uint16_t type;                  /* OFPAT_VENDOR. */
+    uint16_t len;                   /* Length is 16. */
+    uint32_t vendor;                /* NX_VENDOR_ID. */
+    uint16_t subtype;               /* NXAST_*. */
+    uint8_t pad[6];
 };
+OFP_ASSERT(sizeof(struct nx_action_header) == 16);
 
-/* Action structure for NXAST_RESUBMIT. */
+/* Action structure for NXAST_RESUBMIT.
+ *
+ * NXAST_RESUBMIT searches the flow table again, using a flow that is slightly
+ * modified from the original lookup:
+ *
+ *    - The 'in_port' member of struct nx_action_resubmit is used as the flow's
+ *      in_port.
+ *
+ *    - If NXAST_RESUBMIT is preceded by actions that affect the flow
+ *      (e.g. OFPAT_SET_VLAN_VID), then the flow is updated with the new
+ *      values.
+ *
+ * Following the lookup, the original in_port is restored.
+ *
+ * If the modified flow matched in the flow table, then the corresponding
+ * actions are executed.  Afterward, actions following NXAST_RESUBMIT in the
+ * original set of actions, if any, are executed; any changes made to the
+ * packet (e.g. changes to VLAN) by secondary actions persist when those
+ * actions are executed, although the original in_port is restored.
+ *
+ * NXAST_RESUBMIT may be used any number of times within a set of actions.
+ *
+ * NXAST_RESUBMIT may nest to an implementation-defined depth.  Beyond this
+ * implementation-defined depth, further NXAST_RESUBMIT actions are simply
+ * ignored.  (Open vSwitch 1.0.1 and earlier did not support recursion.)
+ */
 struct nx_action_resubmit {
     uint16_t type;                  /* OFPAT_VENDOR. */
     uint16_t len;                   /* Length is 16. */
@@ -235,7 +226,9 @@ struct nx_action_resubmit {
 };
 OFP_ASSERT(sizeof(struct nx_action_resubmit) == 16);
 
-/* Action structure for NXAST_SET_TUNNEL. */
+/* Action structure for NXAST_SET_TUNNEL.
+ *
+ * Sets the encapsulating tunnel ID. */
 struct nx_action_set_tunnel {
     uint16_t type;                  /* OFPAT_VENDOR. */
     uint16_t len;                   /* Length is 16. */
@@ -246,7 +239,30 @@ struct nx_action_set_tunnel {
 };
 OFP_ASSERT(sizeof(struct nx_action_set_tunnel) == 16);
 
-/* Action structure for NXAST_SET_QUEUE. */
+/* Action structure for NXAST_DROP_SPOOFED_ARP.
+ *
+ * Stops processing further actions, if the packet being processed is an
+ * Ethernet+IPv4 ARP packet for which the source Ethernet address inside the
+ * ARP packet differs from the source Ethernet address in the Ethernet header.
+ *
+ * This is useful because OpenFlow does not provide a way to match on the
+ * Ethernet addresses inside ARP packets, so there is no other way to drop
+ * spoofed ARPs other than sending every ARP packet to a controller. */
+struct nx_action_drop_spoofed_arp {
+    uint16_t type;                  /* OFPAT_VENDOR. */
+    uint16_t len;                   /* Length is 16. */
+    uint32_t vendor;                /* NX_VENDOR_ID. */
+    uint16_t subtype;               /* NXAST_DROP_SPOOFED_ARP. */
+    uint8_t pad[6];
+};
+OFP_ASSERT(sizeof(struct nx_action_drop_spoofed_arp) == 16);
+
+/* Action structure for NXAST_SET_QUEUE.
+ *
+ * Set the queue that should be used when packets are output.  This is similar
+ * to the OpenFlow OFPAT_ENQUEUE action, but does not take the output port as
+ * an argument.  This allows the queue to be defined before the port is
+ * known. */
 struct nx_action_set_queue {
     uint16_t type;                  /* OFPAT_VENDOR. */
     uint16_t len;                   /* Length is 16. */
@@ -257,15 +273,19 @@ struct nx_action_set_queue {
 };
 OFP_ASSERT(sizeof(struct nx_action_set_queue) == 16);
 
-/* Header for Nicira-defined actions. */
-struct nx_action_header {
+/* Action structure for NXAST_POP_QUEUE.
+ *
+ * Restores the queue to the value it was before any NXAST_SET_QUEUE actions
+ * were used.  Only the original queue can be restored this way; no stack is
+ * maintained. */
+struct nx_action_pop_queue {
     uint16_t type;                  /* OFPAT_VENDOR. */
     uint16_t len;                   /* Length is 16. */
     uint32_t vendor;                /* NX_VENDOR_ID. */
-    uint16_t subtype;               /* NXAST_*. */
+    uint16_t subtype;               /* NXAST_POP_QUEUE. */
     uint8_t pad[6];
 };
-OFP_ASSERT(sizeof(struct nx_action_header) == 16);
+OFP_ASSERT(sizeof(struct nx_action_pop_queue) == 16);
 
 /* Wildcard for tunnel ID. */
 #define NXFW_TUN_ID  (1 << 25)
-- 
1.7.1





More information about the dev mailing list