vlan: (all) add VLAN MVRP flag
authorJiří Klimeš <jklimes@redhat.com>
Tue, 13 Oct 2015 08:05:19 +0000 (10:05 +0200)
committerThomas Haller <thaller@redhat.com>
Tue, 27 Oct 2015 16:17:05 +0000 (17:17 +0100)
http://patchwork.ozlabs.org/patch/219364/

clients/cli/settings.c
libnm-core/nm-setting-vlan.c
libnm-core/nm-setting-vlan.h
libnm-util/nm-setting-vlan.c
libnm-util/nm-setting-vlan.h
src/platform/nm-linux-platform.c
src/settings/plugins/ifcfg-rh/reader.c
src/settings/plugins/ifcfg-rh/writer.c

index 992f841..e5139ae 100644 (file)
@@ -738,6 +738,8 @@ vlan_flags_to_string (guint32 flags)
                g_string_append (flag_str, _("GVRP, "));
        if (flags & NM_VLAN_FLAG_LOOSE_BINDING)
                g_string_append (flag_str, _("LOOSE_BINDING, "));
+       if (flags & NM_VLAN_FLAG_MVRP)
+               g_string_append (flag_str, _("MVRP, "));
 
        if (flag_str->str[flag_str->len-1] == '(')
                g_string_append (flag_str, _("unknown"));
index a9b105e..66661ec 100644 (file)
@@ -567,9 +567,7 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
                }
        }
 
