summaryrefslogtreecommitdiff
path: root/ofproto
diff options
context:
space:
mode:
authorAndy Zhou <azhou@ovn.org>2017-04-05 16:16:38 -0700
committerAndy Zhou <azhou@ovn.org>2017-04-28 14:22:03 -0700
commit31b29c2ed366611a483ff604ce00e9f1af901b59 (patch)
treeee9ea11b65206d46441557eed5f7d4e190fe699c /ofproto
parent9e638f223feb09a891e653796218982e4d64d342 (diff)
downloadopenvswitch-31b29c2ed366611a483ff604ce00e9f1af901b59.tar.gz
ofproto: Meter sample action when configured.
When slowpath meter is configured, add meter action when translate sample action. Signed-off-by: Andy Zhou <azhou@ovn.org> Acked-by: Jarno Rajahalme <jarno@ovn.org>
Diffstat (limited to 'ofproto')
-rw-r--r--ofproto/ofproto-dpif-xlate.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index ab5eef8c6..32cb022ce 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -2850,8 +2850,14 @@ compose_sample_action(struct xlate_ctx *ctx,
return 0;
}
- /* No need to generate sample action for 100% sampling rate. */
- bool is_sample = probability < UINT32_MAX;
+ /* If the slow path meter is configured by the controller,
+ * insert a meter action before the user space action. */
+ struct ofproto *ofproto = &ctx->xin->ofproto->up;
+ uint32_t meter_id = ofproto->slowpath_meter_id;
+
+ /* When meter action is not required, avoid generate sample action
+ * for 100% sampling rate. */
+ bool is_sample = probability < UINT32_MAX || meter_id != UINT32_MAX;
size_t sample_offset, actions_offset;
if (is_sample) {
sample_offset = nl_msg_start_nested(ctx->odp_actions,
@@ -2862,6 +2868,10 @@ compose_sample_action(struct xlate_ctx *ctx,
OVS_SAMPLE_ATTR_ACTIONS);
}
+ if (meter_id != UINT32_MAX) {
+ nl_msg_put_u32(ctx->odp_actions, OVS_ACTION_ATTR_METER, meter_id);
+ }
+
odp_port_t odp_port = ofp_port_to_odp_port(
ctx->xbridge, ctx->xin->flow.in_port.ofp_port);
uint32_t pid = dpif_port_get_pid(ctx->xbridge->dpif, odp_port,