diff options
author | Jiří Klimeš <jklimes@redhat.com> | 2015-02-20 12:58:30 +0100 |
---|---|---|
committer | Jiří Klimeš <jklimes@redhat.com> | 2015-02-20 14:21:44 +0100 |
commit | b23d28bf1368253f66f59dafa124a1efd7fe7d40 (patch) | |
tree | ce63c8747167c5f006e2f1076aa3b3cf6d8c84c6 | |
parent | 5b56e6f88232db599833e34973281977d5da1e78 (diff) | |
download | NetworkManager-jk/bridge-mcast-snoop-bgo744853.tar.gz |
nmcli: add support for bridge multicast-snooping propertyjk/bridge-mcast-snoop-bgo744853
-rw-r--r-- | clients/cli/connections.c | 39 | ||||
-rw-r--r-- | clients/cli/settings.c | 16 | ||||
-rw-r--r-- | man/nmcli.1.in | 2 |
3 files changed, 51 insertions, 6 deletions
diff --git a/clients/cli/connections.c b/clients/cli/connections.c index 610f53a9b7..7170df6108 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -385,6 +385,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" @@ -3658,14 +3659,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) { @@ -3743,6 +3744,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]: ")); @@ -4892,7 +4907,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; @@ -4903,6 +4920,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} }; @@ -4916,10 +4934,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); @@ -4941,6 +4960,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 */ @@ -4983,6 +5011,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); @@ -4994,6 +5024,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; diff --git a/clients/cli/settings.c b/clients/cli/settings.c index 78947f04c3..47c7321756 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -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 */ diff --git a/man/nmcli.1.in b/man/nmcli.1.in index c9a69cb9bf..fc8f3065b1 100644 --- a/man/nmcli.1.in +++ b/man/nmcli.1.in @@ -579,6 +579,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) |