mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-26 13:30:08 +01:00
bridge: introduce a bridge.group-forward-mask connection property
https://bugzilla.redhat.com/show_bug.cgi?id=1358615
This commit is contained in:
parent
5414239988
commit
17ec3aef2f
10 changed files with 83 additions and 2 deletions
|
|
@ -4915,6 +4915,12 @@ static const NMMetaPropertyInfo *const property_infos_BRIDGE[] = {
|
|||
.prompt = N_("MAC address ageing time [300]"),
|
||||
.property_type = &_pt_gobject_int,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_GROUP_FORWARD_MASK,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "group-forward-mask",
|
||||
.prompt = N_("Group forward mask [0]"),
|
||||
.property_type = &_pt_gobject_int,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_MULTICAST_SNOOPING,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "multicast-snooping",
|
||||
|
|
|
|||
|
|
@ -116,6 +116,7 @@
|
|||
#define DESCRIBE_DOC_NM_SETTING_BOND_OPTIONS N_("Dictionary of key/value pairs of bonding options. Both keys and values must be strings. Option names must contain only alphanumeric characters (ie, [a-zA-Z0-9]).")
|
||||
#define DESCRIBE_DOC_NM_SETTING_BRIDGE_AGEING_TIME N_("The Ethernet MAC address aging time, in seconds.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_BRIDGE_FORWARD_DELAY N_("The Spanning Tree Protocol (STP) forwarding delay, in seconds.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_BRIDGE_GROUP_FORWARD_MASK N_("A mask of group addresses to forward. Usually, group addresses in the range from 01:80:C2:00:00:00 to 01:80:C2:00:00:0F are not forwarded according to standards. This property is a mask of 16 bits, each corrisponding to a group address in that range that must be forwarded. The mask can't have bits 0, 1 or 2 set because they are used for STP, MAC pause frames and LACP.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_BRIDGE_HELLO_TIME N_("The Spanning Tree Protocol (STP) hello time, in seconds.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_BRIDGE_MAC_ADDRESS N_("If specified, the MAC address of bridge. When creating a new bridge, this MAC address will be set. If this field is left unspecified, the \"ethernet.cloned-mac-address\" is referred instead to generate the initial MAC address. Note that setting \"ethernet.cloned-mac-address\" anyway overwrites the MAC address of the bridge later while activating the bridge. Hence, this property is deprecated.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_BRIDGE_MAX_AGE N_("The Spanning Tree Protocol (STP) maximum message age, in seconds.")
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright 2011 - 2013 Red Hat, Inc.
|
||||
* Copyright 2011 - 2017 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include "nm-default.h"
|
||||
|
|
@ -52,6 +52,7 @@ typedef struct {
|
|||
guint16 hello_time;
|
||||
guint16 max_age;
|
||||
guint32 ageing_time;
|
||||
guint16 group_forward_mask;
|
||||
gboolean multicast_snooping;
|
||||
} NMSettingBridgePrivate;
|
||||
|
||||
|
|
@ -64,6 +65,7 @@ enum {
|
|||
PROP_HELLO_TIME,
|
||||
PROP_MAX_AGE,
|
||||
PROP_AGEING_TIME,
|
||||
PROP_GROUP_FORWARD_MASK,
|
||||
PROP_MULTICAST_SNOOPING,
|
||||
LAST_PROP
|
||||
};
|
||||
|
|
@ -179,6 +181,22 @@ nm_setting_bridge_get_ageing_time (NMSettingBridge *setting)
|
|||
return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->ageing_time;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_bridge_get_group_forward_mask:
|
||||
* @setting: the #NMSettingBridge
|
||||
*
|
||||
* Returns: the #NMSettingBridge:group-forward-mask property of the setting
|
||||
*
|
||||
* Since: 1.10
|
||||
**/
|
||||
guint16
|
||||
nm_setting_bridge_get_group_forward_mask (NMSettingBridge *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), 0);
|
||||
|
||||
return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->group_forward_mask;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_bridge_get_multicast_snooping:
|
||||
* @setting: the #NMSettingBridge
|
||||
|
|
@ -278,6 +296,15 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
|
|||
error))
|
||||
return FALSE;
|
||||
|
||||
if (priv->group_forward_mask & 7) {
|
||||
g_set_error_literal (error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_("the mask can't contain bits 0 (STP), 1 (MAC) or 2 (LACP)"));
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_BRIDGE_SETTING_NAME, NM_SETTING_BRIDGE_GROUP_FORWARD_MASK);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return _nm_connection_verify_required_interface_name (connection, error);
|
||||
}
|
||||
|
||||
|
|
@ -326,6 +353,9 @@ set_property (GObject *object, guint prop_id,
|
|||
case PROP_AGEING_TIME:
|
||||
priv->ageing_time = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_GROUP_FORWARD_MASK:
|
||||
priv->group_forward_mask = (guint16) g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_MULTICAST_SNOOPING:
|
||||
priv->multicast_snooping = g_value_get_boolean (value);
|
||||
break;
|
||||
|
|
@ -364,6 +394,9 @@ get_property (GObject *object, guint prop_id,
|
|||
case PROP_AGEING_TIME:
|
||||
g_value_set_uint (value, priv->ageing_time);
|
||||
break;
|
||||
case PROP_GROUP_FORWARD_MASK:
|
||||
g_value_set_uint (value, priv->group_forward_mask);
|
||||
break;
|
||||
case PROP_MULTICAST_SNOOPING:
|
||||
g_value_set_boolean (value, priv->multicast_snooping);
|
||||
break;
|
||||
|
|
@ -561,6 +594,27 @@ nm_setting_bridge_class_init (NMSettingBridgeClass *setting_class)
|
|||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingBridge:group-forward-mask:
|
||||
*
|
||||
* A mask of group addresses to forward. Usually, group addresses in
|
||||
* the range from 01:80:C2:00:00:00 to 01:80:C2:00:00:0F are not
|
||||
* forwarded according to standards. This property is a mask of 16 bits,
|
||||
* each corrisponding to a group address in that range that must be
|
||||
* forwarded. The mask can't have bits 0, 1 or 2 set because they are
|
||||
* used for STP, MAC pause frames and LACP.
|
||||
*
|
||||
* Since: 1.10
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_GROUP_FORWARD_MASK,
|
||||
g_param_spec_uint (NM_SETTING_BRIDGE_GROUP_FORWARD_MASK, "", "",
|
||||
0, 0xFFFF, 0,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingBridge:multicast-snooping:
|
||||
*
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ G_BEGIN_DECLS
|
|||
#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"
|
||||
|
||||
/**
|
||||
|
|
@ -81,6 +82,8 @@ guint16 nm_setting_bridge_get_hello_time (NMSettingBridge *setting);
|
|||
guint16 nm_setting_bridge_get_max_age (NMSettingBridge *setting);
|
||||
|
||||
guint32 nm_setting_bridge_get_ageing_time (NMSettingBridge *setting);
|
||||
NM_AVAILABLE_IN_1_10
|
||||
guint16 nm_setting_bridge_get_group_forward_mask (NMSettingBridge *setting);
|
||||
|
||||
gboolean nm_setting_bridge_get_multicast_snooping (NMSettingBridge *setting);
|
||||
|
||||
|
|
|
|||
|
|
@ -1181,6 +1181,7 @@ global:
|
|||
libnm_1_10_0 {
|
||||
global:
|
||||
nm_device_dummy_get_hw_address;
|
||||
nm_setting_bridge_get_group_forward_mask;
|
||||
nm_setting_wireless_security_get_pmf;
|
||||
nm_setting_wireless_security_get_wps_method;
|
||||
nm_setting_wireless_security_pmf_get_type;
|
||||
|
|
|
|||
|
|
@ -156,6 +156,7 @@ static const Option master_options[] = {
|
|||
{ NM_SETTING_BRIDGE_HELLO_TIME, "hello_time", TRUE, TRUE },
|
||||
{ NM_SETTING_BRIDGE_MAX_AGE, "max_age", TRUE, TRUE },
|
||||
{ NM_SETTING_BRIDGE_AGEING_TIME, "ageing_time", TRUE, TRUE },
|
||||
{ NM_SETTING_BRIDGE_GROUP_FORWARD_MASK, "group_fwd_mask", TRUE, FALSE },
|
||||
{ NM_SETTING_BRIDGE_MULTICAST_SNOOPING, "multicast_snooping", FALSE, FALSE },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4626,6 +4626,12 @@ handle_bridge_option (NMSetting *setting,
|
|||
(gboolean) u, NULL);
|
||||
else
|
||||
PARSE_WARNING ("invalid multicast_snooping value '%s'", value);
|
||||
} else if (!strcmp (key, "group_fwd_mask")) {
|
||||
if (get_uint (value, &u) && u <= 0xFFFF && !NM_FLAGS_ANY (u, 7))
|
||||
g_object_set (setting, NM_SETTING_BRIDGE_GROUP_FORWARD_MASK,
|
||||
(gboolean) u, NULL);
|
||||
else
|
||||
PARSE_WARNING ("invalid group_fwd_mask value '%s'", value);
|
||||
} else
|
||||
PARSE_WARNING ("unhandled bridge option '%s'", key);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1434,6 +1434,13 @@ write_bridge_setting (NMConnection *connection, shvarFile *ifcfg, GError **error
|
|||
g_string_append_printf (opts, "ageing_time=%u", i);
|
||||
}
|
||||
|
||||
i = nm_setting_bridge_get_group_forward_mask (s_bridge);
|
||||
if (i != get_setting_default_uint (NM_SETTING (s_bridge), NM_SETTING_BRIDGE_GROUP_FORWARD_MASK)) {
|
||||
if (opts->len)
|
||||
g_string_append_c (opts, ' ');
|
||||
g_string_append_printf (opts, "group_fwd_mask=%u", i);
|
||||
}
|
||||
|
||||
b = nm_setting_bridge_get_multicast_snooping (s_bridge);
|
||||
if (b != get_setting_default_boolean (NM_SETTING (s_bridge), NM_SETTING_BRIDGE_MULTICAST_SNOOPING)) {
|
||||
if (opts->len)
|
||||
|
|
|
|||
|
|
@ -4,5 +4,5 @@ TYPE=Bridge
|
|||
BOOTPROTO=dhcp
|
||||
STP=on
|
||||
DELAY=2
|
||||
BRIDGING_OPTS="priority=32744 hello_time=7 max_age=39 ageing_time=235352 multicast_snooping=0"
|
||||
BRIDGING_OPTS="priority=32744 hello_time=7 max_age=39 ageing_time=235352 multicast_snooping=0 group_fwd_mask=24"
|
||||
MACADDR=00:16:41:11:22:33
|
||||
|
|
|
|||
|
|
@ -7173,6 +7173,7 @@ test_read_bridge_main (void)
|
|||
g_assert_cmpuint (nm_setting_bridge_get_hello_time (s_bridge), ==, 7);
|
||||
g_assert_cmpuint (nm_setting_bridge_get_max_age (s_bridge), ==, 39);
|
||||
g_assert_cmpuint (nm_setting_bridge_get_ageing_time (s_bridge), ==, 235352);
|
||||
g_assert_cmpuint (nm_setting_bridge_get_group_forward_mask (s_bridge), ==, 24);
|
||||
g_assert (!nm_setting_bridge_get_multicast_snooping (s_bridge));
|
||||
|
||||
/* MAC address */
|
||||
|
|
@ -7218,6 +7219,7 @@ test_write_bridge_main (void)
|
|||
|
||||
g_object_set (s_bridge,
|
||||
NM_SETTING_BRIDGE_MAC_ADDRESS, mac,
|
||||
NM_SETTING_BRIDGE_GROUP_FORWARD_MASK, 19008,
|
||||
NULL);
|
||||
|
||||
/* IP4 setting */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue