mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-05 06:30:33 +01:00
nm-setting-bridge: add 'vlan-stats-enabled' bridge option
https://bugzilla.redhat.com/show_bug.cgi?id=1755768
This commit is contained in:
parent
f5352ff656
commit
bd30491f42
8 changed files with 80 additions and 14 deletions
|
|
@ -4911,6 +4911,9 @@ static const NMMetaPropertyInfo *const property_infos_BRIDGE[] = {
|
|||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_VLAN_DEFAULT_PVID,
|
||||
.property_type = &_pt_gobject_int,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_VLAN_STATS_ENABLED,
|
||||
.property_type = &_pt_gobject_bool,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_VLAN_PROTOCOL,
|
||||
.property_type = &_pt_gobject_string,
|
||||
.property_typ_data = DEFINE_PROPERTY_TYP_DATA (
|
||||
|
|
|
|||
|
|
@ -125,6 +125,7 @@
|
|||
#define DESCRIBE_DOC_NM_SETTING_BRIDGE_VLAN_DEFAULT_PVID N_("The default PVID for the ports of the bridge, that is the VLAN id assigned to incoming untagged frames.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_BRIDGE_VLAN_FILTERING N_("Control whether VLAN filtering is enabled on the bridge.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_BRIDGE_VLAN_PROTOCOL N_("If specified, the protocol used for VLAN filtering. Supported values are: '802.1Q', '802.1ad'. If not specified the default value is '802.1Q'.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_BRIDGE_VLAN_STATS_ENABLED N_("Controls whether per-VLAN stats accounting is enabled.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_BRIDGE_VLANS N_("Array of bridge VLAN objects. In addition to the VLANs specified here, the bridge will also have the default-pvid VLAN configured by the bridge.vlan-default-pvid property. In nmcli the VLAN list can be specified with the following syntax: $vid [pvid] [untagged] [, $vid [pvid] [untagged]]... where $vid is either a single id between 1 and 4094 or a range, represented as a couple of ids separated by a dash.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_BRIDGE_PORT_HAIRPIN_MODE N_("Enables or disables \"hairpin mode\" for the port, which allows frames to be sent back out through the port the frame was received on.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_BRIDGE_PORT_PATH_COST N_("The Spanning Tree Protocol (STP) port cost for destinations via this port.")
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
#define BRIDGE_PRIORITY_DEFAULT 0x8000
|
||||
#define BRIDGE_STP_DEFAULT TRUE
|
||||
#define BRIDGE_VLAN_DEFAULT_PVID_DEFAULT 1
|
||||
#define BRIDGE_VLAN_STATS_ENABLED_DEFAULT FALSE
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
|
@ -47,6 +48,7 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMSettingBridge,
|
|||
PROP_VLAN_FILTERING,
|
||||
PROP_VLAN_DEFAULT_PVID,
|
||||
PROP_VLAN_PROTOCOL,
|
||||
PROP_VLAN_STATS_ENABLED,
|
||||
PROP_VLANS,
|
||||
);
|
||||
|
||||
|
|
@ -65,6 +67,7 @@ typedef struct {
|
|||
bool multicast_snooping:1;
|
||||
bool vlan_filtering:1;
|
||||
bool stp:1;
|
||||
bool vlan_stats_enabled:1;
|
||||
} NMSettingBridgePrivate;
|
||||
|
||||
/**
|
||||
|
|
@ -935,6 +938,22 @@ nm_setting_bridge_get_vlan_protocol (const NMSettingBridge *setting)
|
|||
return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->vlan_protocol;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_bridge_get_vlan_stats_enabled:
|
||||
* @setting: the #NMSettingBridge
|
||||
*
|
||||
* Returns: the #NMSettingBridge:vlan-stats-enabled property of the setting
|
||||
*
|
||||
* Since 1.24
|
||||
**/
|
||||
gboolean
|
||||
nm_setting_bridge_get_vlan_stats_enabled (const NMSettingBridge *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), FALSE);
|
||||
|
||||
return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->vlan_stats_enabled;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static gboolean
|
||||
|
|
@ -1145,6 +1164,9 @@ get_property (GObject *object, guint prop_id,
|
|||
case PROP_VLAN_PROTOCOL:
|
||||
g_value_set_string (value, priv->vlan_protocol);
|
||||
break;
|
||||
case PROP_VLAN_STATS_ENABLED:
|
||||
g_value_set_boolean (value, priv->vlan_stats_enabled);
|
||||
break;
|
||||
case PROP_VLANS:
|
||||
g_value_take_boxed (value, _nm_utils_copy_array (priv->vlans,
|
||||
(NMUtilsCopyFunc) nm_bridge_vlan_ref,
|
||||
|
|
@ -1207,6 +1229,9 @@ set_property (GObject *object, guint prop_id,
|
|||
g_free (priv->vlan_protocol);
|
||||
priv->vlan_protocol = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_VLAN_STATS_ENABLED:
|
||||
priv->vlan_stats_enabled = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_VLANS:
|
||||
g_ptr_array_unref (priv->vlans);
|
||||
priv->vlans = _nm_utils_copy_array (g_value_get_boxed (value),
|
||||
|
|
@ -1236,6 +1261,7 @@ nm_setting_bridge_init (NMSettingBridge *setting)
|
|||
priv->priority = BRIDGE_PRIORITY_DEFAULT;
|
||||
priv->stp = BRIDGE_STP_DEFAULT;
|
||||
priv->vlan_default_pvid = BRIDGE_VLAN_DEFAULT_PVID_DEFAULT;
|
||||
priv->vlan_stats_enabled = BRIDGE_VLAN_STATS_ENABLED_DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1618,6 +1644,25 @@ nm_setting_bridge_class_init (NMSettingBridgeClass *klass)
|
|||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* NMSettingBridge:vlan-stats-enabled:
|
||||
*
|
||||
* Controls whether per-VLAN stats accounting is enabled.
|
||||
**/
|
||||
/* ---ifcfg-rh---
|
||||
* property: vlan-stats-enabled
|
||||
* variable: BRIDGING_OPTS: vlan_stats_enabled=
|
||||
* default: 0
|
||||
* example: BRIDGING_OPTS="vlan_stats_enabled=1"
|
||||
* ---end---
|
||||
*/
|
||||
obj_properties[PROP_VLAN_STATS_ENABLED] =
|
||||
g_param_spec_boolean (NM_SETTING_BRIDGE_VLAN_STATS_ENABLED, "", "",
|
||||
BRIDGE_VLAN_STATS_ENABLED_DEFAULT,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
|
||||
|
||||
_nm_setting_class_commit_full (setting_class, NM_META_SETTING_TYPE_BRIDGE,
|
||||
|
|
|
|||
|
|
@ -23,20 +23,21 @@ G_BEGIN_DECLS
|
|||
|
||||
#define NM_SETTING_BRIDGE_SETTING_NAME "bridge"
|
||||
|
||||
#define NM_SETTING_BRIDGE_MAC_ADDRESS "mac-address"
|
||||
#define NM_SETTING_BRIDGE_STP "stp"
|
||||
#define NM_SETTING_BRIDGE_PRIORITY "priority"
|
||||
#define NM_SETTING_BRIDGE_FORWARD_DELAY "forward-delay"
|
||||
#define NM_SETTING_BRIDGE_HELLO_TIME "hello-time"
|
||||
#define NM_SETTING_BRIDGE_MAX_AGE "max-age"
|
||||
#define NM_SETTING_BRIDGE_AGEING_TIME "ageing-time"
|
||||
#define NM_SETTING_BRIDGE_GROUP_FORWARD_MASK "group-forward-mask"
|
||||
#define NM_SETTING_BRIDGE_MULTICAST_SNOOPING "multicast-snooping"
|
||||
#define NM_SETTING_BRIDGE_VLAN_FILTERING "vlan-filtering"
|
||||
#define NM_SETTING_BRIDGE_VLAN_DEFAULT_PVID "vlan-default-pvid"
|
||||
#define NM_SETTING_BRIDGE_VLANS "vlans"
|
||||
#define NM_SETTING_BRIDGE_GROUP_ADDRESS "group-address"
|
||||
#define NM_SETTING_BRIDGE_VLAN_PROTOCOL "vlan-protocol"
|
||||
#define NM_SETTING_BRIDGE_MAC_ADDRESS "mac-address"
|
||||
#define NM_SETTING_BRIDGE_STP "stp"
|
||||
#define NM_SETTING_BRIDGE_PRIORITY "priority"
|
||||
#define NM_SETTING_BRIDGE_FORWARD_DELAY "forward-delay"
|
||||
#define NM_SETTING_BRIDGE_HELLO_TIME "hello-time"
|
||||
#define NM_SETTING_BRIDGE_MAX_AGE "max-age"
|
||||
#define NM_SETTING_BRIDGE_AGEING_TIME "ageing-time"
|
||||
#define NM_SETTING_BRIDGE_GROUP_FORWARD_MASK "group-forward-mask"
|
||||
#define NM_SETTING_BRIDGE_MULTICAST_SNOOPING "multicast-snooping"
|
||||
#define NM_SETTING_BRIDGE_VLAN_FILTERING "vlan-filtering"
|
||||
#define NM_SETTING_BRIDGE_VLAN_DEFAULT_PVID "vlan-default-pvid"
|
||||
#define NM_SETTING_BRIDGE_VLANS "vlans"
|
||||
#define NM_SETTING_BRIDGE_GROUP_ADDRESS "group-address"
|
||||
#define NM_SETTING_BRIDGE_VLAN_PROTOCOL "vlan-protocol"
|
||||
#define NM_SETTING_BRIDGE_VLAN_STATS_ENABLED "vlan-stats-enabled"
|
||||
|
||||
#define NM_BRIDGE_VLAN_VID_MIN 1
|
||||
#define NM_BRIDGE_VLAN_VID_MAX 4094
|
||||
|
|
@ -124,6 +125,9 @@ const char * nm_setting_bridge_get_group_address (const NMSettingBridge *setti
|
|||
NM_AVAILABLE_IN_1_24
|
||||
const char * nm_setting_bridge_get_vlan_protocol (const NMSettingBridge *setting);
|
||||
|
||||
NM_AVAILABLE_IN_1_24
|
||||
gboolean nm_setting_bridge_get_vlan_stats_enabled (const NMSettingBridge *setting);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __NM_SETTING_BRIDGE_H__ */
|
||||
|
|
|
|||
|
|
@ -1687,6 +1687,7 @@ global:
|
|||
nm_setting_bond_get_option_normalized;
|
||||
nm_setting_bridge_get_group_address;
|
||||
nm_setting_bridge_get_vlan_protocol;
|
||||
nm_setting_bridge_get_vlan_stats_enabled;
|
||||
nm_setting_vrf_get_table;
|
||||
nm_setting_vrf_get_type;
|
||||
nm_setting_vrf_new;
|
||||
|
|
|
|||
|
|
@ -254,6 +254,10 @@ static const Option master_options[] = {
|
|||
to_sysfs_vlan_protocol, from_sysfs_vlan_protocol,
|
||||
0, 0, 0,
|
||||
FALSE, FALSE, FALSE },
|
||||
{ NM_SETTING_BRIDGE_VLAN_STATS_ENABLED, "vlan_stats_enabled",
|
||||
NULL, NULL,
|
||||
0, 1, 0,
|
||||
FALSE, FALSE, FALSE },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -5163,6 +5163,7 @@ handle_bridge_option (NMSetting *setting,
|
|||
{ "group_address", NM_SETTING_BRIDGE_GROUP_ADDRESS, BRIDGE_OPT_TYPE_OPTION },
|
||||
{ "group_fwd_mask", NM_SETTING_BRIDGE_GROUP_FORWARD_MASK, BRIDGE_OPT_TYPE_OPTION },
|
||||
{ "vlan_protocol", NM_SETTING_BRIDGE_VLAN_PROTOCOL, BRIDGE_OPT_TYPE_OPTION },
|
||||
{ "vlan_stats_enabled", NM_SETTING_BRIDGE_VLAN_STATS_ENABLED, BRIDGE_OPT_TYPE_OPTION },
|
||||
{ "priority", NM_SETTING_BRIDGE_PORT_PRIORITY, BRIDGE_OPT_TYPE_PORT_OPTION },
|
||||
{ "path_cost", NM_SETTING_BRIDGE_PORT_PATH_COST, BRIDGE_OPT_TYPE_PORT_OPTION },
|
||||
{ "hairpin_mode", NM_SETTING_BRIDGE_PORT_HAIRPIN_MODE, BRIDGE_OPT_TYPE_PORT_OPTION, .extended_bool = TRUE, },
|
||||
|
|
|
|||
|
|
@ -1529,6 +1529,13 @@ write_bridge_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wire
|
|||
g_string_append_printf (opts, "vlan_protocol=%s", s);
|
||||
}
|
||||
|
||||
b = nm_setting_bridge_get_vlan_stats_enabled (s_bridge);
|
||||
if (b != get_setting_default_boolean (NM_SETTING (s_bridge), NM_SETTING_BRIDGE_VLAN_STATS_ENABLED)) {
|
||||
if (opts->len)
|
||||
g_string_append_c (opts, ' ');
|
||||
g_string_append_printf (opts, "vlan_stats_enabled=%u", (guint) b);
|
||||
}
|
||||
|
||||
if (opts->len)
|
||||
svSetValueStr (ifcfg, "BRIDGING_OPTS", opts->str);
|
||||
g_string_free (opts, TRUE);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue