all: avoid (soon to be) deprecated API instead of nm_setting_option*()
This commit is contained in:
@@ -4097,78 +4097,57 @@ _gobject_enum_pre_set_notify_fcn_wireless_security_wep_key_type (const NMMetaPro
|
||||
static gconstpointer
|
||||
_get_fcn_ethtool (ARGS_GET_FCN)
|
||||
{
|
||||
char *return_str;
|
||||
guint32 u32;
|
||||
NMEthtoolID ethtool_id = property_info->property_typ_data->subtype.ethtool.ethtool_id;
|
||||
const char *s;
|
||||
guint32 u32;
|
||||
gboolean b;
|
||||
|
||||
RETURN_UNSUPPORTED_GET_TYPE ();
|
||||
|
||||
if (nm_ethtool_id_is_coalesce (ethtool_id)) {
|
||||
if (!nm_setting_ethtool_get_coalesce (NM_SETTING_ETHTOOL (setting),
|
||||
if ( nm_ethtool_id_is_coalesce (ethtool_id)
|
||||
|| nm_ethtool_id_is_ring (ethtool_id)) {
|
||||
if (!nm_setting_option_get_uint32 (setting,
|
||||
nm_ethtool_data[ethtool_id]->optname,
|
||||
&u32)) {
|
||||
NM_SET_OUT (out_is_default, TRUE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return_str = g_strdup_printf ("%"G_GUINT32_FORMAT, u32);
|
||||
RETURN_STR_TO_FREE (return_str);
|
||||
} else if (nm_ethtool_id_is_feature (ethtool_id)) {
|
||||
const char *s;
|
||||
NMTernary val;
|
||||
|
||||
val = nm_setting_ethtool_get_feature (NM_SETTING_ETHTOOL (setting),
|
||||
nm_ethtool_data[ethtool_id]->optname);
|
||||
|
||||
if (val == NM_TERNARY_TRUE)
|
||||
s = N_("on");
|
||||
else if (val == NM_TERNARY_FALSE)
|
||||
s = N_("off");
|
||||
else {
|
||||
s = NULL;
|
||||
NM_SET_OUT (out_is_default, TRUE);
|
||||
RETURN_STR_TO_FREE (nm_strdup_int (u32));
|
||||
}
|
||||
|
||||
if (s && get_type == NM_META_ACCESSOR_GET_TYPE_PRETTY)
|
||||
nm_assert (nm_ethtool_id_is_feature (ethtool_id));
|
||||
|
||||
if (!nm_setting_option_get_boolean (setting,
|
||||
nm_ethtool_data[ethtool_id]->optname,
|
||||
&b)) {
|
||||
NM_SET_OUT (out_is_default, TRUE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
s = b
|
||||
? N_("on")
|
||||
: N_("off");
|
||||
if (get_type == NM_META_ACCESSOR_GET_TYPE_PRETTY)
|
||||
s = gettext (s);
|
||||
return s;
|
||||
} else if (nm_ethtool_id_is_ring (ethtool_id)) {
|
||||
if (!nm_setting_ethtool_get_ring (NM_SETTING_ETHTOOL (setting),
|
||||
nm_ethtool_data[ethtool_id]->optname,
|
||||
&u32)) {
|
||||
NM_SET_OUT (out_is_default, TRUE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return_str = g_strdup_printf ("%"G_GUINT32_FORMAT, u32);
|
||||
RETURN_STR_TO_FREE (return_str);
|
||||
}
|
||||
nm_assert_not_reached();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_set_fcn_ethtool (ARGS_SET_FCN)
|
||||
{
|
||||
gint64 i64;
|
||||
NMEthtoolID ethtool_id = property_info->property_typ_data->subtype.ethtool.ethtool_id;
|
||||
NMEthtoolType ethtool_type = nm_ethtool_id_to_type (ethtool_id);
|
||||
gs_free char *value_to_free = NULL;
|
||||
gint64 i64;
|
||||
gboolean b;
|
||||
|
||||
if (NM_IN_SET (ethtool_type,
|
||||
NM_ETHTOOL_TYPE_COALESCE,
|
||||
NM_ETHTOOL_TYPE_RING)) {
|
||||
if (_SET_FCN_DO_RESET_DEFAULT (property_info, modifier, value)) {
|
||||
if (ethtool_type == NM_ETHTOOL_TYPE_COALESCE)
|
||||
nm_setting_ethtool_clear_coalesce (NM_SETTING_ETHTOOL (setting),
|
||||
nm_ethtool_data[ethtool_id]->optname);
|
||||
else
|
||||
nm_setting_ethtool_clear_ring (NM_SETTING_ETHTOOL (setting),
|
||||
nm_ethtool_data[ethtool_id]->optname);
|
||||
return TRUE;
|
||||
}
|
||||
if (_SET_FCN_DO_RESET_DEFAULT (property_info, modifier, value))
|
||||
goto do_unset;
|
||||
|
||||
if ( nm_ethtool_id_is_coalesce (ethtool_id)
|
||||
|| nm_ethtool_id_is_ring (ethtool_id)) {
|
||||
|
||||
i64 = _nm_utils_ascii_str_to_int64 (value, 10, 0, G_MAXUINT32, -1);
|
||||
|
||||
if (i64 == -1) {
|
||||
g_set_error (error, NM_UTILS_ERROR, NM_UTILS_ERROR_INVALID_ARGUMENT,
|
||||
_("'%s' is out of range [%"G_GUINT32_FORMAT", %"G_GUINT32_FORMAT"]"),
|
||||
@@ -4176,34 +4155,21 @@ _set_fcn_ethtool (ARGS_SET_FCN)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (ethtool_type == NM_ETHTOOL_TYPE_COALESCE)
|
||||
nm_setting_ethtool_set_coalesce (NM_SETTING_ETHTOOL (setting),
|
||||
nm_setting_option_set_uint32 (setting,
|
||||
nm_ethtool_data[ethtool_id]->optname,
|
||||
(guint32) i64);
|
||||
else
|
||||
nm_setting_ethtool_set_ring (NM_SETTING_ETHTOOL (setting),
|
||||
nm_ethtool_data[ethtool_id]->optname,
|
||||
(guint32) i64);
|
||||
i64);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (ethtool_type == NM_ETHTOOL_TYPE_FEATURE) {
|
||||
gs_free char *value_to_free = NULL;
|
||||
NMTernary val;
|
||||
|
||||
if (_SET_FCN_DO_RESET_DEFAULT (property_info, modifier, value)) {
|
||||
val = NM_TERNARY_DEFAULT;
|
||||
goto set;
|
||||
}
|
||||
nm_assert (nm_ethtool_id_is_feature (ethtool_id));
|
||||
|
||||
value = nm_strstrip_avoid_copy_a (300, value, &value_to_free);
|
||||
|
||||
if (NM_IN_STRSET (value, "1", "yes", "true", "on"))
|
||||
val = NM_TERNARY_TRUE;
|
||||
b = TRUE;
|
||||
else if (NM_IN_STRSET (value, "0", "no", "false", "off"))
|
||||
val = NM_TERNARY_FALSE;
|
||||
b = FALSE;
|
||||
else if (NM_IN_STRSET (value, "", "ignore", "default"))
|
||||
val = NM_TERNARY_DEFAULT;
|
||||
goto do_unset;
|
||||
else {
|
||||
g_set_error (error, NM_UTILS_ERROR, NM_UTILS_ERROR_INVALID_ARGUMENT,
|
||||
_("'%s' is not valid; use 'on', 'off', or 'ignore'"),
|
||||
@@ -4211,18 +4177,16 @@ _set_fcn_ethtool (ARGS_SET_FCN)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
set:
|
||||
nm_setting_ethtool_set_feature (NM_SETTING_ETHTOOL (setting),
|
||||
nm_setting_option_set_boolean (setting,
|
||||
nm_ethtool_data[ethtool_id]->optname,
|
||||
val);
|
||||
b);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
nm_assert_not_reached();
|
||||
|
||||
g_set_error (error, NM_UTILS_ERROR, NM_UTILS_ERROR_SETTING_MISSING,
|
||||
_("ethtool property not supported"));
|
||||
return FALSE;
|
||||
do_unset:
|
||||
nm_setting_option_set (setting,
|
||||
nm_ethtool_data[ethtool_id]->optname,
|
||||
NULL);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static const char *const*
|
||||
|
@@ -1498,6 +1498,52 @@ test_team_setting (void)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
_setting_ethtool_set_feature (NMSettingEthtool *s_ethtool,
|
||||
const char *opt_name,
|
||||
NMTernary value)
|
||||
{
|
||||
g_assert (NM_IS_SETTING_ETHTOOL (s_ethtool));
|
||||
|
||||
if (nmtst_get_rand_bool ()) {
|
||||
nm_setting_ethtool_set_feature (s_ethtool, opt_name, value);
|
||||
return;
|
||||
}
|
||||
|
||||
if (value == NM_TERNARY_DEFAULT) {
|
||||
nm_setting_option_set (NM_SETTING (s_ethtool), opt_name, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (nmtst_get_rand_bool ())
|
||||
nm_setting_option_set_boolean (NM_SETTING (s_ethtool), opt_name, value);
|
||||
else
|
||||
nm_setting_option_set (NM_SETTING (s_ethtool), opt_name, g_variant_new_boolean (value));
|
||||
}
|
||||
|
||||
static NMTernary
|
||||
_setting_ethtool_get_feature (NMSettingEthtool *s_ethtool,
|
||||
const char *opt_name)
|
||||
{
|
||||
GVariant *v;
|
||||
gboolean b;
|
||||
|
||||
switch (nmtst_get_rand_uint32 () % 3) {
|
||||
case 0:
|
||||
return nm_setting_ethtool_get_feature (s_ethtool, opt_name);
|
||||
case 1:
|
||||
if (!nm_setting_option_get_boolean (NM_SETTING (s_ethtool), opt_name, &b))
|
||||
return NM_TERNARY_DEFAULT;
|
||||
return b;
|
||||
default:
|
||||
v = nm_setting_option_get (NM_SETTING (s_ethtool), opt_name);
|
||||
if ( !v
|
||||
|| !g_variant_is_of_type (v, G_VARIANT_TYPE_BOOLEAN))
|
||||
return NM_TERNARY_DEFAULT;
|
||||
return g_variant_get_boolean (v);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
test_ethtool_features (void)
|
||||
{
|
||||
@@ -1519,16 +1565,16 @@ test_ethtool_features (void)
|
||||
s_ethtool = NM_SETTING_ETHTOOL (nm_setting_ethtool_new ());
|
||||
nm_connection_add_setting (con, NM_SETTING (s_ethtool));
|
||||
|
||||
nm_setting_ethtool_set_feature (s_ethtool,
|
||||
_setting_ethtool_set_feature (s_ethtool,
|
||||
NM_ETHTOOL_OPTNAME_FEATURE_RX,
|
||||
NM_TERNARY_TRUE);
|
||||
nm_setting_ethtool_set_feature (s_ethtool,
|
||||
_setting_ethtool_set_feature (s_ethtool,
|
||||
NM_ETHTOOL_OPTNAME_FEATURE_LRO,
|
||||
NM_TERNARY_FALSE);
|
||||
|
||||
g_assert_cmpint (nm_setting_ethtool_get_feature (s_ethtool, NM_ETHTOOL_OPTNAME_FEATURE_RX), ==, NM_TERNARY_TRUE);
|
||||
g_assert_cmpint (nm_setting_ethtool_get_feature (s_ethtool, NM_ETHTOOL_OPTNAME_FEATURE_LRO), ==, NM_TERNARY_FALSE);
|
||||
g_assert_cmpint (nm_setting_ethtool_get_feature (s_ethtool, NM_ETHTOOL_OPTNAME_FEATURE_SG), ==, NM_TERNARY_DEFAULT);
|
||||
g_assert_cmpint (_setting_ethtool_get_feature (s_ethtool, NM_ETHTOOL_OPTNAME_FEATURE_RX), ==, NM_TERNARY_TRUE);
|
||||
g_assert_cmpint (_setting_ethtool_get_feature (s_ethtool, NM_ETHTOOL_OPTNAME_FEATURE_LRO), ==, NM_TERNARY_FALSE);
|
||||
g_assert_cmpint (_setting_ethtool_get_feature (s_ethtool, NM_ETHTOOL_OPTNAME_FEATURE_SG), ==, NM_TERNARY_DEFAULT);
|
||||
|
||||
nmtst_connection_normalize (con);
|
||||
|
||||
@@ -1539,9 +1585,9 @@ test_ethtool_features (void)
|
||||
|
||||
s_ethtool2 = NM_SETTING_ETHTOOL (nm_connection_get_setting (con2, NM_TYPE_SETTING_ETHTOOL));
|
||||
|
||||
g_assert_cmpint (nm_setting_ethtool_get_feature (s_ethtool2, NM_ETHTOOL_OPTNAME_FEATURE_RX), ==, NM_TERNARY_TRUE);
|
||||
g_assert_cmpint (nm_setting_ethtool_get_feature (s_ethtool2, NM_ETHTOOL_OPTNAME_FEATURE_LRO), ==, NM_TERNARY_FALSE);
|
||||
g_assert_cmpint (nm_setting_ethtool_get_feature (s_ethtool2, NM_ETHTOOL_OPTNAME_FEATURE_SG), ==, NM_TERNARY_DEFAULT);
|
||||
g_assert_cmpint (_setting_ethtool_get_feature (s_ethtool2, NM_ETHTOOL_OPTNAME_FEATURE_RX), ==, NM_TERNARY_TRUE);
|
||||
g_assert_cmpint (_setting_ethtool_get_feature (s_ethtool2, NM_ETHTOOL_OPTNAME_FEATURE_LRO), ==, NM_TERNARY_FALSE);
|
||||
g_assert_cmpint (_setting_ethtool_get_feature (s_ethtool2, NM_ETHTOOL_OPTNAME_FEATURE_SG), ==, NM_TERNARY_DEFAULT);
|
||||
|
||||
nmtst_assert_connection_verifies_without_normalization (con2);
|
||||
|
||||
@@ -1566,9 +1612,9 @@ test_ethtool_features (void)
|
||||
|
||||
s_ethtool3 = NM_SETTING_ETHTOOL (nm_connection_get_setting (con3, NM_TYPE_SETTING_ETHTOOL));
|
||||
|
||||
g_assert_cmpint (nm_setting_ethtool_get_feature (s_ethtool3, NM_ETHTOOL_OPTNAME_FEATURE_RX), ==, NM_TERNARY_TRUE);
|
||||
g_assert_cmpint (nm_setting_ethtool_get_feature (s_ethtool3, NM_ETHTOOL_OPTNAME_FEATURE_LRO), ==, NM_TERNARY_FALSE);
|
||||
g_assert_cmpint (nm_setting_ethtool_get_feature (s_ethtool3, NM_ETHTOOL_OPTNAME_FEATURE_SG), ==, NM_TERNARY_DEFAULT);
|
||||
g_assert_cmpint (_setting_ethtool_get_feature (s_ethtool3, NM_ETHTOOL_OPTNAME_FEATURE_RX), ==, NM_TERNARY_TRUE);
|
||||
g_assert_cmpint (_setting_ethtool_get_feature (s_ethtool3, NM_ETHTOOL_OPTNAME_FEATURE_LRO), ==, NM_TERNARY_FALSE);
|
||||
g_assert_cmpint (_setting_ethtool_get_feature (s_ethtool3, NM_ETHTOOL_OPTNAME_FEATURE_SG), ==, NM_TERNARY_DEFAULT);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1584,7 +1630,7 @@ test_ethtool_coalesce (void)
|
||||
NMSettingEthtool *s_ethtool;
|
||||
NMSettingEthtool *s_ethtool2;
|
||||
NMSettingEthtool *s_ethtool3;
|
||||
guint32 out_value;
|
||||
guint32 u32;
|
||||
|
||||
con = nmtst_create_minimal_connection ("ethtool-coalesce",
|
||||
NULL,
|
||||
@@ -1593,12 +1639,12 @@ test_ethtool_coalesce (void)
|
||||
s_ethtool = NM_SETTING_ETHTOOL (nm_setting_ethtool_new ());
|
||||
nm_connection_add_setting (con, NM_SETTING (s_ethtool));
|
||||
|
||||
nm_setting_ethtool_set_coalesce (s_ethtool,
|
||||
nm_setting_option_set_uint32 (NM_SETTING (s_ethtool),
|
||||
NM_ETHTOOL_OPTNAME_COALESCE_RX_FRAMES,
|
||||
4);
|
||||
|
||||
g_assert_true (nm_setting_ethtool_get_coalesce (s_ethtool, NM_ETHTOOL_OPTNAME_COALESCE_RX_FRAMES, &out_value));
|
||||
g_assert_cmpuint (out_value, ==, 4);
|
||||
g_assert_true (nm_setting_option_get_uint32 (NM_SETTING (s_ethtool), NM_ETHTOOL_OPTNAME_COALESCE_RX_FRAMES, &u32));
|
||||
g_assert_cmpuint (u32, ==, 4);
|
||||
|
||||
nmtst_connection_normalize (con);
|
||||
|
||||
@@ -1609,8 +1655,8 @@ test_ethtool_coalesce (void)
|
||||
|
||||
s_ethtool2 = NM_SETTING_ETHTOOL (nm_connection_get_setting (con2, NM_TYPE_SETTING_ETHTOOL));
|
||||
|
||||
g_assert_true (nm_setting_ethtool_get_coalesce (s_ethtool2, NM_ETHTOOL_OPTNAME_COALESCE_RX_FRAMES, &out_value));
|
||||
g_assert_cmpuint (out_value, ==, 4);
|
||||
g_assert_true (nm_setting_option_get_uint32 (NM_SETTING (s_ethtool2), NM_ETHTOOL_OPTNAME_COALESCE_RX_FRAMES, &u32));
|
||||
g_assert_cmpuint (u32, ==, 4);
|
||||
|
||||
nmtst_assert_connection_verifies_without_normalization (con2);
|
||||
|
||||
@@ -1635,24 +1681,24 @@ test_ethtool_coalesce (void)
|
||||
|
||||
s_ethtool3 = NM_SETTING_ETHTOOL (nm_connection_get_setting (con3, NM_TYPE_SETTING_ETHTOOL));
|
||||
|
||||
g_assert_true (nm_setting_ethtool_get_coalesce (s_ethtool3, NM_ETHTOOL_OPTNAME_COALESCE_RX_FRAMES, &out_value));
|
||||
g_assert_cmpuint (out_value, ==, 4);
|
||||
g_assert_true (nm_setting_option_get_uint32 (NM_SETTING (s_ethtool3), NM_ETHTOOL_OPTNAME_COALESCE_RX_FRAMES, &u32));
|
||||
g_assert_cmpuint (u32, ==, 4);
|
||||
|
||||
|
||||
nm_setting_ethtool_clear_coalesce (s_ethtool, NM_ETHTOOL_OPTNAME_COALESCE_RX_FRAMES);
|
||||
g_assert_false (nm_setting_ethtool_get_coalesce (s_ethtool, NM_ETHTOOL_OPTNAME_COALESCE_RX_FRAMES, NULL));
|
||||
nm_setting_option_set (NM_SETTING (s_ethtool), NM_ETHTOOL_OPTNAME_COALESCE_RX_FRAMES, NULL);
|
||||
g_assert_false (nm_setting_option_get_uint32 (NM_SETTING (s_ethtool), NM_ETHTOOL_OPTNAME_COALESCE_RX_FRAMES, NULL));
|
||||
|
||||
nm_setting_ethtool_set_coalesce (s_ethtool,
|
||||
nm_setting_option_set_uint32 (NM_SETTING (s_ethtool),
|
||||
NM_ETHTOOL_OPTNAME_COALESCE_TX_FRAMES,
|
||||
8);
|
||||
|
||||
g_assert_true (nm_setting_ethtool_get_coalesce (s_ethtool, NM_ETHTOOL_OPTNAME_COALESCE_TX_FRAMES, &out_value));
|
||||
g_assert_cmpuint (out_value, ==, 8);
|
||||
g_assert_true (nm_setting_option_get_uint32 (NM_SETTING (s_ethtool), NM_ETHTOOL_OPTNAME_COALESCE_TX_FRAMES, &u32));
|
||||
g_assert_cmpuint (u32, ==, 8);
|
||||
|
||||
nm_setting_ethtool_clear_coalesce_all (s_ethtool);
|
||||
g_assert_false (nm_setting_ethtool_get_coalesce (s_ethtool, NM_ETHTOOL_OPTNAME_COALESCE_RX_FRAMES, NULL));
|
||||
g_assert_false (nm_setting_ethtool_get_coalesce (s_ethtool, NM_ETHTOOL_OPTNAME_COALESCE_TX_FRAMES, NULL));
|
||||
g_assert_false (nm_setting_ethtool_get_coalesce (s_ethtool, NM_ETHTOOL_OPTNAME_COALESCE_TX_USECS, NULL));
|
||||
nm_setting_option_clear_by_name (NM_SETTING (s_ethtool), nm_ethtool_optname_is_coalesce);
|
||||
g_assert_false (nm_setting_option_get_uint32 (NM_SETTING (s_ethtool), NM_ETHTOOL_OPTNAME_COALESCE_RX_FRAMES, NULL));
|
||||
g_assert_false (nm_setting_option_get_uint32 (NM_SETTING (s_ethtool), NM_ETHTOOL_OPTNAME_COALESCE_TX_FRAMES, NULL));
|
||||
g_assert_false (nm_setting_option_get_uint32 (NM_SETTING (s_ethtool), NM_ETHTOOL_OPTNAME_COALESCE_TX_USECS, NULL));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1677,11 +1723,11 @@ test_ethtool_ring (void)
|
||||
s_ethtool = NM_SETTING_ETHTOOL (nm_setting_ethtool_new ());
|
||||
nm_connection_add_setting (con, NM_SETTING (s_ethtool));
|
||||
|
||||
nm_setting_ethtool_set_ring (s_ethtool,
|
||||
nm_setting_option_set_uint32 (NM_SETTING (s_ethtool),
|
||||
NM_ETHTOOL_OPTNAME_RING_RX_JUMBO,
|
||||
4);
|
||||
|
||||
g_assert_true (nm_setting_ethtool_get_ring (s_ethtool, NM_ETHTOOL_OPTNAME_RING_RX_JUMBO, &out_value));
|
||||
g_assert_true (nm_setting_option_get_uint32 (NM_SETTING (s_ethtool), NM_ETHTOOL_OPTNAME_RING_RX_JUMBO, &out_value));
|
||||
g_assert_cmpuint (out_value, ==, 4);
|
||||
|
||||
nmtst_connection_normalize (con);
|
||||
@@ -1693,7 +1739,7 @@ test_ethtool_ring (void)
|
||||
|
||||
s_ethtool2 = NM_SETTING_ETHTOOL (nm_connection_get_setting (con2, NM_TYPE_SETTING_ETHTOOL));
|
||||
|
||||
g_assert_true (nm_setting_ethtool_get_ring (s_ethtool2, NM_ETHTOOL_OPTNAME_RING_RX_JUMBO, &out_value));
|
||||
g_assert_true (nm_setting_option_get_uint32 (NM_SETTING (s_ethtool2), NM_ETHTOOL_OPTNAME_RING_RX_JUMBO, &out_value));
|
||||
g_assert_cmpuint (out_value, ==, 4);
|
||||
|
||||
nmtst_assert_connection_verifies_without_normalization (con2);
|
||||
@@ -1719,24 +1765,24 @@ test_ethtool_ring (void)
|
||||
|
||||
s_ethtool3 = NM_SETTING_ETHTOOL (nm_connection_get_setting (con3, NM_TYPE_SETTING_ETHTOOL));
|
||||
|
||||
g_assert_true (nm_setting_ethtool_get_ring (s_ethtool3, NM_ETHTOOL_OPTNAME_RING_RX_JUMBO, &out_value));
|
||||
g_assert_true (nm_setting_option_get_uint32 (NM_SETTING (s_ethtool3), NM_ETHTOOL_OPTNAME_RING_RX_JUMBO, &out_value));
|
||||
g_assert_cmpuint (out_value, ==, 4);
|
||||
|
||||
|
||||
nm_setting_ethtool_clear_ring (s_ethtool, NM_ETHTOOL_OPTNAME_RING_RX_JUMBO);
|
||||
g_assert_false (nm_setting_ethtool_get_ring (s_ethtool, NM_ETHTOOL_OPTNAME_RING_RX_JUMBO, NULL));
|
||||
nm_setting_option_set (NM_SETTING (s_ethtool), NM_ETHTOOL_OPTNAME_RING_RX_JUMBO, NULL);
|
||||
g_assert_false (nm_setting_option_get_uint32 (NM_SETTING (s_ethtool), NM_ETHTOOL_OPTNAME_RING_RX_JUMBO, NULL));
|
||||
|
||||
nm_setting_ethtool_set_ring (s_ethtool,
|
||||
nm_setting_option_set_uint32 (NM_SETTING (s_ethtool),
|
||||
NM_ETHTOOL_OPTNAME_RING_RX_JUMBO,
|
||||
8);
|
||||
|
||||
g_assert_true (nm_setting_ethtool_get_ring (s_ethtool, NM_ETHTOOL_OPTNAME_RING_RX_JUMBO, &out_value));
|
||||
g_assert_true (nm_setting_option_get_uint32 (NM_SETTING (s_ethtool), NM_ETHTOOL_OPTNAME_RING_RX_JUMBO, &out_value));
|
||||
g_assert_cmpuint (out_value, ==, 8);
|
||||
|
||||
nm_setting_ethtool_clear_ring_all (s_ethtool);
|
||||
g_assert_false (nm_setting_ethtool_get_ring (s_ethtool, NM_ETHTOOL_OPTNAME_RING_RX_JUMBO, NULL));
|
||||
g_assert_false (nm_setting_ethtool_get_ring (s_ethtool, NM_ETHTOOL_OPTNAME_RING_RX, NULL));
|
||||
g_assert_false (nm_setting_ethtool_get_ring (s_ethtool, NM_ETHTOOL_OPTNAME_RING_TX, NULL));
|
||||
nm_setting_option_clear_by_name (NM_SETTING (s_ethtool), nm_ethtool_optname_is_ring);
|
||||
g_assert_false (nm_setting_option_get_uint32 (NM_SETTING (s_ethtool), NM_ETHTOOL_OPTNAME_RING_RX_JUMBO, NULL));
|
||||
g_assert_false (nm_setting_option_get_uint32 (NM_SETTING (s_ethtool), NM_ETHTOOL_OPTNAME_RING_RX, NULL));
|
||||
g_assert_false (nm_setting_option_get_uint32 (NM_SETTING (s_ethtool), NM_ETHTOOL_OPTNAME_RING_TX, NULL));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@@ -4406,43 +4406,35 @@ parse_ethtool_option (const char *value,
|
||||
/* skip ethtool type && interface name */
|
||||
w_iter = &words[2];
|
||||
|
||||
if (ethtool_type == NM_ETHTOOL_TYPE_FEATURE) {
|
||||
while (w_iter && *w_iter) {
|
||||
if (ethtool_type == NM_ETHTOOL_TYPE_FEATURE) {
|
||||
w_iter = _next_ethtool_options_nmternary (w_iter,
|
||||
ethtool_type,
|
||||
&ifcfg_option);
|
||||
|
||||
if (ifcfg_option.has_value)
|
||||
nm_setting_ethtool_set_feature (*out_s_ethtool,
|
||||
if (ifcfg_option.has_value) {
|
||||
nm_setting_option_set_boolean (NM_SETTING (*out_s_ethtool),
|
||||
ifcfg_option.optname,
|
||||
ifcfg_option.v.nmternary);
|
||||
ifcfg_option.v.nmternary != NM_TERNARY_FALSE);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (NM_IN_SET (ethtool_type,
|
||||
NM_ETHTOOL_TYPE_COALESCE,
|
||||
NM_ETHTOOL_TYPE_RING)) {
|
||||
while (w_iter && *w_iter) {
|
||||
w_iter = _next_ethtool_options_uint32 (w_iter,
|
||||
ethtool_type,
|
||||
&ifcfg_option);
|
||||
|
||||
if (ifcfg_option.has_value) {
|
||||
if (ethtool_type == NM_ETHTOOL_TYPE_COALESCE)
|
||||
nm_setting_ethtool_set_coalesce (*out_s_ethtool,
|
||||
ifcfg_option.optname,
|
||||
ifcfg_option.v.u32);
|
||||
else
|
||||
nm_setting_ethtool_set_ring (*out_s_ethtool,
|
||||
nm_setting_option_set_uint32 (NM_SETTING (*out_s_ethtool),
|
||||
ifcfg_option.optname,
|
||||
ifcfg_option.v.u32);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
/* unsupported ethtool type */
|
||||
nm_assert_not_reached();
|
||||
}
|
||||
|
||||
/* /sbin/ethtool -s ${REALDEVICE} $opts */
|
||||
for (i = 0; words[i]; ) {
|
||||
|
@@ -1184,7 +1184,7 @@ write_ethtool_setting (NMConnection *connection, shvarFile *ifcfg, GError **erro
|
||||
const char *iface;
|
||||
gboolean is_first;
|
||||
guint32 u32;
|
||||
NMTernary t;
|
||||
gboolean b;
|
||||
|
||||
s_con = nm_connection_get_setting_connection (connection);
|
||||
if (s_con) {
|
||||
@@ -1204,20 +1204,19 @@ write_ethtool_setting (NMConnection *connection, shvarFile *ifcfg, GError **erro
|
||||
is_first = TRUE;
|
||||
for (ethtool_id = _NM_ETHTOOL_ID_FEATURE_FIRST; ethtool_id <= _NM_ETHTOOL_ID_FEATURE_LAST; ethtool_id++) {
|
||||
nm_assert (nms_ifcfg_rh_utils_get_ethtool_name (ethtool_id));
|
||||
t = nm_setting_ethtool_get_feature (s_ethtool, nm_ethtool_data[ethtool_id]->optname);
|
||||
if (t == NM_TERNARY_DEFAULT)
|
||||
if (!nm_setting_option_get_boolean (NM_SETTING (s_ethtool), nm_ethtool_data[ethtool_id]->optname, &b))
|
||||
continue;
|
||||
|
||||
_ethtool_gstring_prepare (&str, &is_first, 'K', iface);
|
||||
g_string_append_c (str, ' ');
|
||||
g_string_append (str, nms_ifcfg_rh_utils_get_ethtool_name (ethtool_id));
|
||||
g_string_append (str, t != NM_TERNARY_FALSE ? " on" : " off");
|
||||
g_string_append (str, b ? " on" : " off");
|
||||
}
|
||||
|
||||
is_first = TRUE;
|
||||
for (ethtool_id = _NM_ETHTOOL_ID_COALESCE_FIRST; ethtool_id <= _NM_ETHTOOL_ID_COALESCE_LAST; ethtool_id++) {
|
||||
nm_assert (nms_ifcfg_rh_utils_get_ethtool_name (ethtool_id));
|
||||
if (!nm_setting_ethtool_get_coalesce (s_ethtool, nm_ethtool_data[ethtool_id]->optname, &u32))
|
||||
if (!nm_setting_option_get_uint32 (NM_SETTING (s_ethtool), nm_ethtool_data[ethtool_id]->optname, &u32))
|
||||
continue;
|
||||
|
||||
_ethtool_gstring_prepare (&str, &is_first, 'C', iface);
|
||||
@@ -1229,7 +1228,7 @@ write_ethtool_setting (NMConnection *connection, shvarFile *ifcfg, GError **erro
|
||||
is_first = TRUE;
|
||||
for (ethtool_id = _NM_ETHTOOL_ID_RING_FIRST; ethtool_id <= _NM_ETHTOOL_ID_RING_LAST; ethtool_id++) {
|
||||
nm_assert (nms_ifcfg_rh_utils_get_ethtool_name (ethtool_id));
|
||||
if (!nm_setting_ethtool_get_ring (s_ethtool, nm_ethtool_data[ethtool_id]->optname, &u32))
|
||||
if (!nm_setting_option_get_uint32 (NM_SETTING (s_ethtool), nm_ethtool_data[ethtool_id]->optname, &u32))
|
||||
continue;
|
||||
|
||||
_ethtool_gstring_prepare (&str, &is_first, 'G', iface);
|
||||
|
Reference in New Issue
Block a user