diff options
| author | Michael Biebl <biebl@debian.org> | 2026-07-03 19:53:23 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2026-07-03 19:53:23 +0200 |
| commit | aa308069bebf2d5a3200728caa69a76137c03d8b (patch) | |
| tree | c0ba2281e801c4720a0d8a5e5ee943688234f088 /src/libnm-core-impl/nm-setting-ip4-config.c | |
| parent | 0a4b2c29da4ccf259bbcea3298d15abebb94348f (diff) | |
| parent | 537bfce2bda471c92caabd388589230200891509 (diff) | |
Update upstream source from tag 'upstream/1.58_rc1'
Update to upstream version '1.58~rc1' with Debian dir 451489c9234e2b6b7c2f41ca6670287ea3ac3efd
Diffstat (limited to 'src/libnm-core-impl/nm-setting-ip4-config.c')
| -rw-r--r-- | src/libnm-core-impl/nm-setting-ip4-config.c | 90 |
1 files changed, 75 insertions, 15 deletions
diff --git a/src/libnm-core-impl/nm-setting-ip4-config.c b/src/libnm-core-impl/nm-setting-ip4-config.c index a4fccc6d..2eea98f6 100644 --- a/src/libnm-core-impl/nm-setting-ip4-config.c +++ b/src/libnm-core-impl/nm-setting-ip4-config.c @@ -40,7 +40,8 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_DHCP_CLIENT_ID, PROP_DHCP_FQDN, PROP_DHCP_VENDOR_CLASS_IDENTIFIER, PROP_LINK_LOCAL, - PROP_DHCP_IPV6_ONLY_PREFERRED, ); + PROP_DHCP_IPV6_ONLY_PREFERRED, + PROP_CLAT, ); typedef struct { NMSettingIPConfigPrivate parent; @@ -50,6 +51,7 @@ typedef struct { char *dhcp_vendor_class_identifier; gint32 link_local; gint32 dhcp_ipv6_only_preferred; + gint32 clat; } NMSettingIP4ConfigPrivate; /** @@ -168,6 +170,24 @@ nm_setting_ip4_config_get_dhcp_ipv6_only_preferred(NMSettingIP4Config *setting) return NM_SETTING_IP4_CONFIG_GET_PRIVATE(setting)->dhcp_ipv6_only_preferred; } +/** + * nm_setting_ip4_config_get_clat: + * @setting: the #NMSettingIP4Config + * + * Returns the value in the #NMSettingIP4Config:clat property. + * + * Returns: the CLAT property value + * + * Since: 1.58 + */ +NMSettingIp4ConfigClat +nm_setting_ip4_config_get_clat(NMSettingIP4Config *setting) +{ + g_return_val_if_fail(NM_IS_SETTING_IP4_CONFIG(setting), NM_SETTING_IP4_CONFIG_CLAT_DEFAULT); + + return NM_SETTING_IP4_CONFIG_GET_PRIVATE(setting)->clat; +} + static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { @@ -186,12 +206,15 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) if (!strcmp(method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL)) { if (nm_setting_ip_config_get_num_addresses(s_ip) == 0 - && nm_setting_ip_config_get_num_routes(s_ip) == 0) { - g_set_error(error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_MISSING_PROPERTY, - _("method '%s' requires at least an address or a route"), - method); + && nm_setting_ip_config_get_num_routes(s_ip) == 0 + && nm_setting_ip4_config_get_clat(NM_SETTING_IP4_CONFIG(s_ip)) + != NM_SETTING_IP4_CONFIG_CLAT_FORCE) { + g_set_error( + error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, + _("method '%s' requires at least an address, a route, or CLAT set to 'force'"), + method); g_prefix_error(error, "%s.%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME, @@ -930,10 +953,7 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass) * this is normally not recommended. * * If unset, a globally configured default from NetworkManager.conf is - * used. If still unset, the default depends on the DHCP plugin. The - * internal dhcp client will default to "mac" and the dhclient plugin will - * try to use one from its config file if present, or won't sent any - * client-id otherwise. + * used. If still unset, internal dhcp client will default to "mac". **/ /* ---nmcli--- * property: dhcp-client-id @@ -1259,7 +1279,7 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass) * won't get merged. If the route finds no merge partner, it is * configured as single hop route.</para> <para>Note that in * NetworkManager, currently all nexthops of a ECMP route must share - * the same "onlink" flag in order to be mergable.</para> + * the same "onlink" flag in order to be mergeable.</para> * </listitem> * <listitem> * <para><literal>"window"</literal> - an unsigned 32 bit integer.</para> @@ -1353,18 +1373,25 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass) /** * NMSettingIP4Config:dhcp-ipv6-only-preferred * - * Controls the "IPv6-Only Preferred" DHCPv4 option (RFC 8925). + * Controls the "IPv6-Only Preferred" DHCPv4 option (option 108 - RFC 8925). * * When set to %NM_SETTING_IP4_DHCP_IPV6_ONLY_PREFERRED_YES, the host adds the * option to the parameter request list; if the DHCP server sends the option back, * the host stops the DHCP client for the time interval specified in the option. * * Enable this feature if the host supports an IPv6-only mode, i.e. either all - * applications are IPv6-only capable or there is a form of 464XLAT deployed. + * applications are IPv6-only capable or there is a form of CLAT (464XLAT) + * deployed. + * + * If set to %NM_SETTING_IP4_DHCP_IPV6_ONLY_PREFERRED_AUTO, the option is + * automatically turned on when the IPv6 method is "auto" and the connection + * profile has ipv4.clat set to "yes" or "auto". If these two conditions are + * met, the host can operate in IPv6-only mode and therefore it is safe to + * disable DHCPv4 when the network also supports it. * * When set to %NM_SETTING_IP4_DHCP_IPV6_ONLY_PREFERRED_DEFAULT, the actual value * is looked up in the global configuration; if not specified, it defaults to - * %NM_SETTING_IP4_DHCP_IPV6_ONLY_PREFERRED_NO. + * %NM_SETTING_IP4_DHCP_IPV6_ONLY_PREFERRED_AUTO. * * If the connection has IPv6 method set to "disabled", this property does not * have effect and the "IPv6-Only Preferred" option is always disabled. @@ -1382,6 +1409,39 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass) NMSettingIP4ConfigPrivate, dhcp_ipv6_only_preferred); + /** + * NMSettingIP4Config:clat + * + * Controls the CLAT (Customer-side translator) functionality. CLAT is used to implement the + * client part of 464XLAT (RFC 6877), an architecture that provides IPv4 connectivity to hosts + * on IPv6-only networks. + * + * When CLAT is enabled, NetworkManager discovers the NAT64 prefix from IPv6 Router Advertisements; + * if a NAT64 prefix is announced, NetworkManager installs a BPF program to perform the stateless + * translation of packets between IPv4 and IPv6. + * + * Setting %NM_SETTING_IP4_CONFIG_CLAT_NO completely disables CLAT. %NM_SETTING_IP4_CONFIG_CLAT_AUTO + * enables CLAT only when the IPv4 method is 'auto' and the device doesn't have a native IPv4 gateway. + * %NM_SETTING_IP4_CONFIG_CLAT_FORCE enables CLAT even if the IPv4 method is not 'auto' and even if + * the device has a native IPv4 gateway. + * + * When set to %NM_SETTING_IP4_CONFIG_CLAT_DEFAULT, the actual value is looked up in the global + * configuration; if not specified it defaults to %NM_SETTING_IP4_CONFIG_CLAT_NO. In the future the + * default fall back value will change to %NM_SETTING_IP4_CONFIG_CLAT_AUTO. + * + * Since: 1.58 + */ + _nm_setting_property_define_direct_enum(properties_override, + obj_properties, + NM_SETTING_IP4_CONFIG_CLAT, + PROP_CLAT, + NM_TYPE_SETTING_IP4_CONFIG_CLAT, + NM_SETTING_IP4_CONFIG_CLAT_DEFAULT, + NM_SETTING_PARAM_NONE, + NULL, + NMSettingIP4ConfigPrivate, + clat); + g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); _nm_setting_class_commit(setting_class, |