summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Zhou <azhou@ovn.org>2017-01-11 16:00:04 -0800
committerAndy Zhou <azhou@ovn.org>2017-02-03 14:43:15 -0800
commit70a0573d0a73807a67869eeaa5b6e039b35e57a1 (patch)
treeaef4ffff1cdcacd968ffc45d275730c7681d1d70
parentf75612a12f669cba914c1c386176316aac9ddee0 (diff)
downloadopenvswitch-70a0573d0a73807a67869eeaa5b6e039b35e57a1.tar.gz
odp: Fix sample action in userspace
User space implementation of the sample action is not consistent with kernel datapath. In kernel datapath, the side effects of actions within the sample actions are not visible to the subsequent actions. Current user space handling does not follow the same logic. This patch makes them consistent. Signed-off-by: Andy Zhou <azhou@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
-rw-r--r--lib/odp-execute.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/odp-execute.c b/lib/odp-execute.c
index 9612ef512..1f6812a6d 100644
--- a/lib/odp-execute.c
+++ b/lib/odp-execute.c
@@ -523,8 +523,16 @@ odp_execute_sample(void *dp, struct dp_packet *packet, bool steal,
}
}
+ if (!steal) {
+ /* The 'subactions' may modify the packet, but the modification
+ * should not propagate beyond this sample action. Make a copy
+ * the packet in case we don't own the packet, so that the
+ * 'subactions' are only applid to the clone. 'odp_execute_actions'
+ * will free the clone. */
+ packet = dp_packet_clone(packet);
+ }
dp_packet_batch_init_packet(&pb, packet);
- odp_execute_actions(dp, &pb, steal, nl_attr_get(subactions),
+ odp_execute_actions(dp, &pb, true, nl_attr_get(subactions),
nl_attr_get_size(subactions), dp_execute_action);
}