Re: [ovs-dev] [PATCH ovn v4 05/16] northd: Add a new engine 'lr_stateful' to manage lr's stateful data.

2024-01-04 Thread 0-day Robot
Bleep bloop.  Greetings Numan Siddique, I am a robot and I have tried out your 
patch.
Thanks for your contribution.

I encountered some error that I wasn't expecting.  See the details below.


checkpatch:
ERROR: Inappropriate bracing around statement
#100 FILE: northd/en-lr-nat.h:90:
HMAP_FOR_EACH (LR_NAT_REC, key_node, &(TABLE)->entries)

ERROR: Inappropriate bracing around statement
#824 FILE: northd/en-lr-stateful.h:67:
HMAP_FOR_EACH (LR_LB_NAT_REC, key_node, &(TABLE)->entries)

Lines checked: 2982, Warnings: 0, Errors: 2


Please check this out.  If you feel there has been an error, please email 
acon...@redhat.com

Thanks,
0-day Robot
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH ovn v4 05/16] northd: Add a new engine 'lr_stateful' to manage lr's stateful data.

2024-01-04 Thread numans
From: Numan Siddique 

This new engine now maintains the load balancer and NAT data of a
logical router which was earlier part of northd engine node data.
The main inputs to this engine are:
   - northd node
   - lr_nat node
   - lb_data node

A record for each logical router is maintained in the 'lr_stateful_table'
hmap table and this record
   - stores the lb related data
   - embeds the 'lr_nat' record.

This engine node becomes an input to 'lflow' node.

Signed-off-by: Numan Siddique 
---
 lib/stopwatch-names.h|   1 +
 northd/automake.mk   |   2 +
 northd/en-lflow.c|   4 +
 northd/en-lr-nat.h   |   3 +
 northd/en-lr-stateful.c  | 641 +++
 northd/en-lr-stateful.h  | 105 ++
 northd/en-sync-sb.c  |  49 +--
 northd/inc-proc-northd.c |  13 +-
 northd/northd.c  | 708 ---
 northd/northd.h  | 136 +++-
 northd/ovn-northd.c  |   1 +
 tests/ovn-northd.at  |  62 
 12 files changed, 1210 insertions(+), 515 deletions(-)
 create mode 100644 northd/en-lr-stateful.c
 create mode 100644 northd/en-lr-stateful.h

diff --git a/lib/stopwatch-names.h b/lib/stopwatch-names.h
index 782d64320a..e5e41fbfd8 100644
--- a/lib/stopwatch-names.h
+++ b/lib/stopwatch-names.h
@@ -30,5 +30,6 @@
 #define PORT_GROUP_RUN_STOPWATCH_NAME "port_group_run"
 #define SYNC_METERS_RUN_STOPWATCH_NAME "sync_meters_run"
 #define LR_NAT_RUN_STOPWATCH_NAME "lr_nat_run"
+#define LR_STATEFUL_RUN_STOPWATCH_NAME "lr_stateful"
 
 #endif
diff --git a/northd/automake.mk b/northd/automake.mk
index a477105470..b886356c9c 100644
--- a/northd/automake.mk
+++ b/northd/automake.mk
@@ -26,6 +26,8 @@ northd_ovn_northd_SOURCES = \
northd/en-lb-data.h \
northd/en-lr-nat.c \
northd/en-lr-nat.h \
+   northd/en-lr-stateful.c \
+   northd/en-lr-stateful.h \
northd/inc-proc-northd.c \
northd/inc-proc-northd.h \
northd/ipam.c \
diff --git a/northd/en-lflow.c b/northd/en-lflow.c
index e4f875ef7c..bb9f78a6a1 100644
--- a/northd/en-lflow.c
+++ b/northd/en-lflow.c
@@ -20,6 +20,7 @@
 
 #include "en-lflow.h"
 #include "en-lr-nat.h"
+#include "en-lr-stateful.h"
 #include "en-northd.h"
 #include "en-meters.h"
 
@@ -43,6 +44,8 @@ lflow_get_input_data(struct engine_node *node,
 engine_get_input_data("sync_meters", node);
 struct ed_type_lr_nat_data *lr_nat_data =
 engine_get_input_data("lr_nat", node);
+struct ed_type_lr_stateful *lr_stateful_data =
+engine_get_input_data("lr_stateful", node);
 
 lflow_input->nbrec_bfd_table =
 EN_OVSDB_GET(engine_get_input("NB_bfd", node));
@@ -66,6 +69,7 @@ lflow_get_input_data(struct engine_node *node,
 lflow_input->lr_ports = _data->lr_ports;
 lflow_input->ls_port_groups = _data->ls_port_groups;
 lflow_input->lr_nats = _nat_data->lr_nats;
+lflow_input->lr_stateful_table = _stateful_data->table;
 lflow_input->meter_groups = _meters_data->meter_groups;
 lflow_input->lb_datapaths_map = _data->lb_datapaths_map;
 lflow_input->svc_monitor_map = _data->svc_monitor_map;
diff --git a/northd/en-lr-nat.h b/northd/en-lr-nat.h
index 3ec4c7b506..4d8e142ae6 100644
--- a/northd/en-lr-nat.h
+++ b/northd/en-lr-nat.h
@@ -86,6 +86,9 @@ struct lr_nat_table {
 const struct lr_nat_record * lr_nat_table_find_by_index(
 const struct lr_nat_table *, size_t od_index);
 
+#define LR_NAT_TABLE_FOR_EACH(LR_NAT_REC, TABLE) \
+HMAP_FOR_EACH (LR_NAT_REC, key_node, &(TABLE)->entries)
+
 struct ed_type_lr_nat_data {
 struct lr_nat_table lr_nats;
 
diff --git a/northd/en-lr-stateful.c b/northd/en-lr-stateful.c
new file mode 100644
index 00..dedfdf6747
--- /dev/null
+++ b/northd/en-lr-stateful.c
@@ -0,0 +1,641 @@
+/*
+ * Copyright (c) 2023, Red Hat, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+
+/* OVS includes */
+#include "include/openvswitch/hmap.h"
+#include "lib/bitmap.h"
+#include "lib/socket-util.h"
+#include "lib/uuidset.h"
+#include "openvswitch/util.h"
+#include "openvswitch/vlog.h"
+#include "stopwatch.h"
+
+/* OVN includes */
+#include "en-lb-data.h"
+#include "en-lr-nat.h"
+#include "en-lr-stateful.h"
+#include "lib/inc-proc-eng.h"
+#include "lib/lb.h"
+#include "lib/ovn-nb-idl.h"
+#include "lib/ovn-sb-idl.h"
+#include "lib/ovn-util.h"
+#include "lib/stopwatch-names.h"
+#include "northd.h"
+