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