@@ -73,6 +73,39 @@ void set_idl_probe_interval(struct ovsdb_idl *idl, const char *remote,
ovsdb_idl_set_probe_interval(idl, interval);
}
+struct ovsdb_idl_txn *
+run_idl_loop(struct ovsdb_idl_loop *idl_loop, const char *name,
+ uint64_t *idl_duration)
+{
+ unsigned long long duration, start = time_msec();
+ unsigned int seqno = UINT_MAX;
+ struct ovsdb_idl_txn *txn;
+ int n = 0;
+
+ /* Accumulate database changes as long as there are some,
+ * but no longer than "IDL_LOOP_MAX_DURATION_MS". */
+ while (seqno != ovsdb_idl_get_seqno(idl_loop->idl)
+ && time_msec() - start < IDL_LOOP_MAX_DURATION_MS) {
+ seqno = ovsdb_idl_get_seqno(idl_loop->idl);
+ ovsdb_idl_run(idl_loop->idl);
+ n++;
+ }
+
+ txn = ovsdb_idl_loop_run(idl_loop);
+
+ duration = time_msec() - start;
+ *idl_duration = duration;
+ /* ovsdb_idl_run() is called at least 2 times. Once directly and
+ * once in the ovsdb_idl_loop_run(). n > 2 means that we received
+ * data on at least 2 subsequent calls. */
+ if (n > 2 || duration > 100) {
+ VLOG(duration > IDL_LOOP_MAX_DURATION_MS ? VLL_INFO : VLL_DBG,
+ "%s IDL run: %d iterations in %lld ms", name, n + 1, duration);
+ }
+
+ return txn;
+}
+
static void
add_ipv4_netaddr(struct lport_addresses *laddrs, ovs_be32 addr,
unsigned int plen)
@@ -40,6 +40,8 @@
#define GENEVE_TUNNEL_OVERHEAD 38
#define VXLAN_TUNNEL_OVERHEAD 30
+#define IDL_LOOP_MAX_DURATION_MS 500
+
struct eth_addr;
struct nbrec_logical_router;
struct nbrec_logical_router_port;
@@ -160,6 +162,10 @@ void ovn_conn_show(struct unixctl_conn *conn, int argc OVS_UNUSED,
void set_idl_probe_interval(struct ovsdb_idl *idl, const char *remote,
int interval);
+struct ovsdb_idl_txn *run_idl_loop(struct ovsdb_idl_loop *idl_loop,
+ const char *name,
+ uint64_t *idl_duration);
+
#define OVN_MAX_DP_KEY ((1u << 24) - 1)
#define OVN_MAX_DP_GLOBAL_NUM ((1u << 16) - 1)
#define OVN_MIN_DP_KEY_LOCAL 1
@@ -6,8 +6,6 @@
#include "northd.h"
#include "ovsdb-idl.h"
-#define IDL_LOOP_MAX_DURATION_MS 500
-
struct northd_engine_context {
int64_t next_run_ms;
uint64_t nb_idl_duration_ms;
@@ -780,39 +780,6 @@ update_ssl_config(void)
}
}
-static struct ovsdb_idl_txn *
-run_idl_loop(struct ovsdb_idl_loop *idl_loop, const char *name,
- uint64_t *idl_duration)
-{
- unsigned long long duration, start = time_msec();
- unsigned int seqno = UINT_MAX;
- struct ovsdb_idl_txn *txn;
- int n = 0;
-
- /* Accumulate database changes as long as there are some,
- * but no longer than "IDL_LOOP_MAX_DURATION_MS". */
- while (seqno != ovsdb_idl_get_seqno(idl_loop->idl)
- && time_msec() - start < IDL_LOOP_MAX_DURATION_MS) {
- seqno = ovsdb_idl_get_seqno(idl_loop->idl);
- ovsdb_idl_run(idl_loop->idl);
- n++;
- }
-
- txn = ovsdb_idl_loop_run(idl_loop);
-
- duration = time_msec() - start;
- *idl_duration = duration;
- /* ovsdb_idl_run() is called at least 2 times. Once directly and
- * once in the ovsdb_idl_loop_run(). n > 2 means that we received
- * data on at least 2 subsequent calls. */
- if (n > 2 || duration > 100) {
- VLOG(duration > IDL_LOOP_MAX_DURATION_MS ? VLL_INFO : VLL_DBG,
- "%s IDL run: %d iterations in %lld ms", name, n + 1, duration);
- }
-
- return txn;
-}
-
#define DEFAULT_NORTHD_TRIM_TO_MS 30000
static void
The run_idl_loop function is shared by ovn-northd and ovn-ic, therefore to avoid code duplication, the function is being repositioned in lib/ovn-util.c present in the ovn code base. Signed-off-by: Paulo Guilherme Silva <guilherme.paulo@luizalabs.com> --- lib/ovn-util.c | 33 +++++++++++++++++++++++++++++++++ lib/ovn-util.h | 6 ++++++ northd/inc-proc-northd.h | 2 -- northd/ovn-northd.c | 33 --------------------------------- 4 files changed, 39 insertions(+), 35 deletions(-)