Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UDP does not bind on send only port. Fixes: #3127 #3143

Open
wants to merge 10 commits into
base: devel
Choose a base branch
from

Conversation

LeStarch
Copy link
Collaborator

@LeStarch LeStarch commented Jan 16, 2025

Related Issue(s)
Has Unit Tests (y/n)
Documentation Included (y/n)

Change Description

Removes the attempt to bind on UDP ports where only send was configured.

I also fixed the reconnect handling now that send can also attempt to reconnect.

UTs to check the following would be nice:

  • UDP (send only)
  • UDP (recv only)
  • Disabled autoconnect properly results in autoconnect disabled.
    • In thread
    • In send
    • Via thread start method
    • Via setAutoConnect method
  • Update SDDs for this behavior
    • UDP in send/recv only mode
    • Autoconnect enabled
    • Autoconnect disabled
    • Implication on client recv loop
    • Implication on server recv loop

Rationale

UDP may send, receive, or both depending. When a send only UDP calls bind it fails because the receive port is invalid.

Fixed: #3127 #3133.

Testing/Review Recommendations

Tested with UDP in the downlink chain of Ref (only downlink) works as expected with the following caveat:

configureSend must be called before starting threads.

Future Work

Decided to do the future work!

@LeStarch
Copy link
Collaborator Author

@zimri-leisher want to take a look?

@LeStarch LeStarch requested a review from thomas-bc January 16, 2025 20:29
Drv/Ip/UdpSocket.cpp Fixed Show fixed Hide fixed
Drv/Ip/UdpSocket.cpp Fixed Show fixed Hide fixed
@LeStarch LeStarch requested a review from csmith608 January 16, 2025 21:09
Drv/Ip/SocketComponentHelper.cpp Dismissed Show dismissed Hide dismissed
Drv/Ip/SocketComponentHelper.cpp Fixed Show fixed Hide fixed
Drv/Ip/SocketComponentHelper.cpp Fixed Show fixed Hide fixed
Drv/Ip/SocketComponentHelper.hpp Fixed Show fixed Hide fixed
Drv/Ip/SocketComponentHelper.cpp Fixed Show fixed Hide fixed
Drv/Ip/SocketComponentHelper.cpp Fixed Show fixed Hide fixed
@zimri-leisher
Copy link
Collaborator

Awesome, thanks for figuring out the issue!

Drv/Ip/SocketComponentHelper.cpp Show resolved Hide resolved
Drv/Ip/SocketComponentHelper.cpp Outdated Show resolved Hide resolved
Drv/Ip/SocketComponentHelper.cpp Outdated Show resolved Hide resolved
Drv/Ip/SocketComponentHelper.cpp Show resolved Hide resolved
Drv/Ip/UdpSocket.cpp Show resolved Hide resolved
@LeStarch LeStarch added the Update Instructions Needed Need to add instructions in the release notes for updates. label Jan 22, 2025
Drv/TcpServer/TcpServerComponentImpl.cpp Dismissed Show dismissed Hide dismissed
Drv/Ip/SocketComponentHelper.cpp Dismissed Show dismissed Hide dismissed
Drv/Ip/SocketComponentHelper.cpp Dismissed Show dismissed Hide dismissed
Drv/Ip/SocketComponentHelper.cpp Dismissed Show dismissed Hide dismissed
Drv/Ip/SocketComponentHelper.cpp Dismissed Show dismissed Hide dismissed
Drv/Ip/SocketComponentHelper.cpp Dismissed Show dismissed Hide dismissed
Drv/Ip/SocketComponentHelper.cpp Dismissed Show dismissed Hide dismissed
Drv/Ip/SocketComponentHelper.hpp Dismissed Show dismissed Hide dismissed
Drv/Ip/UdpSocket.cpp Dismissed Show dismissed Hide dismissed
Drv/Ip/SocketComponentHelper.cpp Dismissed Show dismissed Hide dismissed
@LeStarch
Copy link
Collaborator Author

@zimri-leisher I think this is now done. Here is a summary of the decisions and changes I made:

  1. reconnect -> reopen as specifically the code is reopening a socket. This change makes all of the language of the SDDs more understadable.
  2. start no longer accepts a reconnect/reopen flag. Since this property affects the component in both send and recv I decided it did not belong in the start call. The start call now looks identical to other threads.
  3. configure on UDP now asserts. The user must call the configureSend/configureRecv variants explicitly.
  4. I am keeping the simplified loop break behavior.

Let me know if you like these changes, 2 and 3 will require some users to update code.

@LeStarch
Copy link
Collaborator Author

@zimri-leisher this work should be ready. Would you mind reading the summary and let me know any more comments?

@thomas-bc would you do the official review?

LeStarch added a commit to LeStarch/fprime-tools that referenced this pull request Jan 23, 2025
@zimri-leisher
Copy link
Collaborator

Sorry for the late response. 1 and 2 are great! 3 is interesting, it makes sense to me, but generally when things like this happen (a class has a method that should not ever be called), it's pointing towards a larger issue with the class hierarchy. I think this is a fine fix for now, but maybe in the future the socket class hierarchy could be simplified into a more linear, C-style layout (depth-one or -zero inheritance, and helper libraries of static functions). I think most of the problems we're facing, and code that's confusing, is just us fighting abstraction that could be removed altogether. I will keep this in mind for future contributions to FPrime. Finally, I agree with 4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Update Instructions Needed Need to add instructions in the release notes for updates.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UDP driver errno 22: Invalid Argument
2 participants