]> git.proxmox.com Git - mirror_frr.git/commitdiff
mgmtd: Add note to SETCFG_REQ and debug logging
authorChristian Hopps <chopps@labn.net>
Tue, 16 May 2023 12:23:09 +0000 (08:23 -0400)
committerChristian Hopps <chopps@labn.net>
Tue, 30 May 2023 06:09:51 +0000 (02:09 -0400)
- convert impossible situation into assert

Signed-off-by: Christian Hopps <chopps@labn.net>
mgmtd/mgmt_fe_adapter.c

index 7327940c19eb0e27da784dece7d0b5363a459a28..7509d24a6adb7b2a70fbfd6d6562a2db720f4632 100644 (file)
@@ -755,6 +755,11 @@ mgmt_fe_session_handle_lockds_req_msg(struct mgmt_fe_session_ctx *session,
        return 0;
 }
 
+/*
+ * TODO: this function has too many conditionals relating to complex error
+ * conditions. It needs to be simplified and these complex error conditions
+ * probably need to just disconnect the client with a suitably loud log message.
+ */
 static int
 mgmt_fe_session_handle_setcfg_req_msg(struct mgmt_fe_session_ctx *session,
                                          Mgmtd__FeSetConfigReq *setcfg_req)
@@ -796,8 +801,8 @@ mgmt_fe_session_handle_setcfg_req_msg(struct mgmt_fe_session_ctx *session,
                 * from another session is already in progress.
                 */
                cfg_session_id = mgmt_config_txn_in_progress();
-               if (cfg_session_id != MGMTD_SESSION_ID_NONE
-                  && cfg_session_id != session->session_id) {
+               if (cfg_session_id != MGMTD_SESSION_ID_NONE) {
+                       assert(cfg_session_id != session->session_id);
                        mgmt_fe_send_setcfg_reply(
                                session, setcfg_req->ds_id, setcfg_req->req_id,
                                false,
@@ -811,6 +816,10 @@ mgmt_fe_session_handle_setcfg_req_msg(struct mgmt_fe_session_ctx *session,
                 * Try taking write-lock on the requested DS (if not already).
                 */
                if (!session->ds_write_locked[setcfg_req->ds_id]) {
+                       MGMTD_FE_ADAPTER_ERR(
+                               "SETCFG_REQ on session-id: %" PRIu64
+                               " without obtaining lock",
+                               session->session_id);
                        if (mgmt_fe_session_write_lock_ds(setcfg_req->ds_id,
                                                              ds_ctx, session)
                            != 0) {