We create meters only if both log and meter is set for given
ACL. Do not recompute if the ACL is created with only one
of those. This should make it more efficient especially for
ovn-kubernetes which always creates ACLs with meters set, but
enables logging only when needed.

Fixes: b2ac717fcec2 ("northd: Avoid recompute of lflow from ACLs without 
meters.")
Reported-at: https://redhat.atlassian.net/browse/FDP-3976
Signed-off-by: Ales Musil <[email protected]>
---
v2: Rebase on top of latest main.
    Fix the ACL meter column errornous uuid assign.
---
 northd/en-meters.c  | 11 +++++++----
 tests/ovn-northd.at | 27 ++++++++++++++++++++++-----
 2 files changed, 29 insertions(+), 9 deletions(-)

diff --git a/northd/en-meters.c b/northd/en-meters.c
index ef0da25c9..18db9a1fc 100644
--- a/northd/en-meters.c
+++ b/northd/en-meters.c
@@ -81,10 +81,13 @@ sync_meters_nb_acl_handler(struct engine_node *node, void 
*data OVS_UNUSED)
 
     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;
+        /* New or deleted ACL with meter and log needs to be recomputed. */
+        if (nbrec_acl_is_new(nb_acl) || nbrec_acl_is_deleted(nb_acl)) {
+            if (nb_acl->log && nb_acl->meter) {
+                return EN_UNHANDLED;
+            }
+
+            continue;
         }
 
         /* Addition or removal of meter requires recompute. */
diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at
index 1e567704d..af231fb87 100644
--- a/tests/ovn-northd.at
+++ b/tests/ovn-northd.at
@@ -20557,8 +20557,8 @@ 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_engine_stats lflow norecompute compute
+check_engine_stats sync_meters norecompute compute
 CHECK_NO_CHANGE_AFTER_RECOMPUTE
 check as northd ovn-appctl -t ovn-northd inc-engine/clear-stats
 
@@ -20579,12 +20579,12 @@ 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_engine_stats lflow norecompute compute
+check_engine_stats sync_meters norecompute compute
 CHECK_NO_CHANGE_AFTER_RECOMPUTE
 check as northd ovn-appctl -t ovn-northd inc-engine/clear-stats
 
-AS_BOX([ACL with meter])
+AS_BOX([ACL with log and 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
@@ -20614,6 +20614,23 @@ 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_uuid ovn-nbctl --wait=sb --id=@id create ACL action=drop \
+    direction=from-lport match=tcp priority=1001 meter=meter1 \
+    -- set logical_switch ls acls=@id
+check_engine_stats northd norecompute compute
+check_engine_stats lflow norecompute compute
+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 acl-del ls
+check_engine_stats northd norecompute compute
+check_engine_stats lflow norecompute compute
+check_engine_stats sync_meters norecompute compute
+CHECK_NO_CHANGE_AFTER_RECOMPUTE
+check as northd ovn-appctl -t ovn-northd inc-engine/clear-stats
+
 AS_BOX([ACLs attached to LS])
 check ovn-nbctl --wait=sb acl-add ls from-lport 100 tcp drop
 acl_id=$(fetch_column nb:Acl _uuid match=tcp action=drop)
-- 
2.55.0

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to