From patchwork Thu Aug 1 09:53:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dumitru Ceara X-Patchwork-Id: 1967579 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=JX5aMyCn; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WZPTS4v7Fz1yYq for ; Thu, 1 Aug 2024 19:55:08 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id D649E40D3B; Thu, 1 Aug 2024 09:55:04 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id zJi-gX8TGH9E; Thu, 1 Aug 2024 09:55:01 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.9.56; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 72E7840C4B Authentication-Results: smtp4.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=JX5aMyCn Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 72E7840C4B; Thu, 1 Aug 2024 09:55:00 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 2A3FFC0033; Thu, 1 Aug 2024 09:55:00 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) by lists.linuxfoundation.org (Postfix) with ESMTP id A4BD9C002B for ; Thu, 1 Aug 2024 09:54:58 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id E684E40C4B for ; Thu, 1 Aug 2024 09:54:14 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id vDW-Uu14LBTG for ; Thu, 1 Aug 2024 09:54:12 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.129.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=dceara@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp4.osuosl.org A961040E46 Authentication-Results: smtp4.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org A961040E46 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp4.osuosl.org (Postfix) with ESMTPS id A961040E46 for ; Thu, 1 Aug 2024 09:54:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722506050; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qbTWQb5+EmmmiJTWPmGlK75jE0MLtuFuy3BDSbMYzDI=; b=JX5aMyCnZmKjkMBwk3BpiiPO9henjxo4a4jKIcZJUL9SPucxMiPFvIx3iFthEKVMQ+b/72 lZrS/tzh+5El5MQHpl/zVaAI3BPSUqOnrvKs+uiIgyyQu7QV1DqNdyNSHxatpf1G7Uidj0 ILWqc7jdDAagPWZXHXkPTyTi9MTn/IU= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-383-wXFgjVqoPCyPIrND_gOAAQ-1; Thu, 01 Aug 2024 05:54:05 -0400 X-MC-Unique: wXFgjVqoPCyPIrND_gOAAQ-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E47691955F42; Thu, 1 Aug 2024 09:54:04 +0000 (UTC) Received: from cecil-rh.redhat.com (unknown [10.39.194.158]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B39831955E70; Thu, 1 Aug 2024 09:54:02 +0000 (UTC) From: Dumitru Ceara To: ovs-dev@openvswitch.org Date: Thu, 1 Aug 2024 11:53:17 +0200 Message-ID: <20240801095319.467255-9-dceara@redhat.com> In-Reply-To: <20240801095319.467255-1-dceara@redhat.com> References: <20240801095319.467255-1-dceara@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn v5 8/9] actions: Add support for sample with register. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: i.maximets@ovn.org Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Ales Musil Allow sample to accept obs_point_id as register instead of integer literal value. Acked-by: Dumitru Ceara Signed-off-by: Ales Musil --- V5: - Added Dumitru's ack --- include/ovn/actions.h | 16 +++++++++------- lib/actions.c | 12 ++++++++---- tests/ovn.at | 13 ++++++++++++- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/include/ovn/actions.h b/include/ovn/actions.h index 88cf4de79f..c8dd66ed83 100644 --- a/include/ovn/actions.h +++ b/include/ovn/actions.h @@ -498,13 +498,15 @@ struct ovnact_lookup_fdb { /* OVNACT_SAMPLE */ struct ovnact_sample { struct ovnact ovnact; - uint16_t probability; /* probability over UINT16_MAX. */ - uint8_t obs_domain_id; /* most significant byte of the - observation domain id. The other 24 bits - will come from the datapath's tunnel key. */ - uint32_t collector_set_id; /* colector_set_id. */ - uint32_t obs_point_id; /* observation point id. */ - bool use_cookie; /* use cookie as obs_point_id */ + uint16_t probability; /* probability over UINT16_MAX. */ + uint8_t obs_domain_id; /* most significant byte of the + observation domain id. The other + 24 bits will come from the + datapath's tunnel key. */ + uint32_t collector_set_id; /* colector_set_id. */ + struct expr_field obs_point_id_src; /* observation point id source reg */ + uint32_t obs_point_id; /* observation point id */ + bool use_cookie; /* use cookie as obs_point_id */ }; /* OVNACT_COMMIT_ECMP_NH. */ diff --git a/lib/actions.c b/lib/actions.c index 37676ef81b..586c64af36 100644 --- a/lib/actions.c +++ b/lib/actions.c @@ -4523,10 +4523,13 @@ format_SAMPLE(const struct ovnact_sample *sample, struct ds *s) ds_put_format(s, ",collector_set=%"PRIu32, sample->collector_set_id); ds_put_format(s, ",obs_domain=%"PRIu8, sample->obs_domain_id); + ds_put_cstr(s, ",obs_point="); if (sample->use_cookie) { - ds_put_cstr(s, ",obs_point=$cookie"); + ds_put_cstr(s, "$cookie"); + } else if (sample->obs_point_id_src.symbol) { + expr_field_format(&sample->obs_point_id_src, s); } else { - ds_put_format(s, ",obs_point=%"PRIu32, sample->obs_point_id); + ds_put_format(s, "%"PRIu32, sample->obs_point_id); } ds_put_format(s, ");"); } @@ -4551,6 +4554,8 @@ encode_SAMPLE(const struct ovnact_sample *sample, if (sample->use_cookie) { os->obs_point_imm = ep->lflow_uuid.parts[0]; + } else if (sample->obs_point_id_src.symbol) { + os->obs_point_src = expr_resolve_field(&sample->obs_point_id_src); } else { os->obs_point_imm = sample->obs_point_id; } @@ -4584,8 +4589,7 @@ parse_sample_arg(struct action_context *ctx, struct ovnact_sample *sample) sample->obs_point_id = ntohll(ctx->lexer->token.value.integer); lexer_get(ctx->lexer); } else { - lexer_syntax_error(ctx->lexer, - "malformed sample observation_point_id"); + action_parse_field(ctx, 32, false, &sample->obs_point_id_src); } } else if (lexer_match_id(ctx->lexer, "obs_domain")) { if (!lexer_force_match(ctx->lexer, LEX_T_EQUALS)) { diff --git a/tests/ovn.at b/tests/ovn.at index 0f401ab96a..f1fc29503f 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -2333,11 +2333,19 @@ sample(probability=10); sample(probability=100,collector_set=999,obs_domain=0,obs_point=1000); encodes as drop +sample(probability=10, obs_point=reg3); + formats as sample(probability=10,collector_set=0,obs_domain=0,obs_point=reg3); + encodes as sample(probability=10,collector_set_id=0,obs_domain_id=11259375,obs_point_id=NXM_NX_XXREG0[[0..31]]) + +sample(probability=10, obs_point=ct_label.obs_point_id); + formats as sample(probability=10,collector_set=0,obs_domain=0,obs_point=ct_label.obs_point_id); + encodes as sample(probability=10,collector_set_id=0,obs_domain_id=11259375,obs_point_id=NXM_NX_CT_LABEL[[96..127]]) + sample(probability=0,collector_set=200,obs_domain=0,obs_point=1000); probability must be greater than zero sample(probability=0,collector_set=200,obs_domain=0,obs_point=foo); - Syntax error at `foo' malformed sample observation_point_id. + Syntax error at `foo' expecting field name. sample(probability=0,collector_set=200,obs_domain=300,obs_point=foo); Syntax error at `300' obs_domain must be 8-bit long. @@ -2345,6 +2353,9 @@ sample(probability=0,collector_set=200,obs_domain=300,obs_point=foo); sample(probability=10,foo=bar,obs_domain=0,obs_point=1000); Syntax error at `foo' unknown argument. +sample(probability=10, obs_point=ct_label); + Cannot use 128-bit field ct_label[[0..127]] where 32-bit field is required. + # mac_cache_use mac_cache_use; encodes as resubmit(,OFTABLE_MAC_CACHE_USE)