From 6156f05629d6cbcc1827309314c5337eb95d801b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Tue, 13 Oct 2015 10:05:19 +0200 Subject: vlan: (all) add VLAN MVRP flag http://patchwork.ozlabs.org/patch/219364/ --- clients/cli/settings.c | 2 ++ libnm-core/nm-setting-vlan.c | 11 +++++------ libnm-core/nm-setting-vlan.h | 8 ++++++++ libnm-util/nm-setting-vlan.c | 7 +++---- libnm-util/nm-setting-vlan.h | 8 ++++++++ src/platform/nm-linux-platform.c | 6 ++++-- src/settings/plugins/ifcfg-rh/reader.c | 3 +++ src/settings/plugins/ifcfg-rh/writer.c | 2 ++ 8 files changed, 35 insertions(+), 12 deletions(-) diff --git a/clients/cli/settings.c b/clients/cli/settings.c index 0c10cf533e..8f6d3cd0e6 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -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")); diff --git a/libnm-core/nm-setting-vlan.c b/libnm-core/nm-setting-vlan.c index 78359a766b..43300e91ba 100644 --- a/libnm-core/nm-setting-vlan.c +++ b/libnm-core/nm-setting-vlan.c @@ -563,9 +563,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, @@ -756,12 +754,13 @@ 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). **/ /* ---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--- */ diff --git a/libnm-core/nm-setting-vlan.h b/libnm-core/nm-setting-vlan.h index 30305d327c..d3d4381b62 100644 --- a/libnm-core/nm-setting-vlan.h +++ b/libnm-core/nm-setting-vlan.h @@ -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); diff --git a/libnm-util/nm-setting-vlan.c b/libnm-util/nm-setting-vlan.c index c3d4bb58f1..0ed2c6e9b5 100644 --- a/libnm-util/nm-setting-vlan.c +++ b/libnm-util/nm-setting-vlan.c @@ -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, diff --git a/libnm-util/nm-setting-vlan.h b/libnm-util/nm-setting-vlan.h index 3e209480c8..ce42dd4154 100644 --- a/libnm-util/nm-setting-vlan.h +++ b/libnm-util/nm-setting-vlan.h @@ -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); diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index d2b5f136b3..bc0f4c85da 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -3240,7 +3240,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) @@ -3249,6 +3249,8 @@ vlan_add (NMPlatform *platform, kernel_flags |= VLAN_FLAG_GVRP; if (vlan_flags & NM_VLAN_FLAG_LOOSE_BINDING) kernel_flags |= VLAN_FLAG_LOOSE_BINDING; + 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); @@ -3286,7 +3288,7 @@ static gboolean vlan_set_flags (NMPlatform *platform, int ifindex, guint32 flags) { auto_nl_object struct rtnl_link *change = (struct rtnl_link *) build_rtnl_link (ifindex, NULL, NM_LINK_TYPE_VLAN); - unsigned int all_flags = VLAN_FLAG_REORDER_HDR | VLAN_FLAG_GVRP | VLAN_FLAG_LOOSE_BINDING; + unsigned int all_flags = NM_VLAN_FLAGS_ALL; rtnl_link_vlan_unset_flags (change, all_flags); rtnl_link_vlan_set_flags (change, flags); diff --git a/src/settings/plugins/ifcfg-rh/reader.c b/src/settings/plugins/ifcfg-rh/reader.c index f876b34d10..71bbe030a3 100644 --- a/src/settings/plugins/ifcfg-rh/reader.c +++ b/src/settings/plugins/ifcfg-rh/reader.c @@ -4620,6 +4620,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); diff --git a/src/settings/plugins/ifcfg-rh/writer.c b/src/settings/plugins/ifcfg-rh/writer.c index 550dc6b720..98b4967905 100644 --- a/src/settings/plugins/ifcfg-rh/writer.c +++ b/src/settings/plugins/ifcfg-rh/writer.c @@ -1268,6 +1268,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); -- cgit v1.2.1