]> git.puffer.fish Git - matthieu/frr.git/commit
mgmtd, vtysh: fix possible conflict when reading the config
authorIgor Ryzhov <iryzhov@nfware.com>
Fri, 2 Feb 2024 22:42:58 +0000 (00:42 +0200)
committerIgor Ryzhov <iryzhov@nfware.com>
Wed, 7 Feb 2024 16:37:29 +0000 (18:37 +0200)
commit0db4d555e98f90da320a802be67b75757eb78abc
treeaab58927a2e3f0470694763d37a51c55f6a249bb
parent3d57f0439533f415b0ab1c95e5fed15e099a32c3
mgmtd, vtysh: fix possible conflict when reading the config

When FRR starts, after mgmtd is initialized, backend clients connect to
it and request their config. To supply the config, mgmtd creates a
configuration transaction. At the same time, `vtysh -b` tries to read
the startup config and configure mgmtd, which also creates a
configuration transaction. If these two actions happen at the exact same
time, there's a conflict between them, because only a single
configuration translaction is allowed. Because of that, vtysh fails and
the config is completely ignored.

When starting the config reading, vtysh locks candidate and running
datastores in mgmtd. This commit adds locking of running datastore when
initializing the backend client. It allows to retry locking on the vtysh
side and read the config only when the lock is aquired instead of
failing.

This change also prevents running datastore from being changed during
initialization of backend clients. This could lead to a desynchronized
state between mgmtd and backends.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
mgmtd/mgmt_fe_adapter.c
mgmtd/mgmt_txn.c
vtysh/vtysh_config.c