| From 4d2419632b6317efae974fb6695f844e62b47439 Mon Sep 17 00:00:00 2001 |
| From: Kasun Athukorala <kasunath@google.com> |
| Date: Sat, 13 Sep 2025 00:37:59 +0000 |
| Subject: [PATCH] dsp: base: Omit checksum for Multipart receive |
| ACKNOWLEDGE_COMPLETION |
| |
| This fix is based on DSP0240 v1.2.0 section 9.6.5 MultipartReceive. |
| |
| DataIntegrityChecksum property should be there unless the |
| response TransferFlag property is ACKNOWLEDGE_COMPLETION |
| |
| This patch fixes the issue where DataIntegrityChecksum is only |
| included if the TransferFlag is PLDM_END or PLDM_START_AND_END |
| |
| gitlint-ignore: T1 |
| Change-Id: I6d715d21d9d9d55bbda6139108be9cfb288ad209 |
| Signed-off-by: Kasun Athukorala <kasunath@google.com> |
| --- |
| CHANGELOG.md | 2 ++ |
| src/dsp/base.c | 12 +++++++++--- |
| tests/dsp/base.cpp | 34 ++++++++++------------------------ |
| 3 files changed, 21 insertions(+), 27 deletions(-) |
| |
| diff --git a/CHANGELOG.md b/CHANGELOG.md |
| index b28a4fc..712c858 100644 |
| --- a/CHANGELOG.md |
| +++ b/CHANGELOG.md |
| @@ -99,6 +99,8 @@ Change categories: |
| - base: |
| - Removed RequestedSectionOffset check in decode_multipart_receive_req() |
| - Updated DataTransferHandle check in decode_multipart_receive_req() |
| + - Updated encode_base_multipart_receive_resp() to insert checksum except when |
| + TransferFlag is ACKNOWLEDGE_COMPLETION |
| |
| ### Security |
| |
| diff --git a/src/dsp/base.c b/src/dsp/base.c |
| index eb0aaa4..e69d286 100644 |
| --- a/src/dsp/base.c |
| +++ b/src/dsp/base.c |
| @@ -680,7 +680,11 @@ int encode_base_multipart_receive_resp( |
| PLDM_MSGBUF_RW_DEFINE_P(buf); |
| int rc; |
| |
| - if (!msg || !resp || !payload_length || !resp->data.ptr) { |
| + if (!msg || !resp || !payload_length) { |
| + return -EINVAL; |
| + } |
| + |
| + if ((resp->data.length > 0) && !resp->data.ptr) { |
| return -EINVAL; |
| } |
| |
| @@ -725,8 +729,10 @@ int encode_base_multipart_receive_resp( |
| return pldm_msgbuf_discard(buf, rc); |
| } |
| |
| - if (resp->transfer_flag == PLDM_END || |
| - resp->transfer_flag == PLDM_START_AND_END) { |
| + // Checksum is present for all data parts except when response transfer flag is |
| + // ACKNOWLEDGE_COMPLETION |
| + if (resp->transfer_flag != |
| + PLDM_BASE_MULTIPART_RECEIVE_TRANSFER_FLAG_ACK_COMPLETION) { |
| pldm_msgbuf_insert(buf, checksum); |
| } |
| |
| diff --git a/tests/dsp/base.cpp b/tests/dsp/base.cpp |
| index b2e9294..88539ba 100644 |
| --- a/tests/dsp/base.cpp |
| +++ b/tests/dsp/base.cpp |
| @@ -1093,37 +1093,23 @@ TEST(EncodeMultipartReceiveResponse, GoodTestWithoutChecksum) |
| { |
| uint8_t instance_id = 0; |
| uint8_t completionCode = PLDM_SUCCESS; |
| - uint8_t transferFlag = PLDM_BASE_MULTIPART_RECEIVE_TRANSFER_FLAG_START; |
| - uint32_t nextDataTransferHandle = 0x16; |
| - static constexpr const uint32_t dataLength = 9; |
| - std::vector<uint8_t> data = {1, 2, 3, 4, 5, 6, 7, 8, 9}; |
| + uint8_t transferFlag = |
| + PLDM_BASE_MULTIPART_RECEIVE_TRANSFER_FLAG_ACK_COMPLETION; |
| + uint32_t nextDataTransferHandle = 0; |
| + static constexpr const uint32_t dataLength = 0; |
| static constexpr const size_t responseMsgLength = |
| PLDM_BASE_MULTIPART_RECEIVE_RESP_MIN_BYTES + dataLength; |
| size_t payload_length = responseMsgLength; |
| |
| - struct variable_field payload = {data.data(), dataLength}; |
| + struct variable_field payload = {nullptr, dataLength}; |
| struct pldm_base_multipart_receive_resp resp_data = { |
| completionCode, transferFlag, nextDataTransferHandle, payload}; |
| std::array<uint8_t, responseMsgLength> responseMsg = { |
| - completionCode, |
| - transferFlag, |
| - 0x16, // nextDataTransferHandle |
| - 0x00, |
| - 0x00, |
| - 0x00, |
| - 0x09, // dataLength |
| - 0x00, |
| - 0x00, |
| - 0x00, |
| - 0x1, // data |
| - 0x2, |
| - 0x3, |
| - 0x4, |
| - 0x5, |
| - 0x6, |
| - 0x7, |
| - 0x8, |
| - 0x9}; |
| + completionCode, transferFlag, |
| + 0x00, // nextDataTransferHandle |
| + 0x00, 0x00, 0x00, |
| + 0x00, // dataLength |
| + 0x00, 0x00, 0x00}; |
| |
| PLDM_MSG_DEFINE_P(responsePtr, responseMsgLength); |
| int rc; |
| -- |
| 2.51.0.536.g15c5d4f767-goog |
| |