From patchwork Wed May 14 08:12:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ales Musil X-Patchwork-Id: 2085463 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=DUQLKVKR; 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 4Zy5gJ2R4wz1yPv for ; Wed, 14 May 2025 18:12:44 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 6285A414D3; Wed, 14 May 2025 08:12:57 +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 G6z40umGH7he; Wed, 14 May 2025 08:12:56 +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 EFE6A414A1 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=DUQLKVKR Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id EFE6A414A1; Wed, 14 May 2025 08:12:55 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id D99ACC007B; Wed, 14 May 2025 08:12:55 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 79135C08A9 for ; Wed, 14 May 2025 08:12:54 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 7720361060 for ; Wed, 14 May 2025 08:12:54 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id tLdQVyL5rDVY for ; Wed, 14 May 2025 08:12:53 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.129.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=amusil@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp3.osuosl.org 9E86161062 Authentication-Results: smtp3.osuosl.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 9E86161062 Authentication-Results: smtp3.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=DUQLKVKR Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp3.osuosl.org (Postfix) with ESMTPS id 9E86161062 for ; Wed, 14 May 2025 08:12:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747210372; 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=Ovc46vwyvEs9DMyj5Nf2VySGVNiWtgpNZR0bLpaUvj0=; b=DUQLKVKR1fcLc7Rc67newhXRfOLfTKb96+GhWb8lzdijRhZXpvNHUCC4kxST+/sJIbCkIw vfQnj2TEJ0hrBBJ9JZbannLEXApo+SkEDLqnpR62BxeOcafHc3F+/ZlHtUehbATwaVefrP rTZHwRSoO4LMdf42Ucc3lEXCUBIS/CY= Received: from mx-prod-mc-01.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-513-OXusdl9aPuCD89tcmQy8XQ-1; Wed, 14 May 2025 04:12:50 -0400 X-MC-Unique: OXusdl9aPuCD89tcmQy8XQ-1 X-Mimecast-MFC-AGG-ID: OXusdl9aPuCD89tcmQy8XQ_1747210369 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B1F0C195DE36 for ; Wed, 14 May 2025 08:12:49 +0000 (UTC) Received: from amusil.brq.redhat.com (unknown [10.43.17.21]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C6B7B30002E5; Wed, 14 May 2025 08:12:48 +0000 (UTC) To: dev@openvswitch.org Date: Wed, 14 May 2025 10:12:44 +0200 Message-ID: <20250514081246.985906-2-amusil@redhat.com> In-Reply-To: <20250514081246.985906-1-amusil@redhat.com> References: <20250514081246.985906-1-amusil@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: _-PNMtfL2-LERDazIU3JU43KhWIw5oCxkanboZp2PzY_1747210369 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn v2 1/3] northd: Avoid recompute of lflow from ACLs without meters. 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: , X-Patchwork-Original-From: Ales Musil via dev From: Ales Musil Reply-To: Ales Musil Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" The lflow has dependency on sync_meters node so any change in sync_meters will cause full lflow recompute. Add handler for ACLs into sync_meters node that will check if the ACL actually requires any meters. In case it does it will trigger recompute. However, in most cases the ACLs are without metering which should avoid expensive recomopute of lflow node. Signed-off-by: Ales Musil --- v2: Rebase on top of latest main. --- northd/en-meters.c | 24 ++++++++++++ northd/en-meters.h | 2 + northd/inc-proc-northd.c | 2 +- tests/ovn-northd.at | 80 +++++++++++++++++++++++++++++++++++++++- 4 files changed, 105 insertions(+), 3 deletions(-) diff --git a/northd/en-meters.c b/northd/en-meters.c index a0352c34b..288134108 100644 --- a/northd/en-meters.c +++ b/northd/en-meters.c @@ -79,6 +79,30 @@ en_sync_meters_run(struct engine_node *node, void *data_) return EN_UPDATED; } +enum engine_input_handler_result +sync_meters_nb_acl_handler(struct engine_node *node, void *data OVS_UNUSED) +{ + const struct nbrec_acl_table *acl_table = + EN_OVSDB_GET(engine_get_input("NB_acl", node)); + + const struct nbrec_acl *nb_acl; + NBREC_ACL_TABLE_FOR_EACH_TRACKED (nb_acl, acl_table) { + /* New or deleted ACL with meter needs to be recomputed. */ + if ((nbrec_acl_is_new(nb_acl) || nbrec_acl_is_deleted(nb_acl)) && + (nb_acl->log || nb_acl->meter)) { + return EN_UNHANDLED; + } + + /* Addition or removal of meter requires recompute. */ + if (nbrec_acl_is_updated(nb_acl, NBREC_ACL_COL_LOG) || + nbrec_acl_is_updated(nb_acl, NBREC_ACL_COL_METER)) { + return EN_UNHANDLED; + } + } + + return EN_HANDLED_UNCHANGED; +} + const struct nbrec_meter* fair_meter_lookup_by_name(const struct shash *meter_groups, const char *meter_name) diff --git a/northd/en-meters.h b/northd/en-meters.h index e0ef07fad..e1deb5daf 100644 --- a/northd/en-meters.h +++ b/northd/en-meters.h @@ -29,6 +29,8 @@ struct sync_meters_data { void *en_sync_meters_init(struct engine_node *, struct engine_arg *); void en_sync_meters_cleanup(void *data); enum engine_node_state en_sync_meters_run(struct engine_node *, void *data); +enum engine_input_handler_result +sync_meters_nb_acl_handler(struct engine_node *, void *data); const struct nbrec_meter *fair_meter_lookup_by_name( const struct shash *meter_groups, diff --git a/northd/inc-proc-northd.c b/northd/inc-proc-northd.c index b1e4994a4..5905462ec 100644 --- a/northd/inc-proc-northd.c +++ b/northd/inc-proc-northd.c @@ -319,7 +319,7 @@ void inc_proc_northd_init(struct ovsdb_idl_loop *nb, engine_add_input(&en_group_ecmp_route, &en_learned_route_sync, group_ecmp_route_learned_route_change_handler); - engine_add_input(&en_sync_meters, &en_nb_acl, NULL); + engine_add_input(&en_sync_meters, &en_nb_acl, sync_meters_nb_acl_handler); engine_add_input(&en_sync_meters, &en_nb_meter, NULL); engine_add_input(&en_sync_meters, &en_sb_meter, NULL); diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at index 69b75fe9d..39f27772b 100644 --- a/tests/ovn-northd.at +++ b/tests/ovn-northd.at @@ -11352,14 +11352,14 @@ check as northd ovn-appctl -t ovn-northd inc-engine/clear-stats check ovn-nbctl --wait=sb meter-add m drop 1 pktps check ovn-nbctl --wait=sb acl-add ls from-lport 1 1 allow dnl Only triggers recompute of the sync_meters and lflow nodes. -check_recompute_counter 0 2 2 +check_recompute_counter 0 2 1 CHECK_NO_CHANGE_AFTER_RECOMPUTE(1) check as northd ovn-appctl -t ovn-northd inc-engine/clear-stats check ovn-nbctl --wait=sb meter-del m check ovn-nbctl --wait=sb acl-del ls dnl Only triggers recompute of the sync_meters and lflow nodes. -check_recompute_counter 0 2 2 +check_recompute_counter 0 2 1 CHECK_NO_CHANGE_AFTER_RECOMPUTE(1) AT_CLEANUP @@ -17290,3 +17290,79 @@ AT_CHECK([cat trace | grep output], [0], [dnl AT_CLEANUP ]) + +OVN_FOR_EACH_NORTHD_NO_HV([ +AT_SETUP([ACL incremental processing]) +ovn_start + +check ovn-nbctl ls-add ls +check ovn-nbctl meter-add meter1 drop 10 kbps +check ovn-nbctl meter-add meter2 drop 20 kbps + +# Wait for sb to be connected before clearing stats. +check ovn-nbctl --wait=sb sync +check as northd ovn-appctl -t ovn-northd inc-engine/clear-stats + +AS_BOX([ACL with log]) +check ovn-nbctl --wait=sb --log acl-add ls from-lport 100 tcp drop +acl_id=$(fetch_column nb:Acl _uuid action=drop) +check_engine_stats northd norecompute compute +check_engine_stats lflow recompute nocompute +check_engine_stats sync_meters recompute nocompute +CHECK_NO_CHANGE_AFTER_RECOMPUTE +check as northd ovn-appctl -t ovn-northd inc-engine/clear-stats + +check ovn-nbctl --wait=sb set acl $acl_id match=udp +check_engine_stats northd norecompute compute +check_engine_stats lflow recompute nocompute +check_engine_stats sync_meters norecompute compute +CHECK_NO_CHANGE_AFTER_RECOMPUTE +check as northd ovn-appctl -t ovn-northd inc-engine/clear-stats + +check ovn-nbctl --wait=sb set acl $acl_id log=false +check_engine_stats northd norecompute compute +check_engine_stats lflow recompute nocompute +check_engine_stats sync_meters recompute nocompute +CHECK_NO_CHANGE_AFTER_RECOMPUTE +check ovn-nbctl --wait=sb set acl $acl_id log=true +check as northd ovn-appctl -t ovn-northd inc-engine/clear-stats + +check ovn-nbctl --wait=sb acl-del ls +check_engine_stats northd norecompute compute +check_engine_stats lflow recompute nocompute +check_engine_stats sync_meters recompute nocompute +CHECK_NO_CHANGE_AFTER_RECOMPUTE +check as northd ovn-appctl -t ovn-northd inc-engine/clear-stats + +AS_BOX([ACL with meter]) +check ovn-nbctl --wait=sb --meter=meter1 acl-add ls from-lport 100 tcp drop +acl_id=$(fetch_column nb:Acl _uuid action=drop) +check_engine_stats northd norecompute compute +check_engine_stats lflow recompute nocompute +check_engine_stats sync_meters recompute nocompute +CHECK_NO_CHANGE_AFTER_RECOMPUTE +check as northd ovn-appctl -t ovn-northd inc-engine/clear-stats + +check ovn-nbctl --wait=sb set acl $acl_id match=udp +check_engine_stats northd norecompute compute +check_engine_stats lflow recompute nocompute +check_engine_stats sync_meters norecompute compute +CHECK_NO_CHANGE_AFTER_RECOMPUTE +check as northd ovn-appctl -t ovn-northd inc-engine/clear-stats + +check ovn-nbctl --wait=sb set acl $acl_id meter=meter2 +check_engine_stats northd norecompute compute +check_engine_stats lflow recompute nocompute +check_engine_stats sync_meters recompute nocompute +CHECK_NO_CHANGE_AFTER_RECOMPUTE +check as northd ovn-appctl -t ovn-northd inc-engine/clear-stats + +check ovn-nbctl --wait=sb acl-del ls +check_engine_stats northd norecompute compute +check_engine_stats lflow recompute nocompute +check_engine_stats sync_meters recompute nocompute +CHECK_NO_CHANGE_AFTER_RECOMPUTE +check as northd ovn-appctl -t ovn-northd inc-engine/clear-stats + +AT_CLEANUP +])