summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-06-22 13:43:08 +0200
committerThomas Haller <thaller@redhat.com>2016-06-30 08:27:17 +0200
commitc7cee12189d8fe64bc9037d5b9daaf1c887e0466 (patch)
tree56cf52f08d42ce5cee4ac551239a3e26b39b2225
parent3cda2df12b6a5e3c4c62415c50eb45cd1b1b63f8 (diff)
downloadNetworkManager-c7cee12189d8fe64bc9037d5b9daaf1c887e0466.tar.gz
config: make "ignore-carrier" a per-device configuration option
NetworkManager.conf already contains several per-device settings, that is, settings that have a device-spec as argument. main.ignore-carrier main.no-auto-default main.assume-ipv6ll-only keyfile.unmanged-devices Optimally, these settings should be moved to the new [device*] section. For now, only move main.ignore-carrier there. For the others it may not make sense to do so: - main.no-auto-default: is already merged with internal state from /var/lib/NetworkManager/no-auto-default.state. While NMConfig's write API would be fine to also persist and merge the no-auto-default setting, we'd still have to read the old file too. Thus, deprecating this setting gets quite cumbersome to still handle the old state file. Also, it seems a less useful setting to configure in the global configuration aside setting main.no-auto-default=*. - main.assume-ipv6ll-only: one day, I hope that we no longer assume connections at all, and this setting becomes entirely obsolete. - keyfile.unmanged-devices: this sets NM_UNMANAGED_USER_SETTINGS, which cannot be overruled via D-Bus. For a future device.managed setting we want it it to be overwritable via D-Bus by an explicit user action. Thus, a device.managed property should have a different semantic, this should be more like a device.unmanaged-force setting, which could be done.
-rw-r--r--man/NetworkManager.conf.xml65
-rw-r--r--src/nm-config-data.c7
-rw-r--r--src/nm-config.h2
3 files changed, 49 insertions, 25 deletions
diff --git a/man/NetworkManager.conf.xml b/man/NetworkManager.conf.xml
index 580bdd3c9e..9f5906efed 100644
--- a/man/NetworkManager.conf.xml
+++ b/man/NetworkManager.conf.xml
@@ -224,30 +224,12 @@ no-auto-default=*
<term><varname>ignore-carrier</varname></term>
<listitem>
<para>
- Specify devices for which NetworkManager will (partially)
- ignore the carrier state. Normally, for
- device types that support carrier-detect, such as Ethernet
- and InfiniBand, NetworkManager will only allow a
- connection to be activated on the device if carrier is
- present (ie, a cable is plugged in), and it will
- deactivate the device if carrier drops for more than a few
- seconds.
- </para>
- <para>
- Listing a device here will allow activating connections on
- that device even when it does not have carrier, provided
- that the connection uses only statically-configured IP
- addresses. Additionally, it will allow any active
- connection (whether static or dynamic) to remain active on
- the device when carrier is lost.
- </para>
- <para>
- Note that the "carrier" property of NMDevices and device D-Bus
- interfaces will still reflect the actual device state; it's just
- that NetworkManager will not make use of that information.
- </para>
- <para>See <xref linkend="device-spec"/> for the syntax how to
- specify a device.
+ This setting is deprecated for the per-device setting
+ <literal>ignore-carrier</literal> which overwrites this setting
+ if specified (See <xref linked="ignore-carrier"/>).
+ Otherwise, it is a list of matches to specify for which device
+ carrier should be ignored. See <xref linkend="device-spec"/> for the
+ syntax how to specify a device.
</para>
</listitem>
</varlistentry>
@@ -713,6 +695,38 @@ unmanaged=1
<para>
The following properties can be configured per-device.
<variablelist>
+ <varlistentry id="ignore-carrier">
+ <term><varname>ignore-carrier</varname></term>
+ <listitem>
+ <para>
+ Specify devices for which NetworkManager will (partially)
+ ignore the carrier state. Normally, for
+ device types that support carrier-detect, such as Ethernet
+ and InfiniBand, NetworkManager will only allow a
+ connection to be activated on the device if carrier is
+ present (ie, a cable is plugged in), and it will
+ deactivate the device if carrier drops for more than a few
+ seconds.
+ </para>
+ <para>
+ A device with carrier ignored will allow activating connections on
+ that device even when it does not have carrier, provided
+ that the connection uses only statically-configured IP
+ addresses. Additionally, it will allow any active
+ connection (whether static or dynamic) to remain active on
+ the device when carrier is lost.
+ </para>
+ <para>
+ Note that the "carrier" property of NMDevices and device D-Bus
+ interfaces will still reflect the actual device state; it's just
+ that NetworkManager will not make use of that information.
+ </para>
+ <para>
+ This setting overwrites the deprecated <literal>main.ignore-carrier</literal>
+ setting above.
+ </para>
+ </listitem>
+ </varlistentry>
</variablelist>
</para>
</refsect2>
@@ -1012,7 +1026,8 @@ enable=nm-version-min:1.3,nm-version-min:1.2.6,nm-version-min:1.0.16
<title>Device List Format</title>
<para>
The configuration options <literal>main.no-auto-default</literal>, <literal>main.ignore-carrier</literal>,
- and <literal>keyfile.unmanaged-devices</literal> select devices based on a list of matchings.
+ <literal>keyfile.unmanaged-devices</literal>, <literal>connection*.match-device</literal> and
+ <literal>device*.match-device</literal> select devices based on a list of matchings.
Devices can be specified using the following format:
</para>
<para>
diff --git a/src/nm-config-data.c b/src/nm-config-data.c
index 37686479c5..23c4cecdc9 100644
--- a/src/nm-config-data.c
+++ b/src/nm-config-data.c
@@ -272,9 +272,16 @@ nm_config_data_get_rc_manager (const NMConfigData *self)
gboolean
nm_config_data_get_ignore_carrier (const NMConfigData *self, NMDevice *device)
{
+ gs_free char *value = NULL;
+ gboolean has_match;
+
g_return_val_if_fail (NM_IS_CONFIG_DATA (self), FALSE);
g_return_val_if_fail (NM_IS_DEVICE (device), FALSE);
+ value = nm_config_data_get_device_config (self, NM_CONFIG_KEYFILE_KEY_DEVICE_IGNORE_CARRIER, device, &has_match);
+ if (has_match)
+ return nm_config_parse_boolean (value, FALSE);
+
return nm_device_spec_match_list (device, NM_CONFIG_DATA_GET_PRIVATE (self)->ignore_carrier);
}
diff --git a/src/nm-config.h b/src/nm-config.h
index acd0e5ff41..a75e393523 100644
--- a/src/nm-config.h
+++ b/src/nm-config.h
@@ -70,6 +70,8 @@
#define NM_CONFIG_KEYFILE_KEY_IFUPDOWN_MANAGED "managed"
#define NM_CONFIG_KEYFILE_KEY_AUDIT "audit"
+#define NM_CONFIG_KEYFILE_KEY_DEVICE_IGNORE_CARRIER "ignore-carrier"
+
#define NM_CONFIG_KEYFILE_KEYPREFIX_WAS ".was."
#define NM_CONFIG_KEYFILE_KEYPREFIX_SET ".set."