Skip to content

Conversation

@lydia-at-amazon
Copy link
Collaborator

During on-target testing, it was found that if a frame is received out of order during a multiframe transfer, then libudpard cannot receive any subsequent transfers for any port IDs because it reports an out of memory error. This is because the memory allocated for the out-of-order multiframe transfer is never freed. Since out-of-order multiframe transfers are not currently supported, the best course of action is drop the entire payload and require the user to resend it.

UdpardRxSubscription* subscription = nullptr;
std::int8_t result =
ins_rx.rxAccept(ti->tx_deadline_usec, ti->frame, 0, ti->specifier, transfer, &subscription);
REQUIRE(((-UDPARD_ERROR_OUT_OF_ORDER == ins_rx.rxAccept(ti->tx_deadline_usec,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this covering the case where the second frame was received as duplicate with the same index?

Copy link
Collaborator Author

@lydia-at-amazon lydia-at-amazon Jun 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Erik, glad you asked! That's what I thought it was doing, but looking more closely, it was covering the case where we call rxAccept on a transport index of 0 and then call rxAccept on a transport index of 1. So, yes, the frame received on the second rxAccept would have the same index as on the first rxAccept. I thought the sessions for different transport indexes would be handled separately, but it seems like this is not currently the case. So, if we try to call rxAccept on the same frame for different transports, we are currently getting an OUT_OF_ORDER error because the frame indexes are the same.

This made me realize that there is another bug. The multiframe code wasn't checking that the rx session transport index matched the index passed into rxSessionUpdate. It should have a check like this: https://github.com/OpenCyphal-Garage/libudpard/blob/main/libudpard/udpard.c#L1001

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to confirm before I make the change, each unique transport index should have its own RX session, correct? So, in rxAcceptFrame, we should return immediately if rxs->redundant_transport_index != redundant_transport_index: https://github.com/OpenCyphal-Garage/libudpard/blob/main/libudpard/udpard.c#L936

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make this change in another CR since we're anxious to get the original fix merged. I have already made the change locally so it will be a quick turnaround.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New issue to fix this bug: #22

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR to fix this bug: #23

Copy link
Member

@thirtytwobits thirtytwobits left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I see it now. nevermind)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants