Repository navigation
CfdpManager: size File Data PDUs from an initialized PDU header - #6367
lestarch-autobot wants to merge 2 commits into
Conversation
sSendFileData called FileDataPdu::getMaxFileDataSize() before FileDataPdu::initialize(), so the File Data capacity was derived from an uninitialized PduHeader (entity ID / sequence number widths and the large-file flag). Initialize the header with the transaction's real source EID, sequence number and destination EID before computing the capacity so every File Data PDU stays within MaxPduSize. Adds a regression test with a two-byte LocalEid and a non-binding OutgoingFileChunkSize, and sizes the tester's PDU buffers to allow for the packet descriptor prepended by the engine. Fixes nasa#6128 Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Coverage report — base
|
| Module | Line | Δ | Function | Δ | Branch | Δ |
|---|---|---|---|---|---|---|
Fw/DataStructures |
97.60 | -0.27 | 96.95 | +0.00 | 82.12 | -0.36 |
Svc/Ccsds/CfdpManager |
90.83 | +0.03 | 96.89 | +0.00 | 78.15 | +0.05 |
Os/Generic/Types |
92.50 | +0.36 | 92.86 | +0.00 | 74.77 | +0.94 |
New modules
| Module | Line | Function | Branch |
|---|---|---|---|
Fw/Prm |
0.00 | 0.00 | 0.00 |
Modules without UTs
CFDP/Checksum/GTest, Drv/LinuxGpioDriver, Drv/LinuxI2cDriver, Drv/LinuxSpiDriver, Drv/Ports/DataTypes, Drv/PosixUartDriver, FppTestProject/FppTest/topology/async, FppTestProject/FppTest/topology/components/Comp, FppTestProject/FppTest/topology/components/Framework, FppTestProject/FppTest/topology/components/Receiver, FppTestProject/FppTest/topology/components/Sender, FppTestProject/FppTest/topology/guarded, FppTestProject/FppTest/topology/sync, FppTestProject/FppTest/topology/top_ports, FppTestProject/FppTest/topology/types, Fw/Com, Fw/Comp, Fw/FilePacket/GTest, Fw/Fpy, Fw/Obj, Fw/Port, Fw/Sm, Fw/Test, Fw/Types/GTest, Os/Models, Svc/Ccsds/Types, Svc/Ccsds/Utils, Svc/FatalHandler, Svc/Subtopologies/CdhCore, Svc/Subtopologies/ComCcsds, Svc/Subtopologies/ComCcsdsSdls, Svc/Subtopologies/ComFprime, Svc/Subtopologies/ComLoggerTee, Svc/Subtopologies/DataProducts, Svc/Subtopologies/DpCompression, Svc/Subtopologies/FileHandling, Svc/Subtopologies/FileHandlingCfdp, Svc/Subtopologies/FileHandlingCfdp/FileHandlingCfdpConfig, TestDeploymentsProject/Ref/DpDemo, TestDeploymentsProject/Ref/PingReceiver, TestDeploymentsProject/Ref/RecvBuffApp, TestDeploymentsProject/Ref/SendBuffApp, TestDeploymentsProject/Ref/Top, TestDeploymentsProject/Ref/TypeDemo, cmake/test/data/TestConfigDeployment, cmake/test/data/TestDeployment/TestBuildAutocoder, cmake/test/data/TestDeployment/TestDuplicateDirective, cmake/test/data/TestDeployment/TestHeaderAutocoder, cmake/test/data/TestDeployment/TestLinkDepends, cmake/test/data/TestDeployment/TestRelative, cmake/test/data/test-fprime-library/TestLibrary/TestComponent, cmake/test/data/test-fprime-library2/TestLibrary2/TestComponent
Change Description
Svc::Ccsds::Cfdp::Transaction::sSendFileData(Svc/Ccsds/CfdpManager/TransactionTx.cpp) calledFileDataPdu::getMaxFileDataSize()on a freshly constructedFileDataPdubeforeinitialize().PduHeaderhas no constructor andFileDataPdu()/PduBase()do not set it, so the entity-ID / sequence-number encoded widths and the large-file flag used to size the File Data payload were read from an uninitialized stack header.The fix initializes the PDU header with the transaction's real source entity ID (
LocalEid), transaction sequence number, destination entity ID and file offset before computing the capacity, sogetMaxFileDataSize()returnsMaxPduSize - <actual header size> - 4. The finalinitialize()call beforesendFdreuses the same cached values; no FPP, parameter, default or public API change.Also:
Svc/Ccsds/CfdpManager/docs/sdd.md: theOutgoingFileChunkSizerow now states that every File Data PDU is additionally capped atMaxPduSizeusing the header size derived from the actual entity IDs / sequence number.Transaction.Class1TxWideEidFileDataPduSizing(two-byteLocalEid,OutgoingFileChunkSize = MaxPduSize, two File Data PDUs; asserts the first PDU exactly fillsMaxPduSizeand that every PDU, offset and payload is correct), andFileDataPduHelper.GetBufferSizeAndMaxSizenow checks the exactgetMaxFileDataSize()formula. The tester's PDU buffers / allocation bound were sized toMaxPduSize + PACKET_DESCRIPTOR_SIZEto match the buffer the engine actually requests (Engine::serializeAndSendPduOnChanneladds the packet descriptor); the previous< MaxPduSizebound could never admit a full-size PDU.Rationale
Fixes #6128. With the default
OutgoingFileChunkSize(981) the bug is masked because the chunk size binds first, but any deployment that raises the chunk size, or uses wider entity IDs / sequence numbers, could emit File Data PDUs larger thanMaxPduSize(or undersized ones), depending on whatever happened to be on the stack. Sizing from the initialized header makes the payload capacity deterministic and always withinMaxPduSize.Testing/Review Recommendations
fprime-util generate --ut && fprime-util build --ut -j"$(nproc)"thenctestinbuild-fprime-automatic-native-ut: 134/135 unit test executables pass, includingSvc_Ccsds_CfdpManager_ut_exeandSvc_Ccsds_CfdpManager_Types_ut_exe; the remaining one (Svc_WasmSequencer_ut_exe) could not be built in the sandbox for the same crates.io reason as below and is unrelated to this change.Transaction.Class1TxWideEidFileDataPduSizingtest was run againstdevelwithout theTransactionTx.cppchange and fails there (over-sized buffer request / only one PDU emitted), and passes with it.TestDeploymentsProject/Ref: every target except theSvc/WasmSequencerRust crate built (thatcargo buildneeds crates.io, which the sandbox used here could not reach), so theRefbinary was not linked. No in-tree deployment instantiatesCfdpManager(theFileHandlingCfdpsubtopology is not used byRef), so no GDS-level run was performed; the behavior is covered at the unit-test level.fdPdu.initialize(...)calls insSendFileDatamust carry identical header fields (they do: same cachedsourceEid/seqNum/destEid, samefoffs), and the tester bound change inCfdpManagerTester.{hpp,cpp}.Future Work
None.
Contributor Checklist
AI Usage (see policy)
This PR was authored by an AI agent (Devin): root-cause analysis of the issue, the
TransactionTx.cppfix, the unit-test additions, the SDD update, and this description were AI-generated, following the repository'sfprime-maintenance,fprime-cpp-designandfprime-unit-testingskills, and validated by building and running the unit tests locally.AGENTS.md).IAMAI