Skip to content

Commit

Permalink
mgmtd: don't try to send config to disconnected clients
Browse files Browse the repository at this point in the history
When determining the interested backend clients for a configuration
change, don't consider disconnected clients. This fixes a crash in
`mgmt_txn_send_be_txn_create` when trying to send data to a non-existing
adapter.

Signed-off-by: Igor Ryzhov <[email protected]>
  • Loading branch information
idryzhov committed Jan 11, 2024
1 parent 86cbd58 commit 8276f4d
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions mgmtd/mgmt_txn.c
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,6 @@ static int mgmt_txn_create_config_batches(struct mgmt_txn_req *txn_req,
enum mgmt_be_client_id id;
struct mgmt_be_client_adapter *adapter;
struct mgmt_commit_cfg_req *cmtcfg_req;
bool found_validator;
int num_chgs = 0;
int xpath_len, value_len;
uint64_t clients;
Expand Down Expand Up @@ -881,11 +880,8 @@ static int mgmt_txn_create_config_batches(struct mgmt_txn_req *txn_req,
value ? value : "NIL");

clients = mgmt_be_interested_clients(xpath, true);
cmtcfg_req->clients |= clients;
if (clients)
found_validator = true;
else
found_validator = false;

cmtcfg_req->clients = 0;

xpath_len = strlen(xpath) + 1;
value_len = strlen(value) + 1;
Expand All @@ -894,6 +890,8 @@ static int mgmt_txn_create_config_batches(struct mgmt_txn_req *txn_req,
if (!adapter)
continue;

cmtcfg_req->clients |= (1ull << id);

batch = cmtcfg_req->last_be_cfg_batch[id];
if (!batch ||
(batch->num_cfg_data ==
Expand Down Expand Up @@ -940,7 +938,7 @@ static int mgmt_txn_create_config_batches(struct mgmt_txn_req *txn_req,
num_chgs++;
}

if (!found_validator) {
if (!cmtcfg_req->clients) {
snprintf(err_buf, sizeof(err_buf),
"No validator module found for XPATH: '%s",
xpath);
Expand Down

0 comments on commit 8276f4d

Please sign in to comment.