about summary refs log tree commit diff
path: root/src/core/devices/nm-device-wireguard.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2022-02-14 19:23:28 +0100
committerMichael Biebl <biebl@debian.org>2022-02-14 19:23:28 +0100
commit2f94dba7385fd0e0ef19a06eb4a2fcf6c43d7946 (patch)
treee2222f5577115985dd52044d2991253403cdd952 /src/core/devices/nm-device-wireguard.c
parent88c227d90a6b7b388c5c85d72802a0ca8f05ed5c (diff)
New upstream version 1.35.91 upstream/1.35.91
Diffstat (limited to 'src/core/devices/nm-device-wireguard.c')
-rw-r--r--src/core/devices/nm-device-wireguard.c261
1 files changed, 129 insertions, 132 deletions
diff --git a/src/core/devices/nm-device-wireguard.c b/src/core/devices/nm-device-wireguard.c
index f129478f..bdb96cb2 100644
--- a/src/core/devices/nm-device-wireguard.c
+++ b/src/core/devices/nm-device-wireguard.c
@@ -12,12 +12,13 @@
 
 #include "nm-setting-wireguard.h"
 #include "libnm-core-aux-intern/nm-libnm-core-utils.h"
+#include "nm-l3-config-data.h"
 #include "libnm-core-intern/nm-core-internal.h"
 #include "libnm-glib-aux/nm-secret-utils.h"
 #include "nm-device-private.h"
 #include "libnm-platform/nm-platform.h"
 #include "libnm-platform/nmp-object.h"
-#include "libnm-platform/nmp-rules-manager.h"
+#include "libnm-platform/nmp-route-manager.h"
 #include "nm-device-factory.h"
 #include "nm-active-connection.h"
 #include "nm-act-request.h"
