Skip to content

Commit

Permalink
dco-win: multipeer support
Browse files Browse the repository at this point in the history
This is the main commit for dco-win multipeer
implementation.

This adds concept of "mode" to DCO implementation,
which is peer-to-peer or multipeer. Depending on mode,
some functions use MP-specific IOCTL commands, which
include peer-id as a part of input.

The driver initialization accomodates server mode,
in which tun device is created before transport.

Since on Windows the socket is visible to the kernel only,
control channel packets have to be prepended with remote
sockaddr of the peer - this allows userspace to distinguish
among peers. Sadly there is no reliable way to get peer local
address, such as on Linux/FreeBSD, so we have to do a bit of
guesswork to figure out IP address based on remote IP and local
routing table, which may backfire if there are multiple IPs
assigned to the same network adapter. However, as for now
peer-specific local IP is not used by the driver. We use
instead the result of bind() to the listening address.

Existing sockethandle_finalize() function has been refactored
to accomodate packets with possibly prepended sockaddr.

Change-Id: Ia267276d61fa1425ba205f54ba6eb89021f32dba
Signed-off-by: Lev Stipakov <[email protected]>
Acked-by: Gert Doering <[email protected]>
Message-Id: <[email protected]>
URL: https://www.mail-archive.com/[email protected]/msg30935.html
Signed-off-by: Gert Doering <[email protected]>
  • Loading branch information
lstipakov authored and cron2 committed Feb 20, 2025
1 parent 8720bc8 commit 1625d92
Show file tree
Hide file tree
Showing 11 changed files with 479 additions and 127 deletions.
5 changes: 3 additions & 2 deletions src/openvpn/dco.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,10 @@ bool dco_check_pull_options(int msglevel, const struct options *o);
*
* @param mode the instance operating mode (P2P or multi-peer)
* @param dco the context to initialize
* @param dev_node device node, used on Windows to specify certain DCO adapter
* @return true on success, false otherwise
*/
bool ovpn_dco_init(int mode, dco_context_t *dco);
bool ovpn_dco_init(int mode, dco_context_t *dco, const char *dev_node);

/**
* Open/create a DCO interface
Expand Down Expand Up @@ -293,7 +294,7 @@ dco_check_pull_options(int msglevel, const struct options *o)
}

static inline bool
ovpn_dco_init(int mode, dco_context_t *dco)
ovpn_dco_init(int mode, dco_context_t *dco, const char *dev_node)
{
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/openvpn/dco_freebsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ close_fd(dco_context_t *dco)
}

bool
ovpn_dco_init(int mode, dco_context_t *dco)
ovpn_dco_init(int mode, dco_context_t *dco, const char *dev_node)
{
if (open_fd(dco) < 0)
{
Expand Down
2 changes: 1 addition & 1 deletion src/openvpn/dco_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ ovpn_dco_init_netlink(dco_context_t *dco)
}

bool
ovpn_dco_init(int mode, dco_context_t *dco)
ovpn_dco_init(int mode, dco_context_t *dco, const char *dev_node)
{
switch (mode)
{
Expand Down
Loading

0 comments on commit 1625d92

Please sign in to comment.