Skip to content

Commit 499eae6

Browse files
authored
Merge pull request #13795 from LabNConsulting/chopps/mgmt-lock-cleanup
mgmt lock simplification
2 parents 4fa21aa + 459848d commit 499eae6

20 files changed

+530
-736
lines changed

lib/command.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,11 +1333,12 @@ int config_from_file(struct vty *vty, FILE *fp, unsigned int *line_num)
13331333
/* Configuration from terminal */
13341334
DEFUN (config_terminal,
13351335
config_terminal_cmd,
1336-
"configure [terminal]",
1336+
"configure [terminal [file-lock]]",
13371337
"Configuration from vty interface\n"
1338+
"Configuration with locked datastores\n"
13381339
"Configuration terminal\n")
13391340
{
1340-
return vty_config_enter(vty, false, false);
1341+
return vty_config_enter(vty, false, false, argc == 3);
13411342
}
13421343

13431344
/* Enable command */

lib/mgmt.proto

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ message FeSetConfigReply {
243243
required DatastoreId ds_id = 2;
244244
required uint64 req_id = 3;
245245
required bool success = 4;
246-
optional string error_if_any = 5;
246+
required bool implicit_commit = 5;
247+
optional string error_if_any = 6;
247248
}
248249

249250
message FeCommitConfigReq {

lib/mgmt_fe_client.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ static int mgmt_fe_send_session_req(struct mgmt_fe_client *client,
164164

165165
int mgmt_fe_send_lockds_req(struct mgmt_fe_client *client, uint64_t session_id,
166166
uint64_t req_id, Mgmtd__DatastoreId ds_id,
167-
bool lock)
167+
bool lock, bool scok)
168168
{
169169
(void)req_id;
170170
Mgmtd__FeMessage fe_msg;
@@ -185,7 +185,7 @@ int mgmt_fe_send_lockds_req(struct mgmt_fe_client *client, uint64_t session_id,
185185
lock ? "" : "UN", dsid2name(ds_id), session_id);
186186

187187

188-
return mgmt_fe_client_send_msg(client, &fe_msg, false);
188+
return mgmt_fe_client_send_msg(client, &fe_msg, scok);
189189
}
190190

191191
int mgmt_fe_send_setcfg_req(struct mgmt_fe_client *client, uint64_t session_id,
@@ -411,6 +411,7 @@ static int mgmt_fe_client_handle_msg(struct mgmt_fe_client *client,
411411
session->user_ctx, fe_msg->setcfg_reply->req_id,
412412
fe_msg->setcfg_reply->success,
413413
fe_msg->setcfg_reply->ds_id,
414+
fe_msg->setcfg_reply->implicit_commit,
414415
fe_msg->setcfg_reply->error_if_any);
415416
break;
416417
case MGMTD__FE_MESSAGE__MESSAGE_COMMCFG_REPLY:

lib/mgmt_fe_client.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ struct mgmt_fe_client_cbs {
9191
uintptr_t session_id,
9292
uintptr_t user_session_client,
9393
uint64_t req_id, bool success,
94-
Mgmtd__DatastoreId ds_id,
94+
Mgmtd__DatastoreId ds_id, bool implcit_commit,
9595
char *errmsg_if_any);
9696

9797
void (*commit_config_notify)(struct mgmt_fe_client *client,
@@ -219,7 +219,8 @@ mgmt_fe_destroy_client_session(struct mgmt_fe_client *client,
219219
*/
220220
extern int mgmt_fe_send_lockds_req(struct mgmt_fe_client *client,
221221
uint64_t session_id, uint64_t req_id,
222-
Mgmtd__DatastoreId ds_id, bool lock_ds);
222+
Mgmtd__DatastoreId ds_id, bool lock_ds,
223+
bool scok);
223224

224225
/*
225226
* Send SET_CONFIG_REQ to MGMTD for one or more config data(s).

lib/mgmt_msg.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -548,20 +548,26 @@ int msg_conn_send_msg(struct msg_conn *conn, uint8_t version, void *msg,
548548
if (conn->remote_conn && short_circuit_ok) {
549549
uint8_t *buf = msg;
550550
size_t n = mlen;
551+
bool old;
551552

552553
if (packf) {
553554
buf = XMALLOC(MTYPE_TMP, mlen);
554555
n = packf(msg, buf);
555556
}
556557

558+
++conn->short_circuit_depth;
557559
MGMT_MSG_DBG(dbgtag, "SC send: depth %u msg: %p",
558-
++conn->short_circuit_depth, msg);
560+
conn->short_circuit_depth, msg);
559561

562+
old = conn->remote_conn->is_short_circuit;
563+
conn->remote_conn->is_short_circuit = true;
560564
conn->remote_conn->handle_msg(version, buf, n,
561565
conn->remote_conn);
566+
conn->remote_conn->is_short_circuit = old;
562567

568+
--conn->short_circuit_depth;
563569
MGMT_MSG_DBG(dbgtag, "SC return from depth: %u msg: %p",
564-
conn->short_circuit_depth--, msg);
570+
conn->short_circuit_depth, msg);
565571

566572
if (packf)
567573
XFREE(MTYPE_TMP, buf);
@@ -661,12 +667,10 @@ static bool msg_client_connect_short_circuit(struct msg_client *client)
661667
set_nonblocking(sockets[0]);
662668
setsockopt_so_sendbuf(sockets[0], client->conn.mstate.max_write_buf);
663669
setsockopt_so_recvbuf(sockets[0], client->conn.mstate.max_read_buf);
664-
client->conn.is_short_circuit = true;
665670

666671
/* server side */
667672
memset(&su, 0, sizeof(union sockunion));
668673
server_conn = server->create(sockets[1], &su);
669-
server_conn->is_short_circuit = true;
670674

671675
client->conn.remote_conn = server_conn;
672676
server_conn->remote_conn = &client->conn;

lib/mgmt_msg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ struct msg_conn {
9898
struct msg_conn *conn);
9999
void *user;
100100
uint short_circuit_depth;
101+
bool is_short_circuit; /* true when the message being handled is SC */
101102
bool is_client;
102-
bool is_short_circuit;
103103
bool debug;
104104
};
105105

lib/northbound_cli.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ DEFUN (config_exclusive,
763763
"Configuration from vty interface\n"
764764
"Configure exclusively from this terminal\n")
765765
{
766-
return vty_config_enter(vty, true, true);
766+
return vty_config_enter(vty, true, true, false);
767767
}
768768

769769
/* Configure using a private candidate configuration. */
@@ -773,7 +773,7 @@ DEFUN (config_private,
773773
"Configuration from vty interface\n"
774774
"Configure using a private candidate configuration\n")
775775
{
776-
return vty_config_enter(vty, true, false);
776+
return vty_config_enter(vty, true, false, false);
777777
}
778778

779779
DEFPY (config_commit,

0 commit comments

Comments
 (0)