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 <[email protected]> --- 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(-) diff --git a/lib/ovn-util.c b/lib/ovn-util.c index cec029e42..71098d478 100644 --- a/lib/ovn-util.c +++ b/lib/ovn-util.c @@ -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) diff --git a/lib/ovn-util.h b/lib/ovn-util.h index 1c9b62ebb..393aaeae7 100644 --- a/lib/ovn-util.h +++ b/lib/ovn-util.h @@ -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 diff --git a/northd/inc-proc-northd.h b/northd/inc-proc-northd.h index 0f763d8df..ab2ea3ff4 100644 --- a/northd/inc-proc-northd.h +++ b/northd/inc-proc-northd.h @@ -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; diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index 8f1e8b182..7d7568c6f 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -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 -- 2.34.1 -- _'Esta mensagem é direcionada apenas para os endereços constantes no cabeçalho inicial. Se você não está listado nos endereços constantes no cabeçalho, pedimos-lhe que desconsidere completamente o conteúdo dessa mensagem e cuja cópia, encaminhamento e/ou execução das ações citadas estão imediatamente anuladas e proibidas'._ * **'Apesar do Magazine Luiza tomar todas as precauções razoáveis para assegurar que nenhum vírus esteja presente nesse e-mail, a empresa não poderá aceitar a responsabilidade por quaisquer perdas ou danos causados por esse e-mail ou por seus anexos'.* _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
