Receiving Entity Not Handling EOF (cancel) PDU Correctly
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- c
- Domain
- networking
Research direction
Start in cf_cfdp_r.c at CF_CFDP_R2_SubstateRecvEof and trace how a cancel EOF PDU reaches CF_CFDP_R2_Reset, including deferred EOF acknowledgements. Reproduce a reliable-mode transfer cancellation and verify the receiver sends EOF-Ack and FIN, while the sender sends FIN-Ack and both transactions terminate without waiting for the inactivity timer.
Written by the indexing model from the issue text.
Description
Checklist (Please check before submitting)
- I reviewed the Contributing Guide.
- I performed a cursory search to see if the bug report is relevant, not redundant, nor in conflict with other tickets.
Describe the bug
When 2 entities are transferring a file in Reliable mode, if a Cancel command is sent to the sender entity, there appears to be something broken with the resulting handshaking with the receiver entity, which ultimately does not allow the sender entity to terminate the transaction gracefully.
When the sender receives a Cancel command, it issues an EOF (cancel) PDU to the receiver. Upon receiving this EOF-PDU, the receiver immediately terminates, without any response to the sender. This results in the sender being stuck in a wait-for-EOF-Ack state and only terminating when the inactivity timer is reached.
To Reproduce
Steps to reproduce the behavior:
- Start a file transfer between 2 CFDP entities in Reliable mode
- Send a Cancel command to the sender entity
- Observe that receiver entity immediately terminates the transaction (whereas per the CFDP specification, it should send an EOF-Ack, a FIN PDU, and waiting for the FIN-Ack from the sender before terminating)
- Observe that the sender entity does not terminate correctly because it continues to wait for the EOF-Ack from the receiver
Expected behavior
- File transfer in Reliable mode started between 2 entities
- Cancel command sent to sender entity
- Sender entity issues a EOF (cancel) PDU to the receiver entity
- Receiver entity issues a EOF-Ack PDU to the sender entity
- Receiver entity issues a FIN PDU to the sender entity
- Sender entity issues a FIN-Ack PDU to the receiver entity and terminates
- Receiver entity terminates upon receiving the FIN-Ack
Code snips
I believe issue is in the CF_CFDP_R2_SubstateRecvEof function logic in cf_cfdp_r.c.
The logic defers sending of the EOF-Ack until after CF_CFDP_R2_SubstateRecvEof runs to completion:
/* always ack the EOF, even if we're not done */
t->state_data.r.r2.eof_cc = FGV(eof->cc, PDU_FLAGS_CC);
t->flags.rx.send_ack = 1; /* defer sending ack to tick handling */
EOF (cancel) PDU then follows a path that eventually results in a call to CF_CFDP_R2_Reset:
if(t->state_data.r.r2.eof_cc==CC_NO_ERROR) {
CF_CFDP_R2_Complete(t, 1); /* CF_CFDP_R2_Complete() will change state */
}
else {
CF_CFDP_R2_Reset(t);
}
Then within CF_CFDP_R2_Reset, the current transaction is already reset and freed.
if((t->state_data.r.sub_state==RECV_WAIT_FOR_FIN_ACK)||(t->state_data.r.r2.eof_cc!=CC_NO_ERROR)||(t->history->cc!=CC_NO_ERROR)||t->flags.rx.canceled) {
CF_CFDP_R1_Reset(t); /* it's done */
}
My fix: added an "else if" section to CF_CFDP_R2_SubstateRecvEof:
else if (t->state_data.r.r2.eof_cc == CF_CFDP_ConditionCode_CANCEL_REQUEST_RECEIVED) {
t->flags.rx.send_fin = 1;
t->history->txn_stat = CF_CFDP_ConditionCode_CANCEL_REQUEST_RECEIVED;
}
System observed on:
- Hardware
- OS: Linux Ubuntu 20.04
- Versions CF 3.0.0
Additional context
N/A
Reporter Info
Katie Chou
- Dominant language
- C
- Stars
- 123
- Forks
- 82
- Avg merge
- 2d 22h
- Merged PRs (30d)
- 2
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nasa/CF
-
CF_CFDP_S_SendFileData computes the file checksum from the SB buffer after CFE_SB_TransmitBufferOpen
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Assert checks non-existent variable (`pt`) in `CF_CFDP_ProcessPlaybackDirectory()`May be free again A pull request for this issue was closed without being merged. Openinvalid
Difficulty 1/5 Under an hour Newbie friendliness 68/100
Similar issues
-
needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
389ds/389-ds-base#8251 ·
Maintainers usually reply within 1 day
-
bug data-types
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
ClickHouse/clickhouse-cpp#645 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
ROCm/hrx-system#3628 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
OpenPrinting/cups#1844 ·
Maintainers usually reply within 1 day