[Openvpn-devel,RFC,0/8] server: support listening on multiple ports/IPs

Message ID 20180425195722.20744-1-a@unstable.cc
Headers show
  • server: support listening on multiple ports/IPs
Related show


Antonio Quartulli April 25, 2018, 7:57 p.m.
This patchset allows a server to listen on multiple sockets

Practically this means that an admin can configure his/her server to
listen on multiple IPs and/or multiple ports at the same time.

The new behaviour can be configured by using an extension of the current
"--local" option.
In particular, the new directive syntax is  "--local IP [port]" and it
can appear multiple times in the same server config. Each occurrence
represents a single socket.

"IP" can be an IPv4, IPv6, an hostname or *.
Multiple "--local" directives can combine all of the above.

The special case "*" will mimic what currently happens on a server when
no "--local" is specified, but in this case it gives a chance to specify
a port.

The special addresses and :: are also allowed and they can be
used to explicitly bind only IPv4 o v6.

If no port is specified, the value coming from "lport" is used
(1194 by default).

At the moment the protocol cannot be customized and the one specified by
the "--proto" directive will always be used.
Future development will aim at making the protocol part of the "--local"
directive and finally have multi protocol support on the same instance.

This patchset is an RFC because it requires feedback and testing,
especially when used in client mode with all kind of weird options.

It currently passes "make check" and our "internal buildbot"

Interested users can also get this code branch from:


Antonio Quartulli (8):
  event/multi: add event_arg object to make event handling more generic
  pass link_socket object to i/o functions
  io_work: convert shift argument to uintptr_t
  io_work: pass event_arg object to event handler in case of socket
  allow tcp/udp server to listen on multiple ports at the same time
  if a local IPv6 address is provided, socket must be v6-only
  allow user to specify 'local' multiple times in config files
  override ai_family if 'local' numeric address was specified

 doc/openvpn.8                |  10 +-
 src/openvpn/event.h          |  22 ++++
 src/openvpn/forward-inline.h |  15 ++-
 src/openvpn/forward.c        | 137 +++++++++++++++---------
 src/openvpn/forward.h        |  35 ++++---
 src/openvpn/init.c           | 198 +++++++++++++++++++++++------------
 src/openvpn/init.h           |   3 +-
 src/openvpn/mtcp.c           | 113 ++++++++++++--------
 src/openvpn/mudp.c           |  19 +++-
 src/openvpn/mudp.h           |   6 +-
 src/openvpn/multi.c          |  27 +++--
 src/openvpn/multi.h          |  15 ++-
 src/openvpn/openvpn.c        |   2 +-
 src/openvpn/openvpn.h        |   9 +-
 src/openvpn/options.c        | 162 +++++++++++++++++++++++-----
 src/openvpn/options.h        |  15 ++-
 src/openvpn/ping-inline.h    |   2 +-
 src/openvpn/socket.c         |  55 ++++++++--
 src/openvpn/socket.h         |   8 +-
 19 files changed, 602 insertions(+), 251 deletions(-)