Commit 92f8f30d authored by Lubomir Rintel's avatar Lubomir Rintel 🥕

clients: add tc qdisc support

What works:

  nmcli c add con-name dum0 ifname dum0 type dummy \
      tc.qdiscs 'ingress, root pfifo_fast'
  nmcli c modify dum0 -tc.qdiscs 'root pfifo_fast'
  nmcli c modify dum0 +tc.qdiscs 'root handle 666: fq_codel'
parent 85473879
......@@ -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,82 @@ _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 const char *
_validate_fcn_team_config (const char *value, char **out_to_free, GError **error)
{
......@@ -6357,6 +6433,19 @@ 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,
),
),
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 +7456,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 +7642,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 +7723,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,
};
......
......@@ -2291,10 +2291,10 @@ nm_utils_tc_qdisc_from_str (const char *str, GError **error)
nm_assert (str);
nm_assert (!error || !*error);
ht = nm_utils_parse_variant_attributes (str,
' ', ' ', FALSE,
tc_object_attribute_spec,
error);
ht = nm_utils_parse_variant_attributes (str,
' ', ' ', FALSE,
tc_object_attribute_spec,
error);
if (!ht)
return NULL;
......
......@@ -15,7 +15,7 @@
* 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 __NETWORKMANAGER_H__
......@@ -84,6 +84,7 @@
#include "nm-setting-pppoe.h"
#include "nm-setting-proxy.h"
#include "nm-setting-serial.h"
#include "nm-setting-tc-config.h"
#include "nm-setting-team.h"
#include "nm-setting-team-port.h"
#include "nm-setting-tun.h"
......
......@@ -51,6 +51,7 @@
#include "nm-setting-pppoe.h"
#include "nm-setting-proxy.h"
#include "nm-setting-serial.h"
#include "nm-setting-tc-config.h"
#include "nm-setting-team.h"
#include "nm-setting-team-port.h"
#include "nm-setting-tun.h"
......@@ -279,6 +280,11 @@ const NMMetaSettingInfo nm_meta_setting_infos[] = {
.setting_name = NM_SETTING_SERIAL_SETTING_NAME,
.get_setting_gtype = nm_setting_serial_get_type,
},
[NM_META_SETTING_TYPE_TC_CONFIG] = {
.meta_type = NM_META_SETTING_TYPE_TC_CONFIG,
.setting_name = NM_SETTING_TC_CONFIG_SETTING_NAME,
.get_setting_gtype = nm_setting_tc_config_get_type,
},
[NM_META_SETTING_TYPE_TEAM] = {
.meta_type = NM_META_SETTING_TYPE_TEAM,
.setting_name = NM_SETTING_TEAM_SETTING_NAME,
......
......@@ -83,6 +83,7 @@ typedef enum {
NM_META_SETTING_TYPE_PPPOE,
NM_META_SETTING_TYPE_PROXY,
NM_META_SETTING_TYPE_SERIAL,
NM_META_SETTING_TYPE_TC_CONFIG,
NM_META_SETTING_TYPE_TEAM,
NM_META_SETTING_TYPE_TEAM_PORT,
NM_META_SETTING_TYPE_TUN,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment