settings: honor ipv4.method like before

Rename and replace "none" flag by "auto". That means, to honor
"ipv4.method", like done it the past.

The upside is, that it requires no normalization. Normalization is confusing
to implement, because to get it really right, we probably should support
normalizing link-local based on method, but also vice versa. And since the
method affects how other properties validate/normalize, it's hard to
normalize that one, so that the result makes sense.
Normalization is also often not great to the user, because it
basically means to modify the profile based on other settings.

The downside is that the auto flag becomes API and exists because
we need backward compatibility with ipv4.method.
We would never add this flag, if we would redesign "ipv4.method"
(by replacing by per-method-specific settings).
This commit is contained in:
Thomas Haller 2022-05-11 09:20:10 +02:00 committed by Adrian Freihofer
parent 4b9d031627
commit adfc7f1539
7 changed files with 797 additions and 783 deletions

View file

@ -1521,6 +1521,14 @@ _prop_get_ipv4_link_local(NMDevice *self)
return NM_SETTING_IP4_LL_DISABLED;
link_local = nm_setting_ip4_config_get_link_local(s_ip4);
if (link_local == NM_SETTING_IP4_LL_AUTO) {
link_local = nm_streq(nm_setting_ip_config_get_method((NMSettingIPConfig *) s_ip4),
NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL)
? NM_SETTING_IP4_LL_ENABLED
: NM_SETTING_IP4_LL_DISABLED;
}
return link_local;
}

View file

