mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-04 18:50:29 +01:00
nmcli: add support for bridge multicast-snooping property
This commit is contained in:
parent
dead766c3b
commit
591908c8bd
3 changed files with 51 additions and 6 deletions
|
|
@ -386,6 +386,7 @@ usage_connection_add (void)
|
|||
" [hello-time <1-10>]\n"
|
||||
" [max-age <6-40>]\n"
|
||||
" [ageing-time <0-1000000>]\n"
|
||||
" [multicast-snooping yes|no]\n"
|
||||
" [mac <MAC address>]\n\n"
|
||||
" bridge-slave: master <master (ifname, or connection UUID or name)>\n"
|
||||
" [priority <0-63>]\n"
|
||||
|
|
@ -3811,14 +3812,14 @@ do_questionnaire_team_slave (char **config)
|
|||
|
||||
static void
|
||||
do_questionnaire_bridge (char **stp, char **priority, char **fwd_delay, char **hello_time,
|
||||
char **max_age, char **ageing_time, char **mac)
|
||||
char **max_age, char **ageing_time, char **mcast_snoop, char **mac)
|
||||
{
|
||||
unsigned long tmp;
|
||||
gboolean once_more;
|
||||
GError *error = NULL;
|
||||
|
||||
/* Ask for optional 'bridge' arguments. */
|
||||
if (!want_provide_opt_args (_("bridge"), 7))
|
||||
if (!want_provide_opt_args (_("bridge"), 8))
|
||||
return;
|
||||
|
||||
if (!*stp) {
|
||||
|
|
@ -3896,6 +3897,20 @@ do_questionnaire_bridge (char **stp, char **priority, char **fwd_delay, char **h
|
|||
}
|
||||
} while (once_more);
|
||||
}
|
||||
if (!*mcast_snoop) {
|
||||
gboolean mcast_snoop_bool;
|
||||
do {
|
||||
*mcast_snoop = nmc_readline (_("Enable IGMP snooping %s"), prompt_yes_no (TRUE, ":"));
|
||||
*mcast_snoop = *mcast_snoop ? *mcast_snoop : g_strdup ("yes");
|
||||
normalize_yes_no (mcast_snoop);
|
||||
once_more = !nmc_string_to_bool (*mcast_snoop, &mcast_snoop_bool, &error);
|
||||
if (once_more) {
|
||||
g_print (_("Error: 'multicast-snooping': %s.\n"), error->message);
|
||||
g_clear_error (&error);
|
||||
g_free (*mcast_snoop);
|
||||
}
|
||||
} while (once_more);
|
||||
}
|
||||
if (!*mac) {
|
||||
do {
|
||||
*mac = nmc_get_user_input (_("MAC [none]: "));
|
||||
|
|
@ -5045,7 +5060,9 @@ cleanup_team_slave:
|
|||
char *max_age = NULL;
|
||||
const char *ageing_time_c = NULL;
|
||||
char *ageing_time = NULL;
|
||||
gboolean stp_bool;
|
||||
const char *mcast_snoop_c = NULL;
|
||||
char *mcast_snoop = NULL;
|
||||
gboolean stp_bool, mcast_snoop_bool;
|
||||
unsigned long stp_prio_int, fwd_delay_int, hello_time_int,
|
||||
max_age_int, ageing_time_int;
|
||||
const char *mac_c = NULL;
|
||||
|
|
@ -5056,6 +5073,7 @@ cleanup_team_slave:
|
|||
{"hello-time", TRUE, &hello_time_c, FALSE},
|
||||
{"max-age", TRUE, &max_age_c, FALSE},
|
||||
{"ageing-time", TRUE, &ageing_time_c, FALSE},
|
||||
{"multicast-snooping", TRUE, &mcast_snoop_c, FALSE},
|
||||
{"mac", TRUE, &mac_c, FALSE},
|
||||
{NULL} };
|
||||
|
||||
|
|
@ -5069,10 +5087,11 @@ cleanup_team_slave:
|
|||
hello_time = g_strdup (hello_time_c);
|
||||
max_age = g_strdup (max_age_c);
|
||||
ageing_time = g_strdup (ageing_time_c);
|
||||
mcast_snoop = g_strdup (mcast_snoop_c);
|
||||
mac = g_strdup (mac_c);
|
||||
if (ask)
|
||||
do_questionnaire_bridge (&stp, &priority, &fwd_delay, &hello_time,
|
||||
&max_age, &ageing_time, &mac);
|
||||
&max_age, &ageing_time, &mcast_snoop, &mac);
|
||||
|
||||
/* Generate ifname if conneciton doesn't have one */
|
||||
ifname = nm_setting_connection_get_interface_name (s_con);
|
||||
|
|
@ -5094,6 +5113,15 @@ cleanup_team_slave:
|
|||
goto cleanup_bridge;
|
||||
}
|
||||
}
|
||||
if (mcast_snoop) {
|
||||
GError *tmp_err = NULL;
|
||||
if (!nmc_string_to_bool (mcast_snoop, &mcast_snoop_bool, &tmp_err)) {
|
||||
g_set_error (error, NMCLI_ERROR, NMC_RESULT_ERROR_USER_INPUT,
|
||||
_("Error: 'multicast-snooping': %s."), tmp_err->message);
|
||||
g_clear_error (&tmp_err);
|
||||
goto cleanup_bridge;
|
||||
}
|
||||
}
|
||||
|
||||
/* Add 'bond' setting */
|
||||
/* Must be done *before* bridge_prop_string_to_uint() so that the type is known */
|
||||
|
|
@ -5136,6 +5164,8 @@ cleanup_team_slave:
|
|||
g_object_set (s_bridge, NM_SETTING_BRIDGE_MAX_AGE, max_age_int, NULL);
|
||||
if (ageing_time)
|
||||
g_object_set (s_bridge, NM_SETTING_BRIDGE_AGEING_TIME, ageing_time_int, NULL);
|
||||
if (mcast_snoop)
|
||||
g_object_set (s_bridge, NM_SETTING_BRIDGE_MULTICAST_SNOOPING, mcast_snoop_bool, NULL);
|
||||
if (mac)
|
||||
g_object_set (s_bridge, NM_SETTING_BRIDGE_MAC_ADDRESS, mac, NULL);
|
||||
|
||||
|
|
@ -5147,6 +5177,7 @@ cleanup_bridge:
|
|||
g_free (hello_time);
|
||||
g_free (max_age);
|
||||
g_free (ageing_time);
|
||||
g_free (mcast_snoop);
|
||||
g_free (mac);
|
||||
if (!success)
|
||||
return FALSE;
|
||||
|
|
|
|||
|
|
@ -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 - 2014 Red Hat, Inc.
|
||||
* Copyright 2010 - 2015 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
|
@ -578,6 +578,7 @@ NmcOutputField nmc_fields_setting_bridge[] = {
|
|||
SETTING_FIELD (NM_SETTING_BRIDGE_HELLO_TIME, 6), /* 5 */
|
||||
SETTING_FIELD (NM_SETTING_BRIDGE_MAX_AGE, 6), /* 6 */
|
||||
SETTING_FIELD (NM_SETTING_BRIDGE_AGEING_TIME, 6), /* 7 */
|
||||
SETTING_FIELD (NM_SETTING_BRIDGE_MULTICAST_SNOOPING, 6), /* 8 */
|
||||
{NULL, NULL, 0, NULL, FALSE, FALSE, 0}
|
||||
};
|
||||
#define NMC_FIELDS_SETTING_BRIDGE_ALL "name"","\
|
||||
|
|
@ -587,7 +588,8 @@ NmcOutputField nmc_fields_setting_bridge[] = {
|
|||
NM_SETTING_BRIDGE_FORWARD_DELAY","\
|
||||
NM_SETTING_BRIDGE_HELLO_TIME","\
|
||||
NM_SETTING_BRIDGE_MAX_AGE","\
|
||||
NM_SETTING_BRIDGE_AGEING_TIME
|
||||
NM_SETTING_BRIDGE_AGEING_TIME","\
|
||||
NM_SETTING_BRIDGE_MULTICAST_SNOOPING
|
||||
#define NMC_FIELDS_SETTING_BRIDGE_COMMON NMC_FIELDS_SETTING_BRIDGE_ALL
|
||||
|
||||
/* Available fields for NM_SETTING_BRIDGE_PORT_SETTING_NAME */
|
||||
|
|
@ -996,6 +998,7 @@ DEFINE_GETTER (nmc_property_bridge_get_forward_delay, NM_SETTING_BRIDGE_FORWARD_
|
|||
DEFINE_GETTER (nmc_property_bridge_get_hello_time, NM_SETTING_BRIDGE_HELLO_TIME)
|
||||
DEFINE_GETTER (nmc_property_bridge_get_max_age, NM_SETTING_BRIDGE_MAX_AGE)
|
||||
DEFINE_GETTER (nmc_property_bridge_get_ageing_time, NM_SETTING_BRIDGE_AGEING_TIME)
|
||||
DEFINE_GETTER (nmc_property_bridge_get_multicast_snooping, NM_SETTING_BRIDGE_MULTICAST_SNOOPING)
|
||||
|
||||
/* --- NM_SETTING_BRIDGE_PORT_SETTING_NAME property get functions --- */
|
||||
DEFINE_GETTER (nmc_property_bridge_port_get_priority, NM_SETTING_BRIDGE_PORT_PRIORITY)
|
||||
|
|
@ -5146,6 +5149,14 @@ nmc_properties_init (void)
|
|||
NULL,
|
||||
NULL);
|
||||
|
||||
nmc_add_prop_funcs (GLUE (BRIDGE, MULTICAST_SNOOPING),
|
||||
nmc_property_bridge_get_multicast_snooping,
|
||||
nmc_property_set_bool,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
/* Add editable properties for NM_SETTING_BRIDGE_PORT_SETTING_NAME */
|
||||
nmc_add_prop_funcs (GLUE (BRIDGE_PORT, PRIORITY),
|
||||
nmc_property_bridge_port_get_priority,
|
||||
|
|
@ -7350,6 +7361,7 @@ setting_bridge_details (NMSetting *setting, NmCli *nmc, const char *one_prop, g
|
|||
set_val_str (arr, 5, nmc_property_bridge_get_hello_time (setting));
|
||||
set_val_str (arr, 6, nmc_property_bridge_get_max_age (setting));
|
||||
set_val_str (arr, 7, nmc_property_bridge_get_ageing_time (setting));
|
||||
set_val_str (arr, 8, nmc_property_bridge_get_multicast_snooping (setting));
|
||||
g_ptr_array_add (nmc->output_data, arr);
|
||||
|
||||
print_data (nmc); /* Print all data */
|
||||
|
|
|
|||
|
|
@ -605,6 +605,8 @@ The value can be prefixed with \fBifname/\fP, \fBuuid/\fP or \fBid/\fP to disamb
|
|||
\(en STP maximum message age, in seconds (default: 20)
|
||||
.IP "\fI[ageing-time <0-1000000>]\fP" 42
|
||||
\(en the Ethernet MAC address aging time, in seconds (default: 300)
|
||||
.IP "\fI[multicast-snooping yes|no]\fP" 42
|
||||
\(en controls whether IGMP snooping is enabled (default: yes)
|
||||
.IP "\fI[mac <MAC address>]\fP" 42
|
||||
\(en MAC address of the bridge (note: this requires a recent kernel feature,
|
||||
originally introduced in 3.15 upstream kernel)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue