[ovs-dev] [PATCH ovn 05/21] ovn-northd-ddlog: Upgrade to ddlog 0.38.

Ben Pfaff blp at ovn.org
Sat Mar 27 00:31:31 UTC 2021


From: Leonid Ryzhyk <lryzhyk at vmware.com>

Upcoming commits will use a new --intern-table option of ovsdb2ddlog,
so we need to upgrade to the version of ddlog that has that feature.

To do so, we need to adapt the code to language changes in ddlog.  This
commit does that for a change in 0.37 in which, when iterating over a
`Group` in a for-loop, the iterator returns `(value, weight)` tuples.

This also adapts ovn-northd-ddlog.c to a slightly updated C API.

Signed-off-by: Leonid Ryzhyk <lryzhyk at vmware.com>
Signed-off-by: Ben Pfaff <blp at ovn.org>
---
 NEWS                      |  2 +-
 northd/lrouter.dl         |  2 +-
 northd/ovn-northd-ddlog.c | 21 +++++++++++----------
 3 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/NEWS b/NEWS
index 5048433148b8..66976c03dc80 100644
--- a/NEWS
+++ b/NEWS
@@ -5,7 +5,7 @@ Post-v21.03.0
     needed for the southbound database when northbound changes occur.  It is
     expected to scale better than the C implementation, for large deployments.
     (This may take testing and tuning to be effective.)  This version of OVN
-    requires DDLog 0.36.
+    requires DDLog 0.38.
   - Introduce ovn-controller incremetal processing engine statistics
   - ovn-sbctl can now run as a daemon (long-lived, background process).
     See ovn-sbctl(8) for details.
diff --git a/northd/lrouter.dl b/northd/lrouter.dl
index 36cedd2dc219..e3afff72f41d 100644
--- a/northd/lrouter.dl
+++ b/northd/lrouter.dl
@@ -382,7 +382,7 @@ LogicalRouterSnatIP(lr, snat_ip, Some{nat}) :-
 
 function group_to_setunionmap(g: Group<'K1, ('K2,Set<'V>)>): Map<'K2,Set<'V>> {
     var map = map_empty();
-    for (entry in g) {
+    for ((entry, _) in g) {
         (var key, var value) = entry;
         match (map.get(key)) {
             None -> map.insert(key, value),
diff --git a/northd/ovn-northd-ddlog.c b/northd/ovn-northd-ddlog.c
index b7d2c8a5ef8d..0352e40117c8 100644
--- a/northd/ovn-northd-ddlog.c
+++ b/northd/ovn-northd-ddlog.c
@@ -79,10 +79,11 @@ static table_id WARNING_TABLE_ID;
 static table_id NB_CFG_TIMESTAMP_ID;
 
 /* Initialize frequently used table ids. */
-static void init_table_ids(void)
+static void
+init_table_ids(ddlog_prog ddlog)
 {
-    WARNING_TABLE_ID = ddlog_get_table_id("helpers::Warning");
-    NB_CFG_TIMESTAMP_ID = ddlog_get_table_id("NbCfgTimestamp");
+    WARNING_TABLE_ID = ddlog_get_table_id(ddlog, "helpers::Warning");
+    NB_CFG_TIMESTAMP_ID = ddlog_get_table_id(ddlog, "NbCfgTimestamp");
 }
 
 struct northd_ctx {
@@ -346,7 +347,8 @@ ddlog_clear(struct northd_ctx *ctx)
     int n_failures = 0;
     for (int i = 0; ctx->input_relations[i]; i++) {
         char *table = xasprintf("%s%s", ctx->prefix, ctx->input_relations[i]);
-        if (ddlog_clear_relation(ctx->ddlog, ddlog_get_table_id(table))) {
+        if (ddlog_clear_relation(ctx->ddlog, ddlog_get_table_id(ctx->ddlog,
+                                                                table))) {
             n_failures++;
         }
         free(table);
@@ -610,7 +612,7 @@ northd_update_probe_interval(struct northd_ctx *nb, struct northd_ctx *sb)
      * Any other value is an explicit probe interval request from the
      * database. */
     int probe_interval = 0;
-    table_id tid = ddlog_get_table_id("Northd_Probe_Interval");
+    table_id tid = ddlog_get_table_id(nb->ddlog, "Northd_Probe_Interval");
     ddlog_delta *probe_delta = ddlog_delta_remove_table(nb->delta, tid);
     ddlog_delta_enumerate(probe_delta, northd_update_probe_interval_cb, (uintptr_t) &probe_interval);
     ddlog_free_delta(probe_delta);
@@ -669,7 +671,7 @@ ddlog_table_update_output(struct ds *ds, ddlog_prog ddlog, ddlog_delta *delta,
         return;
     }
     char *table_name = xasprintf("%s::Out_%s", db, table);
-    ddlog_delta_clear_table(delta, ddlog_get_table_id(table_name));
+    ddlog_delta_clear_table(delta, ddlog_get_table_id(ddlog, table_name));
     free(table_name);
 
     if (!updates[0]) {
@@ -947,7 +949,7 @@ get_database_ops(struct northd_ctx *ctx)
              * We require output-only tables to have an accompanying index
              * named <table>_Index. */
             char *index = xasprintf("%s_Index", table);
-            index_id idxid = ddlog_get_index_id(index);
+            index_id idxid = ddlog_get_index_id(ctx->ddlog, index);
             if (idxid == -1) {
                 VLOG_WARN_RL(&rl, "%s: unknown index", index);
                 free(index);
@@ -999,7 +1001,7 @@ get_database_ops(struct northd_ctx *ctx)
     static int64_t old_sb_cfg_timestamp = INT64_MIN;
     int64_t new_sb_cfg = old_sb_cfg;
     if (ctx->has_timestamp_columns) {
-        table_id sb_cfg_tid = ddlog_get_table_id("SbCfg");
+        table_id sb_cfg_tid = ddlog_get_table_id(ctx->ddlog, "SbCfg");
         ddlog_delta *sb_cfg_delta = ddlog_delta_remove_table(ctx->delta,
                                                              sb_cfg_tid);
         ddlog_delta_enumerate(sb_cfg_delta, northd_update_sb_cfg_cb,
@@ -1148,8 +1150,6 @@ main(int argc, char *argv[])
     int retval;
     bool exiting;
 
-    init_table_ids();
-
     fatal_ignore_sigpipe();
     ovs_cmdl_proctitle_init(argc, argv);
     set_program_name(argv[0]);
@@ -1179,6 +1179,7 @@ main(int argc, char *argv[])
     if (!ddlog) {
         ovs_fatal(0, "DDlog instance could not be created");
     }
+    init_table_ids(ddlog);
 
     unixctl_command_register("enable-cpu-profiling", "", 0, 0,
                              ovn_northd_enable_cpu_profiling, ddlog);
-- 
2.29.2



More information about the dev mailing list