@ -143,7 +143,7 @@ nm_setting_ip4_config_get_dhcp_vendor_class_identifier(NMSettingIP4Config *setti
NMSettingIP4LinkLocal
nm_setting_ip4_config_get_link_local(NMSettingIP4Config *setting)
{
g_return_val_if_fail(NM_IS_SETTING_IP4_CONFIG(setting), NM_SETTING_IP4_LL_NONE);
g_return_val_if_fail(NM_IS_SETTING_IP4_CONFIG(setting), NM_SETTING_IP4_LL_AUTO);
return NM_SETTING_IP4_CONFIG_GET_PRIVATE(setting)->link_local;
}
@ -240,7 +240,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
}
if (!NM_IN_SET(priv->link_local,
NM_SETTING_IP4_LL_NONE,
NM_SETTING_IP4_LL_AUTO,
NM_SETTING_IP4_LL_DISABLED,
NM_SETTING_IP4_LL_ENABLED)) {
g_set_error(error,
@ -922,6 +922,11 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass)
* to be obtained in addition to other addresses, such as those manually
* configured or obtained from a DHCP server.
*
* When set to "auto", the value is dependent on "ipv4.method".
* When set to "default", it honors the global connection default before
* falling back to "auto". Note that if "ipv4.method" is "disabled", then
* link local addressing is always disabled too. The default is "auto".
*
* Since 1.40
*/
/* ---ifcfg-rh---
@ -937,7 +942,7 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass)
PROP_LINK_LOCAL,
G_MININT32,
G_MAXINT32,
NM_SETTING_IP4_LL_NONE,
NM_SETTING_IP4_LL_AUTO,
NM_SETTING_PARAM_NONE,
NMSettingIP4ConfigPrivate,
link_local);

View file

@ -80,8 +80,9 @@ G_BEGIN_DECLS
/**
* NMSettingIP4LinkLocal:
* @NM_SETTING_IP4_LL_NONE: default value
* @NM_SETTING_IP4_LL_DISABLED: disable link-local protocol
* @NM_SETTING_IP4_LL_AUTO: special value which enables LL if "ipv4.method" is set to
* "link-local".
* @NM_SETTING_IP4_LL_DISABLED: disable link-local protocol.
* @NM_SETTING_IP4_LL_ENABLED: enable the link-local protocol regardless what other protocols
* such as DHCP or manually assigned IP addresses might be active.
*
@ -90,7 +91,7 @@ G_BEGIN_DECLS
* Since: 1.40
*/
typedef enum {
NM_SETTING_IP4_LL_NONE = 0,
NM_SETTING_IP4_LL_AUTO = 0,
NM_SETTING_IP4_LL_DISABLED = 2,
NM_SETTING_IP4_LL_ENABLED = 3,
} NMSettingIP4LinkLocal;

View file

@ -246,7 +246,7 @@
#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_GATEWAY N_("The gateway associated with this configuration. This is only meaningful if \"addresses\" is also set. The gateway's main purpose is to control the next hop of the standard default route on the device. Hence, the gateway property conflicts with \"never-default\" and will be automatically dropped if the IP configuration is set to never-default. As an alternative to set the gateway, configure a static default route with /0 as prefix length.")
#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS N_("When \"method\" is set to \"auto\" and this property to TRUE, automatically configured name servers and search domains are ignored and only name servers and search domains specified in the \"dns\" and \"dns-search\" properties, if any, are used.")
#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_IGNORE_AUTO_ROUTES N_("When \"method\" is set to \"auto\" and this property to TRUE, automatically configured routes are ignored and only routes specified in the \"routes\" property, if any, are used.")
#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_LINK_LOCAL N_("Enable and disable the IPv4 link-local configuration independently of the ipv4.method configuration. This allows a link-local address (169.254.x.y/16) to be obtained in addition to other addresses, such as those manually configured or obtained from a DHCP server. Since 1.40")
#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_LINK_LOCAL N_("Enable and disable the IPv4 link-local configuration independently of the ipv4.method configuration. This allows a link-local address (169.254.x.y/16) to be obtained in addition to other addresses, such as those manually configured or obtained from a DHCP server. When set to \"auto\", the value is dependent on \"ipv4.method\". When set to \"default\", it honors the global connection default before falling back to \"auto\". Note that if \"ipv4.method\" is \"disabled\", then link local addressing is always disabled too. The default is \"auto\". Since 1.40")
#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_MAY_FAIL N_("If TRUE, allow overall network configuration to proceed even if the configuration specified by this property times out. Note that at least one IP configuration must succeed or overall network configuration will still fail. For example, in IPv6-only networks, setting this property to TRUE on the NMSettingIP4Config allows the overall network configuration to succeed if IPv4 configuration fails but IPv6 configuration completes successfully.")
#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_METHOD N_("IP configuration method. NMSettingIP4Config and NMSettingIP6Config both support \"disabled\", \"auto\", \"manual\", and \"link-local\". See the subclass-specific documentation for other values. In general, for the \"auto\" method, properties such as \"dns\" and \"routes\" specify information that is added on to the information returned from automatic configuration. The \"ignore-auto-routes\" and \"ignore-auto-dns\" properties modify this behavior. For methods that imply no upstream network, such as \"shared\" or \"link-local\", these properties must be empty. For IPv4 method \"shared\", the IP subnet can be configured by adding one manual IPv4 address or otherwise 10.42.x.0/24 is chosen. Note that the shared method must be configured on the interface which shares the internet to a subnet, not on the uplink which is shared.")
#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_NEVER_DEFAULT N_("If TRUE, this connection will never be the default connection for this IP type, meaning it will never be assigned the default route by NetworkManager.")

View file

@ -697,7 +697,7 @@
<property name="dhcp-vendor-class-identifier"
description="The Vendor Class Identifier DHCP option (60). Special characters in the data string may be escaped using C-style escapes, nevertheless this property cannot contain nul bytes. If the per-profile value is unspecified (the default), a global connection default gets consulted. If still unspecified, the DHCP option is not sent to the server. Since 1.28" />
<property name="link-local"
description="Enable and disable the IPv4 link-local configuration independently of the ipv4.method configuration. This allows a link-local address (169.254.x.y/16) to be obtained in addition to other addresses, such as those manually configured or obtained from a DHCP server. Since 1.40" />
description="Enable and disable the IPv4 link-local configuration independently of the ipv4.method configuration. This allows a link-local address (169.254.x.y/16) to be obtained in addition to other addresses, such as those manually configured or obtained from a DHCP server. When set to &quot;auto&quot;, the value is dependent on &quot;ipv4.method&quot;. When set to &quot;default&quot;, it honors the global connection default before falling back to &quot;auto&quot;. Note that if &quot;ipv4.method&quot; is &quot;disabled&quot;, then link local addressing is always disabled too. The default is &quot;auto&quot;. Since 1.40" />
<property name="dhcp-reject-servers"
description="Array of servers from which DHCP offers must be rejected. This property is useful to avoid getting a lease from misconfigured or rogue servers. For DHCPv4, each element must be an IPv4 address, optionally followed by a slash and a prefix length (e.g. &quot;192.168.122.0/24&quot;). This property is currently not implemented for DHCPv6." />
</setting>

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff