Skip to content

Commit

Permalink
ovn-nbctl: Monitor nb_cfg to detect and handle potential overflows
Browse files Browse the repository at this point in the history
ovn-nbctl sync command will increase nb_cfg value each time it is executed
with a specific wait_type, this increment will be handled without testing
the current nb_cfg value because it is not monitored and that could lead
to an overflow issue if nb_cfg == LLONG_MAX.

To avoid such potential overflow cases we must monitor the real value
of nb_cfg each time sync is executed and if there is any overflow issue
it will be handled by function nbctl_pre_execute later on the execution.

Fixes: be3a60f ("ovn-nbctl: Deal with nb_cfg overflows.")
Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=1979774
Signed-off-by: Mohammad Heib <mheib@redhat.com>
Signed-off-by: Numan Siddique <numans@ovn.org>
  • Loading branch information
mohammadheib authored and numansiddique committed Aug 24, 2021
1 parent c008522 commit b1a0709
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions AUTHORS.rst
Expand Up @@ -273,6 +273,7 @@ Miguel Angel Ajo majopela@redhat.com
Mijo Safradin mijo@linux.vnet.ibm.com
Mika Vaisanen mika.vaisanen@gmail.com
Minoru TAKAHASHI takahashi.minoru7@gmail.com
Mohammad Heib mheib@redhat.com
Moshe Levi moshele@mellanox.com
Murphy McCauley murphy.mccauley@gmail.com
Natasha Gude
Expand Down
31 changes: 31 additions & 0 deletions tests/ovn-controller.at
Expand Up @@ -392,6 +392,37 @@ OVN_CLEANUP([hv])
AT_CLEANUP
])

# check that nb_cfg overflow cases handled properly
AT_SETUP([ovn-controller - overflow the nb_cfg value across the tables])
AT_KEYWORDS([ovn])
ovn_start

net_add n1
sim_add hv
as hv
ovs-vsctl add-br br-phys
ovn_attach n1 br-phys 192.168.0.1

check ovn-nbctl --wait=hv sync

# overflow the NB_Global nb_cfg value
check ovn-nbctl set NB_Global . nb_cfg=9223372036854775806

# nb_cfg must be set to zero if it exceed the value of LLONG_MAX
# the command below will try incress the value of nb_cfg to be greater than LLONG_MAX and
# expect zero as a return value
check ovn-nbctl --wait=hv sync
check ovn-nbctl --wait=hv sync

# nb_cfg should be set to 1 in the chassis_private/nb_global/sb_global table
check_column 1 chassis_private nb_cfg
check_column 1 sb_global nb_cfg
check_column 1 nb:nb_global nb_cfg
check_column 0 chassis nb_cfg

OVN_CLEANUP([hv])
AT_CLEANUP

# Test unix command: debug/delay-nb-cfg-report
OVN_FOR_EACH_NORTHD([
AT_SETUP([ovn-controller - debug/delay-nb-cfg-report])
Expand Down
2 changes: 2 additions & 0 deletions utilities/ovn-nbctl.c
Expand Up @@ -830,6 +830,8 @@ static void
nbctl_pre_sync(struct ctl_context *base OVS_UNUSED)
{
force_wait = true;
/* Monitor nb_cfg to detect and handle potential overflows. */
ovsdb_idl_add_column(base->idl, &nbrec_nb_global_col_nb_cfg);
}

static void
Expand Down

0 comments on commit b1a0709

Please sign in to comment.