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

sockaddr prefix in write payload #84

Open
lstipakov opened this issue Sep 17, 2024 · 8 comments
Open

sockaddr prefix in write payload #84

lstipakov opened this issue Sep 17, 2024 · 8 comments
Assignees
Labels
enhancement New feature or request multipeer

Comments

@lstipakov
Copy link
Member

In MP mode, the driver doesn't know to which peer it should send CC message. For that, userspace prepends the write payload with the sockaddr, containing the address of the remote peer. DCO passes this to WskSendMessages/WskSendTo.

@lstipakov lstipakov added enhancement New feature or request multipeer labels Sep 17, 2024
@lstipakov lstipakov self-assigned this Sep 17, 2024
@cron2
Copy link

cron2 commented Sep 17, 2024

How does Unix-DCO deal with this? Send CC messages directly over the socket, hand over peer ID, or sockaddr? @schwabe?

@lstipakov
Copy link
Member Author

lstipakov commented Sep 17, 2024

My understanding is that in Linux socket descriptor is shared between user/kernel. For instance, userspace calls recvfrom() in link_socket_read_udp_posix() and gets both UDP payload and sockaddr, which it copies to c->c2.from. In Windows sockets cannot be shared, so we prepend payload with sockaddr instead. @ordex

@ordex
Copy link
Member

ordex commented Sep 17, 2024

Correct: Linux userspace does not even know there is DCO when reading/writing CC packets. Everything happens over the socket as usual. It's DCO in kernel that does some magic to make this happen transparently. (Originally we used netlink, but we dropped that approach)

@ordex
Copy link
Member

ordex commented Sep 17, 2024

@lstipakov why not using just the peer ID instead of the whole sockaddr?

@lstipakov
Copy link
Member Author

Because there might be no peers yet when CC messages are exchanged.

lstipakov added a commit to lstipakov/ovpn-dco-win that referenced this issue Sep 18, 2024
In multipeer UDP mode, we expect userspace to prepend CC packets
with SOCKADDR to know where to send the control packet. Likewise,
when we receive the control packet, we prepend it with remote SOCKADDR
before pushing to userspace.

OpenVPN#84

Co-authored-by: Leon Dang <[email protected]>

Signed-off-by: Leon Dang <[email protected]>
Signed-off-by: Lev Stipakov <[email protected]>
@ordex
Copy link
Member

ordex commented Sep 18, 2024

In that case there is only the server socket open. Is that under win-dco control?

@lstipakov
Copy link
Member Author

Yep, the socket exist only in the driver and is controlled by the driver via Winsock Kernel API. Userspace can read/write by using standard IO API on the driver handle. The driver handles IO requests and proxies them to the socket.

@ordex
Copy link
Member

ordex commented Sep 18, 2024

Ok, I thought this happened only for peer sockets, but in UDP it's just the same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request multipeer
Projects
None yet
Development

No branches or pull requests

3 participants