libnm-core: add explicit team properties to NMSettingTeamPort

This commit is contained in:
Francesco Giudici 2017-10-30 12:27:58 +01:00
parent e1220c933f
commit 1c99d379eb
4 changed files with 223 additions and 0 deletions

View file

@ -332,7 +332,12 @@
#define DESCRIBE_DOC_NM_SETTING_TEAM_RUNNER_TX_BALANCER_INTERVAL N_("Corresponds to the teamd runner.tx_balancer.interval.")
#define DESCRIBE_DOC_NM_SETTING_TEAM_RUNNER_TX_HASH N_("Corresponds to the teamd runner.tx_hash.")
#define DESCRIBE_DOC_NM_SETTING_TEAM_PORT_CONFIG N_("The JSON configuration for the team port. 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_PORT_LACP_KEY N_("Corresponds to the teamd ports.PORTIFNAME.lacp_key.")
#define DESCRIBE_DOC_NM_SETTING_TEAM_PORT_LACP_PRIO N_("Corresponds to the teamd ports.PORTIFNAME.lacp_prio.")
#define DESCRIBE_DOC_NM_SETTING_TEAM_PORT_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_TEAM_PORT_PRIO N_("Corresponds to the teamd ports.PORTIFNAME.prio.")
#define DESCRIBE_DOC_NM_SETTING_TEAM_PORT_QUEUE_ID N_("Corresponds to the teamd ports.PORTIFNAME.queue_id. When set to -1 means the parameter is skipped from the json config.")
#define DESCRIBE_DOC_NM_SETTING_TEAM_PORT_STICKY N_("Corresponds to the teamd ports.PORTIFNAME.sticky.")
#define DESCRIBE_DOC_NM_SETTING_TUN_GROUP N_("The group ID which will own the device. If set to NULL everyone will be able to use the device.")
#define DESCRIBE_DOC_NM_SETTING_TUN_MODE N_("The operating mode of the virtual device. Allowed values are NM_SETTING_TUN_MODE_TUN (1) to create a layer 3 device and NM_SETTING_TUN_MODE_TAP (2) to create an Ethernet-like layer 2 one.")
#define DESCRIBE_DOC_NM_SETTING_TUN_MULTI_QUEUE N_("If the property is set to TRUE, the interface will support multiple file descriptors (queues) to parallelize packet sending or receiving. Otherwise, the interface will only support a single queue.")

View file

