]> git.puffer.fish Git - matthieu/frr.git/commitdiff
mgmtd, lib: remove batch ids from cfg apply reply
authorIgor Ryzhov <iryzhov@nfware.com>
Tue, 17 Oct 2023 12:02:57 +0000 (15:02 +0300)
committerIgor Ryzhov <iryzhov@nfware.com>
Tue, 17 Oct 2023 12:06:13 +0000 (15:06 +0300)
The config is always applied fully, all batches are included. There's no
need to pass a list of applied batches as it always contains all of
them.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
lib/mgmt.proto
lib/mgmt_be_client.c
mgmtd/mgmt_be_adapter.c
mgmtd/mgmt_txn.c
mgmtd/mgmt_txn.h

index 9e4b39abe4d2f1cf0f1a152aa37419c58c5e4fa2..c901a923d8810969dec76a9cc02ffacee3368453 100644 (file)
@@ -112,9 +112,8 @@ message BeCfgDataApplyReq {
 
 message BeCfgDataApplyReply {
   required uint64 txn_id = 1;
-  repeated uint64 batch_ids = 2;
-  required bool success = 3;
-  optional string error_if_any = 4;
+  required bool success = 2;
+  optional string error_if_any = 3;
 }
 
 message BeOperDataGetReq {
index 7bd9980357d5039611e0be460c39256ab20c05cd..be10dcf6a19fb8db75ed472834a3aefd65f10674 100644 (file)
@@ -610,8 +610,7 @@ failed:
 }
 
 static int mgmt_be_send_apply_reply(struct mgmt_be_client *client_ctx,
-                                   uint64_t txn_id, uint64_t batch_ids[],
-                                   size_t num_batch_ids, bool success,
+                                   uint64_t txn_id, bool success,
                                    const char *error_if_any)
 {
        Mgmtd__BeMessage be_msg;
@@ -620,8 +619,6 @@ static int mgmt_be_send_apply_reply(struct mgmt_be_client *client_ctx,
        mgmtd__be_cfg_data_apply_reply__init(&apply_reply);
        apply_reply.success = success;
        apply_reply.txn_id = txn_id;
-       apply_reply.batch_ids = (uint64_t *)batch_ids;
-       apply_reply.n_batch_ids = num_batch_ids;
 
        if (error_if_any)
                apply_reply.error_if_any = (char *)error_if_any;
@@ -630,12 +627,7 @@ static int mgmt_be_send_apply_reply(struct mgmt_be_client *client_ctx,
        be_msg.message_case = MGMTD__BE_MESSAGE__MESSAGE_CFG_APPLY_REPLY;
        be_msg.cfg_apply_reply = &apply_reply;
 
-       MGMTD_BE_CLIENT_DBG(
-               "Sending CFG_APPLY_REPLY txn-id %" PRIu64
-               " %zu batch ids %" PRIu64 " - %" PRIu64,
-               txn_id, num_batch_ids,
-               success && num_batch_ids ? batch_ids[0] : 0,
-               success && num_batch_ids ? batch_ids[num_batch_ids - 1] : 0);
+       MGMTD_BE_CLIENT_DBG("Sending CFG_APPLY_REPLY txn-id %" PRIu64, txn_id);
 
        return mgmt_be_client_send_msg(client_ctx, &be_msg);
 }
@@ -648,14 +640,11 @@ static int mgmt_be_txn_proc_cfgapply(struct mgmt_be_txn_ctx *txn)
        unsigned long apply_nb_cfg_tm;
        struct mgmt_be_batch_ctx *batch;
        char err_buf[BUFSIZ];
-       size_t num_processed;
-       static uint64_t batch_ids[MGMTD_BE_MAX_BATCH_IDS_IN_REQ];
 
        assert(txn && txn->client);
        client_ctx = txn->client;
 
        assert(txn->nb_txn);
-       num_processed = 0;
 
        /*
         * Now apply all the batches we have applied in one go.
@@ -673,9 +662,6 @@ static int mgmt_be_txn_proc_cfgapply(struct mgmt_be_txn_ctx *txn)
        client_ctx->num_apply_nb_cfg++;
        txn->nb_txn = NULL;
 
-       /*
-        * Send back CFG_APPLY_REPLY for all batches applied.
-        */
        FOREACH_BE_APPLY_BATCH_IN_LIST (txn, batch) {
                /*
                 * No need to delete the batch yet. Will be deleted during
@@ -684,19 +670,9 @@ static int mgmt_be_txn_proc_cfgapply(struct mgmt_be_txn_ctx *txn)
                SET_FLAG(batch->flags, MGMTD_BE_TXN_FLAGS_CFG_APPLIED);
                mgmt_be_batches_del(&txn->apply_cfgs, batch);
                mgmt_be_batches_add_tail(&txn->cfg_batches, batch);
-
-               batch_ids[num_processed] = batch->batch_id;
-               num_processed++;
-               if (num_processed == MGMTD_BE_MAX_BATCH_IDS_IN_REQ) {
-                       mgmt_be_send_apply_reply(client_ctx, txn->txn_id,
-                                                   batch_ids, num_processed,
-                                                   true, NULL);
-                       num_processed = 0;
-               }
        }
 
-       mgmt_be_send_apply_reply(client_ctx, txn->txn_id, batch_ids,
-                                   num_processed, true, NULL);
+       mgmt_be_send_apply_reply(client_ctx, txn->txn_id, true, NULL);
 
        MGMTD_BE_CLIENT_DBG("Nb-apply-duration %lu (avg: %lu) uSec",
                            apply_nb_cfg_tm, client_ctx->avg_apply_nb_cfg_tm);
index 399fdafded1a6b2f80309c59641b7c1aa3484736..5ab11ea4917ba6347960c74f2459f5d78a2b9926 100644 (file)
@@ -469,14 +469,10 @@ mgmt_be_adapter_handle_msg(struct mgmt_be_client_adapter *adapter,
        case MGMTD__BE_MESSAGE__MESSAGE_CFG_APPLY_REPLY:
                MGMTD_BE_ADAPTER_DBG(
                        "Got %s CFG_APPLY_REPLY from '%s' txn-id %" PRIx64
-                       " for %zu batches id %" PRIu64 "-%" PRIu64 " err:'%s'",
+                       " err:'%s'",
                        be_msg->cfg_apply_reply->success ? "successful"
                                                         : "failed",
                        adapter->name, be_msg->cfg_apply_reply->txn_id,
-                       be_msg->cfg_apply_reply->n_batch_ids,
-                       be_msg->cfg_apply_reply->batch_ids[0],
-                       be_msg->cfg_apply_reply->batch_ids
-                               [be_msg->cfg_apply_reply->n_batch_ids - 1],
                        be_msg->cfg_apply_reply->error_if_any
                                ? be_msg->cfg_apply_reply->error_if_any
                                : "None");
@@ -486,8 +482,6 @@ mgmt_be_adapter_handle_msg(struct mgmt_be_client_adapter *adapter,
                mgmt_txn_notify_be_cfg_apply_reply(
                        be_msg->cfg_apply_reply->txn_id,
                        be_msg->cfg_apply_reply->success,
-                       (uint64_t *)be_msg->cfg_apply_reply->batch_ids,
-                       be_msg->cfg_apply_reply->n_batch_ids,
                        be_msg->cfg_apply_reply->error_if_any, adapter);
                break;
        case MGMTD__BE_MESSAGE__MESSAGE_GET_REPLY:
index 53b9b7df46c269a16a4cbe9e3f26312142816840..ebad48e8323b93c0ed9e2e89a7aa86ecea29323a 100644 (file)
@@ -2471,14 +2471,11 @@ int mgmt_txn_notify_be_cfgdata_reply(uint64_t txn_id, uint64_t batch_id,
 }
 
 int mgmt_txn_notify_be_cfg_apply_reply(uint64_t txn_id, bool success,
-                                      uint64_t batch_ids[],
-                                      size_t num_batch_ids, char *error_if_any,
+                                      char *error_if_any,
                                       struct mgmt_be_client_adapter *adapter)
 {
        struct mgmt_txn_ctx *txn;
-       struct mgmt_txn_be_cfg_batch *batch;
        struct mgmt_commit_cfg_req *cmtcfg_req = NULL;
-       size_t indx;
 
        txn = mgmt_txn_id2ctx(txn_id);
        if (!txn || txn->type != MGMTD_TXN_TYPE_CONFIG || !txn->commit_cfg_req)
@@ -2488,9 +2485,8 @@ int mgmt_txn_notify_be_cfg_apply_reply(uint64_t txn_id, bool success,
 
        if (!success) {
                MGMTD_TXN_ERR("CFGDATA_APPLY_REQ sent to '%s' failed txn-id: %" PRIu64
-                             " batch ids %" PRIu64 " - %" PRIu64 " err: %s",
-                             adapter->name, txn->txn_id, batch_ids[0],
-                             batch_ids[num_batch_ids - 1],
+                             " err: %s",
+                             adapter->name, txn->txn_id,
                              error_if_any ? error_if_any : "None");
                mgmt_txn_send_commit_cfg_reply(
                        txn, MGMTD_INTERNAL_ERROR,
@@ -2500,25 +2496,17 @@ int mgmt_txn_notify_be_cfg_apply_reply(uint64_t txn_id, bool success,
                return 0;
        }
 
-       for (indx = 0; indx < num_batch_ids; indx++) {
-               batch = mgmt_txn_cfgbatch_id2ctx(txn, batch_ids[indx]);
-               if (batch->txn != txn)
-                       return -1;
-               mgmt_move_txn_cfg_batch_to_next(
-                       cmtcfg_req, batch,
-                       &cmtcfg_req->curr_batches[adapter->id],
-                       &cmtcfg_req->next_batches[adapter->id], true,
-                       MGMTD_COMMIT_PHASE_TXN_DELETE);
-       }
+       mgmt_move_txn_cfg_batches(txn, cmtcfg_req,
+                                 &cmtcfg_req->curr_batches[adapter->id],
+                                 &cmtcfg_req->next_batches[adapter->id],
+                                 true, MGMTD_COMMIT_PHASE_TXN_DELETE);
 
-       if (!mgmt_txn_batches_count(&cmtcfg_req->curr_batches[adapter->id])) {
-               /*
-                * All configuration for the specific backend has been applied.
-                * Send TXN-DELETE to wrap up the transaction for this backend.
-                */
-               SET_FLAG(adapter->flags, MGMTD_BE_ADAPTER_FLAGS_CFG_SYNCED);
-               mgmt_txn_send_be_txn_delete(txn, adapter);
-       }
+       /*
+        * All configuration for the specific backend has been applied.
+        * Send TXN-DELETE to wrap up the transaction for this backend.
+        */
+       SET_FLAG(adapter->flags, MGMTD_BE_ADAPTER_FLAGS_CFG_SYNCED);
+       mgmt_txn_send_be_txn_delete(txn, adapter);
 
        mgmt_try_move_commit_to_next_phase(txn, cmtcfg_req);
        if (mm->perf_stats_en)
index 068f07a5ca8adf43dd0912a6f31d751ac62b77b5..8ca7e70cab6d89d1793b8d240cd27ac17203a461 100644 (file)
@@ -223,8 +223,7 @@ extern int mgmt_txn_notify_be_cfg_validate_reply(
  */
 extern int
 mgmt_txn_notify_be_cfg_apply_reply(uint64_t txn_id, bool success,
-                                      uint64_t batch_ids[],
-                                      size_t num_batch_ids, char *error_if_any,
+                                      char *error_if_any,
                                       struct mgmt_be_client_adapter *adapter);
 
 /*