From 2ae8433520be69b95dccefba416c19d28fb38a85 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Fri, 15 Jul 2022 10:43:53 +0200 Subject: [PATCH 1/3] device: add "is_manual" argument to ready_for_ip_config() device method Some device types might want to run manual ip configuration while skipping other methods. --- src/core/devices/nm-device.c | 4 ++-- src/core/devices/nm-device.h | 2 +- src/core/devices/ovs/nm-device-ovs-bridge.c | 2 +- src/core/devices/ovs/nm-device-ovs-interface.c | 2 +- src/core/devices/ovs/nm-device-ovs-port.c | 2 +- src/core/devices/wwan/nm-device-modem.c | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 6ad98af1b6..8c58453b55 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -11806,7 +11806,7 @@ activate_stage3_ip_config_for_addr_family(NMDevice *self, int addr_family, const priv->ip_data_x[IS_IPv4].wait_for_ports = FALSE; } - if (klass->ready_for_ip_config && !klass->ready_for_ip_config(self)) + if (klass->ready_for_ip_config && !klass->ready_for_ip_config(self, FALSE)) goto out_devip; if (IS_IPv4) { @@ -12073,7 +12073,7 @@ activate_stage3_ip_config(NMDevice *self) } if (!nm_device_sys_iface_state_is_external(self) - && (!klass->ready_for_ip_config || klass->ready_for_ip_config(self))) { + && (!klass->ready_for_ip_config || klass->ready_for_ip_config(self, TRUE))) { if (priv->ipmanual_data.state_6 == NM_DEVICE_IP_STATE_NONE && !NM_IN_STRSET(ipv6_method, NM_SETTING_IP6_CONFIG_METHOD_DISABLED, diff --git a/src/core/devices/nm-device.h b/src/core/devices/nm-device.h index 377c2fb6b8..382c866053 100644 --- a/src/core/devices/nm-device.h +++ b/src/core/devices/nm-device.h @@ -347,7 +347,7 @@ typedef struct _NMDeviceClass { NMActStageReturn (*act_stage1_prepare)(NMDevice *self, NMDeviceStateReason *out_failure_reason); NMActStageReturn (*act_stage2_config)(NMDevice *self, NMDeviceStateReason *out_failure_reason); void (*act_stage3_ip_config)(NMDevice *self, int addr_family); - gboolean (*ready_for_ip_config)(NMDevice *self); + gboolean (*ready_for_ip_config)(NMDevice *self, gboolean is_manual); const char *(*get_ip_method_auto)(NMDevice *self, int addr_family); diff --git a/src/core/devices/ovs/nm-device-ovs-bridge.c b/src/core/devices/ovs/nm-device-ovs-bridge.c index bea6e77bc8..048afb02b5 100644 --- a/src/core/devices/ovs/nm-device-ovs-bridge.c +++ b/src/core/devices/ovs/nm-device-ovs-bridge.c @@ -67,7 +67,7 @@ get_generic_capabilities(NMDevice *device) } static gboolean -ready_for_ip_config(NMDevice *device) +ready_for_ip_config(NMDevice *device, gboolean is_manual) { return FALSE; } diff --git a/src/core/devices/ovs/nm-device-ovs-interface.c b/src/core/devices/ovs/nm-device-ovs-interface.c index 6b9d3d7ed4..1f531a6f84 100644 --- a/src/core/devices/ovs/nm-device-ovs-interface.c +++ b/src/core/devices/ovs/nm-device-ovs-interface.c @@ -198,7 +198,7 @@ set_platform_mtu(NMDevice *device, guint32 mtu) } static gboolean -ready_for_ip_config(NMDevice *device) +ready_for_ip_config(NMDevice *device, gboolean is_manual) { return nm_device_get_ip_ifindex(device) > 0; } diff --git a/src/core/devices/ovs/nm-device-ovs-port.c b/src/core/devices/ovs/nm-device-ovs-port.c index a64314dd0c..5510e39fbd 100644 --- a/src/core/devices/ovs/nm-device-ovs-port.c +++ b/src/core/devices/ovs/nm-device-ovs-port.c @@ -61,7 +61,7 @@ get_generic_capabilities(NMDevice *device) } static gboolean -ready_for_ip_config(NMDevice *device) +ready_for_ip_config(NMDevice *device, gboolean is_manual) { return FALSE; } diff --git a/src/core/devices/wwan/nm-device-modem.c b/src/core/devices/wwan/nm-device-modem.c index 77ba1b248f..8c00a6d3f9 100644 --- a/src/core/devices/wwan/nm-device-modem.c +++ b/src/core/devices/wwan/nm-device-modem.c @@ -621,7 +621,7 @@ is_available(NMDevice *device, NMDeviceCheckDevAvailableFlags flags) } static gboolean -ready_for_ip_config(NMDevice *device) +ready_for_ip_config(NMDevice *device, gboolean is_manual) { /* Tell NMDevice to only run device-specific IP * configuration (devip) and skip other methods From 0717589972324bc06b9b5324134a45a543c80aa4 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Fri, 15 Jul 2022 10:52:11 +0200 Subject: [PATCH 2/3] wwan: enable manual IP configuration Before 1.36, manual addresses from the profile were assigned to the interface; restore that behavior. The manual IP configuration also contains the DNS priority from the profile; so this change ensures that the merged l3cd has a DNS priority and that dynamically discovered DNS servers are not ignored by the DNS manager. Fixes: 58287cbcc0c8 ('core: rework IP configuration in NetworkManager using layer 3 configuration') --- src/core/devices/wwan/nm-device-modem.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/devices/wwan/nm-device-modem.c b/src/core/devices/wwan/nm-device-modem.c index 8c00a6d3f9..e0209affcd 100644 --- a/src/core/devices/wwan/nm-device-modem.c +++ b/src/core/devices/wwan/nm-device-modem.c @@ -623,11 +623,11 @@ is_available(NMDevice *device, NMDeviceCheckDevAvailableFlags flags) static gboolean ready_for_ip_config(NMDevice *device, gboolean is_manual) { - /* Tell NMDevice to only run device-specific IP + /* Tell NMDevice to only run manual and device-specific IP * configuration (devip) and skip other methods - * (manual, dhcp, etc). + * (dhcp, link-local, shared, etc). */ - return FALSE; + return is_manual; } /*****************************************************************************/ From 8c17760f62f5dc34f459c5b6e6d791f3f0e220d6 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 14 Jul 2022 11:45:27 +0200 Subject: [PATCH 3/3] ppp,wwan: remove explicit initialization of DNS priority It's no longer necessary, as modem devices get the priority from the ipmanual configuration created from the profile. --- src/core/devices/wwan/nm-modem-broadband.c | 5 +---- src/core/ppp/nm-ppp-manager.c | 2 -- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/core/devices/wwan/nm-modem-broadband.c b/src/core/devices/wwan/nm-modem-broadband.c index cbf30f565c..997fe72729 100644 --- a/src/core/devices/wwan/nm-modem-broadband.c +++ b/src/core/devices/wwan/nm-modem-broadband.c @@ -1032,7 +1032,6 @@ stage3_ip_config_start(NMModem *modem, int addr_family, NMModemIPMethod ip_metho l3cd = nm_l3_config_data_new(nm_platform_get_multi_idx(NM_PLATFORM_GET), ifindex, NM_IP_CONFIG_SOURCE_WWAN); - nm_l3_config_data_set_dns_priority(l3cd, AF_INET, 0); address = (NMPlatformIP4Address){ .address = address_network, @@ -1116,11 +1115,9 @@ stage3_ip_config_start(NMModem *modem, int addr_family, NMModemIPMethod ip_metho _LOGI("IPv6 base configuration:"); - l3cd = nm_l3_config_data_new(nm_platform_get_multi_idx(NM_PLATFORM_GET), + l3cd = nm_l3_config_data_new(nm_platform_get_multi_idx(NM_PLATFORM_GET), ifindex, NM_IP_CONFIG_SOURCE_WWAN); - nm_l3_config_data_set_dns_priority(l3cd, AF_INET6, 0); - do_auto = TRUE; address.plen = mm_bearer_ip_config_get_prefix(self->_priv.ipv6_config); diff --git a/src/core/ppp/nm-ppp-manager.c b/src/core/ppp/nm-ppp-manager.c index 5c2b7681bb..003a9806a0 100644 --- a/src/core/ppp/nm-ppp-manager.c +++ b/src/core/ppp/nm-ppp-manager.c @@ -545,7 +545,6 @@ impl_ppp_manager_set_ip4_config(NMDBusObject *obj, NM_IP_CONFIG_SOURCE_PPP); nm_l3_config_data_set_mtu(l3cd, mtu); - nm_l3_config_data_set_dns_priority(l3cd, AF_INET, 0); address = (NMPlatformIP4Address){ .plen = 32, @@ -661,7 +660,6 @@ impl_ppp_manager_set_ip6_config(NMDBusObject *obj, NM_IP_CONFIG_SOURCE_PPP); nm_l3_config_data_set_mtu(l3cd, mtu); - nm_l3_config_data_set_dns_priority(l3cd, AF_INET6, 0); address = (NMPlatformIP6Address){ .plen = 64,