diff mbox

[ovs-dev,v3,1/4] ofproto-dpif-xlate: Make "clone" save action set and stack.

Message ID 20170106163345.5622-2-blp@ovn.org
State Accepted
Headers show

Commit Message

Ben Pfaff Jan. 6, 2017, 4:33 p.m. UTC
This is a design decision but it seems conceptually cleaner than having
them leak through into the clone.

Reported-by: Mickey Spiegel <mickeys.dev@gmail.com>
Reported-at: https://mail.openvswitch.org/pipermail/ovs-dev/2017-January/326981.html
Fixes: 7ae62a676d3a ("ofp-actions: Add clone action.")
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Mickey Spiegel <mickeys.dev@gmail.com>
---
 ofproto/ofproto-dpif-xlate.c | 18 +++++++++++++++++-
 utilities/ovs-ofctl.8.in     |  3 ++-
 2 files changed, 19 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index fb552ce..36b7ac0 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -1,4 +1,4 @@ 
-/* Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Nicira, Inc.
+/* Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -4319,8 +4319,24 @@  compose_clone_action(struct xlate_ctx *ctx, const struct ofpact_nest *oc)
     bool old_conntracked = ctx->conntracked;
     struct flow old_flow = ctx->xin->flow;
 
+    struct ofpbuf old_stack = ctx->stack;
+    union mf_subvalue new_stack[1024 / sizeof(union mf_subvalue)];
+    ofpbuf_use_stub(&ctx->stack, new_stack, sizeof new_stack);
+    ofpbuf_put(&ctx->stack, old_stack.data, old_stack.size);
+
+    struct ofpbuf old_action_set = ctx->action_set;
+    uint64_t actset_stub[1024 / 8];
+    ofpbuf_use_stub(&ctx->action_set, actset_stub, sizeof actset_stub);
+    ofpbuf_put(&ctx->action_set, old_action_set.data, old_action_set.size);
+
     do_xlate_actions(oc->actions, ofpact_nest_get_action_len(oc), ctx);
 
+    ofpbuf_uninit(&ctx->action_set);
+    ctx->action_set = old_action_set;
+
+    ofpbuf_uninit(&ctx->stack);
+    ctx->stack = old_stack;
+
     ctx->xin->flow = old_flow;
 
     /* The clone's conntrack execution should have no effect on the original
diff --git a/utilities/ovs-ofctl.8.in b/utilities/ovs-ofctl.8.in
index 49d87ab..0fdaa48 100644
--- a/utilities/ovs-ofctl.8.in
+++ b/utilities/ovs-ofctl.8.in
@@ -2638,7 +2638,8 @@  in Open vSwitch 2.4.
 Executes each nested \fIaction\fR, saving much of the packet and
 pipeline state beforehand and then restoring it afterward.  The state
 that is saved and restored includes all flow data and metadata
-(including, for example, \fBct_state\fR).
+(including, for example, \fBct_state\fR), the stack accessed by
+\fBpush\fR and \fBpop\fR actions, and the OpenFlow action set.
 .IP
 This action was added in Open vSwitch 2.6.90.
 .RE