summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/devices/nm-device.c90
1 files changed, 35 insertions, 55 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 9b018ccc8c..aae1949887 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -950,50 +950,6 @@ _ethtool_coalesce_set (NMDevice *self,
_LOGD (LOGD_DEVICE, "ethtool: coalesce settings successfully set");
}
-static gboolean
-_ethtool_init_ring (NMDevice *self,
- NMPlatform *platform,
- NMSettingEthtool *s_ethtool,
- NMEthtoolRingState *ring)
-{
- GHashTable *hash;
- GHashTableIter iter;
- const char *name;
- GVariant *variant;
- gsize n_ring_set = 0;
-
- nm_assert (self);
- nm_assert (platform);
- nm_assert (ring);
- nm_assert (NM_IS_SETTING_ETHTOOL (s_ethtool));
-
- hash = _nm_setting_option_hash (NM_SETTING (s_ethtool), FALSE);
- if (!hash)
- return FALSE;
-
- g_hash_table_iter_init (&iter, hash);
- while (g_hash_table_iter_next (&iter, (gpointer *) &name, (gpointer *) &variant)) {
- if (!g_variant_is_of_type (variant, G_VARIANT_TYPE_UINT32))
- continue;
- if (!nm_ethtool_optname_is_ring (name))
- continue;
-
- if (!nm_platform_ethtool_init_ring (platform,
- ring,
- name,
- g_variant_get_uint32(variant))) {
- _LOGW (LOGD_DEVICE, "ethtool: invalid ring setting %s", name);
- return FALSE;
- }
- ++n_ring_set;
-
- }
-
- return !!n_ring_set;
-}
-
-
-
static void
_ethtool_ring_reset (NMDevice *self,
NMPlatform *platform,
@@ -1025,25 +981,49 @@ _ethtool_ring_set (NMDevice *self,
{
NMEthtoolRingState ring_old;
NMEthtoolRingState ring_new;
+ GHashTable *hash;
+ GHashTableIter iter;
+ const char *name;
+ GVariant *variant;
+ gboolean has_old = FALSE;
- nm_assert (ethtool_state);
nm_assert (NM_IS_DEVICE (self));
nm_assert (NM_IS_PLATFORM (platform));
nm_assert (NM_IS_SETTING_ETHTOOL (s_ethtool));
+ nm_assert (ethtool_state);
+ nm_assert (!ethtool_state->ring);
- if (!nm_platform_ethtool_get_link_ring (platform,
- ethtool_state->ifindex,
- &ring_old)) {
- _LOGW (LOGD_DEVICE, "ethtool: failure getting ring settings (cannot read)");
+ hash = _nm_setting_option_hash (NM_SETTING (s_ethtool), FALSE);
+ if (!hash)
return;
- }
- ring_new = ring_old;
+ g_hash_table_iter_init (&iter, hash);
+ while (g_hash_table_iter_next (&iter, (gpointer *) &name, (gpointer *) &variant)) {
+ if (!nm_ethtool_optname_is_ring (name))
+ continue;
+ nm_assert (g_variant_is_of_type (variant, G_VARIANT_TYPE_UINT32));
+
+ if (!has_old) {
+ if (!nm_platform_ethtool_get_link_ring (platform,
+ ethtool_state->ifindex,
+ &ring_old)) {
+ _LOGW (LOGD_DEVICE, "ethtool: failure setting ring options (cannot read existing setting)");
+ return;
+ }
+ has_old = TRUE;
+ ring_new = ring_old;
+ }
- if (!_ethtool_init_ring (self,
- platform,
- s_ethtool,
- &ring_new))
+ if (!nm_platform_ethtool_init_ring (platform,
+ &ring_new,
+ name,
+ g_variant_get_uint32 (variant))) {
+ _LOGW (LOGD_DEVICE, "ethtool: invalid ring setting %s", name);
+ return;
+ }
+ }
+
+ if (!has_old)
return;
ethtool_state->ring = nm_memdup (&ring_old, sizeof (ring_old));