@ -47,11 +47,21 @@ NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_TEAM_PORT)
typedef struct {
char *config;
int queue_id;
int prio;
gboolean sticky;
int lacp_prio;
int lacp_key;
} NMSettingTeamPortPrivate;
enum {
PROP_0,
PROP_CONFIG,
PROP_QUEUE_ID,
PROP_PRIO,
PROP_STICKY,
PROP_LACP_PRIO,
PROP_LACP_KEY,
LAST_PROP
};
@ -82,6 +92,86 @@ nm_setting_team_port_get_config (NMSettingTeamPort *setting)
return NM_SETTING_TEAM_PORT_GET_PRIVATE (setting)->config;
}
/**
* nm_setting_team_port_get_queue_id:
* @setting: the #NMSettingTeamPort
*
* Returns: the #NMSettingTeamPort:queue_id property of the setting
*
* Since 1.12
**/
gint
nm_setting_team_port_get_queue_id (NMSettingTeamPort *setting)
{
g_return_val_if_fail (NM_IS_SETTING_TEAM_PORT (setting), -1);
return NM_SETTING_TEAM_PORT_GET_PRIVATE (setting)->queue_id;
}
/**
* nm_setting_team_port_get_prio:
* @setting: the #NMSettingTeamPort
*
* Returns: the #NMSettingTeamPort:prio property of the setting
*
* Since 1.12
**/
gint
nm_setting_team_port_get_prio (NMSettingTeamPort *setting)
{
g_return_val_if_fail (NM_IS_SETTING_TEAM_PORT (setting), 0);
return NM_SETTING_TEAM_PORT_GET_PRIVATE (setting)->prio;
}
/**
* nm_setting_team_port_get_sticky:
* @setting: the #NMSettingTeamPort
*
* Returns: the #NMSettingTeamPort:sticky property of the setting
*
* Since 1.12
**/
gboolean
nm_setting_team_port_get_sticky (NMSettingTeamPort *setting)
{
g_return_val_if_fail (NM_IS_SETTING_TEAM_PORT (setting), FALSE);
return NM_SETTING_TEAM_PORT_GET_PRIVATE (setting)->sticky;
}
/**
* nm_setting_team_port_get_lacp_prio:
* @setting: the #NMSettingTeamPort
*
* Returns: the #NMSettingTeamPort:lacp-prio property of the setting
*
* Since 1.12
**/
gint
nm_setting_team_port_get_lacp_prio (NMSettingTeamPort *setting)
{
g_return_val_if_fail (NM_IS_SETTING_TEAM_PORT (setting), 0);
return NM_SETTING_TEAM_PORT_GET_PRIVATE (setting)->lacp_prio;
}
/**
* nm_setting_team_port_get_lacp_key:
* @setting: the #NMSettingTeamPort
*
* Returns: the #NMSettingTeamPort:lacp-key property of the setting
*
* Since 1.12
**/
gint
nm_setting_team_port_get_lacp_key (NMSettingTeamPort *setting)
{
g_return_val_if_fail (NM_IS_SETTING_TEAM_PORT (setting), 0);
return NM_SETTING_TEAM_PORT_GET_PRIVATE (setting)->lacp_key;
}
static gboolean
verify (NMSetting *setting, NMConnection *connection, GError **error)
{
@ -171,6 +261,10 @@ compare_property (NMSetting *setting,
static void
nm_setting_team_port_init (NMSettingTeamPort *setting)
{
NMSettingTeamPortPrivate *priv = NM_SETTING_TEAM_PORT_GET_PRIVATE (setting);
priv->queue_id = -1;
priv->lacp_prio = 255;
}
static void
@ -184,6 +278,21 @@ set_property (GObject *object, guint prop_id,
g_free (priv->config);
priv->config = g_value_dup_string (value);
break;
case PROP_QUEUE_ID:
priv->queue_id = g_value_get_int (value);
break;
case PROP_PRIO:
priv->prio = g_value_get_int (value);
break;
case PROP_STICKY:
priv->sticky = g_value_get_boolean (value);
break;
case PROP_LACP_PRIO:
priv->lacp_prio = g_value_get_int (value);
break;
case PROP_LACP_KEY:
priv->lacp_key = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -195,11 +304,27 @@ get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
NMSettingTeamPort *setting = NM_SETTING_TEAM_PORT (object);
NMSettingTeamPortPrivate *priv = NM_SETTING_TEAM_PORT_GET_PRIVATE (setting);
switch (prop_id) {
case PROP_CONFIG:
g_value_set_string (value, nm_setting_team_port_get_config (setting));
break;
case PROP_QUEUE_ID:
g_value_set_int (value, priv->queue_id);
break;
case PROP_PRIO:
g_value_set_int (value, priv->prio);
break;
case PROP_STICKY:
g_value_set_boolean (value, priv->sticky);
break;
case PROP_LACP_PRIO:
g_value_set_int (value, priv->lacp_prio);
break;
case PROP_LACP_KEY:
g_value_set_int (value, priv->lacp_key);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -253,4 +378,77 @@ nm_setting_team_port_class_init (NMSettingTeamPortClass *setting_class)
G_PARAM_READWRITE |
NM_SETTING_PARAM_INFERRABLE |
G_PARAM_STATIC_STRINGS));
/**
* NMSettingTeamPort:queue-id:
*
* Corresponds to the teamd ports.PORTIFNAME.queue_id.
* When set to -1 means the parameter is skipped from the json config.
*
* Since: 1.12
**/
g_object_class_install_property
(object_class, PROP_QUEUE_ID,
g_param_spec_int (NM_SETTING_TEAM_PORT_QUEUE_ID, "", "",
G_MININT32, G_MAXINT32, 0,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
/**
* NMSettingTeamPort:prio:
*
* Corresponds to the teamd ports.PORTIFNAME.prio.
*
* Since: 1.12
**/
g_object_class_install_property
(object_class, PROP_PRIO,
g_param_spec_int (NM_SETTING_TEAM_PORT_PRIO, "", "",
G_MININT32, G_MAXINT32, 0,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
/**
* NMSettingTeamPort:sticky:
*
* Corresponds to the teamd ports.PORTIFNAME.sticky.
*
* Since: 1.12
**/
g_object_class_install_property
(object_class, PROP_STICKY,
g_param_spec_boolean (NM_SETTING_TEAM_PORT_STICKY, "", "",
FALSE,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
/**
* NMSettingTeamPort:lacp-prio:
*
* Corresponds to the teamd ports.PORTIFNAME.lacp_prio.
*
* Since: 1.12
**/
g_object_class_install_property
(object_class, PROP_LACP_PRIO,
g_param_spec_int (NM_SETTING_TEAM_PORT_LACP_PRIO, "", "",
G_MININT32, G_MAXINT32, 0,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
/**
* NMSettingTeamPort:lacp-key:
*
* Corresponds to the teamd ports.PORTIFNAME.lacp_key.
*
* Since: 1.12
**/
g_object_class_install_property
(object_class, PROP_LACP_KEY,
g_param_spec_int (NM_SETTING_TEAM_PORT_LACP_KEY, "", "",
G_MININT32, G_MAXINT32, 0,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
}

View file

@ -39,6 +39,11 @@ G_BEGIN_DECLS
#define NM_SETTING_TEAM_PORT_SETTING_NAME "team-port"
#define NM_SETTING_TEAM_PORT_CONFIG "config"
#define NM_SETTING_TEAM_PORT_QUEUE_ID "queue-id"
#define NM_SETTING_TEAM_PORT_PRIO "prio"
#define NM_SETTING_TEAM_PORT_STICKY "sticky"
#define NM_SETTING_TEAM_PORT_LACP_PRIO "lacp-prio"
#define NM_SETTING_TEAM_PORT_LACP_KEY "lacp-key"
/**
* NMSettingTeamPort:
@ -61,6 +66,16 @@ GType nm_setting_team_port_get_type (void);
NMSetting * nm_setting_team_port_new (void);
const char * nm_setting_team_port_get_config (NMSettingTeamPort *setting);
NM_AVAILABLE_IN_1_12
gint nm_setting_team_port_get_queue_id (NMSettingTeamPort *setting);
NM_AVAILABLE_IN_1_12
gint nm_setting_team_port_get_prio (NMSettingTeamPort *setting);
NM_AVAILABLE_IN_1_12
gboolean nm_setting_team_port_get_sticky (NMSettingTeamPort *setting);
NM_AVAILABLE_IN_1_12
gint nm_setting_team_port_get_lacp_prio (NMSettingTeamPort *setting);
NM_AVAILABLE_IN_1_12
gint nm_setting_team_port_get_lacp_key (NMSettingTeamPort *setting);
G_END_DECLS

View file

@ -1251,6 +1251,11 @@ global:
nm_setting_team_get_runner_sys_prio;
nm_setting_team_get_runner_min_ports;
nm_setting_team_get_runner_agg_select_policy;
nm_setting_team_port_get_queue_id;
nm_setting_team_port_get_prio;
nm_setting_team_port_get_sticky;
nm_setting_team_port_get_lacp_prio;
nm_setting_team_port_get_lacp_key;
nm_setting_team_remove_runner_tx_hash;
nm_setting_team_remove_runner_tx_hash_by_value;
} libnm_1_10_0;