public inbox for connman@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH 00/46] VPN association state, dual IP support and WG fixes
@ 2025-07-11 14:26 Jussi Laakkonen
  2025-07-11 14:26 ` [PATCH 01/45] agent: Cancel agent request on NoReply D-Bus error Jussi Laakkonen
                   ` (47 more replies)
  0 siblings, 48 replies; 69+ messages in thread
From: Jussi Laakkonen @ 2025-07-11 14:26 UTC (permalink / raw)
  To: connman

This patch set (1) adds the association state also for the VPNs, (2) implements
dual IP support for VPNs and (3) contains fixes for Wireguard address,
especially for FQDN handling. This is a combination of all three improvements
for the sake of testing them together.

(1): association state for VPNs
The association state is to indicate that the VPN is waiting for VPN agent to
provide input given by user. In this state service.c must not do connect
timeout checks as the timers for both differ in length, default being 120s for
connect timeout and 300s for VPN agent dialog timeout.

In order to facilitate this change the association state had to be implemented
also for VPNs. It is common state for services and like with services the
association state for VPNs preceeds the configuration state (on VPN side
connect state). Both vpn.c plugins on connmand and vpnd side require changes
to accommodate this state. When the VPN agent succeeds in getting the input
from the user the state transitions from association to connect (configuration)
state and, thus, requires no specific changes to VPN plugins.

On connmand side the association state is the initial state when VPN is getting
connected and the state needs to be accounted as a connecting state in
plugins/vpn.c to not to lose transport ident for it and in provider.c as a
pre-configuration state to not to start the connect timeout for the VPN before
the VPN is in configuration state. The reason for the latter is that the
connect timeout should be exact and start from the point when
connect/configuration state is entered.

On vpnd side association state is, like on connmand side, the initial state for
the VPN getting connected. After the VPN agent succeeds getting the information
from the user (credentials) the state transitions to connect (configuratioin).
There may be a possibility for a VPN plugin to run without VPN agent and thus
in these cases it is ensured that the vpn/plugins/vpn.c:vpn_notify() does
the state transition in such cases. It is allowed go back to association state
from connect state but not from other states.

(2): dual IP support for VPNs

Dual IP support for VPNs is implemented by adding an family extension that
simply uses a boolean array of 2. With this IPv4 and IPv6 can be both defined
on a VPN such as WireGuard and provider.c will setup the addresses correctly in
connmand.

(3): WireGuard fixes

This improves the WireGuard plugin and adds better error case support for the
vpn/plugins/vpn.c. This allows also to propagate the errors upward and with
other changes, allows the shutdown to follow the same process as the other
VPNs. Also fix the PrefixLength use in the WireGuard plugin by tokenizing the
host before getaddrinfo() check. One of the key fixes here is to make FQDN
work with WireGuard. Also a new option is added for using the transport
nameservers with WireGuard reresolve queries, which by default is off (false).

First, the basic saving of the WireGuard configuration is done similarly to
other plugins, as well as to what wg-quick is utilizing.

Second, the handling of errors is improved within the plugin and vpn.c as well.
This will make it possible to pass the errors upwards from the plugin  In
addition to this there is a limit for reresolve errors (5 by default) after
which WireGuard plugin dies in case the configuration is wrong, or network is
broken.

Third, the use of getaddrinfo() will block with invalid configuration when
doing the reresolve for the endpoint. This is now replaced with GResolv by
adding a wrapper for it in vpn-util.c so it can be used within VPN plugins as
well. This avoids the blocking of the non-existent address resolve that made
vpnd unresponsive for the time being, for example, disconnects did not work.

Fourth, the shutdown is now simulated in a same way other daemon utilizing VPNs
do, by calling the vpn_died() with a slight delay. This makes daemonless VPNs
work in the same way as the rest of the plugins to do the same cleanup steps.

Fifth, the host given in the configuration as an IP-address should contain 
CIDR notation but as getaddrinfo() uses inet_pton(), which is relying on the
address to not to have the notation, the host is tokenized first for this use.

Sixth, there is an option added, "WireGuard.ReresolveUseTransportDNS" that can
be set to boolean values, "true" indicating that the nameservers of the
transport are used for the DNS reresolve queries. This may become useful in
cases where user cannot affect their network setup outside their devices. By
default this option is set off, and is saved among other options.

Seventh, the FQDN server use is fixed by using the resolved IP of the server as
the gateway. The reason this broke networking was that the FQDN name was sent
to connmand "as is" and it was used as gateway, which could not be resolved
when routing packets.

Jussi Laakkonen (45):
  agent: Cancel agent request on NoReply D-Bus error
  vpn-provider: Use association state for VPN agent input wait
  vpn: Add association state before connect state
  vpn-agent: Do connect state transition after input dialog check
  service: Explicit VPN connect timeout, ignore in VPN agent wait
  provider: Handle VPN configuration and association states
  vpn: Add support for association state, add state getter
  vpn: Check if connecting when setting state or disconnecting
  vpn: Add VPN agent use callback for plugins
  vpn-provider: Transition to CONNECT state with agentless VPNs
  doc: Update VPN documentation for association state
  wireguard: Add saving of provider properties
  wireguard: Use positive errors for VPN provider connect_cb
  vpn: Fix VPN_FLAG_NO_DAEMON use in error cases
  wireguard: Handle disconnect, error and network errors better
  gresolv: Add generic error for GResolv struct with getter
  vpn-util: Add wrappers for GResolv hostname lookup use
  wireguard: Use GResolv for DNS reresolve to avoid blocking
  vpn: Drop state changes from update_provider_state()
  wireguard: Fix shutdown, ensure one exit and set no agent is used
  vpn: Check if disconnect is implemented before calling in stop_vpn()
  wireguard: Tokenize host for getaddrinfo()
  util: Add address family set/get/reset helpers
  vpn-provider: Add support for dual-IP VPNs
  provider: Add support for dual-IP VPNs
  vpn: Add support for dual-IP VPNs
  wireguard: Support both IPv4 and IPv6 address
  inet: Expose __connman_inet_is_any_addr() for plugins to use
  wireguard: Set split routing based on AllowedIPs
  Revert "vpn: Remove unused __vpn_provider_check_routes"
  vpn-provider: Allow to add complete routes and to remove routes
  wireguard: Add routes for other than any addresses
  wireguard: Fix string list parsing and IP tunneling
  wireguard: Treat initial connect failure as unreachable host
  service: handle also EALREADY in service_connect()
  vpn-provider: Make daemonless VPNs to connect when connmand is online
  vpn: Implement getter for the flags set by the VPN
  vpn-provider: Delay connect of daemonless VPNs until connmand is
    online
  wireguard: Rework hostname resolve, split code and do not resolve IP
  vpn-util: Add wrapper for adding a namerver for GResolv
  service: Send the DNS servers of VPN's transport when VPN is ready
  vpn-provider: Add support for set/get "TransportNameservers"
  wireguard: Add option for using transport nameservers for DNS
    reresolve
  wireguard: Fix FQDN by using the resolved IP as the gateway
  provider: Add the VPN nameserver routes when connected

 Makefile.am                |   3 +-
 doc/vpn-connection-api.txt |   4 +-
 doc/vpn-overview.txt       |   7 +-
 gweb/gresolv.c             |  15 +-
 gweb/gresolv.h             |   2 +
 include/inet.h             |   1 +
 include/provider.h         |  11 +-
 plugins/vpn.c              | 149 ++++---
 src/agent.c                |   4 +-
 src/connman.h              |   2 +
 src/inet.c                 |   5 +
 src/provider.c             | 114 ++++--
 src/service.c              |  94 ++++-
 src/shared/util.c          |  40 ++
 src/shared/util.h          |  11 +
 vpn/plugins/vpn.c          | 124 ++++--
 vpn/plugins/vpn.h          |  12 +-
 vpn/plugins/wireguard.c    | 817 ++++++++++++++++++++++++++++++++-----
 vpn/vpn-agent.c            |   6 +-
 vpn/vpn-provider.c         | 316 ++++++++++++--
 vpn/vpn-provider.h         |  17 +
 vpn/vpn-util.c             |  38 ++
 vpn/vpn.h                  |  13 +
 23 files changed, 1537 insertions(+), 268 deletions(-)

-- 
2.39.5


^ permalink raw reply	[flat|nested] 69+ messages in thread

end of thread, other threads:[~2025-08-13 11:20 UTC | newest]

Thread overview: 69+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-11 14:26 [PATCH 00/46] VPN association state, dual IP support and WG fixes Jussi Laakkonen
2025-07-11 14:26 ` [PATCH 01/45] agent: Cancel agent request on NoReply D-Bus error Jussi Laakkonen
2025-07-11 14:26 ` [PATCH 02/45] vpn-provider: Use association state for VPN agent input wait Jussi Laakkonen
2025-07-11 14:26 ` [PATCH 03/45] vpn: Add association state before connect state Jussi Laakkonen
2025-07-11 14:26 ` [PATCH 04/45] vpn-agent: Do connect state transition after input dialog check Jussi Laakkonen
2025-07-11 14:26 ` [PATCH 05/45] service: Explicit VPN connect timeout, ignore in VPN agent wait Jussi Laakkonen
2025-08-01 19:31   ` Denis Kenzior
2025-08-08 12:05     ` Jussi Laakkonen
2025-08-08 16:08       ` Denis Kenzior
2025-08-11 14:21         ` Jussi Laakkonen
2025-07-11 14:26 ` [PATCH 06/45] provider: Handle VPN configuration and association states Jussi Laakkonen
2025-08-01 19:34   ` Denis Kenzior
2025-08-08 12:12     ` Jussi Laakkonen
2025-07-11 14:26 ` [PATCH 07/45] vpn: Add support for association state, add state getter Jussi Laakkonen
2025-07-11 14:26 ` [PATCH 08/45] vpn: Check if connecting when setting state or disconnecting Jussi Laakkonen
2025-07-11 14:27 ` [PATCH 09/45] vpn: Add VPN agent use callback for plugins Jussi Laakkonen
2025-08-01 19:39   ` Denis Kenzior
2025-08-08 12:28     ` Jussi Laakkonen
2025-08-08 15:57       ` Denis Kenzior
2025-08-13  9:22         ` Jussi Laakkonen
2025-08-13 11:20         ` Jussi Laakkonen
2025-07-11 14:27 ` [PATCH 10/45] vpn-provider: Transition to CONNECT state with agentless VPNs Jussi Laakkonen
2025-07-11 14:27 ` [PATCH 11/45] doc: Update VPN documentation for association state Jussi Laakkonen
2025-07-11 14:27 ` [PATCH 12/45] wireguard: Add saving of provider properties Jussi Laakkonen
2025-07-11 14:27 ` [PATCH 13/45] wireguard: Use positive errors for VPN provider connect_cb Jussi Laakkonen
2025-07-11 14:27 ` [PATCH 14/45] vpn: Fix VPN_FLAG_NO_DAEMON use in error cases Jussi Laakkonen
2025-07-11 14:27 ` [PATCH 15/45] wireguard: Handle disconnect, error and network errors better Jussi Laakkonen
2025-07-11 14:27 ` [PATCH 16/45] gresolv: Add generic error for GResolv struct with getter Jussi Laakkonen
2025-08-04 14:37   ` Denis Kenzior
2025-08-08 12:34     ` Jussi Laakkonen
2025-07-11 14:27 ` [PATCH 17/45] vpn-util: Add wrappers for GResolv hostname lookup use Jussi Laakkonen
2025-08-04 14:39   ` Denis Kenzior
2025-08-08 12:36     ` Jussi Laakkonen
2025-08-08 15:39       ` Denis Kenzior
2025-07-11 14:27 ` [PATCH 18/45] wireguard: Use GResolv for DNS reresolve to avoid blocking Jussi Laakkonen
2025-07-11 14:27 ` [PATCH 19/45] vpn: Drop state changes from update_provider_state() Jussi Laakkonen
2025-07-11 14:27 ` [PATCH 20/45] wireguard: Fix shutdown, ensure one exit and set no agent is used Jussi Laakkonen
2025-07-11 14:27 ` [PATCH 21/45] vpn: Check if disconnect is implemented before calling in stop_vpn() Jussi Laakkonen
2025-07-11 14:27 ` [PATCH 22/45] wireguard: Tokenize host for getaddrinfo() Jussi Laakkonen
2025-07-11 14:27 ` [PATCH 23/45] util: Add address family set/get/reset helpers Jussi Laakkonen
2025-08-04 14:47   ` Denis Kenzior
2025-08-08 12:29     ` Jussi Laakkonen
2025-07-11 14:27 ` [PATCH 24/45] vpn-provider: Add support for dual-IP VPNs Jussi Laakkonen
2025-07-11 14:27 ` [PATCH 25/45] provider: " Jussi Laakkonen
2025-07-11 14:27 ` [PATCH 26/45] vpn: " Jussi Laakkonen
2025-07-11 14:27 ` [PATCH 27/45] wireguard: Support both IPv4 and IPv6 address Jussi Laakkonen
2025-07-11 14:27 ` [PATCH 28/45] inet: Expose __connman_inet_is_any_addr() for plugins to use Jussi Laakkonen
2025-08-04 14:57   ` Denis Kenzior
2025-08-08 12:40     ` Jussi Laakkonen
2025-07-11 14:27 ` [PATCH 29/45] wireguard: Set split routing based on AllowedIPs Jussi Laakkonen
2025-07-11 14:27 ` [PATCH 30/45] Revert "vpn: Remove unused __vpn_provider_check_routes" Jussi Laakkonen
2025-07-11 14:27 ` [PATCH 31/45] vpn-provider: Allow to add complete routes and to remove routes Jussi Laakkonen
2025-07-11 14:27 ` [PATCH 32/45] wireguard: Add routes for other than any addresses Jussi Laakkonen
2025-07-11 14:27 ` [PATCH 33/45] wireguard: Fix string list parsing and IP tunneling Jussi Laakkonen
2025-07-11 14:27 ` [PATCH 34/45] wireguard: Treat initial connect failure as unreachable host Jussi Laakkonen
2025-07-11 14:27 ` [PATCH 35/45] service: handle also EALREADY in service_connect() Jussi Laakkonen
2025-07-11 14:27 ` [PATCH 36/45] vpn-provider: Make daemonless VPNs to connect when connmand is online Jussi Laakkonen
2025-07-11 14:27 ` [PATCH 37/45] vpn: Implement getter for the flags set by the VPN Jussi Laakkonen
2025-07-11 14:27 ` [PATCH 38/45] vpn-provider: Delay connect of daemonless VPNs until connmand is online Jussi Laakkonen
2025-07-11 14:27 ` [PATCH 39/45] wireguard: Rework hostname resolve, split code and do not resolve IP Jussi Laakkonen
2025-07-11 14:27 ` [PATCH 40/45] vpn-util: Add wrapper for adding a namerver for GResolv Jussi Laakkonen
2025-07-11 14:27 ` [PATCH 41/45] service: Send the DNS servers of VPN's transport when VPN is ready Jussi Laakkonen
2025-07-11 14:27 ` [PATCH 42/45] vpn-provider: Add support for set/get "TransportNameservers" Jussi Laakkonen
2025-07-11 14:27 ` [PATCH 43/45] wireguard: Add option for using transport nameservers for DNS reresolve Jussi Laakkonen
2025-07-11 14:27 ` [PATCH 44/45] wireguard: Fix FQDN by using the resolved IP as the gateway Jussi Laakkonen
2025-07-11 14:27 ` [PATCH 45/45] provider: Add the VPN nameserver routes when connected Jussi Laakkonen
2025-07-18 16:52 ` [PATCH 00/46] VPN association state, dual IP support and WG fixes Jussi Laakkonen
2025-07-28 14:54 ` Denis Kenzior
2025-08-04 15:10 ` patchwork-bot+connman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox