[Kimchi-devel] [PATCH] Issue #693: VLAN ID accepting only one digit

Ramon Medeiros ramonn at linux.vnet.ibm.com
Mon Aug 31 17:09:28 UTC 2015


Verify vlan name size before adding it. If name greater than 15
characters, display an error.

Signed-off-by: Ramon Medeiros <ramonn at linux.vnet.ibm.com>

The size limit of vlan name is defined in kernel headers:

https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Networking_Guide/sec-Naming_Scheme_for_VLAN_Interfaces.html
---
 src/kimchi/i18n.py           | 1 +
 src/kimchi/model/networks.py | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py
index 862df7f..2f9c8d2 100644
--- a/src/kimchi/i18n.py
+++ b/src/kimchi/i18n.py
@@ -257,6 +257,7 @@ messages = {
     "KCHNET0020E": _("Failed to activate interface %(iface)s: %(err)s."),
     "KCHNET0021E": _("Failed to activate interface %(iface)s. Please check the physical link status."),
     "KCHNET0022E": _("Failed to start network %(name)s. Details: %(err)s"),
+    "KCHNET0023E": _("Interface name %(name)s exceeds kernel limit of 15 characters"),
 
     "KCHDR0001E": _("Debug report %(name)s does not exist"),
     "KCHDR0002E": _("Debug report tool not found in system"),
diff --git a/src/kimchi/model/networks.py b/src/kimchi/model/networks.py
index 275e12b..03737d1 100644
--- a/src/kimchi/model/networks.py
+++ b/src/kimchi/model/networks.py
@@ -216,6 +216,9 @@ class NetworksModel(object):
         if br_name in bridges:
             raise InvalidOperation("KCHNET0010E", {'iface': br_name})
 
+        if  len(br_name) > 15:
+            raise InvalidOperation("KCHNET0023E", {'name': br_name})
+
         with RollbackContext() as rollback:
             try:
                 vlan_tagged_br = conn.interfaceDefineXML(br_xml, 0)
-- 
2.1.0




More information about the Kimchi-devel mailing list