]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: enable short circuit for FE client/adapter connection
authorChristian Hopps <chopps@labn.net>
Sat, 6 May 2023 04:15:49 +0000 (00:15 -0400)
committerChristian Hopps <chopps@labn.net>
Sun, 28 May 2023 09:13:22 +0000 (05:13 -0400)
Signed-off-by: Christian Hopps <chopps@labn.net>
lib/mgmt_fe_client.c
lib/vty.c

index 9f87c387840e22c10bcc4e46c80534f3931f6c2f..a7f86201de29003d2ad58413d07ed9ac3b3e8e07 100644 (file)
@@ -645,7 +645,7 @@ uintptr_t mgmt_fe_client_lib_init(struct mgmt_fe_client_params *params,
                        MGMTD_FE_SERVER_PATH, mgmt_fe_client_notify_connect,
                        mgmt_fe_client_notify_disconnect,
                        mgmt_fe_client_process_msg, MGMTD_FE_MAX_NUM_MSG_PROC,
-                       MGMTD_FE_MAX_NUM_MSG_WRITE, MGMTD_FE_MSG_MAX_LEN, false,
+                       MGMTD_FE_MAX_NUM_MSG_WRITE, MGMTD_FE_MSG_MAX_LEN, true,
                        "FE-client", MGMTD_DBG_FE_CLIENT_CHECK());
 
        MGMTD_FE_CLIENT_DBG("Initialized client '%s'", params->name);
@@ -683,11 +683,12 @@ enum mgmt_result mgmt_fe_create_client_session(uintptr_t lib_hndl,
        session->client_ctx = client_ctx;
        session->session_id = 0;
 
+       mgmt_sessions_add_tail(&client_ctx->client_sessions, session);
+
        if (mgmt_fe_send_session_req(client_ctx, session, true) != 0) {
                XFREE(MTYPE_MGMTD_FE_SESSION, session);
                return MGMTD_INTERNAL_ERROR;
        }
-       mgmt_sessions_add_tail(&client_ctx->client_sessions, session);
 
        return MGMTD_SUCCESS;
 }
index 6164126fb4ce320b595a25f3f0404f0a9fa0b25f..52d2f2ff68450c667de981f2849c358e796896bc 100644 (file)
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -146,7 +146,9 @@ void vty_mgmt_resume_response(struct vty *vty, bool success)
        header[3] = ret;
        buffer_put(vty->obuf, header, 4);
 
-       if (!vty->t_write && (vtysh_flush(vty) < 0))
+       /* XXX this is crashing */
+       // if (!vty->t_write && (vtysh_flush(vty) < 0))
+       if (!vty->t_write)
                /* Try to flush results; exit if a write
                 * error occurs.
                 */
@@ -3493,6 +3495,17 @@ int vty_mgmt_send_config_data(struct vty *vty)
        int cnt;
        bool implicit_commit = false;
 
+       if (mgmt_lib_hndl && vty->mgmt_client_id && !vty->mgmt_session_id) {
+               /*
+                * We are connected to mgmtd but we do not yet have an
+                * established session. this means we need to send any changes
+                * made during this "down-time" to all backend clients when this
+                * FE client finishes coming up.
+                */
+               MGMTD_FE_CLIENT_DBG("skipping as no session exists");
+               return 0;
+       }
+
        if (mgmt_lib_hndl && vty->mgmt_session_id) {
                cnt = 0;
                for (indx = 0; indx < vty->num_cfg_changes; indx++) {