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

Ben Pfaff blp at ovn.org
Fri Jan 6 16:33:42 UTC 2017


This is a design decision but it seems conceptually cleaner than having
them leak through into the clone.

Reported-by: Mickey Spiegel <mickeys.dev at 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 at ovn.org>
Acked-by: Mickey Spiegel <mickeys.dev at gmail.com>
---
 ofproto/ofproto-dpif-xlate.c | 18 +++++++++++++++++-
 utilities/ovs-ofctl.8.in     |  3 ++-
 2 files changed, 19 insertions(+), 2 deletions(-)

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
-- 
2.10.2



More information about the dev mailing list