@@ -178,9 +179,9 @@ static NM_UTILS_LOOKUP_STR_DEFINE(_link_config_mode_to_string,
 
 static void
 _auto_default_route_get_enabled(NMSettingWireGuard *s_wg,
-                                NMConnection *      connection,
-                                gboolean *          out_enabled_v4,
-                                gboolean *          out_enabled_v6)
+                                NMConnection       *connection,
+                                gboolean           *out_enabled_v4,
+                                gboolean           *out_enabled_v6)
 {
     NMTernary enabled_v4;
     NMTernary enabled_v6;
@@ -326,7 +327,7 @@ static void
 _auto_default_route_init(NMDeviceWireGuard *self)
 {
     NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self);
-    NMConnection *            connection;
+    NMConnection             *connection;
     gboolean                  enabled_v4 = FALSE;
     gboolean                  enabled_v6 = FALSE;
     gboolean                  refreshing_only;
@@ -379,12 +380,12 @@ _auto_default_route_init(NMDeviceWireGuard *self)
 static GPtrArray *
 get_extra_rules(NMDevice *device)
 {
-    NMDeviceWireGuard *       self           = NM_DEVICE_WIREGUARD(device);
-    NMDeviceWireGuardPrivate *priv           = NM_DEVICE_WIREGUARD_GET_PRIVATE(self);
+    NMDeviceWireGuard           *self        = NM_DEVICE_WIREGUARD(device);
+    NMDeviceWireGuardPrivate    *priv        = NM_DEVICE_WIREGUARD_GET_PRIVATE(self);
     gs_unref_ptrarray GPtrArray *extra_rules = NULL;
     guint32                      priority    = 0;
     int                          is_ipv4;
-    NMConnection *               connection;
+    NMConnection                *connection;
 
     _auto_default_route_init(self);
 
@@ -456,7 +457,7 @@ get_extra_rules(NMDevice *device)
 static guint32
 coerce_route_table(NMDevice *device, int addr_family, guint32 route_table, gboolean is_user_config)
 {
-    NMDeviceWireGuard *       self = NM_DEVICE_WIREGUARD(device);
+    NMDeviceWireGuard        *self = NM_DEVICE_WIREGUARD(device);
     NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self);
     gboolean                  auto_default_route_enabled;
 
@@ -580,7 +581,7 @@ static PeerData *
 _peers_add(NMDeviceWireGuard *self, NMWireGuardPeer *peer)
 {
     NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self);
-    PeerData *                peer_data;
+    PeerData                 *peer_data;
 
     nm_assert(peer);
     nm_assert(nm_wireguard_peer_is_sealed(peer));
@@ -605,9 +606,9 @@ _peers_add(NMDeviceWireGuard *self, NMWireGuardPeer *peer)
 static gboolean
 _peers_resolve_retry_timeout(gpointer user_data)
 {
-    NMDeviceWireGuard *       self = user_data;
+    NMDeviceWireGuard        *self = user_data;
     NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self);
-    PeerData *                peer_data;
+    PeerData                 *peer_data;
     gint64                    now;
     gint64                    next;
 
@@ -683,7 +684,7 @@ _peers_resolve_retry_reschedule(NMDeviceWireGuard *self, gint64 new_next_try_at_
 
 static void
 _peers_resolve_retry_reschedule_for_peer(NMDeviceWireGuard *self,
-                                         PeerData *         peer_data,
+                                         PeerData          *peer_data,
                                          gint64             retry_in_msec)
 {
     nm_assert(retry_in_msec >= 0);
@@ -725,16 +726,16 @@ _peers_retry_in_msec(PeerData *peer_data, gboolean after_failure)
 static void
 _peers_resolve_cb(GObject *source_object, GAsyncResult *res, gpointer user_data)
 {
-    NMDeviceWireGuard *       self;
+    NMDeviceWireGuard        *self;
     NMDeviceWireGuardPrivate *priv;
-    PeerData *                peer_data;
-    gs_free_error GError *resolv_error = NULL;
-    GList *               list;
-    gboolean              changed;
-    NMSockAddrUnion       sockaddr;
-    gint64                retry_in_msec;
-    char                  s_sockaddr[100];
-    char                  s_retry[100];
+    PeerData                 *peer_data;
+    gs_free_error GError     *resolv_error = NULL;
+    GList                    *list;
+    gboolean                  changed;
+    NMSockAddrUnion           sockaddr;
+    gint64                    retry_in_msec;
+    char                      s_sockaddr[100];
+    char                      s_retry[100];
 
     list = g_resolver_lookup_by_name_finish(G_RESOLVER(source_object), res, &resolv_error);
 
@@ -782,7 +783,7 @@ _peers_resolve_cb(GObject *source_object, GAsyncResult *res, gpointer user_data)
         GList *iter;
 
         for (iter = list; iter; iter = iter->next) {
-            GInetAddress *   a = iter->data;
+            GInetAddress    *a = iter->data;
             NMSockAddrUnion  sockaddr_tmp;
             NMSockAddrUnion *s;
 
@@ -874,9 +875,9 @@ _peers_resolve_cb(GObject *source_object, GAsyncResult *res, gpointer user_data)
 static void
 _peers_resolve_start(NMDeviceWireGuard *self, PeerData *peer_data)
 {
-    NMDeviceWireGuardPrivate *priv      = NM_DEVICE_WIREGUARD_GET_PRIVATE(self);
+    NMDeviceWireGuardPrivate  *priv     = NM_DEVICE_WIREGUARD_GET_PRIVATE(self);
     gs_unref_object GResolver *resolver = NULL;
-    const char *               host;
+    const char                *host;
 
     resolver = g_resolver_get_default();
 
@@ -913,7 +914,7 @@ static void
 _peers_resolve_reresolve_all(NMDeviceWireGuard *self)
 {
     NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self);
-    PeerData *                peer_data;
+    PeerData                 *peer_data;
 
     c_list_for_each_entry (peer_data, &priv->lst_peers_head, lst_peers) {
         if (peer_data->ep_resolv.cancellable) {
@@ -931,13 +932,13 @@ _peers_resolve_reresolve_all(NMDeviceWireGuard *self)
 
 static gboolean
 _peers_update(NMDeviceWireGuard *self,
-              PeerData *         peer_data,
-              NMWireGuardPeer *  peer,
+              PeerData          *peer_data,
+              NMWireGuardPeer   *peer,
               gboolean           force_update)
 {
     nm_auto_unref_wgpeer NMWireGuardPeer *old_peer = NULL;
-    NMSockAddrEndpoint *                  old_endpoint;
-    NMSockAddrEndpoint *                  endpoint;
+    NMSockAddrEndpoint                   *old_endpoint;
+    NMSockAddrEndpoint                   *endpoint;
     gboolean                              endpoint_changed = FALSE;
     gboolean                              changed;
     NMSockAddrUnion                       sockaddr;
@@ -1018,7 +1019,7 @@ static void
 _peers_remove_all(NMDeviceWireGuard *self)
 {
     NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self);
-    PeerData *                peer_data;
+    PeerData                 *peer_data;
 
     while ((peer_data = c_list_first_entry(&priv->lst_peers_head, PeerData, lst_peers)))
         _peers_remove(self, peer_data);
@@ -1028,8 +1029,8 @@ static void
 _peers_update_all(NMDeviceWireGuard *self, NMSettingWireGuard *s_wg, gboolean *out_peers_removed)
 {
     NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self);
-    PeerData *                peer_data_safe;
-    PeerData *                peer_data;
+    PeerData                 *peer_data_safe;
+    PeerData                 *peer_data;
     guint                     i, n;
     gboolean                  peers_removed = FALSE;
 
@@ -1061,22 +1062,22 @@ _peers_update_all(NMDeviceWireGuard *self, NMSettingWireGuard *s_wg, gboolean *o
 }
 
 static void
-_peers_get_platform_list(NMDeviceWireGuardPrivate *           priv,
+_peers_get_platform_list(NMDeviceWireGuardPrivate            *priv,
                          LinkConfigMode                       config_mode,
-                         NMPWireGuardPeer **                  out_peers,
+                         NMPWireGuardPeer                   **out_peers,
                          NMPlatformWireGuardChangePeerFlags **out_peer_flags,
-                         guint *                              out_len,
-                         GArray **                            out_allowed_ips_data)
+                         guint                               *out_len,
+                         GArray                             **out_allowed_ips_data)
 {
-    gs_free NMPWireGuardPeer *plpeers                        = NULL;
+    gs_free NMPWireGuardPeer                   *plpeers      = NULL;
     gs_free NMPlatformWireGuardChangePeerFlags *plpeer_flags = NULL;
-    gs_unref_array GArray *allowed_ips                       = NULL;
-    PeerData *             peer_data;
-    guint                  i_good;
-    guint                  n_aip;
-    guint                  i_aip;
-    guint                  len;
-    guint                  i;
+    gs_unref_array GArray                      *allowed_ips  = NULL;
+    PeerData                                   *peer_data;
+    guint                                       i_good;
+    guint                                       n_aip;
+    guint                                       i_aip;
+    guint                                       len;
+    guint                                       i;
 
     nm_assert(out_peers && !*out_peers);
     nm_assert(out_peer_flags && !*out_peer_flags);
@@ -1096,7 +1097,7 @@ _peers_get_platform_list(NMDeviceWireGuardPrivate *           priv,
     i_good = 0;
     c_list_for_each_entry (peer_data, &priv->lst_peers_head, lst_peers) {
         NMPlatformWireGuardChangePeerFlags *plf = &plpeer_flags[i_good];
-        NMPWireGuardPeer *                  plp = &plpeers[i_good];
+        NMPWireGuardPeer                   *plp = &plpeers[i_good];
         NMSettingSecretFlags                psk_secret_flags;
 
         if (!nm_utils_base64secret_decode(nm_wireguard_peer_get_public_key(peer_data->peer),
@@ -1211,9 +1212,9 @@ skip:
 static void
 update_properties(NMDevice *device)
 {
-    NMDeviceWireGuard *           self;
-    NMDeviceWireGuardPrivate *    priv;
-    const NMPlatformLink *        plink;
+    NMDeviceWireGuard            *self;
+    NMDeviceWireGuardPrivate     *priv;
+    const NMPlatformLink         *plink;
     const NMPlatformLnkWireGuard *props = NULL;
     int                           ifindex;
 
@@ -1273,11 +1274,11 @@ get_generic_capabilities(NMDevice *dev)
 /*****************************************************************************/
 
 static gboolean
-create_and_realize(NMDevice *             device,
-                   NMConnection *         connection,
-                   NMDevice *             parent,
+create_and_realize(NMDevice              *device,
+                   NMConnection          *connection,
+                   NMDevice              *parent,
                    const NMPlatformLink **out_plink,
-                   GError **              error)
+                   GError               **error)
 {
     const char *iface = nm_device_get_iface(device);
     int         r;
@@ -1312,14 +1313,14 @@ _secrets_cancel(NMDeviceWireGuard *self)
 }
 
 static void
-_secrets_cb(NMActRequest *                req,
+_secrets_cb(NMActRequest                 *req,
             NMActRequestGetSecretsCallId *call_id,
-            NMSettingsConnection *        connection,
-            GError *                      error,
+            NMSettingsConnection         *connection,
+            GError                       *error,
             gpointer                      user_data)
 {
-    NMDeviceWireGuard *       self   = NM_DEVICE_WIREGUARD(user_data);
-    NMDevice *                device = NM_DEVICE(self);
+    NMDeviceWireGuard        *self   = NM_DEVICE_WIREGUARD(user_data);
+    NMDevice                 *device = NM_DEVICE(self);
     NMDeviceWireGuardPrivate *priv;
 
     g_return_if_fail(NM_IS_DEVICE_WIREGUARD(self));
@@ -1348,13 +1349,13 @@ _secrets_cb(NMActRequest *                req,
 }
 
 static void
-_secrets_get_secrets(NMDeviceWireGuard *          self,
-                     const char *                 setting_name,
+_secrets_get_secrets(NMDeviceWireGuard           *self,
+                     const char                  *setting_name,
                      NMSecretAgentGetSecretsFlags flags,
-                     const char *const *          hints)
+                     const char *const           *hints)
 {
     NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self);
-    NMActRequest *            req;
+    NMActRequest             *req;
 
     _secrets_cancel(self);
 
@@ -1369,8 +1370,8 @@ _secrets_get_secrets(NMDeviceWireGuard *          self,
 static NMActStageReturn
 _secrets_handle_auth_or_fail(NMDeviceWireGuard *self, NMActRequest *req, gboolean new_secrets)
 {
-    NMConnection *    applied_connection;
-    const char *      setting_name;
+    NMConnection                *applied_connection;
+    const char                  *setting_name;
     gs_unref_ptrarray GPtrArray *hints = NULL;
 
     if (!nm_device_auth_retries_try_next(NM_DEVICE(self)))
@@ -1415,22 +1416,22 @@ _dns_config_changed(NMDnsManager *dns_manager, NMDeviceWireGuard *self)
 /*****************************************************************************/
 
 static NMActStageReturn
-link_config(NMDeviceWireGuard *  self,
-            const char *         reason,
+link_config(NMDeviceWireGuard   *self,
+            const char          *reason,
             LinkConfigMode       config_mode,
             NMDeviceStateReason *out_failure_reason)
 {
-    NMDeviceWireGuardPrivate *           priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self);
-    nm_auto_bzero_secret_ptr NMSecretPtr wg_lnk_clear_private_key = NM_SECRET_PTR_INIT();
-    NMSettingWireGuard *                 s_wg;
-    NMConnection *                       connection;
-    NMActStageReturn                     ret;
-    gs_unref_array GArray *allowed_ips_data = NULL;
-    NMPlatformLnkWireGuard wg_lnk;
-    gs_free NMPWireGuardPeer *plpeers                        = NULL;
+    NMDeviceWireGuardPrivate                   *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self);
+    nm_auto_bzero_secret_ptr NMSecretPtr        wg_lnk_clear_private_key = NM_SECRET_PTR_INIT();
+    NMSettingWireGuard                         *s_wg;
+    NMConnection                               *connection;
+    NMActStageReturn                            ret;
+    gs_unref_array GArray                      *allowed_ips_data = NULL;
+    NMPlatformLnkWireGuard                      wg_lnk;
+    gs_free NMPWireGuardPeer                   *plpeers      = NULL;
     gs_free NMPlatformWireGuardChangePeerFlags *plpeer_flags = NULL;
     guint                                       plpeers_len  = 0;
-    const char *                                setting_name;
+    const char                                 *setting_name;
     gboolean                                    peers_removed;
     NMPlatformWireGuardChangeFlags              wg_change_flags;
     int                                         ifindex;
@@ -1583,7 +1584,7 @@ link_config_delayed_resolver_cb(gpointer user_data)
 static NMActStageReturn
 act_stage2_config(NMDevice *device, NMDeviceStateReason *out_failure_reason)
 {
-    NMDeviceWireGuard *       self = NM_DEVICE_WIREGUARD(device);
+    NMDeviceWireGuard        *self = NM_DEVICE_WIREGUARD(device);
     NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self);
     NMDeviceSysIfaceState     sys_iface_state;
     NMDeviceStateReason       failure_reason;
@@ -1625,19 +1626,19 @@ act_stage2_config(NMDevice *device, NMDeviceStateReason *out_failure_reason)
     return ret;
 }
 
-static NMIPConfig *
+static const NML3ConfigData *
 _get_dev2_ip_config(NMDeviceWireGuard *self, int addr_family)
 {
-    NMDeviceWireGuardPrivate *priv        = NM_DEVICE_WIREGUARD_GET_PRIVATE(self);
-    gs_unref_object NMIPConfig *ip_config = NULL;
-    NMConnection *              connection;
-    NMSettingWireGuard *        s_wg;
-    guint                       n_peers;
-    guint                       i;
-    int                         ip_ifindex;
-    guint32                     route_metric;
-    guint32                     route_table_coerced;
-    gboolean                    auto_default_route_enabled;
+    NMDeviceWireGuardPrivate               *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self);
+    nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL;
+    NMConnection                           *connection;
+    NMSettingWireGuard                     *s_wg;
+    guint                                   n_peers;
+    guint                                   i;
+    int                                     ip_ifindex;
+    guint32                                 route_metric;
+    guint32                                 route_table_coerced;
+    gboolean                                auto_default_route_enabled;
 
     _auto_default_route_init(self);
 
@@ -1693,7 +1694,7 @@ _get_dev2_ip_config(NMDeviceWireGuard *self, int addr_family)
         for (j = 0; j < n_aips; j++) {
             NMPlatformIPXRoute rt;
             NMIPAddr           addrbin;
-            const char *       aip;
+            const char        *aip;
             gboolean           valid;
             int                prefix;
             guint32            rtable_coerced;
@@ -1715,11 +1716,10 @@ _get_dev2_ip_config(NMDeviceWireGuard *self, int addr_family)
                     continue;
             }
 
-            if (!ip_config) {
-                ip_config = nm_device_ip_config_new(NM_DEVICE(self), addr_family);
-                nm_ip_config_set_config_flags(ip_config,
-                                              NM_IP_CONFIG_FLAGS_IGNORE_MERGE_NO_DEFAULT_ROUTES,
-                                              0);
+            if (!l3cd) {
+                l3cd = nm_device_create_l3_config_data(NM_DEVICE(self), NM_IP_CONFIG_SOURCE_USER);
+                nm_l3_config_data_set_flags(l3cd,
+                                            NM_L3_CONFIG_DAT_FLAGS_IGNORE_MERGE_NO_DEFAULT_ROUTES);
             }
 
             nm_utils_ipx_address_clear_host_address(addr_family, &addrbin, NULL, prefix);
@@ -1754,27 +1754,23 @@ _get_dev2_ip_config(NMDeviceWireGuard *self, int addr_family)
                 };
             }
 
-            nm_ip_config_add_route(ip_config, &rt.rx, NULL);
+            nm_l3_config_data_add_route(l3cd, addr_family, NULL, &rt.rx);
         }
     }
 
-    return g_steal_pointer(&ip_config);
+    if (!l3cd)
+        return NULL;
+
+    return nm_l3_config_data_seal(g_steal_pointer(&l3cd));
 }
 
-static NMActStageReturn
-act_stage3_ip_config_start(NMDevice *           device,
-                           int                  addr_family,
-                           gpointer *           out_config,
-                           NMDeviceStateReason *out_failure_reason)
+static void
+act_stage3_ip_config(NMDevice *device, int addr_family)
 {
-    gs_unref_object NMIPConfig *ip_config = NULL;
+    nm_auto_unref_l3cd const NML3ConfigData *l3cd = NULL;
 
-    ip_config = _get_dev2_ip_config(NM_DEVICE_WIREGUARD(device), addr_family);
-
-    nm_device_set_dev2_ip_config(device, addr_family, ip_config);
-
-    return NM_DEVICE_CLASS(nm_device_wireguard_parent_class)
-        ->act_stage3_ip_config_start(device, addr_family, out_config, out_failure_reason);
+    l3cd = _get_dev2_ip_config(NM_DEVICE_WIREGUARD(device), addr_family);
+    nm_device_devip_set_state(device, addr_family, NM_DEVICE_IP_STATE_READY, l3cd);
 }
 
 static guint32
@@ -1819,7 +1815,7 @@ _device_cleanup(NMDeviceWireGuard *self)
 }
 
 static void
-device_state_changed(NMDevice *          device,
+device_state_changed(NMDevice           *device,
                      NMDeviceState       new_state,
                      NMDeviceState       old_state,
                      NMDeviceStateReason reason)
@@ -1833,12 +1829,12 @@ device_state_changed(NMDevice *          device,
 /*****************************************************************************/
 
 static gboolean
-can_reapply_change(NMDevice *  device,
+can_reapply_change(NMDevice   *device,
                    const char *setting_name,
-                   NMSetting * s_old,
-                   NMSetting * s_new,
+                   NMSetting  *s_old,
+                   NMSetting  *s_new,
                    GHashTable *diffs,
-                   GError **   error)
+                   GError    **error)
 {
     if (nm_streq(setting_name, NM_SETTING_WIREGUARD_SETTING_NAME)) {
         /* Most, but not all WireGuard settings can be reapplied. Whitelist.
@@ -1864,11 +1860,9 @@ can_reapply_change(NMDevice *  device,
 static void
 reapply_connection(NMDevice *device, NMConnection *con_old, NMConnection *con_new)
 {
-    NMDeviceWireGuard *       self         = NM_DEVICE_WIREGUARD(device);
-    NMDeviceWireGuardPrivate *priv         = NM_DEVICE_WIREGUARD_GET_PRIVATE(self);
-    gs_unref_object NMIPConfig *ip4_config = NULL;
-    gs_unref_object NMIPConfig *ip6_config = NULL;
-    NMDeviceState               state      = nm_device_get_state(device);
+    NMDeviceWireGuard        *self  = NM_DEVICE_WIREGUARD(device);
+    NMDeviceWireGuardPrivate *priv  = NM_DEVICE_WIREGUARD_GET_PRIVATE(self);
+    NMDeviceState             state = nm_device_get_state(device);
 
     NM_DEVICE_CLASS(nm_device_wireguard_parent_class)->reapply_connection(device, con_old, con_new);
 
@@ -1878,11 +1872,14 @@ reapply_connection(NMDevice *device, NMConnection *con_old, NMConnection *con_ne
     }
 
     if (state >= NM_DEVICE_STATE_IP_CONFIG) {
-        ip4_config = _get_dev2_ip_config(self, AF_INET);
-        ip6_config = _get_dev2_ip_config(self, AF_INET6);
+        nm_auto_unref_l3cd const NML3ConfigData *l3cd_4 = NULL;
+        nm_auto_unref_l3cd const NML3ConfigData *l3cd_6 = NULL;
+
+        l3cd_4 = _get_dev2_ip_config(self, AF_INET);
+        l3cd_6 = _get_dev2_ip_config(self, AF_INET6);
 
-        nm_device_set_dev2_ip_config(device, AF_INET, ip4_config);
-        nm_device_set_dev2_ip_config(device, AF_INET6, ip6_config);
+        nm_device_devip_set_state(device, AF_INET, NM_DEVICE_IP_STATE_READY, l3cd_4);
+        nm_device_devip_set_state(device, AF_INET6, NM_DEVICE_IP_STATE_READY, l3cd_6);
     }
 }
 
@@ -1893,7 +1890,7 @@ update_connection(NMDevice *device, NMConnection *connection)
 {
     NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(device);
     NMSettingWireGuard *s_wg = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_WIREGUARD);
-    const NMPObject *   obj_wg;
+    const NMPObject    *obj_wg;
     const NMPObjectLnkWireGuard *olnk_wg;
     guint                        i;
 
@@ -1914,7 +1911,7 @@ update_connection(NMDevice *device, NMConnection *connection)
 
     for (i = 0; i < olnk_wg->peers_len; i++) {
         nm_auto_unref_wgpeer NMWireGuardPeer *peer  = NULL;
-        const NMPWireGuardPeer *              ppeer = &olnk_wg->peers[i];
+        const NMPWireGuardPeer               *ppeer = &olnk_wg->peers[i];
 
         peer = nm_wireguard_peer_new();
 
@@ -1929,7 +1926,7 @@ update_connection(NMDevice *device, NMConnection *connection)
 static void
 get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
 {
-    NMDeviceWireGuard *       self = NM_DEVICE_WIREGUARD(object);
+    NMDeviceWireGuard        *self = NM_DEVICE_WIREGUARD(object);
     NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self);
 
     switch (prop_id) {
@@ -1974,7 +1971,7 @@ dispose(GObject *object)
 static void
 finalize(GObject *object)
 {
-    NMDeviceWireGuard *       self = NM_DEVICE_WIREGUARD(object);
+    NMDeviceWireGuard        *self = NM_DEVICE_WIREGUARD(object);
     NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self);
 
     nm_explicit_bzero(priv->lnk_curr.private_key, sizeof(priv->lnk_curr.private_key));
@@ -2007,9 +2004,9 @@ static const NMDBusInterfaceInfoExtended interface_info_device_wireguard = {
 static void
 nm_device_wireguard_class_init(NMDeviceWireGuardClass *klass)
 {
-    GObjectClass *     object_class      = G_OBJECT_CLASS(klass);
+    GObjectClass      *object_class      = G_OBJECT_CLASS(klass);
     NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass);
-    NMDeviceClass *    device_class      = NM_DEVICE_CLASS(klass);
+    NMDeviceClass     *device_class      = NM_DEVICE_CLASS(klass);
 
     object_class->get_property = get_property;
     object_class->dispose      = dispose;
@@ -2025,7 +2022,7 @@ nm_device_wireguard_class_init(NMDeviceWireGuardClass *klass)
     device_class->create_and_realize                            = create_and_realize;
     device_class->act_stage2_config                             = act_stage2_config;
     device_class->act_stage2_config_also_for_external_or_assume = TRUE;
-    device_class->act_stage3_ip_config_start                    = act_stage3_ip_config_start;
+    device_class->act_stage3_ip_config                          = act_stage3_ip_config;
     device_class->get_generic_capabilities                      = get_generic_capabilities;
     device_class->link_changed                                  = link_changed;
     device_class->update_connection                             = update_connection;
@@ -2069,11 +2066,11 @@ nm_device_wireguard_class_init(NMDeviceWireGuardClass *klass)
     (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_WIREGUARD_DEVICE_FACTORY, NMWireGuardDeviceFactory))
 
 static NMDevice *
-create_device(NMDeviceFactory *     factory,
-              const char *          iface,
+create_device(NMDeviceFactory      *factory,
+              const char           *iface,
               const NMPlatformLink *plink,
-              NMConnection *        connection,
-              gboolean *            out_ignore)
+              NMConnection         *connection,
+              gboolean             *out_ignore)
 {
     return g_object_new(NM_TYPE_DEVICE_WIREGUARD,
                         NM_DEVICE_IFACE,