Update handling of the following actions to use the dl_type set by MPLS
push and pop actions if it differs from the original dl_type. This is
consistent with the existing checking of load actions and allows
their existing checks to enforce dl_type pre-requisites correctly.

        output_reg
        bundle
        reg_move
        stack_push
        stack_pop
        learn
        multipath

In order to avoid the verbosity of updating the flow for each applicable
action the update is treated as a common case and performed at the top of
ofpact_check__().  This was suggested by Jesse Gross.

Cc: Jesse Gross <je...@nicira.com>
Signed-off-by: Simon Horman <ho...@verge.net.au>
---
 lib/ofp-actions.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c
index 068699f..cd8d229 100644
--- a/lib/ofp-actions.c
+++ b/lib/ofp-actions.c
@@ -1141,6 +1141,13 @@ ofpact_check__(const struct ofpact *a, const struct flow 
*flow, int max_ports,
                ovs_be16 *dl_type)
 {
     const struct ofpact_enqueue *enqueue;
+    struct flow updated_flow;
+
+    if (flow->dl_type != *dl_type) {
+        updated_flow = *flow;
+        updated_flow.dl_type = *dl_type;
+        flow = &updated_flow;
+    }
 
     switch (a->type) {
     case OFPACT_OUTPUT:
@@ -1181,13 +1188,7 @@ ofpact_check__(const struct ofpact *a, const struct flow 
*flow, int max_ports,
         return nxm_reg_move_check(ofpact_get_REG_MOVE(a), flow);
 
     case OFPACT_REG_LOAD:
-        if (*dl_type != flow->dl_type) {
-            struct flow updated_flow = *flow;
-            updated_flow.dl_type = *dl_type;
-            return nxm_reg_load_check(ofpact_get_REG_LOAD(a), &updated_flow);
-        } else {
-            return nxm_reg_load_check(ofpact_get_REG_LOAD(a), flow);
-        }
+        return nxm_reg_load_check(ofpact_get_REG_LOAD(a), flow);
 
     case OFPACT_STACK_PUSH:
         return nxm_stack_push_check(ofpact_get_STACK_PUSH(a), flow);
-- 
1.8.2.1

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to