Blame SOURCES/netcf-redhat-support-vlan-devices-named-as-vlan-TAG.patch

f586e2
From 1a98ab3a0d95e0e7699de547e2c327c62197db8f Mon Sep 17 00:00:00 2001
f586e2
From: Leno Hou <lenohou@gmail.com>
f586e2
Date: Thu, 8 Dec 2016 21:04:15 +0800
f586e2
Subject: [PATCH 1/2] redhat: support vlan devices named as "vlan${TAG}"
f586e2
f586e2
Since at least the version of initscripts that is in current
f586e2
RHEL6/CentOS6 (9.03.53) initscripts supports two different naming
f586e2
styles for vlan interfaces:
f586e2
f586e2
   $PHYSDEV.$TAG, e.g. "eth0.52"
f586e2
   vlan$TAG, e.g. "vlan52"
f586e2
f586e2
In the former case, both the physical device and the vlan tag are
f586e2
embedded in the vlan device name; in the latter case, only the vlan
f586e2
tag is embedded in the name, and initscripts (or NetworkManager) looks
f586e2
for the attribute PHYSDEV in the ifcfg file, and uses that as the
f586e2
physical device.
f586e2
f586e2
netcf was originally written back in the days of RHEL5, and interfaces
f586e2
named "vlanXXX" weren't supported yet, so until now netcf has only
f586e2
recognized the old "eth0.42" style.
f586e2
f586e2
This patch fixes that omission - existing vlan interfaces named
f586e2
"vlanXYZ" are now properly recognized, and new ones can be created.
f586e2
f586e2
(NB: It is still odd that the digits at the end of the interface name
f586e2
must match the vlan tag, but there's unfortunately nothing that can be
f586e2
done about that, since there is no explicit variable in the ifcfg file
f586e2
that can be used to set the vlan tag.)
f586e2
f586e2
 Resolves: https://bugzilla.redhat.com/1286890
f586e2
f586e2
(cherry picked from commit 0f6596c3e2f914fd36a771421151f409924f65e2)
f586e2
f586e2
Signed-off-by: Leno Hou <lenohou@gmail.com>
f586e2
---
f586e2
 data/xml/redhat-get.xsl | 21 ++++++++++++++++-----
f586e2
 data/xml/redhat-put.xsl | 21 ++++++++++++++++-----
f586e2
 2 files changed, 32 insertions(+), 10 deletions(-)
f586e2
f586e2
diff --git a/data/xml/redhat-get.xsl b/data/xml/redhat-get.xsl
f586e2
index ec56f01..a0bf180 100644
f586e2
--- a/data/xml/redhat-get.xsl
f586e2
+++ b/data/xml/redhat-get.xsl
f586e2
@@ -46,11 +46,22 @@
f586e2
   </xsl:template>
f586e2
 
f586e2
   <xsl:template name="vlan-interface-common">
f586e2
-    <xsl:variable name="iface" select="pathcomponent:escape(concat(vlan/interface/@name, '.', vlan/@tag))"/>
f586e2
-
f586e2
-    <xsl:attribute name="path">/files/etc/sysconfig/network-scripts/ifcfg-<xsl:value-of select="$iface"/></xsl:attribute>
f586e2
-    <node label="DEVICE" value="{$iface}"/>
f586e2
-    <node label="VLAN" value="yes"/>
f586e2
+    <xsl:variable name="vlan-name" select="@name"/>
f586e2
+      <xsl:choose>
f586e2
+        <xsl:when test="contains($vlan-name, '.')">
f586e2
+          <xsl:variable name="iface" select="pathcomponent:escape(concat(vlan/interface/@name, '.', vlan/@tag))"/>
f586e2
+          <xsl:attribute name="path">/files/etc/sysconfig/network-scripts/ifcfg-<xsl:value-of select="$iface"/></xsl:attribute>
f586e2
+          <node label="DEVICE" value="{$iface}"/>
f586e2
+          <node label="VLAN" value="yes"/>
f586e2
+        </xsl:when>
f586e2
+        <xsl:otherwise>
f586e2
+          <xsl:variable name="iface" select="/interface/@name"/>
f586e2
+          <xsl:attribute name="path">/files/etc/sysconfig/network-scripts/ifcfg-<xsl:value-of select="$iface"/></xsl:attribute>
f586e2
+          <node label="DEVICE" value="{$iface}"/>
f586e2
+          <node label="PHYSDEV" value="{vlan/interface/@name}"/>
f586e2
+          <node label="VLAN" value="yes"/>
f586e2
+        </xsl:otherwise>
f586e2
+      </xsl:choose>
f586e2
   </xsl:template>
f586e2
 
f586e2
   <xsl:template name='bare-vlan-interface'>
f586e2
diff --git a/data/xml/redhat-put.xsl b/data/xml/redhat-put.xsl
f586e2
index ed56c66..2997621 100644
f586e2
--- a/data/xml/redhat-put.xsl
f586e2
+++ b/data/xml/redhat-put.xsl
f586e2
@@ -56,11 +56,22 @@
f586e2
 
f586e2
   <xsl:template name="vlan-device">
f586e2
     <xsl:variable name="name" select="node[@label = 'DEVICE']/@value"/>
f586e2
-    <xsl:variable name="device" select="substring-before($name, '.')"/>
f586e2
-    <xsl:variable name="tag" select="substring-after($name, '.')"/>
f586e2
-    <vlan tag="{$tag}">
f586e2
-      <interface name="{$device}"/>
f586e2
-    </vlan>
f586e2
+    <xsl:choose>
f586e2
+      <xsl:when test="contains($name, '.')">
f586e2
+        <xsl:variable name="device" select="substring-before($name, '.')"/>
f586e2
+        <xsl:variable name="tag" select="substring-after($name, '.')"/>
f586e2
+        <vlan tag="{$tag}">
f586e2
+          <interface name="{$device}"/>
f586e2
+        </vlan>
f586e2
+      </xsl:when>
f586e2
+      <xsl:otherwise>
f586e2
+        <xsl:variable name="device" select="node[@label = 'PHYSDEV']/@value"/>
f586e2
+        <xsl:variable name="tag" select="translate($name, translate($name, '0123456789', ''), '')"/>
f586e2
+        <vlan tag="{$tag}">
f586e2
+          <interface name="{$device}"/>
f586e2
+        </vlan>
f586e2
+      </xsl:otherwise>
f586e2
+    </xsl:choose>
f586e2
   </xsl:template>
f586e2
 
f586e2
   
f586e2
-- 
f586e2
1.8.3.1
f586e2