From 498142d9421b16c40043aa84deb44d318f2907a4 Mon Sep 17 00:00:00 2001 From: Pavel Valach Date: Fri, 12 Apr 2024 21:31:13 +0000 Subject: [PATCH] wwan: perform SLAAC and DNS assignment when IPv6 is on auto method This allows SLAAC for IPv6 to be performed, even when no IPv6 address was passed by the bearer. The link-local address will be assigned, because of do_auto = TRUE. The commit also allows the DNS assignment to be made statically when no IPv6 address has been statically assigned yet. This is to be able to receive IPv6 DNS servers via signalling, where host SLAAC still needs to be performed for some modems (e.g. some huawei modems). This also changes the logging so that SLAAC usage is logged on a separate line. --- NEWS | 2 + src/core/devices/wwan/nm-modem-broadband.c | 50 +++++++++++----------- 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/NEWS b/NEWS index 5dd05ed1b..6420f894c 100644 --- a/NEWS +++ b/NEWS @@ -16,6 +16,8 @@ USE AT YOUR OWN RISK. NOT RECOMMENDED FOR PRODUCTION USE! * Deprecated 802-11-wireless and 802-11-wired property 'mac-address-blacklist' and introduced the 'mac-address-denylist' property. * Fix detection of 6 GHz band capability for WiFi devices +* Allow IPv6 SLAAC and static IPv6 DNS server assignment for modem broadband + when IPv6 device address was not explicitly passed on by ModemManager ============================================= NetworkManager-1.46 diff --git a/src/core/devices/wwan/nm-modem-broadband.c b/src/core/devices/wwan/nm-modem-broadband.c index 6d41ae861..c03446b95 100644 --- a/src/core/devices/wwan/nm-modem-broadband.c +++ b/src/core/devices/wwan/nm-modem-broadband.c @@ -1167,20 +1167,8 @@ stage3_ip_config_start(NMModem *modem, int addr_family, NMModemIPMethod ip_metho NM_DEVICE_ERROR_INVALID_CONNECTION, "(%s) retrieving IPv6 configuration failed: no address given", nm_modem_get_uid(NM_MODEM(self))); + goto out; } - goto out; - } - - address = (NMPlatformIP6Address){}; - - if (!inet_pton(AF_INET6, address_string, &address.address)) { - g_set_error(&error, - NM_DEVICE_ERROR, - NM_DEVICE_ERROR_INVALID_CONNECTION, - "(%s) retrieving IPv6 configuration failed: invalid address given '%s'", - nm_modem_get_uid(NM_MODEM(self)), - address_string); - goto out; } data_port = mm_bearer_get_interface(self->_priv.bearer); @@ -1204,19 +1192,33 @@ stage3_ip_config_start(NMModem *modem, int addr_family, NMModemIPMethod ip_metho NM_IP_CONFIG_SOURCE_WWAN); do_auto = TRUE; - address.plen = mm_bearer_ip_config_get_prefix(self->_priv.ipv6_config); - if (address.plen <= 128) { - if (IN6_IS_ADDR_LINKLOCAL(&address.address)) { - nm_utils_ipv6_interface_identifier_get_from_addr(&iid_data, &address.address); - iid = &iid_data; - } else - do_auto = FALSE; - nm_l3_config_data_add_address_6(l3cd, &address); + if (address_string) { + address = (NMPlatformIP6Address){}; + + if (!inet_pton(AF_INET6, address_string, &address.address)) { + g_set_error(&error, + NM_DEVICE_ERROR, + NM_DEVICE_ERROR_INVALID_CONNECTION, + "(%s) retrieving IPv6 configuration failed: invalid address given '%s'", + nm_modem_get_uid(NM_MODEM(self)), + address_string); + goto out; + } + + address.plen = mm_bearer_ip_config_get_prefix(self->_priv.ipv6_config); + if (address.plen <= 128) { + if (IN6_IS_ADDR_LINKLOCAL(&address.address)) { + nm_utils_ipv6_interface_identifier_get_from_addr(&iid_data, &address.address); + iid = &iid_data; + } else + do_auto = FALSE; + nm_l3_config_data_add_address_6(l3cd, &address); + } + + _LOGI(" address %s", nm_platform_ip6_address_to_string(&address, sbuf, sizeof(sbuf))); } - _LOGI(" address %s (slaac %s)", - nm_platform_ip6_address_to_string(&address, sbuf, sizeof(sbuf)), - do_auto ? "enabled" : "disabled"); + _LOGI(" slaac %s", do_auto ? "enabled" : "disabled"); gw_string = mm_bearer_ip_config_get_gateway(self->_priv.ipv6_config); if (gw_string) {