settings: ipv4.link-local global default

Add a "default" value, which allows to set the flag via global
defaults.

The default for the new property can be "default" because old uses
who upgrade to a new version that supports ipv4.link-local won't have
the global default configured in NetworkManager.conf. So they will
always get the expected default to "auto", unless the change their
configuration.
This commit is contained in:
Thomas Haller 2022-05-11 09:20:10 +02:00 committed by Adrian Freihofer
parent adfc7f1539
commit 49d5e76204
8 changed files with 517 additions and 491 deletions

View file

@ -922,6 +922,10 @@ ipv6.ip6-privacy=0
<varlistentry>
<term><varname>ipv4.required-timeout</varname></term>
</varlistentry>
<varlistentry>
<term><varname>ipv4.link-local</varname></term>
<listitem><para>If left unspecified, fallback to "auto" which makes it dependent on "ipv4.method" setting.</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>ipv4.route-metric</varname></term>
</varlistentry>

View file

@ -1522,6 +1522,23 @@ _prop_get_ipv4_link_local(NMDevice *self)
link_local = nm_setting_ip4_config_get_link_local(s_ip4);
if (link_local == NM_SETTING_IP4_LL_DEFAULT) {
link_local = nm_config_data_get_connection_default_int64(NM_CONFIG_GET_DATA,
NM_CON_DEFAULT("ipv4.link-local"),
self,
NM_SETTING_IP4_LL_AUTO,
NM_SETTING_IP4_LL_ENABLED,
NM_SETTING_IP4_LL_DEFAULT);
if (link_local == NM_SETTING_IP4_LL_DEFAULT)
link_local = NM_SETTING_IP4_LL_AUTO;
else if (link_local == NM_SETTING_IP4_LL_ENABLED
&& nm_streq(nm_setting_ip_config_get_method((NMSettingIPConfig *) s_ip4),
NM_SETTING_IP4_CONFIG_METHOD_DISABLED)) {
/* Cannot enable via global defaults, if the method says disabled. */
link_local = NM_SETTING_IP4_LL_DISABLED;
}
}
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)

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_AUTO);
g_return_val_if_fail(NM_IS_SETTING_IP4_CONFIG(setting), NM_SETTING_IP4_LL_DEFAULT);
return NM_SETTING_IP4_CONFIG_GET_PRIVATE(setting)->link_local;
}
@ -241,6 +241,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
if (!NM_IN_SET(priv->link_local,
NM_SETTING_IP4_LL_AUTO,
NM_SETTING_IP4_LL_DEFAULT,
NM_SETTING_IP4_LL_DISABLED,
NM_SETTING_IP4_LL_ENABLED)) {
g_set_error(error,
@ -923,9 +924,9 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass)
* 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
* 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".
* link local addressing is always disabled too. The default is "default".
*
* Since 1.40
*/
@ -942,7 +943,7 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass)
PROP_LINK_LOCAL,
G_MININT32,
G_MAXINT32,
NM_SETTING_IP4_LL_AUTO,
NM_SETTING_IP4_LL_DEFAULT,
NM_SETTING_PARAM_NONE,
NMSettingIP4ConfigPrivate,
link_local);

View file

@ -80,18 +80,22 @@ G_BEGIN_DECLS
/**
* NMSettingIP4LinkLocal:
* @NM_SETTING_IP4_LL_AUTO: special value which enables LL if "ipv4.method" is set to
* @NM_SETTING_IP4_LL_DEFAULT: Allow fallback to a globally configured default. If unspecified,
* fallback to "auto". Note that if "ipv4.method" is "disabled", this always implies link-local
* addresses disabled too.
* @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
* @NM_SETTING_IP4_LL_DISABLED: Disable IPv4 link-local protocol.
* @NM_SETTING_IP4_LL_ENABLED: Enable the IPv4 link-local protocol regardless what other protocols
* such as DHCP or manually assigned IP addresses might be active.
*
* #NMSettingIP4LinkLocal values indicate whether link-local address protocol should be enabled.
* #NMSettingIP4LinkLocal values indicate whether IPv4 link-local address protocol should be enabled.
*
* Since: 1.40
*/
typedef enum {
NM_SETTING_IP4_LL_AUTO = 0,
NM_SETTING_IP4_LL_DEFAULT = 0,
NM_SETTING_IP4_LL_AUTO = 1,
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. 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_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 \"default\". 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. 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" />
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;default&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