OpenVPN / ovpn-dco-win

OpenVPN Data Channel Offload driver for Windows
MIT License
47 stars 22 forks source link

sockaddr prefix in write payload #84

Open lstipakov opened 1 week ago

lstipakov commented 1 week ago

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.

cron2 commented 1 week ago

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

lstipakov commented 1 week ago

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 commented 1 week ago

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 commented 1 week ago

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

lstipakov commented 1 week ago

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

ordex commented 1 week ago

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

lstipakov commented 1 week ago

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 commented 1 week ago

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