-       if (priv->flags & ~(NM_VLAN_FLAG_REORDER_HEADERS |
-                           NM_VLAN_FLAG_GVRP |
-                           NM_VLAN_FLAG_LOOSE_BINDING)) {
+       if (priv->flags & ~NM_VLAN_FLAGS_ALL) {
                g_set_error_literal (error,
                                     NM_CONNECTION_ERROR,
                                     NM_CONNECTION_ERROR_INVALID_PROPERTY,
@@ -778,7 +776,8 @@ nm_setting_vlan_class_init (NMSettingVlanClass *setting_class)
         * interface.  Flags include %NM_VLAN_FLAG_REORDER_HEADERS (reordering of
         * output packet headers), %NM_VLAN_FLAG_GVRP (use of the GVRP protocol),
         * and %NM_VLAN_FLAG_LOOSE_BINDING (loose binding of the interface to its
-        * master device's operating state).
+        * master device's operating state). %NM_VLAN_FLAG_MVRP (use of the MVRP
+        * protocol).
         *
         * The default value of this property is NM_VLAN_FLAG_REORDER_HEADERS,
         * but it used to be 0. To preserve backward compatibility, the default-value
@@ -787,8 +786,8 @@ nm_setting_vlan_class_init (NMSettingVlanClass *setting_class)
         **/
        /* ---ifcfg-rh---
         * property: flags
-        * variable: REORDER_HDR, GVRP, VLAN_FLAGS
-        * values: "yes or "no" for REORDER_HDR and GVRP; "LOOSE_BINDING" for VLAN_FLAGS
+        * variable: REORDER_HDR, GVRP, MVRP, VLAN_FLAGS
+        * values: "yes or "no" for REORDER_HDR, GVRP and MVRP; "LOOSE_BINDING" for VLAN_FLAGS
         * description: VLAN flags.
         * ---end---
         */
index 30305d3..d3d4381 100644 (file)
@@ -79,6 +79,8 @@ typedef enum {
  * @NM_VLAN_FLAG_LOOSE_BINDING: indicates that this interface's operating
  *  state is tied to the underlying network interface but other details
  *  (like routing) are not.
+ * @NM_VLAN_FLAG_MVRP: indicates that this interface should use MVRP to register
+ *  itself with it's switch
  *
  * #NMVlanFlags values control the behavior of the VLAN interface.
  **/
@@ -86,10 +88,16 @@ typedef enum { /*< flags >*/
        NM_VLAN_FLAG_REORDER_HEADERS = 0x1,
        NM_VLAN_FLAG_GVRP            = 0x2,
        NM_VLAN_FLAG_LOOSE_BINDING   = 0x4,
+       NM_VLAN_FLAG_MVRP            = 0x8,
 
        /* NOTE: if adding flags update nm-setting-vlan.c::verify() */
 } NMVlanFlags;
 
+#define NM_VLAN_FLAGS_ALL  (NM_VLAN_FLAG_REORDER_HEADERS | \
+                            NM_VLAN_FLAG_GVRP | \
+                            NM_VLAN_FLAG_LOOSE_BINDING | \
+                            NM_VLAN_FLAG_MVRP)
+
 GType nm_setting_vlan_get_type (void);
 NMSetting *nm_setting_vlan_new (void);
 
index 52676d4..310a7da 100644 (file)
@@ -584,9 +584,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
                }
        }
 
-       if (priv->flags & ~(NM_VLAN_FLAG_REORDER_HEADERS |
-                           NM_VLAN_FLAG_GVRP |
-                           NM_VLAN_FLAG_LOOSE_BINDING)) {
+       if (priv->flags & ~NM_VLAN_FLAGS_ALL) {
                g_set_error_literal (error,
                                     NM_SETTING_VLAN_ERROR,
                                     NM_SETTING_VLAN_ERROR_INVALID_PROPERTY,
@@ -800,7 +798,8 @@ nm_setting_vlan_class_init (NMSettingVlanClass *setting_class)
         * interface.  Flags include %NM_VLAN_FLAG_REORDER_HEADERS (reordering of
         * output packet headers), %NM_VLAN_FLAG_GVRP (use of the GVRP protocol),
         * and %NM_VLAN_FLAG_LOOSE_BINDING (loose binding of the interface to its
-        * master device's operating state).
+        * master device's operating state), %NM_VLAN_FLAG_MVRP (use of the MVRP
+        * protocol).
         **/
        g_object_class_install_property
                (object_class, PROP_FLAGS,
index 3e20948..ce42dd4 100644 (file)
@@ -98,6 +98,8 @@ typedef enum {
  * @NM_VLAN_FLAG_LOOSE_BINDING: indicates that this interface's operating
  *  state is tied to the underlying network interface but other details
  *  (like routing) are not.
+ * @NM_VLAN_FLAG_MVRP: indicates that this interface should use MVRP to register
+ *  itself with it's switch
  *
  * #NMVlanFlags values control the behavior of the VLAN interface.
  **/
@@ -105,10 +107,16 @@ typedef enum {
        NM_VLAN_FLAG_REORDER_HEADERS = 0x1,
        NM_VLAN_FLAG_GVRP            = 0x2,
        NM_VLAN_FLAG_LOOSE_BINDING   = 0x4,
+       NM_VLAN_FLAG_MVRP            = 0x8,
 
        /* NOTE: if adding flags update nm-setting-vlan.c::verify() */
 } NMVlanFlags;
 
+#define NM_VLAN_FLAGS_ALL  (NM_VLAN_FLAG_REORDER_HEADERS | \
+                            NM_VLAN_FLAG_GVRP | \
+                            NM_VLAN_FLAG_LOOSE_BINDING | \
+                            NM_VLAN_FLAG_MVRP)
+
 GType nm_setting_vlan_get_type (void);
 NMSetting *nm_setting_vlan_new (void);
 
index 61e0aca..4b9e486 100644 (file)
@@ -3220,7 +3220,7 @@ vlan_add (NMPlatform *platform,
 {
        auto_nl_object struct rtnl_link *rtnllink = (struct rtnl_link *) build_rtnl_link (0, name, NM_LINK_TYPE_VLAN);
        unsigned int kernel_flags;
-       unsigned int all_flags = VLAN_FLAG_REORDER_HDR | VLAN_FLAG_GVRP | VLAN_FLAG_LOOSE_BINDING;
+       unsigned int all_flags = NM_VLAN_FLAGS_ALL;
 
        kernel_flags = 0;
        if (vlan_flags & NM_VLAN_FLAG_REORDER_HEADERS)
@@ -3229,6 +3229,9 @@ vlan_add (NMPlatform *platform,
                kernel_flags |= VLAN_FLAG_GVRP;
        if (vlan_flags & NM_VLAN_FLAG_LOOSE_BINDING)
                kernel_flags |= VLAN_FLAG_LOOSE_BINDING;
+#define VLAN_FLAG_MVRP 0x8
+       if (vlan_flags & NM_VLAN_FLAG_MVRP)
+               kernel_flags |= VLAN_FLAG_MVRP;
 
        rtnl_link_set_link (rtnllink, parent);
        rtnl_link_vlan_set_id (rtnllink, vlan_id);
index 2aef7ad..60d0bce 100644 (file)
@@ -4666,6 +4666,9 @@ make_vlan_setting (shvarFile *ifcfg,
                        vlan_flags |= NM_VLAN_FLAG_LOOSE_BINDING;
        }
 
+       if (svGetValueBoolean (ifcfg, "MVRP", FALSE))
+               vlan_flags |= NM_VLAN_FLAG_MVRP;
+
        g_object_set (s_vlan, NM_SETTING_VLAN_FLAGS, vlan_flags, NULL);
        g_free (value);
 
index ca29fc0..b2d1419 100644 (file)
@@ -1270,6 +1270,8 @@ write_vlan_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired,
        if (vlan_flags & NM_VLAN_FLAG_LOOSE_BINDING)
                svSetValue (ifcfg, "VLAN_FLAGS", "LOOSE_BINDING", FALSE);
 
+       svSetValue (ifcfg, "MVRP", vlan_flags & NM_VLAN_FLAG_MVRP ? "yes" : "no", FALSE);
+
        tmp = vlan_priority_maplist_to_stringlist (s_vlan, NM_VLAN_INGRESS_MAP);
        svSetValue (ifcfg, "VLAN_INGRESS_PRIORITY_MAP", tmp, FALSE);
        g_free (tmp);