Clone action is optimized by cloning a batch of packets together instead of
executing independently on every packet in a batch.
Rebased onto commit: edb417cc256e7d5f02f230867865c8cf7f26e542
ovs-ofctl: fix memory leak reported by valgrind.
Signed-off-by: Sugesh Chandran <[email protected]>
Signed-off-by: Zoltán Balogh <[email protected]>
Co-authored-by: Zoltán Balogh <[email protected]>
---
lib/odp-execute.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/lib/odp-execute.c b/lib/odp-execute.c
index 1f6812a..9cb85c1 100644
--- a/lib/odp-execute.c
+++ b/lib/odp-execute.c
@@ -537,23 +537,26 @@ odp_execute_sample(void *dp, struct dp_packet *packet,
bool steal,
}
static void
-odp_execute_clone(void *dp, struct dp_packet *packet, bool steal,
+odp_execute_clone(void *dp, struct dp_packet_batch *batch, bool steal,
const struct nlattr *actions,
odp_execute_cb dp_execute_action)
{
- struct dp_packet_batch pb;
-
if (!steal) {
/* The 'actions' may modify the packet, but the modification
* should not propagate beyond this clone action. Make a copy
* the packet in case we don't own the packet, so that the
* 'actions' are only applied 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, true, nl_attr_get(actions),
+ struct dp_packet_batch clone_pkt_batch;
+ dp_packet_batch_clone(&clone_pkt_batch, batch);
+ dp_packet_batch_reset_cutlen(batch);
+ odp_execute_actions(dp, &clone_pkt_batch, true, nl_attr_get(actions),
nl_attr_get_size(actions), dp_execute_action);
+ }
+ else {
+ odp_execute_actions(dp, batch, true, nl_attr_get(actions),
+ nl_attr_get_size(actions), dp_execute_action);
+ }
}
static bool
@@ -712,11 +715,8 @@ odp_execute_actions(void *dp, struct dp_packet_batch
*batch, bool steal,
}
case OVS_ACTION_ATTR_CLONE:
- DP_PACKET_BATCH_FOR_EACH (packet, batch) {
- odp_execute_clone(dp, packet, steal && last_action, a,
- dp_execute_action);
- }
-
+ odp_execute_clone(dp, batch, steal && last_action, a,
+ dp_execute_action);
if (last_action) {
/* We do not need to free the packets. odp_execute_clone() has
* stolen them. */
--
2.7.4
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev