diff mbox series

[ovs-dev,v3,6/7] northd: Add lflow node

Message ID 20211018121403.842185-7-mark.d.gray@redhat.com
State Superseded
Headers show
Series northd: Introduce incremental processing framework | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_ovn-kubernetes success github build: passed
ovsrobot/github-robot-_Build_and_Test fail github build: failed

Commit Message

Mark Gray Oct. 18, 2021, 12:14 p.m. UTC
Add an additional node that initially does nothing. This serves as a
template for how to add a new node. This node is inserted after
the northd_node.

This node will be updated in a later commit to generate logical
flows for the SBDB.

Signed-off-by: Mark Gray <mark.d.gray@redhat.com>
---
 northd/automake.mk       |  2 ++
 northd/en-lflow.c        | 42 ++++++++++++++++++++++++++++++++++++++++
 northd/en-lflow.h        | 16 +++++++++++++++
 northd/inc-proc-northd.c |  5 ++++-
 northd/northd.c          |  2 --
 5 files changed, 64 insertions(+), 3 deletions(-)
 create mode 100644 northd/en-lflow.c
 create mode 100644 northd/en-lflow.h

Comments

Han Zhou Oct. 25, 2021, 3:33 a.m. UTC | #1
On Mon, Oct 18, 2021 at 5:14 AM Mark Gray <mark.d.gray@redhat.com> wrote:
>
> Add an additional node that initially does nothing. This serves as a
> template for how to add a new node. This node is inserted after
> the northd_node.
>
> This node will be updated in a later commit to generate logical
> flows for the SBDB.
>
Thanks Mark. This looks clean, but I'd expect the engine data definition
included in this patch (or the next). For this node, the data should be the
lflow table, which should be persistent across runs (and of course,
destroyed and rebuilt in en_lflow_run() if there are input changes).

> Signed-off-by: Mark Gray <mark.d.gray@redhat.com>
> ---
>  northd/automake.mk       |  2 ++
>  northd/en-lflow.c        | 42 ++++++++++++++++++++++++++++++++++++++++
>  northd/en-lflow.h        | 16 +++++++++++++++
>  northd/inc-proc-northd.c |  5 ++++-
>  northd/northd.c          |  2 --
>  5 files changed, 64 insertions(+), 3 deletions(-)
>  create mode 100644 northd/en-lflow.c
>  create mode 100644 northd/en-lflow.h
>
> diff --git a/northd/automake.mk b/northd/automake.mk
> index f0c1fb11c83a..4862ec7b7ff3 100644
> --- a/northd/automake.mk
> +++ b/northd/automake.mk
> @@ -6,6 +6,8 @@ northd_ovn_northd_SOURCES = \
>         northd/ovn-northd.c \
>         northd/en-northd.c \
>         northd/en-northd.h \
> +       northd/en-lflow.c \
> +       northd/en-lflow.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
> new file mode 100644
> index 000000000000..46072cb0162e
> --- /dev/null
> +++ b/northd/en-lflow.c
> @@ -0,0 +1,42 @@
> +/*
> + * 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 <config.h>
> +
> +#include <getopt.h>
> +#include <stdlib.h>
> +#include <stdio.h>
> +
> +#include "en-lflow.h"
> +#include "en-northd.h"
> +
> +#include "lib/inc-proc-eng.h"
> +#include "northd.h"
> +#include "openvswitch/vlog.h"
> +
> +VLOG_DEFINE_THIS_MODULE(en_lflow);
> +
> +void en_lflow_run(struct engine_node *node, void *data OVS_UNUSED)
> +{
> +    engine_set_node_state(node, EN_UPDATED);
> +}
> +void *en_lflow_init(struct engine_node *node OVS_UNUSED,
> +                     struct engine_arg *arg OVS_UNUSED)
> +{
> +    return NULL;
> +}
> +
> +void en_lflow_cleanup(void *data OVS_UNUSED)
> +{
> +}
> diff --git a/northd/en-lflow.h b/northd/en-lflow.h
> new file mode 100644
> index 000000000000..0e4d522ff3fe
> --- /dev/null
> +++ b/northd/en-lflow.h
> @@ -0,0 +1,16 @@
> +#ifndef EN_LFLOW_H
> +#define EN_LFLOW_H 1
> +
> +#include <config.h>
> +
> +#include <getopt.h>
> +#include <stdlib.h>
> +#include <stdio.h>
> +
> +#include "lib/inc-proc-eng.h"
> +
> +void en_lflow_run(struct engine_node *node, void *data);
> +void *en_lflow_init(struct engine_node *node, struct engine_arg *arg);
> +void en_lflow_cleanup(void *data);
> +
> +#endif /* EN_LFLOW_H */
> diff --git a/northd/inc-proc-northd.c b/northd/inc-proc-northd.c
> index 572b8de6536a..519fc1d0cb46 100644
> --- a/northd/inc-proc-northd.c
> +++ b/northd/inc-proc-northd.c
> @@ -25,6 +25,7 @@
>  #include "openvswitch/vlog.h"
>  #include "inc-proc-northd.h"
>  #include "en-northd.h"
> +#include "en-lflow.h"
>  #include "util.h"
>
>  VLOG_DEFINE_THIS_MODULE(inc_proc_northd);
> @@ -140,6 +141,7 @@ enum sb_engine_node {
>  /* Define engine nodes for other nodes. They should be defined as static
to
>   * avoid sparse errors. */
>  static ENGINE_NODE(northd, "northd");
> +static ENGINE_NODE(lflow, "lflow");
>
>  void inc_proc_northd_init(struct ovsdb_idl_loop *nb,
>                            struct ovsdb_idl_loop *sb)
> @@ -204,13 +206,14 @@ void inc_proc_northd_init(struct ovsdb_idl_loop *nb,
>      engine_add_input(&en_northd, &en_sb_load_balancer, NULL);
>      engine_add_input(&en_northd, &en_sb_bfd, NULL);
>      engine_add_input(&en_northd, &en_sb_fdb, NULL);
> +    engine_add_input(&en_lflow, &en_northd, NULL);
>
>      struct engine_arg engine_arg = {
>          .nb_idl = nb->idl,
>          .sb_idl = sb->idl,
>      };
>
> -    engine_init(&en_northd, &engine_arg);
> +    engine_init(&en_lflow, &engine_arg);
>  }
>
>  void inc_proc_northd_run(struct northd_idl_context *ctx,
> diff --git a/northd/northd.c b/northd/northd.c
> index 6426fcbe1215..e1097e6b301a 100644
> --- a/northd/northd.c
> +++ b/northd/northd.c
> @@ -12974,7 +12974,6 @@ struct lflows_thread_pool {
>      struct worker_pool *pool;
>  };
>
> -
>  static void *
>  build_lflows_thread(void *arg)
>  {
> @@ -14556,7 +14555,6 @@ ovnnb_db_run(struct northd_data *data,
>      cleanup_stale_fdp_entries(ctx, &data->datapaths);
>      bfd_cleanup_connections(ctx, &data->bfd_connections);
>      stopwatch_stop(CLEAR_LFLOWS_CTX_STOPWATCH_NAME, time_msec());
> -
>  }
>
>  /* Stores the list of chassis which references an ha_chassis_group.
> --
> 2.27.0
>
diff mbox series

Patch

diff --git a/northd/automake.mk b/northd/automake.mk
index f0c1fb11c83a..4862ec7b7ff3 100644
--- a/northd/automake.mk
+++ b/northd/automake.mk
@@ -6,6 +6,8 @@  northd_ovn_northd_SOURCES = \
 	northd/ovn-northd.c \
 	northd/en-northd.c \
 	northd/en-northd.h \
+	northd/en-lflow.c \
+	northd/en-lflow.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
new file mode 100644
index 000000000000..46072cb0162e
--- /dev/null
+++ b/northd/en-lflow.c
@@ -0,0 +1,42 @@ 
+/*
+ * 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 <config.h>
+
+#include <getopt.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "en-lflow.h"
+#include "en-northd.h"
+
+#include "lib/inc-proc-eng.h"
+#include "northd.h"
+#include "openvswitch/vlog.h"
+
+VLOG_DEFINE_THIS_MODULE(en_lflow);
+
+void en_lflow_run(struct engine_node *node, void *data OVS_UNUSED)
+{
+    engine_set_node_state(node, EN_UPDATED);
+}
+void *en_lflow_init(struct engine_node *node OVS_UNUSED,
+                     struct engine_arg *arg OVS_UNUSED)
+{
+    return NULL;
+}
+
+void en_lflow_cleanup(void *data OVS_UNUSED)
+{
+}
diff --git a/northd/en-lflow.h b/northd/en-lflow.h
new file mode 100644
index 000000000000..0e4d522ff3fe
--- /dev/null
+++ b/northd/en-lflow.h
@@ -0,0 +1,16 @@ 
+#ifndef EN_LFLOW_H
+#define EN_LFLOW_H 1
+
+#include <config.h>
+
+#include <getopt.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "lib/inc-proc-eng.h"
+
+void en_lflow_run(struct engine_node *node, void *data);
+void *en_lflow_init(struct engine_node *node, struct engine_arg *arg);
+void en_lflow_cleanup(void *data);
+
+#endif /* EN_LFLOW_H */
diff --git a/northd/inc-proc-northd.c b/northd/inc-proc-northd.c
index 572b8de6536a..519fc1d0cb46 100644
--- a/northd/inc-proc-northd.c
+++ b/northd/inc-proc-northd.c
@@ -25,6 +25,7 @@ 
 #include "openvswitch/vlog.h"
 #include "inc-proc-northd.h"
 #include "en-northd.h"
+#include "en-lflow.h"
 #include "util.h"
 
 VLOG_DEFINE_THIS_MODULE(inc_proc_northd);
@@ -140,6 +141,7 @@  enum sb_engine_node {
 /* Define engine nodes for other nodes. They should be defined as static to
  * avoid sparse errors. */
 static ENGINE_NODE(northd, "northd");
+static ENGINE_NODE(lflow, "lflow");
 
 void inc_proc_northd_init(struct ovsdb_idl_loop *nb,
                           struct ovsdb_idl_loop *sb)
@@ -204,13 +206,14 @@  void inc_proc_northd_init(struct ovsdb_idl_loop *nb,
     engine_add_input(&en_northd, &en_sb_load_balancer, NULL);
     engine_add_input(&en_northd, &en_sb_bfd, NULL);
     engine_add_input(&en_northd, &en_sb_fdb, NULL);
+    engine_add_input(&en_lflow, &en_northd, NULL);
 
     struct engine_arg engine_arg = {
         .nb_idl = nb->idl,
         .sb_idl = sb->idl,
     };
 
-    engine_init(&en_northd, &engine_arg);
+    engine_init(&en_lflow, &engine_arg);
 }
 
 void inc_proc_northd_run(struct northd_idl_context *ctx,
diff --git a/northd/northd.c b/northd/northd.c
index 6426fcbe1215..e1097e6b301a 100644
--- a/northd/northd.c
+++ b/northd/northd.c
@@ -12974,7 +12974,6 @@  struct lflows_thread_pool {
     struct worker_pool *pool;
 };
 
-
 static void *
 build_lflows_thread(void *arg)
 {
@@ -14556,7 +14555,6 @@  ovnnb_db_run(struct northd_data *data,
     cleanup_stale_fdp_entries(ctx, &data->datapaths);
     bfd_cleanup_connections(ctx, &data->bfd_connections);
     stopwatch_stop(CLEAR_LFLOWS_CTX_STOPWATCH_NAME, time_msec());
-
 }
 
 /* Stores the list of chassis which references an ha_chassis_group.