Skip to content

Commit

Permalink
ovn-nbctl: Prevent sync exiting early on nb_cfg overflow
Browse files Browse the repository at this point in the history
We are correctly wrapping nb_cfg over when the value is LLONG_MAX.
However, the sync code is expecting the value to be always raising,
so it would exit early as the current >= next is true for the
wrap back to 0. To detect that use delta between those two values.
The delta threshold is set to INT32_MAX as we don't expect the nb_cfg
to be updated more than that during the sync call.

Signed-off-by: Ales Musil <[email protected]>
Acked-by: Mark Michelson <[email protected]>
Signed-off-by: Mark Michelson <[email protected]>
  • Loading branch information
almusil authored and putnopvut committed Aug 24, 2023
1 parent 2f2324d commit 7915565
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion northd/ovn-northd.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,9 @@ update_sequence_numbers(int64_t loop_start_time,
chassis_priv->name);
}

if (chassis_priv->nb_cfg < hv_cfg) {
/* Detect if overflows happened within the cfg update. */
int64_t delta = chassis_priv->nb_cfg - hv_cfg;
if (chassis_priv->nb_cfg < hv_cfg || delta > INT32_MAX) {
hv_cfg = chassis_priv->nb_cfg;
hv_cfg_ts = chassis_priv->nb_cfg_timestamp;
} else if (chassis_priv->nb_cfg == hv_cfg &&
Expand Down
4 changes: 3 additions & 1 deletion utilities/ovn-nbctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ nbctl_post_execute(struct ovsdb_idl *idl, struct ovsdb_idl_txn *txn,
int64_t cur_cfg = (wait_type == NBCTL_WAIT_SB
? nb->sb_cfg
: MIN(nb->sb_cfg, nb->hv_cfg));
if (cur_cfg >= next_cfg) {
/* Detect if overflows happened within the cfg update. */
int64_t delta = cur_cfg - next_cfg;
if (cur_cfg >= next_cfg && delta < INT32_MAX) {
if (print_wait_time) {
printf("Time spent on processing nb_cfg %"PRId64":\n",
next_cfg);
Expand Down

0 comments on commit 7915565

Please sign in to comment.