Commit e75fc827 authored by Lubomir Rintel's avatar Lubomir Rintel

lr/tc: initial support for TC qdiscs and filters

https://bugzilla.gnome.org/show_bug.cgi?id=790630
parents 45ad3ec8 902bbfdb
......@@ -413,6 +413,7 @@ libnm_core_lib_h_pub_real = \
libnm-core/nm-setting-pppoe.h \
libnm-core/nm-setting-proxy.h \
libnm-core/nm-setting-serial.h \
libnm-core/nm-setting-tc-config.h \
libnm-core/nm-setting-team-port.h \
libnm-core/nm-setting-team.h \
libnm-core/nm-setting-tun.h \
......@@ -497,6 +498,7 @@ libnm_core_lib_c_real = \
libnm-core/nm-setting-pppoe.c \
libnm-core/nm-setting-proxy.c \
libnm-core/nm-setting-serial.c \
libnm-core/nm-setting-tc-config.c \
libnm-core/nm-setting-team-port.c \
libnm-core/nm-setting-team.c \
libnm-core/nm-setting-tun.c \
......@@ -1864,6 +1866,7 @@ EXTRA_DIST += \
src/settings/plugins/keyfile/tests/keyfiles/Test_Enum_Property \
src/settings/plugins/keyfile/tests/keyfiles/Test_Flags_Property \
src/settings/plugins/keyfile/tests/keyfiles/Test_dcb_connection \
src/settings/plugins/keyfile/tests/keyfiles/Test_TC_Config \
\
src/settings/plugins/keyfile/tests/keyfiles/test-ca-cert.pem \
src/settings/plugins/keyfile/tests/keyfiles/test-key-and-cert.pem
......
......@@ -14,7 +14,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright 2010 - 2015 Red Hat, Inc.
* Copyright 2010 - 2017 Red Hat, Inc.
*/
#include "nm-default.h"
......@@ -144,7 +144,8 @@ const NmcMetaGenericInfo *const nmc_fields_con_active_details_general[] = {
NM_SETTING_MACSEC_SETTING_NAME"," \
NM_SETTING_MACVLAN_SETTING_NAME"," \
NM_SETTING_VXLAN_SETTING_NAME"," \
NM_SETTING_PROXY_SETTING_NAME
NM_SETTING_PROXY_SETTING_NAME"," \
NM_SETTING_TC_CONFIG_SETTING_NAME
// NM_SETTING_DUMMY_SETTING_NAME
// NM_SETTING_WIMAX_SETTING_NAME
......
......@@ -743,7 +743,7 @@ do_general_logging (NmCli *nmc, int argc, char **argv)
"AGENTS", "SETTINGS", "SUSPEND", "CORE", "DEVICE", "OLPC",
"INFINIBAND", "FIREWALL", "ADSL", "BOND", "VLAN", "BRIDGE",
"DBUS_PROPS", "TEAM", "CONCHECK", "DCB", "DISPATCH", "AUDIT",
"SYSTEMD", "VPN_PLUGIN", "PROXY", NULL);
"SYSTEMD", "VPN_PLUGIN", "PROXY", "TC", NULL);
}
domains = *argv;
} else {
......
......@@ -3786,6 +3786,158 @@ _validate_fcn_proxy_pac_script (const char *value, char **out_to_free, GError **
RETURN_STR_TO_FREE (script);
}
static gconstpointer
_get_fcn_tc_config_qdiscs (ARGS_GET_FCN)
{
NMSettingTCConfig *s_tc = NM_SETTING_TC_CONFIG (setting);
GString *printable;
guint num_qdiscs, i;
NMTCQdisc *qdisc;
char *str;
RETURN_UNSUPPORTED_GET_TYPE ();
printable = g_string_new (NULL);
num_qdiscs = nm_setting_tc_config_get_num_qdiscs (s_tc);
for (i = 0; i < num_qdiscs; i++) {
qdisc = nm_setting_tc_config_get_qdisc (s_tc, i);
if (printable->len > 0)
g_string_append (printable, ", ");
str = nm_utils_tc_qdisc_to_str (qdisc, NULL);
if (str) {
g_string_append (printable, str);
g_free (str);
}
}
RETURN_STR_TO_FREE (g_string_free (printable, FALSE));
}
static gboolean
_set_fcn_tc_config_qdiscs (ARGS_SET_FCN)
{
gs_free const char **strv = NULL;
const char *const*iter;
NMTCQdisc *tc_qdisc;
GError *local = NULL;
strv = nm_utils_strsplit_set (value, ",");
for (iter = strv; strv && *iter; iter++) {
tc_qdisc = nm_utils_tc_qdisc_from_str (*iter, &local);
if (!tc_qdisc) {
g_set_error (error, 1, 0, "%s %s", local->message,
_("The valid syntax is: '[root | parent <handle>] [handle <handle>] <qdisc>'"));
return FALSE;
}
nm_setting_tc_config_add_qdisc (NM_SETTING_TC_CONFIG (setting), tc_qdisc);
nm_tc_qdisc_unref (tc_qdisc);
}
return TRUE;
}
static gboolean
_validate_and_remove_tc_qdisc (NMSettingTCConfig *setting,
const char *value,
GError **error)
{
NMTCQdisc *qdisc;
gboolean ret;
qdisc = nm_utils_tc_qdisc_from_str (value, error);
if (!qdisc)
return FALSE;
ret = nm_setting_tc_config_remove_qdisc_by_value (setting, qdisc);
if (!ret)
g_set_error (error, 1, 0, _("the property doesn't contain qdisc '%s'"), value);
nm_tc_qdisc_unref (qdisc);
return ret;
}
DEFINE_REMOVER_INDEX_OR_VALUE (_remove_fcn_tc_config_qdiscs,
NM_SETTING_TC_CONFIG,
nm_setting_tc_config_get_num_qdiscs,
nm_setting_tc_config_remove_qdisc,
_validate_and_remove_tc_qdisc)
static gconstpointer
_get_fcn_tc_config_tfilters (ARGS_GET_FCN)
{
NMSettingTCConfig *s_tc = NM_SETTING_TC_CONFIG (setting);
GString *printable;
guint num_tfilters, i;
NMTCTfilter *tfilter;
char *str;
RETURN_UNSUPPORTED_GET_TYPE ();
printable = g_string_new (NULL);
num_tfilters = nm_setting_tc_config_get_num_tfilters (s_tc);
for (i = 0; i < num_tfilters; i++) {
tfilter = nm_setting_tc_config_get_tfilter (s_tc, i);
if (printable->len > 0)
g_string_append (printable, ", ");
str = nm_utils_tc_tfilter_to_str (tfilter, NULL);
if (str) {
g_string_append (printable, str);
g_free (str);
}
}
RETURN_STR_TO_FREE (g_string_free (printable, FALSE));
}
static gboolean
_set_fcn_tc_config_tfilters (ARGS_SET_FCN)
{
gs_free const char **strv = NULL;
const char *const*iter;
NMTCTfilter *tc_tfilter;
GError *local = NULL;
strv = nm_utils_strsplit_set (value, ",");
for (iter = strv; strv && *iter; iter++) {
tc_tfilter = nm_utils_tc_tfilter_from_str (*iter, &local);
if (!tc_tfilter) {
g_set_error (error, 1, 0, "%s %s", local->message,
_("The valid syntax is: '[root | parent <handle>] [handle <handle>] <tfilter>'"));
return FALSE;
}
nm_setting_tc_config_add_tfilter (NM_SETTING_TC_CONFIG (setting), tc_tfilter);
nm_tc_tfilter_unref (tc_tfilter);
}
return TRUE;
}
static gboolean
_validate_and_remove_tc_tfilter (NMSettingTCConfig *setting,
const char *value,
GError **error)
{
NMTCTfilter *tfilter;
gboolean ret;
tfilter = nm_utils_tc_tfilter_from_str (value, error);
if (!tfilter)
return FALSE;
ret = nm_setting_tc_config_remove_tfilter_by_value (setting, tfilter);
if (!ret)
g_set_error (error, 1, 0, _("the property doesn't contain tfilter '%s'"), value);
nm_tc_tfilter_unref (tfilter);
return ret;
}
DEFINE_REMOVER_INDEX_OR_VALUE (_remove_fcn_tc_config_tfilters,
NM_SETTING_TC_CONFIG,
nm_setting_tc_config_get_num_tfilters,
nm_setting_tc_config_remove_tfilter,
_validate_and_remove_tc_tfilter)
static const char *
_validate_fcn_team_config (const char *value, char **out_to_free, GError **error)
{
......@@ -6357,6 +6509,26 @@ static const NMMetaPropertyInfo *const property_infos_PROXY[] = {
NULL
};
#undef _CURRENT_NM_META_SETTING_TYPE
#define _CURRENT_NM_META_SETTING_TYPE NM_META_SETTING_TYPE_TC_CONFIG
static const NMMetaPropertyInfo *const property_infos_TC_CONFIG[] = {
PROPERTY_INFO (NM_SETTING_TC_CONFIG_QDISCS, DESCRIBE_DOC_NM_SETTING_TC_CONFIG_QDISCS,
.property_type = DEFINE_PROPERTY_TYPE (
.get_fcn = _get_fcn_tc_config_qdiscs,
.set_fcn = _set_fcn_tc_config_qdiscs,
.remove_fcn = _remove_fcn_tc_config_qdiscs,
),
),
PROPERTY_INFO (NM_SETTING_TC_CONFIG_TFILTERS, DESCRIBE_DOC_NM_SETTING_TC_CONFIG_TFILTERS,
.property_type = DEFINE_PROPERTY_TYPE (
.get_fcn = _get_fcn_tc_config_tfilters,
.set_fcn = _set_fcn_tc_config_tfilters,
.remove_fcn = _remove_fcn_tc_config_tfilters,
),
),
NULL
};
#undef _CURRENT_NM_META_SETTING_TYPE
#define _CURRENT_NM_META_SETTING_TYPE NM_META_SETTING_TYPE_TEAM
static const NMMetaPropertyInfo *const property_infos_TEAM[] = {
......@@ -7367,6 +7539,7 @@ _setting_init_fcn_wireless (ARGS_SETTING_INIT_FCN)
#define SETTING_PRETTY_NAME_PPPOE N_("PPPoE")
#define SETTING_PRETTY_NAME_PROXY N_("Proxy")
#define SETTING_PRETTY_NAME_SERIAL N_("Serial settings")
#define SETTING_PRETTY_NAME_TC_CONFIG N_("Traffic controls")
#define SETTING_PRETTY_NAME_TEAM N_("Team device")
#define SETTING_PRETTY_NAME_TEAM_PORT N_("Team port")
#define SETTING_PRETTY_NAME_TUN N_("Tun device")
......@@ -7552,6 +7725,7 @@ const NMMetaSettingInfoEditor nm_meta_setting_infos_editor[] = {
.setting_init_fcn = _setting_init_fcn_proxy,
),
SETTING_INFO (SERIAL),
SETTING_INFO (TC_CONFIG),
SETTING_INFO (TEAM,
.valid_parts = NM_META_SETTING_VALID_PARTS (
NM_META_SETTING_VALID_PART_ITEM (CONNECTION, TRUE),
......@@ -7632,6 +7806,7 @@ const NMMetaSettingValidPartItem *const nm_meta_setting_info_valid_parts_default
static const NMMetaSettingValidPartItem *const valid_settings_noslave[] = {
NM_META_SETTING_VALID_PART_ITEM (IP4_CONFIG, FALSE),
NM_META_SETTING_VALID_PART_ITEM (IP6_CONFIG, FALSE),
NM_META_SETTING_VALID_PART_ITEM (TC_CONFIG, FALSE),
NM_META_SETTING_VALID_PART_ITEM (PROXY, FALSE),
NULL,
};
......
......@@ -315,6 +315,9 @@
#define DESCRIBE_DOC_NM_SETTING_SERIAL_PARITY N_("Parity setting of the serial port.")
#define DESCRIBE_DOC_NM_SETTING_SERIAL_SEND_DELAY N_("Time to delay between each byte sent to the modem, in microseconds.")
#define DESCRIBE_DOC_NM_SETTING_SERIAL_STOPBITS N_("Number of stop bits for communication on the serial port. Either 1 or 2. The 1 in \"8n1\" for example.")
#define DESCRIBE_DOC_NM_SETTING_TC_CONFIG_NAME N_("The setting's name, which uniquely identifies the setting within the connection. Each setting type has a name unique to that type, for example \"ppp\" or \"wireless\" or \"wired\".")
#define DESCRIBE_DOC_NM_SETTING_TC_CONFIG_QDISCS N_("Array of TC queuening disciplines.")
#define DESCRIBE_DOC_NM_SETTING_TC_CONFIG_TFILTERS N_("Array of TC traffic filters.")
#define DESCRIBE_DOC_NM_SETTING_TEAM_CONFIG N_("The JSON configuration for the team network interface. The property should contain raw JSON configuration data suitable for teamd, because the value is passed directly to teamd. If not specified, the default configuration is used. See man teamd.conf for the format details.")
#define DESCRIBE_DOC_NM_SETTING_TEAM_LINK_WATCHERS N_("Link watchers configuration for the connection: each link watcher is defined by a dictionary, whose keys depend upon the selected link watcher. Available link watchers are 'ethtool', 'nsna_ping' and 'arp_ping' and it is specified in the dictionary with the key 'name'. Available keys are: ethtool: 'delay-up', 'delay-down', 'init-wait'; nsna_ping: 'init-wait', 'interval', 'missed-max', 'target-host'; arp_ping: all the ones in nsna_ping and 'source-host', 'validate-active', 'validate-incative', 'send-always'. See teamd.conf man for more details.")
#define DESCRIBE_DOC_NM_SETTING_TEAM_MCAST_REJOIN_COUNT N_("Corresponds to the teamd mcast_rejoin.count.")
......
......@@ -38,7 +38,7 @@ NM-colorize() {
GREP_COLOR='01;31' grep -a --color=always '^\|^\(.* \)\?<\(warn> \|error>\) \[[0-9.]*\]' | \
GREP_COLOR='01;33' grep -a --color=always '^\|^\(.* \)\?<info> \[[0-9.]*\]\( .*\<is starting\>.*$\)\?' | \
GREP_COLOR='01;37' grep -a --color=always '^\|\<platform: signal: .*$' | \
GREP_COLOR='01;34' grep -a --color=always '^\|\<platform\(-linux\)\?: link: \(add\|adding\|change\|setting\|deleting\) \|\<platform: address: \(deleting\|adding or updating\) IPv. address:\? \|\<platform: route: \([a-z]\+\|adding or updating\|new\[0x[0-9A-Za-z]*\]\) \+IPv. route:\? \|\<platform-linux: sysctl: setting ' | \
GREP_COLOR='01;34' grep -a --color=always '^\|\<platform\(-linux\)\?: link: \(add\|adding\|change\|setting\|deleting\) \|\<platform: address: \(deleting\|adding or updating\) IPv. address:\? \|\<platform: \(route\|ip4-route\|ip6-route\|qdisc\|tfilter\): \([a-z]\+\|adding or updating\|new\[0x[0-9A-Za-z]*\]\) \|\<platform-linux: sysctl: setting ' | \
GREP_COLOR='01;35' grep -a --color=always '^\|\<audit: .*$' | \
GREP_COLOR='01;32' grep -a --color=always '^\|\<device (.*): state change: '
else
......
......@@ -16,7 +16,7 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* Copyright 2007 - 2013 Red Hat, Inc.
* Copyright 2007 - 2017 Red Hat, Inc.
* Copyright 2007 - 2008 Novell, Inc.
*/
......@@ -2530,6 +2530,22 @@ nm_connection_get_setting_serial (NMConnection *connection)
return _connection_get_setting_check (connection, NM_TYPE_SETTING_SERIAL);
}
/**
* nm_connection_get_setting_tc_config:
* @connection: the #NMConnection
*
* A shortcut to return any #NMSettingTCConfig the connection might contain.
*
* Returns: (transfer none): an #NMSettingTCConfig if the connection contains one, otherwise %NULL
*
* Since: 1.12
**/
NMSettingTCConfig *
nm_connection_get_setting_tc_config (NMConnection *connection)
{
return _connection_get_setting_check (connection, NM_TYPE_SETTING_TC_CONFIG);
}
/**
* nm_connection_get_setting_tun:
* @connection: the #NMConnection
......
......@@ -16,7 +16,7 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* Copyright 2007 - 2013 Red Hat, Inc.
* Copyright 2007 - 2017 Red Hat, Inc.
* Copyright 2007 - 2008 Novell, Inc.
*/
......@@ -229,6 +229,8 @@ NMSettingPppoe * nm_connection_get_setting_pppoe (NMConnec
NM_AVAILABLE_IN_1_6
NMSettingProxy * nm_connection_get_setting_proxy (NMConnection *connection);
NMSettingSerial * nm_connection_get_setting_serial (NMConnection *connection);
NM_AVAILABLE_IN_1_12
NMSettingTCConfig * nm_connection_get_setting_tc_config (NMConnection *connection);
NMSettingTun * nm_connection_get_setting_tun (NMConnection *connection);
NMSettingVpn * nm_connection_get_setting_vpn (NMConnection *connection);
NMSettingWimax * nm_connection_get_setting_wimax (NMConnection *connection);
......
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -16,7 +15,7 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2014 Red Hat, Inc.
* (C) Copyright 2014 - 2017 Red Hat, Inc.
*/
#ifndef NM_CORE_NM_INTERNAL_H
......@@ -63,6 +62,7 @@
#include "nm-setting-ppp.h"
#include "nm-setting-pppoe.h"
#include "nm-setting-serial.h"
#include "nm-setting-tc-config.h"
#include "nm-setting-team-port.h"
#include "nm-setting-team.h"
#include "nm-setting-tun.h"
......@@ -472,4 +472,17 @@ nm_setting_ip_config_get_addr_family (NMSettingIPConfig *s_ip)
/*****************************************************************************/
guint32 _nm_utils_parse_tc_handle (const char *str,
GError **error);
void _nm_utils_string_append_tc_parent (GString *string,
const char *prefix,
guint32 parent);
void _nm_utils_string_append_tc_qdisc_rest (GString *string,
NMTCQdisc *qdisc);
gboolean _nm_utils_string_append_tc_tfilter_rest (GString *string,
NMTCTfilter *tfilter,
GError **error);
/*****************************************************************************/
#endif
......@@ -15,7 +15,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright 2014 Red Hat, Inc.
* Copyright 2014 - 2017 Red Hat, Inc.
*/
#ifndef __NM_CORE_TYPES_H__
......@@ -57,6 +57,7 @@ typedef struct _NMSettingOvsPort NMSettingOvsPort;
typedef struct _NMSettingPpp NMSettingPpp;
typedef struct _NMSettingPppoe NMSettingPppoe;
typedef struct _NMSettingSerial NMSettingSerial;
typedef struct _NMSettingTCConfig NMSettingTCConfig;
typedef struct _NMSettingTeam NMSettingTeam;
typedef struct _NMSettingTeamPort NMSettingTeamPort;
typedef struct _NMSettingTun NMSettingTun;
......
......@@ -16,7 +16,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2008 - 2009 Novell, Inc.
* Copyright (C) 2008 - 2015 Red Hat, Inc.
* Copyright (C) 2008 - 2017 Red Hat, Inc.
*/
#include "nm-default.h"
......@@ -30,6 +30,7 @@
#include <sys/types.h>
#include <arpa/inet.h>
#include <string.h>
#include <linux/pkt_sched.h>
#include "nm-common-macros.h"
#include "nm-core-internal.h"
......@@ -1313,6 +1314,102 @@ team_config_parser (KeyfileReaderInfo *info, NMSetting *setting, const char *key
g_object_set (G_OBJECT (setting), key, conf, NULL);
}
static void
qdisc_parser (KeyfileReaderInfo *info, NMSetting *setting, const char *key)
{
const char *setting_name = nm_setting_get_name (setting);
GPtrArray *qdiscs;
gs_strfreev gchar **keys = NULL;
gsize n_keys = 0;
int i;
qdiscs = g_ptr_array_new_with_free_func ((GDestroyNotify) nm_tc_qdisc_unref);
keys = nm_keyfile_plugin_kf_get_keys (info->keyfile, setting_name, &n_keys, NULL);
if (!keys || n_keys == 0)
return;
for (i = 0; i < n_keys; i++) {
NMTCQdisc *qdisc;
const char *qdisc_parent;
gs_free char *qdisc_rest = NULL;
gs_free char *qdisc_str = NULL;
gs_free_error GError *err = NULL;
if (!g_str_has_prefix (keys[i], "qdisc."))
continue;
qdisc_parent = keys[i] + sizeof ("qdisc.") - 1;
qdisc_rest = nm_keyfile_plugin_kf_get_string (info->keyfile, setting_name, keys[i], NULL);
qdisc_str = g_strdup_printf ("%s%s %s",
_nm_utils_parse_tc_handle (qdisc_parent, NULL) != TC_H_UNSPEC ? "parent " : "",
qdisc_parent,
qdisc_rest);
qdisc = nm_utils_tc_qdisc_from_str (qdisc_str, &err);
if (!qdisc) {
handle_warn (info, keys[i], NM_KEYFILE_WARN_SEVERITY_WARN,
_("invalid qdisc: %s"),
err->message);
} else {
g_ptr_array_add (qdiscs, qdisc);
}
}
if (qdiscs->len >= 1)
g_object_set (setting, key, qdiscs, NULL);
g_ptr_array_unref (qdiscs);
}
static void
tfilter_parser (KeyfileReaderInfo *info, NMSetting *setting, const char *key)
{
const char *setting_name = nm_setting_get_name (setting);
GPtrArray *tfilters;
gs_strfreev gchar **keys = NULL;
gsize n_keys = 0;
int i;
tfilters = g_ptr_array_new_with_free_func ((GDestroyNotify) nm_tc_tfilter_unref);
keys = nm_keyfile_plugin_kf_get_keys (info->keyfile, setting_name, &n_keys, NULL);
if (!keys || n_keys == 0)
return;
for (i = 0; i < n_keys; i++) {
NMTCTfilter *tfilter;
const char *tfilter_parent;
gs_free char *tfilter_rest = NULL;
gs_free char *tfilter_str = NULL;
gs_free_error GError *err = NULL;
if (!g_str_has_prefix (keys[i], "tfilter."))
continue;
tfilter_parent = keys[i] + sizeof ("tfilter.") - 1;
tfilter_rest = nm_keyfile_plugin_kf_get_string (info->keyfile, setting_name, keys[i], NULL);
tfilter_str = g_strdup_printf ("%s%s %s",
_nm_utils_parse_tc_handle (tfilter_parent, NULL) != TC_H_UNSPEC ? "parent " : "",
tfilter_parent,
tfilter_rest);
tfilter = nm_utils_tc_tfilter_from_str (tfilter_str, &err);
if (!tfilter) {
handle_warn (info, keys[i], NM_KEYFILE_WARN_SEVERITY_WARN,
_("invalid tfilter: %s"),
err->message);
} else {
g_ptr_array_add (tfilters, tfilter);
}
}
if (tfilters->len >= 1)
g_object_set (setting, key, tfilters, NULL);
g_ptr_array_unref (tfilters);
}
typedef struct {
const char *setting_name;
const char *key;
......@@ -1439,6 +1536,14 @@ static KeyParser key_parsers[] = {
NM_SETTING_TEAM_CONFIG,
TRUE,
team_config_parser },
{ NM_SETTING_TC_CONFIG_SETTING_NAME,
NM_SETTING_TC_CONFIG_QDISCS,
FALSE,
qdisc_parser },
{ NM_SETTING_TC_CONFIG_SETTING_NAME,
NM_SETTING_TC_CONFIG_TFILTERS,
FALSE,
tfilter_parser },
{ NULL, NULL, FALSE }
};
......
......@@ -16,7 +16,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2008 Novell, Inc.
* Copyright (C) 2008 - 2015 Red Hat, Inc.
* Copyright (C) 2008 - 2017 Red Hat, Inc.
*/
#include "nm-default.h"
......@@ -253,6 +253,72 @@ route_writer (KeyfileWriterInfo *info,
write_ip_values (info->keyfile, setting_name, array, NULL, TRUE);
}
static void
qdisc_writer (KeyfileWriterInfo *info,
NMSetting *setting,
const char *key,
const GValue *value)
{
gsize i;
GPtrArray *array;
array = (GPtrArray *) g_value_get_boxed (value);
if (!array || !array->len)
return;
for (i = 0; i < array->len; i++) {
NMTCQdisc *qdisc = array->pdata[i];
GString *key_name = g_string_sized_new (16);
GString *value_str = g_string_sized_new (60);
g_string_append (key_name, "qdisc.");
_nm_utils_string_append_tc_parent (key_name, NULL,
nm_tc_qdisc_get_parent (qdisc));
_nm_utils_string_append_tc_qdisc_rest (value_str, qdisc);
nm_keyfile_plugin_kf_set_string (info->keyfile,
NM_SETTING_TC_CONFIG_SETTING_NAME,
key_name->str,
value_str->str);
g_string_free (key_name, TRUE);
g_string_free (value_str, TRUE);
}
}
static void
tfilter_writer (KeyfileWriterInfo *info,
NMSetting *setting,
const char *key,
const GValue *value)
{
gsize i;
GPtrArray *array;
array = (GPtrArray *) g_value_get_boxed (value);
if (!array || !array->len)
return;
for (i = 0; i < array->len; i++) {
NMTCTfilter *tfilter = array->pdata[i];
GString *key_name = g_string_sized_new (16);
GString *value_str = g_string_sized_new (60);
g_string_append (key_name, "tfilter.");
_nm_utils_string_append_tc_parent (key_name, NULL,
nm_tc_tfilter_get_parent (tfilter));
_nm_utils_string_append_tc_tfilter_rest (value_str, tfilter, NULL);
nm_keyfile_plugin_kf_set_string (info->keyfile,
NM_SETTING_TC_CONFIG_SETTING_NAME,
key_name->str,
value_str->str);
g_string_free (key_name, TRUE);
g_string_free (value_str, TRUE);
}
}
static void
write_hash_of_string (GKeyFile *file,
NMSetting *setting,
......@@ -585,6 +651,12 @@ static KeyWriter key_writers[] = {
{ NM_SETTING_802_1X_SETTING_NAME,
NM_SETTING_802_1X_PHASE2_PRIVATE_KEY,
cert_writer },
{ NM_SETTING_TC_CONFIG_SETTING_NAME,
NM_SETTING_TC_CONFIG_QDISCS,
qdisc_writer },
{ NM_SETTING_TC_CONFIG_SETTING_NAME,
NM_SETTING_TC_CONFIG_TFILTERS,
tfilter_writer },
{ NM_SETTING_TEAM_SETTING_NAME,
NM_SETTING_TEAM_NOTIFY_PEERS_COUNT,
null_writer},
......
......@@ -16,7 +16,7 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* Copyright 2007 - 2014 Red Hat, Inc.
* Copyright 2007 - 2017 Red Hat, Inc.
* Copyright 2007 - 2008 Novell, Inc.
*/
......@@ -1238,7 +1238,7 @@ nm_ip_route_set_attribute (NMIPRoute *route, const char *name, GVariant *value)