|
|
ab7d06 |
From 0a37f5cc3ebcf93e1ed52d3e5fc5f75d48518804 Mon Sep 17 00:00:00 2001
|
|
|
ab7d06 |
From: Beniamino Galvani <bgalvani@redhat.com>
|
|
|
ab7d06 |
Date: Mon, 21 Sep 2015 18:24:07 +0200
|
|
|
ab7d06 |
Subject: [PATCH 1/4] wake-on-lan: add option to keep existing settings
|
|
|
ab7d06 |
|
|
|
ab7d06 |
Add a new 'ignore' option to NMSettingWired.wake-on-lan which disables
|
|
|
ab7d06 |
management of wake-on-lan by NetworkManager (i.e. the pre-existing
|
|
|
ab7d06 |
option will not be touched). Also, change the default behavior to be
|
|
|
ab7d06 |
'ignore' instead of 'disabled'.
|
|
|
ab7d06 |
|
|
|
ab7d06 |
https://bugzilla.gnome.org/show_bug.cgi?id=755182
|
|
|
ab7d06 |
(cherry picked from commit e587dcb16eb045f55f6cba45987be75f83d0c230)
|
|
|
ab7d06 |
---
|
|
|
ab7d06 |
clients/cli/settings.c | 13 ++++++++-----
|
|
|
ab7d06 |
libnm-core/nm-setting-wired.c | 11 +++++++----
|
|
|
ab7d06 |
libnm-core/nm-setting-wired.h | 19 ++++++++++++++-----
|
|
|
ab7d06 |
src/devices/nm-device-ethernet.c | 11 +++++++++--
|
|
|
ab7d06 |
src/platform/nm-platform-utils.c | 3 +++
|
|
|
ab7d06 |
src/settings/plugins/ifcfg-rh/reader.c | 21 +++++++++++++--------
|
|
|
ab7d06 |
src/settings/plugins/ifcfg-rh/writer.c | 4 +++-
|
|
|
ab7d06 |
7 files changed, 57 insertions(+), 25 deletions(-)
|
|
|
ab7d06 |
|
|
|
ab7d06 |
diff --git a/clients/cli/settings.c b/clients/cli/settings.c
|
|
|
ab7d06 |
index 2b42eb4..efac7b2 100644
|
|
|
ab7d06 |
--- a/clients/cli/settings.c
|
|
|
ab7d06 |
+++ b/clients/cli/settings.c
|
|
|
ab7d06 |
@@ -1545,7 +1545,10 @@ nmc_property_wired_set_wake_on_lan (NMSetting *setting, const char *prop,
|
|
|
ab7d06 |
gboolean ret;
|
|
|
ab7d06 |
long int t;
|
|
|
ab7d06 |
|
|
|
ab7d06 |
- if (nmc_string_to_int_base (val, 0, TRUE, 0, NM_SETTING_WIRED_WAKE_ON_LAN_ALL, &t))
|
|
|
ab7d06 |
+ if (nmc_string_to_int_base (val, 0, TRUE, 0,
|
|
|
ab7d06 |
+ NM_SETTING_WIRED_WAKE_ON_LAN_ALL
|
|
|
ab7d06 |
+ | NM_SETTING_WIRED_WAKE_ON_LAN_EXCLUSIVE_FLAGS,
|
|
|
ab7d06 |
+ &t))
|
|
|
ab7d06 |
wol = (NMSettingWiredWakeOnLan) t;
|
|
|
ab7d06 |
else {
|
|
|
ab7d06 |
ret = nm_utils_enum_from_str (nm_setting_wired_wake_on_lan_get_type (), val,
|
|
|
ab7d06 |
@@ -1557,7 +1560,7 @@ nmc_property_wired_set_wake_on_lan (NMSetting *setting, const char *prop,
|
|
|
ab7d06 |
|| g_ascii_strcasecmp (err_token, "disabled") == 0)
|
|
|
ab7d06 |
wol = NM_SETTING_WIRED_WAKE_ON_LAN_NONE;
|
|
|
ab7d06 |
else {
|
|
|
ab7d06 |
- g_set_error (error, 1, 0, _("invalid option '%s', use a combination of [%s] or 'default' or 'none'"),
|
|
|
ab7d06 |
+ g_set_error (error, 1, 0, _("invalid option '%s', use a combination of [%s] or 'ignore', 'default' or 'none'"),
|
|
|
ab7d06 |
err_token,
|
|
|
ab7d06 |
nm_utils_enum_to_str (nm_setting_wired_wake_on_lan_get_type (),
|
|
|
ab7d06 |
NM_SETTING_WIRED_WAKE_ON_LAN_ALL));
|
|
|
ab7d06 |
@@ -1566,9 +1569,9 @@ nmc_property_wired_set_wake_on_lan (NMSetting *setting, const char *prop,
|
|
|
ab7d06 |
}
|
|
|
ab7d06 |
}
|
|
|
ab7d06 |
|
|
|
ab7d06 |
- if (NM_FLAGS_HAS (wol, NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT) &&
|
|
|
ab7d06 |
- NM_FLAGS_ANY (wol, NM_SETTING_WIRED_WAKE_ON_LAN_ALL)) {
|
|
|
ab7d06 |
- g_set_error_literal (error, 1, 0, _("'default' is incompatible with other flags"));
|
|
|
ab7d06 |
+ if ( NM_FLAGS_ANY (wol, NM_SETTING_WIRED_WAKE_ON_LAN_EXCLUSIVE_FLAGS)
|
|
|
ab7d06 |
+ && !nm_utils_is_power_of_two (wol)) {
|
|
|
ab7d06 |
+ g_set_error_literal (error, 1, 0, _("'default' and 'ignore' are incompatible with other flags"));
|
|
|
ab7d06 |
return FALSE;
|
|
|
ab7d06 |
}
|
|
|
ab7d06 |
|
|
|
ab7d06 |
diff --git a/libnm-core/nm-setting-wired.c b/libnm-core/nm-setting-wired.c
|
|
|
ab7d06 |
index 3d0c5b6..c38b187 100644
|
|
|
ab7d06 |
--- a/libnm-core/nm-setting-wired.c
|
|
|
ab7d06 |
+++ b/libnm-core/nm-setting-wired.c
|
|
|
ab7d06 |
@@ -696,12 +696,12 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
|
|
|
ab7d06 |
return FALSE;
|
|
|
ab7d06 |
}
|
|
|
ab7d06 |
|
|
|
ab7d06 |
- if ( NM_FLAGS_HAS (priv->wol, NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT)
|
|
|
ab7d06 |
- && NM_FLAGS_ANY (priv->wol, NM_SETTING_WIRED_WAKE_ON_LAN_ALL)) {
|
|
|
ab7d06 |
+ if ( NM_FLAGS_ANY (priv->wol, NM_SETTING_WIRED_WAKE_ON_LAN_EXCLUSIVE_FLAGS)
|
|
|
ab7d06 |
+ && !nm_utils_is_power_of_two (priv->wol)) {
|
|
|
ab7d06 |
g_set_error_literal (error,
|
|
|
ab7d06 |
NM_CONNECTION_ERROR,
|
|
|
ab7d06 |
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
ab7d06 |
- _("Wake-on-LAN mode 'default' is incompatible with other flags"));
|
|
|
ab7d06 |
+ _("Wake-on-LAN mode 'default' and 'ignore' are exclusive flags"));
|
|
|
ab7d06 |
g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_WAKE_ON_LAN);
|
|
|
ab7d06 |
return FALSE;
|
|
|
ab7d06 |
}
|
|
|
ab7d06 |
@@ -1190,7 +1190,10 @@ nm_setting_wired_class_init (NMSettingWiredClass *setting_class)
|
|
|
ab7d06 |
* May be any combination of %NM_SETTING_WIRED_WAKE_ON_LAN_PHY,
|
|
|
ab7d06 |
* %NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST, %NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST,
|
|
|
ab7d06 |
* %NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST, %NM_SETTING_WIRED_WAKE_ON_LAN_ARP,
|
|
|
ab7d06 |
- * %NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC.
|
|
|
ab7d06 |
+ * %NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC or the special values
|
|
|
ab7d06 |
+ * %NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT (to use global settings) and
|
|
|
ab7d06 |
+ * %NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE (to disable management of Wake-on-LAN in
|
|
|
ab7d06 |
+ * NetworkManager).
|
|
|
ab7d06 |
*
|
|
|
ab7d06 |
* Since: 1.0.6
|
|
|
ab7d06 |
**/
|
|
|
ab7d06 |
diff --git a/libnm-core/nm-setting-wired.h b/libnm-core/nm-setting-wired.h
|
|
|
ab7d06 |
index 44b7c4d..e1fd6f6 100644
|
|
|
ab7d06 |
--- a/libnm-core/nm-setting-wired.h
|
|
|
ab7d06 |
+++ b/libnm-core/nm-setting-wired.h
|
|
|
ab7d06 |
@@ -43,14 +43,19 @@ G_BEGIN_DECLS
|
|
|
ab7d06 |
/**
|
|
|
ab7d06 |
* NMSettingWiredWakeOnLan:
|
|
|
ab7d06 |
* @NM_SETTING_WIRED_WAKE_ON_LAN_NONE: Wake-on-LAN disabled
|
|
|
ab7d06 |
- * @NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT: Use the default value
|
|
|
ab7d06 |
* @NM_SETTING_WIRED_WAKE_ON_LAN_PHY: Wake on PHY activity
|
|
|
ab7d06 |
* @NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST: Wake on unicast messages
|
|
|
ab7d06 |
* @NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST: Wake on multicast messages
|
|
|
ab7d06 |
* @NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST: Wake on broadcast messages
|
|
|
ab7d06 |
* @NM_SETTING_WIRED_WAKE_ON_LAN_ARP: Wake on ARP
|
|
|
ab7d06 |
* @NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC: Wake on magic packet
|
|
|
ab7d06 |
- * @NM_SETTING_WIRED_WAKE_ON_LAN_ALL: Wake on all events
|
|
|
ab7d06 |
+ * @NM_SETTING_WIRED_WAKE_ON_LAN_ALL: Wake on all events. This does not
|
|
|
ab7d06 |
+ * include the exclusive flags @NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT or
|
|
|
ab7d06 |
+ * @NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE.
|
|
|
ab7d06 |
+ * @NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT: Use the default value
|
|
|
ab7d06 |
+ * @NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE: Don't change configured settings
|
|
|
ab7d06 |
+ * @NM_SETTING_WIRED_WAKE_ON_LAN_EXCLUSIVE_FLAGS: Mask of flags that are
|
|
|
ab7d06 |
+ * incompatible with other flags
|
|
|
ab7d06 |
*
|
|
|
ab7d06 |
* Options for #NMSettingWired:wake-on-lan. Note that not all options
|
|
|
ab7d06 |
* are supported by all devices.
|
|
|
ab7d06 |
@@ -59,15 +64,19 @@ G_BEGIN_DECLS
|
|
|
ab7d06 |
*/
|
|
|
ab7d06 |
typedef enum { /*< flags >*/
|
|
|
ab7d06 |
NM_SETTING_WIRED_WAKE_ON_LAN_NONE = 0, /*< skip >*/
|
|
|
ab7d06 |
- NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT = (1 << 0),
|
|
|
ab7d06 |
NM_SETTING_WIRED_WAKE_ON_LAN_PHY = (1 << 1),
|
|
|
ab7d06 |
NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST = (1 << 2),
|
|
|
ab7d06 |
NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST = (1 << 3),
|
|
|
ab7d06 |
NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST = (1 << 4),
|
|
|
ab7d06 |
NM_SETTING_WIRED_WAKE_ON_LAN_ARP = (1 << 5),
|
|
|
ab7d06 |
NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC = (1 << 6),
|
|
|
ab7d06 |
- _NM_SETTING_WIRED_WAKE_ON_LAN_LAST, /*< skip >*/
|
|
|
ab7d06 |
- NM_SETTING_WIRED_WAKE_ON_LAN_ALL = (((_NM_SETTING_WIRED_WAKE_ON_LAN_LAST - 1) << 1) - 1 - NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT) /*< skip >*/
|
|
|
ab7d06 |
+
|
|
|
ab7d06 |
+ _NM_SETTING_WIRED_WAKE_ON_LAN_LAST_OPT, /*< skip >*/
|
|
|
ab7d06 |
+ NM_SETTING_WIRED_WAKE_ON_LAN_ALL = (((_NM_SETTING_WIRED_WAKE_ON_LAN_LAST_OPT - 1) << 1) - 1) - (1 << 0 /*DEFAULT*/), /*< skip >*/
|
|
|
ab7d06 |
+
|
|
|
ab7d06 |
+ NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT = (1 << 0),
|
|
|
ab7d06 |
+ NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE = (1 << 15),
|
|
|
ab7d06 |
+ NM_SETTING_WIRED_WAKE_ON_LAN_EXCLUSIVE_FLAGS = NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT | NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE, /*< skip >*/
|
|
|
ab7d06 |
} NMSettingWiredWakeOnLan;
|
|
|
ab7d06 |
|
|
|
ab7d06 |
#define NM_SETTING_WIRED_PORT "port"
|
|
|
ab7d06 |
diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c
|
|
|
ab7d06 |
index beb86e1..7c0de88 100644
|
|
|
ab7d06 |
--- a/src/devices/nm-device-ethernet.c
|
|
|
ab7d06 |
+++ b/src/devices/nm-device-ethernet.c
|
|
|
ab7d06 |
@@ -1195,15 +1195,22 @@ wake_on_lan_enable (NMDevice *device)
|
|
|
ab7d06 |
value = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA,
|
|
|
ab7d06 |
"ethernet.wake-on-lan",
|
|
|
ab7d06 |
device);
|
|
|
ab7d06 |
+
|
|
|
ab7d06 |
if (value) {
|
|
|
ab7d06 |
wol = _nm_utils_ascii_str_to_int64 (value, 10,
|
|
|
ab7d06 |
NM_SETTING_WIRED_WAKE_ON_LAN_NONE,
|
|
|
ab7d06 |
- NM_SETTING_WIRED_WAKE_ON_LAN_ALL,
|
|
|
ab7d06 |
+ G_MAXINT32,
|
|
|
ab7d06 |
NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT);
|
|
|
ab7d06 |
+
|
|
|
ab7d06 |
+ if ( NM_FLAGS_ANY (wol, NM_SETTING_WIRED_WAKE_ON_LAN_EXCLUSIVE_FLAGS)
|
|
|
ab7d06 |
+ && !nm_utils_is_power_of_two (wol)) {
|
|
|
ab7d06 |
+ nm_log_dbg (LOGD_ETHER, "invalid default value %u for wake-on-lan", (guint) wol);
|
|
|
ab7d06 |
+ wol = NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT;
|
|
|
ab7d06 |
+ }
|
|
|
ab7d06 |
if (wol != NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT)
|
|
|
ab7d06 |
goto found;
|
|
|
ab7d06 |
}
|
|
|
ab7d06 |
- wol = NM_SETTING_WIRED_WAKE_ON_LAN_NONE;
|
|
|
ab7d06 |
+ wol = NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE;
|
|
|
ab7d06 |
found:
|
|
|
ab7d06 |
return nmp_utils_ethtool_set_wake_on_lan (nm_device_get_iface (device), wol, password);
|
|
|
ab7d06 |
}
|
|
|
ab7d06 |
diff --git a/src/platform/nm-platform-utils.c b/src/platform/nm-platform-utils.c
|
|
|
ab7d06 |
index 051a873..e9b8d4b 100644
|
|
|
ab7d06 |
--- a/src/platform/nm-platform-utils.c
|
|
|
ab7d06 |
+++ b/src/platform/nm-platform-utils.c
|
|
|
ab7d06 |
@@ -279,6 +279,9 @@ nmp_utils_ethtool_set_wake_on_lan (const char *ifname,
|
|
|
ab7d06 |
{
|
|
|
ab7d06 |
struct ethtool_wolinfo wol_info = { };
|
|
|
ab7d06 |
|
|
|
ab7d06 |
+ if (wol == NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE)
|
|
|
ab7d06 |
+ return TRUE;
|
|
|
ab7d06 |
+
|
|
|
ab7d06 |
nm_log_dbg (LOGD_PLATFORM, "setting Wake-on-LAN options 0x%x, password '%s'",
|
|
|
ab7d06 |
(unsigned int) wol, wol_password);
|
|
|
ab7d06 |
|
|
|
ab7d06 |
diff --git a/src/settings/plugins/ifcfg-rh/reader.c b/src/settings/plugins/ifcfg-rh/reader.c
|
|
|
ab7d06 |
index 5bba38f..845b139 100644
|
|
|
ab7d06 |
--- a/src/settings/plugins/ifcfg-rh/reader.c
|
|
|
ab7d06 |
+++ b/src/settings/plugins/ifcfg-rh/reader.c
|
|
|
ab7d06 |
@@ -3506,18 +3506,23 @@ wireless_connection_from_ifcfg (const char *file,
|
|
|
ab7d06 |
static void
|
|
|
ab7d06 |
parse_ethtool_options (shvarFile *ifcfg, NMSettingWired *s_wired, char *value)
|
|
|
ab7d06 |
{
|
|
|
ab7d06 |
- NMSettingWiredWakeOnLan wol_flags = NM_SETTING_WIRED_WAKE_ON_LAN_NONE;
|
|
|
ab7d06 |
+ NMSettingWiredWakeOnLan wol_flags = NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE;
|
|
|
ab7d06 |
gboolean use_password = FALSE;
|
|
|
ab7d06 |
- char **words, **iter, *flag;
|
|
|
ab7d06 |
+ char **words = NULL, **iter = NULL, *flag;
|
|
|
ab7d06 |
|
|
|
ab7d06 |
- if (!value || !value[0])
|
|
|
ab7d06 |
+ if (!value)
|
|
|
ab7d06 |
return;
|
|
|
ab7d06 |
|
|
|
ab7d06 |
- words = g_strsplit_set (value, " ", 0);
|
|
|
ab7d06 |
- iter = words;
|
|
|
ab7d06 |
+ if (value[0]) {
|
|
|
ab7d06 |
+ words = g_strsplit_set (value, " ", 0);
|
|
|
ab7d06 |
+ iter = words;
|
|
|
ab7d06 |
+ }
|
|
|
ab7d06 |
|
|
|
ab7d06 |
- while (iter[0]) {
|
|
|
ab7d06 |
+ while (iter && iter[0]) {
|
|
|
ab7d06 |
if (g_str_equal (iter[0], "wol") && iter[1] && *iter[1]) {
|
|
|
ab7d06 |
+
|
|
|
ab7d06 |
+ wol_flags = NM_SETTING_WIRED_WAKE_ON_LAN_NONE;
|
|
|
ab7d06 |
+
|
|
|
ab7d06 |
for (flag = iter[1]; *flag; flag++) {
|
|
|
ab7d06 |
switch (*flag) {
|
|
|
ab7d06 |
case 'p':
|
|
|
ab7d06 |
@@ -3553,7 +3558,6 @@ parse_ethtool_options (shvarFile *ifcfg, NMSettingWired *s_wired, char *value)
|
|
|
ab7d06 |
if (!NM_FLAGS_HAS (wol_flags, NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC))
|
|
|
ab7d06 |
use_password = FALSE;
|
|
|
ab7d06 |
|
|
|
ab7d06 |
- g_object_set (s_wired, NM_SETTING_WIRED_WAKE_ON_LAN, wol_flags, NULL);
|
|
|
ab7d06 |
iter += 2;
|
|
|
ab7d06 |
continue;
|
|
|
ab7d06 |
}
|
|
|
ab7d06 |
@@ -3574,6 +3578,7 @@ parse_ethtool_options (shvarFile *ifcfg, NMSettingWired *s_wired, char *value)
|
|
|
ab7d06 |
iter++;
|
|
|
ab7d06 |
}
|
|
|
ab7d06 |
|
|
|
ab7d06 |
+ g_object_set (s_wired, NM_SETTING_WIRED_WAKE_ON_LAN, wol_flags, NULL);
|
|
|
ab7d06 |
g_strfreev (words);
|
|
|
ab7d06 |
}
|
|
|
ab7d06 |
|
|
|
ab7d06 |
@@ -3712,7 +3717,7 @@ make_wired_setting (shvarFile *ifcfg,
|
|
|
ab7d06 |
g_free (value);
|
|
|
ab7d06 |
}
|
|
|
ab7d06 |
|
|
|
ab7d06 |
- value = svGetValue (ifcfg, "ETHTOOL_OPTS", FALSE);
|
|
|
ab7d06 |
+ value = svGetValueFull (ifcfg, "ETHTOOL_OPTS", FALSE);
|
|
|
ab7d06 |
parse_ethtool_options (ifcfg, s_wired, value);
|
|
|
ab7d06 |
g_free (value);
|
|
|
ab7d06 |
|
|
|
ab7d06 |
diff --git a/src/settings/plugins/ifcfg-rh/writer.c b/src/settings/plugins/ifcfg-rh/writer.c
|
|
|
ab7d06 |
index 69b7d64..4f9498b 100644
|
|
|
ab7d06 |
--- a/src/settings/plugins/ifcfg-rh/writer.c
|
|
|
ab7d06 |
+++ b/src/settings/plugins/ifcfg-rh/writer.c
|
|
|
ab7d06 |
@@ -1137,7 +1137,9 @@ write_wired_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
|
|
|
ab7d06 |
|
|
|
ab7d06 |
wol = nm_setting_wired_get_wake_on_lan (s_wired);
|
|
|
ab7d06 |
wol_password = nm_setting_wired_get_wake_on_lan_password (s_wired);
|
|
|
ab7d06 |
- if (wol == NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT)
|
|
|
ab7d06 |
+ if (wol == NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE)
|
|
|
ab7d06 |
+ svSetValueFull (ifcfg, "ETHTOOL_OPTS", "", FALSE);
|
|
|
ab7d06 |
+ else if (wol == NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT)
|
|
|
ab7d06 |
svSetValue (ifcfg, "ETHTOOL_OPTS", NULL, FALSE);
|
|
|
ab7d06 |
else {
|
|
|
ab7d06 |
str = g_string_sized_new (30);
|
|
|
ab7d06 |
--
|
|
|
ab7d06 |
2.4.3
|
|
|
ab7d06 |
|
|
|
ab7d06 |
From 4bfa6ec3f2a5579d4898b656575df17681780075 Mon Sep 17 00:00:00 2001
|
|
|
ab7d06 |
From: Thomas Haller <thaller@redhat.com>
|
|
|
ab7d06 |
Date: Thu, 24 Sep 2015 17:31:19 +0200
|
|
|
ab7d06 |
Subject: [PATCH 2/4] ifcfg-rh: improve parsing of Wake-on-LAN options
|
|
|
ab7d06 |
|
|
|
ab7d06 |
Initscripts do:
|
|
|
ab7d06 |
oldifs=$IFS;
|
|
|
ab7d06 |
IFS=';';
|
|
|
ab7d06 |
[ -n "${ETHTOOL_DELAY}" ] && /bin/usleep ${ETHTOOL_DELAY}
|
|
|
ab7d06 |
for opts in $ETHTOOL_OPTS ; do
|
|
|
ab7d06 |
IFS=$oldifs;
|
|
|
ab7d06 |
if [[ "${opts}" =~ [[:space:]]*- ]]; then
|
|
|
ab7d06 |
/sbin/ethtool $opts
|
|
|
ab7d06 |
else
|
|
|
ab7d06 |
/sbin/ethtool -s ${REALDEVICE} $opts
|
|
|
ab7d06 |
fi
|
|
|
ab7d06 |
IFS=';';
|
|
|
ab7d06 |
done
|
|
|
ab7d06 |
IFS=$oldifs;
|
|
|
ab7d06 |
|
|
|
ab7d06 |
thus, we want to split on ';', otherwise we parse
|
|
|
ab7d06 |
"wol d;something else"
|
|
|
ab7d06 |
wrong.
|
|
|
ab7d06 |
|
|
|
ab7d06 |
Also, g_strsplit_set() returns multiple empty tokens. So
|
|
|
ab7d06 |
we must skip over empty tokens in case of "wol d".
|
|
|
ab7d06 |
|
|
|
ab7d06 |
The @use_password was wrong, because we would warn if sopass is specified
|
|
|
ab7d06 |
before wol:
|
|
|
ab7d06 |
"sopass AA:BB:CC:DD:EE:FF wol g"
|
|
|
ab7d06 |
|
|
|
ab7d06 |
More resilently handle wrong configurations:
|
|
|
ab7d06 |
"wol pu wol m" => gives m.
|
|
|
ab7d06 |
"wol pu wol" => should give NONE and warn (instead of "pu").
|
|
|
ab7d06 |
|
|
|
ab7d06 |
Also accept tab as separator.
|
|
|
ab7d06 |
|
|
|
ab7d06 |
(cherry picked from commit bd1c0086bd17e8ff2852eec530d48dc3136e915b)
|
|
|
ab7d06 |
---
|
|
|
ab7d06 |
src/settings/plugins/ifcfg-rh/reader.c | 114 +++++++++++++++------
|
|
|
ab7d06 |
.../plugins/ifcfg-rh/tests/test-ifcfg-rh.c | 3 +-
|
|
|
ab7d06 |
2 files changed, 81 insertions(+), 36 deletions(-)
|
|
|
ab7d06 |
|
|
|
ab7d06 |
diff --git a/src/settings/plugins/ifcfg-rh/reader.c b/src/settings/plugins/ifcfg-rh/reader.c
|
|
|
ab7d06 |
index 845b139..e45ad63 100644
|
|
|
ab7d06 |
--- a/src/settings/plugins/ifcfg-rh/reader.c
|
|
|
ab7d06 |
+++ b/src/settings/plugins/ifcfg-rh/reader.c
|
|
|
ab7d06 |
@@ -3504,26 +3504,49 @@ wireless_connection_from_ifcfg (const char *file,
|
|
|
ab7d06 |
}
|
|
|
ab7d06 |
|
|
|
ab7d06 |
static void
|
|
|
ab7d06 |
-parse_ethtool_options (shvarFile *ifcfg, NMSettingWired *s_wired, char *value)
|
|
|
ab7d06 |
+parse_ethtool_option (const char *value, NMSettingWiredWakeOnLan *out_flags, char **out_password)
|
|
|
ab7d06 |
{
|
|
|
ab7d06 |
- NMSettingWiredWakeOnLan wol_flags = NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE;
|
|
|
ab7d06 |
- gboolean use_password = FALSE;
|
|
|
ab7d06 |
- char **words = NULL, **iter = NULL, *flag;
|
|
|
ab7d06 |
+ gs_strfreev char **words = NULL;
|
|
|
ab7d06 |
+ const char **iter = NULL, *flag;
|
|
|
ab7d06 |
+ gboolean has_flags = FALSE;
|
|
|
ab7d06 |
+ gboolean has_password = FALSE;
|
|
|
ab7d06 |
|
|
|
ab7d06 |
- if (!value)
|
|
|
ab7d06 |
+ if (!value || !value[0])
|
|
|
ab7d06 |
return;
|
|
|
ab7d06 |
|
|
|
ab7d06 |
- if (value[0]) {
|
|
|
ab7d06 |
- words = g_strsplit_set (value, " ", 0);
|
|
|
ab7d06 |
- iter = words;
|
|
|
ab7d06 |
- }
|
|
|
ab7d06 |
+ words = g_strsplit_set (value, "\t ", 0);
|
|
|
ab7d06 |
+ iter = (const char **) words;
|
|
|
ab7d06 |
+
|
|
|
ab7d06 |
+ while (iter[0]) {
|
|
|
ab7d06 |
+ gboolean is_wol;
|
|
|
ab7d06 |
+
|
|
|
ab7d06 |
+ if (g_str_equal (iter[0], "wol"))
|
|
|
ab7d06 |
+ is_wol = TRUE;
|
|
|
ab7d06 |
+ else if (g_str_equal (iter[0], "sopass"))
|
|
|
ab7d06 |
+ is_wol = FALSE;
|
|
|
ab7d06 |
+ else {
|
|
|
ab7d06 |
+ /* Silently skip unknown options */
|
|
|
ab7d06 |
+ iter++;
|
|
|
ab7d06 |
+ continue;
|
|
|
ab7d06 |
+ }
|
|
|
ab7d06 |
+
|
|
|
ab7d06 |
+ iter++;
|
|
|
ab7d06 |
+
|
|
|
ab7d06 |
+ /* g_strsplit_set() returns empty tokens, meaning that we must skip over repeated
|
|
|
ab7d06 |
+ * space characters like to parse "wol d". */
|
|
|
ab7d06 |
+ while (iter[0] && !*iter[0])
|
|
|
ab7d06 |
+ iter++;
|
|
|
ab7d06 |
|
|
|
ab7d06 |
- while (iter && iter[0]) {
|
|
|
ab7d06 |
- if (g_str_equal (iter[0], "wol") && iter[1] && *iter[1]) {
|
|
|
ab7d06 |
+ if (is_wol) {
|
|
|
ab7d06 |
+ NMSettingWiredWakeOnLan wol_flags = NM_SETTING_WIRED_WAKE_ON_LAN_NONE;
|
|
|
ab7d06 |
+ has_flags = TRUE;
|
|
|
ab7d06 |
|
|
|
ab7d06 |
- wol_flags = NM_SETTING_WIRED_WAKE_ON_LAN_NONE;
|
|
|
ab7d06 |
+ if (!iter[0]) {
|
|
|
ab7d06 |
+ PARSE_WARNING ("Wake-on-LAN options missing");
|
|
|
ab7d06 |
+ break;
|
|
|
ab7d06 |
+ }
|
|
|
ab7d06 |
|
|
|
ab7d06 |
- for (flag = iter[1]; *flag; flag++) {
|
|
|
ab7d06 |
+ for (flag = iter[0]; *flag; flag++) {
|
|
|
ab7d06 |
switch (*flag) {
|
|
|
ab7d06 |
case 'p':
|
|
|
ab7d06 |
wol_flags |= NM_SETTING_WIRED_WAKE_ON_LAN_PHY;
|
|
|
ab7d06 |
@@ -3544,42 +3567,65 @@ parse_ethtool_options (shvarFile *ifcfg, NMSettingWired *s_wired, char *value)
|
|
|
ab7d06 |
wol_flags |= NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC;
|
|
|
ab7d06 |
break;
|
|
|
ab7d06 |
case 's':
|
|
|
ab7d06 |
- use_password = TRUE;
|
|
|
ab7d06 |
break;
|
|
|
ab7d06 |
case 'd':
|
|
|
ab7d06 |
wol_flags = NM_SETTING_WIRED_WAKE_ON_LAN_NONE;
|
|
|
ab7d06 |
- use_password = FALSE;
|
|
|
ab7d06 |
break;
|
|
|
ab7d06 |
default:
|
|
|
ab7d06 |
PARSE_WARNING ("unrecognized Wake-on-LAN option '%c'", *flag);
|
|
|
ab7d06 |
}
|
|
|
ab7d06 |
}
|
|
|
ab7d06 |
|
|
|
ab7d06 |
- if (!NM_FLAGS_HAS (wol_flags, NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC))
|
|
|
ab7d06 |
- use_password = FALSE;
|
|
|
ab7d06 |
+ *out_flags = wol_flags;
|
|
|
ab7d06 |
+ } else {
|
|
|
ab7d06 |
+ has_password = TRUE;
|
|
|
ab7d06 |
|
|
|
ab7d06 |
- iter += 2;
|
|
|
ab7d06 |
- continue;
|
|
|
ab7d06 |
- }
|
|
|
ab7d06 |
+ if (!iter[0]) {
|
|
|
ab7d06 |
+ PARSE_WARNING ("Wake-on-LAN password missing");
|
|
|
ab7d06 |
+ break;
|
|
|
ab7d06 |
+ }
|
|
|
ab7d06 |
|
|
|
ab7d06 |
- if (g_str_equal (iter[0], "sopass") && iter[1] && *iter[1]) {
|
|
|
ab7d06 |
- if (use_password) {
|
|
|
ab7d06 |
- if (nm_utils_hwaddr_valid (iter[1], ETH_ALEN))
|
|
|
ab7d06 |
- g_object_set (s_wired, NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD, iter[1], NULL);
|
|
|
ab7d06 |
- else
|
|
|
ab7d06 |
- PARSE_WARNING ("Wake-on-LAN password '%s' is invalid", iter[1]);
|
|
|
ab7d06 |
- } else
|
|
|
ab7d06 |
- PARSE_WARNING ("Wake-on-LAN password not expected");
|
|
|
ab7d06 |
- iter += 2;
|
|
|
ab7d06 |
- continue;
|
|
|
ab7d06 |
- }
|
|
|
ab7d06 |
|
|
|
ab7d06 |
- /* Silently skip unknown options */
|
|
|
ab7d06 |
+ g_clear_pointer (out_password, g_free);
|
|
|
ab7d06 |
+ if (nm_utils_hwaddr_valid (iter[0], ETH_ALEN))
|
|
|
ab7d06 |
+ *out_password = g_strdup (iter[0]);
|
|
|
ab7d06 |
+ else
|
|
|
ab7d06 |
+ PARSE_WARNING ("Wake-on-LAN password '%s' is invalid", iter[0]);
|
|
|
ab7d06 |
+ }
|
|
|
ab7d06 |
iter++;
|
|
|
ab7d06 |
}
|
|
|
ab7d06 |
+}
|
|
|
ab7d06 |
+
|
|
|
ab7d06 |
+static void
|
|
|
ab7d06 |
+parse_ethtool_options (shvarFile *ifcfg, NMSettingWired *s_wired, const char *value)
|
|
|
ab7d06 |
+{
|
|
|
ab7d06 |
+ NMSettingWiredWakeOnLan wol_flags = NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT;
|
|
|
ab7d06 |
+ gs_free char *wol_password = NULL;
|
|
|
ab7d06 |
+ gboolean ignore_wol_password = FALSE;
|
|
|
ab7d06 |
+
|
|
|
ab7d06 |
+ if (value) {
|
|
|
ab7d06 |
+ gs_strfreev char **opts = NULL;
|
|
|
ab7d06 |
+ const char **iter;
|
|
|
ab7d06 |
+
|
|
|
ab7d06 |
+ wol_flags = NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE;
|
|
|
ab7d06 |
+
|
|
|
ab7d06 |
+ opts = g_strsplit_set (value, ";", 0);
|
|
|
ab7d06 |
+ for (iter = (const char **) opts; iter[0]; iter++) {
|
|
|
ab7d06 |
+ /* in case of repeated wol_passwords, parse_ethtool_option()
|
|
|
ab7d06 |
+ * will do the right thing and clear wol_password before resetting. */
|
|
|
ab7d06 |
+ parse_ethtool_option (iter[0], &wol_flags, &wol_password);
|
|
|
ab7d06 |
+ }
|
|
|
ab7d06 |
+ }
|
|
|
ab7d06 |
|
|
|
ab7d06 |
- g_object_set (s_wired, NM_SETTING_WIRED_WAKE_ON_LAN, wol_flags, NULL);
|
|
|
ab7d06 |
- g_strfreev (words);
|
|
|
ab7d06 |
+ if ( wol_password
|
|
|
ab7d06 |
+ && !NM_FLAGS_HAS (wol_flags, NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC)) {
|
|
|
ab7d06 |
+ PARSE_WARNING ("Wake-on-LAN password not expected");
|
|
|
ab7d06 |
+ ignore_wol_password = TRUE;
|
|
|
ab7d06 |
+ }
|
|
|
ab7d06 |
+ g_object_set (s_wired,
|
|
|
ab7d06 |
+ NM_SETTING_WIRED_WAKE_ON_LAN, wol_flags,
|
|
|
ab7d06 |
+ NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD, ignore_wol_password ? NULL : wol_password,
|
|
|
ab7d06 |
+ NULL);
|
|
|
ab7d06 |
}
|
|
|
ab7d06 |
|
|
|
ab7d06 |
static NMSetting *
|
|
|
ab7d06 |
diff --git a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
|
|
|
ab7d06 |
index f42dbf4..42a91d3 100644
|
|
|
ab7d06 |
--- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
|
|
|
ab7d06 |
+++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
|
|
|
ab7d06 |
@@ -6122,8 +6122,7 @@ test_write_wired_static (void)
|
|
|
ab7d06 |
g_assert_cmpint (nm_setting_ip_config_get_route_metric (reread_s_ip4), ==, 204);
|
|
|
ab7d06 |
g_assert_cmpint (nm_setting_ip_config_get_route_metric (reread_s_ip6), ==, 206);
|
|
|
ab7d06 |
|
|
|
ab7d06 |
- ASSERT (nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT) == TRUE,
|
|
|
ab7d06 |
- "wired-static-write", "written and re-read connection weren't the same.");
|
|
|
ab7d06 |
+ nmtst_assert_connection_equals (connection, FALSE, reread, FALSE);
|
|
|
ab7d06 |
|
|
|
ab7d06 |
route6file = utils_get_route6_path (testfile);
|
|
|
ab7d06 |
unlink (route6file);
|
|
|
ab7d06 |
--
|
|
|
ab7d06 |
2.4.3
|
|
|
ab7d06 |
|
|
|
ab7d06 |
From 88b1515f3eaafa357763d827f4fbd1be302a7ec4 Mon Sep 17 00:00:00 2001
|
|
|
ab7d06 |
From: Thomas Haller <thaller@redhat.com>
|
|
|
ab7d06 |
Date: Tue, 20 Oct 2015 17:39:35 +0200
|
|
|
ab7d06 |
Subject: [PATCH 3/4] ifcfg-rh: remove unused variable in
|
|
|
ab7d06 |
parse_ethtool_option()
|
|
|
ab7d06 |
|
|
|
ab7d06 |
(cherry picked from commit f840d9465f83ed1a5c559c2bd340068782c7d72e)
|
|
|
ab7d06 |
---
|
|
|
ab7d06 |
src/settings/plugins/ifcfg-rh/reader.c | 4 ----
|
|
|
ab7d06 |
1 file changed, 4 deletions(-)
|
|
|
ab7d06 |
|
|
|
ab7d06 |
diff --git a/src/settings/plugins/ifcfg-rh/reader.c b/src/settings/plugins/ifcfg-rh/reader.c
|
|
|
ab7d06 |
index e45ad63..90706b5 100644
|
|
|
ab7d06 |
--- a/src/settings/plugins/ifcfg-rh/reader.c
|
|
|
ab7d06 |
+++ b/src/settings/plugins/ifcfg-rh/reader.c
|
|
|
ab7d06 |
@@ -3509,7 +3509,6 @@ parse_ethtool_option (const char *value, NMSettingWiredWakeOnLan *out_flags, cha
|
|
|
ab7d06 |
gs_strfreev char **words = NULL;
|
|
|
ab7d06 |
const char **iter = NULL, *flag;
|
|
|
ab7d06 |
gboolean has_flags = FALSE;
|
|
|
ab7d06 |
- gboolean has_password = FALSE;
|
|
|
ab7d06 |
|
|
|
ab7d06 |
if (!value || !value[0])
|
|
|
ab7d06 |
return;
|
|
|
ab7d06 |
@@ -3578,14 +3577,11 @@ parse_ethtool_option (const char *value, NMSettingWiredWakeOnLan *out_flags, cha
|
|
|
ab7d06 |
|
|
|
ab7d06 |
*out_flags = wol_flags;
|
|
|
ab7d06 |
} else {
|
|
|
ab7d06 |
- has_password = TRUE;
|
|
|
ab7d06 |
-
|
|
|
ab7d06 |
if (!iter[0]) {
|
|
|
ab7d06 |
PARSE_WARNING ("Wake-on-LAN password missing");
|
|
|
ab7d06 |
break;
|
|
|
ab7d06 |
}
|
|
|
ab7d06 |
|
|
|
ab7d06 |
-
|
|
|
ab7d06 |
g_clear_pointer (out_password, g_free);
|
|
|
ab7d06 |
if (nm_utils_hwaddr_valid (iter[0], ETH_ALEN))
|
|
|
ab7d06 |
*out_password = g_strdup (iter[0]);
|
|
|
ab7d06 |
--
|
|
|
ab7d06 |
2.4.3
|
|
|
ab7d06 |
|
|
|
ab7d06 |
From 446320300b87105f65285d1b04643ee7c2583010 Mon Sep 17 00:00:00 2001
|
|
|
ab7d06 |
From: Thomas Haller <thaller@redhat.com>
|
|
|
ab7d06 |
Date: Tue, 20 Oct 2015 17:42:59 +0200
|
|
|
ab7d06 |
Subject: [PATCH 4/4] ifcfg-rh: remove another unused variable in
|
|
|
ab7d06 |
parse_ethtool_option()
|
|
|
ab7d06 |
|
|
|
ab7d06 |
(cherry picked from commit 58fc4381ff718a009fe7eb72a42a9c22e0b0a56a)
|
|
|
ab7d06 |
---
|
|
|
ab7d06 |
src/settings/plugins/ifcfg-rh/reader.c | 2 --
|
|
|
ab7d06 |
1 file changed, 2 deletions(-)
|
|
|
ab7d06 |
|
|
|
ab7d06 |
diff --git a/src/settings/plugins/ifcfg-rh/reader.c b/src/settings/plugins/ifcfg-rh/reader.c
|
|
|
ab7d06 |
index 90706b5..a1b2813 100644
|
|
|
ab7d06 |
--- a/src/settings/plugins/ifcfg-rh/reader.c
|
|
|
ab7d06 |
+++ b/src/settings/plugins/ifcfg-rh/reader.c
|
|
|
ab7d06 |
@@ -3508,7 +3508,6 @@ parse_ethtool_option (const char *value, NMSettingWiredWakeOnLan *out_flags, cha
|
|
|
ab7d06 |
{
|
|
|
ab7d06 |
gs_strfreev char **words = NULL;
|
|
|
ab7d06 |
const char **iter = NULL, *flag;
|
|
|
ab7d06 |
- gboolean has_flags = FALSE;
|
|
|
ab7d06 |
|
|
|
ab7d06 |
if (!value || !value[0])
|
|
|
ab7d06 |
return;
|
|
|
ab7d06 |
@@ -3538,7 +3537,6 @@ parse_ethtool_option (const char *value, NMSettingWiredWakeOnLan *out_flags, cha
|
|
|
ab7d06 |
|
|
|
ab7d06 |
if (is_wol) {
|
|
|
ab7d06 |
NMSettingWiredWakeOnLan wol_flags = NM_SETTING_WIRED_WAKE_ON_LAN_NONE;
|
|
|
ab7d06 |
- has_flags = TRUE;
|
|
|
ab7d06 |
|
|
|
ab7d06 |
if (!iter[0]) {
|
|
|
ab7d06 |
PARSE_WARNING ("Wake-on-LAN options missing");
|
|
|
ab7d06 |
--
|
|
|
ab7d06 |
2.4.3
|
|
|
ab7d06 |
|