Discussion:
[netcf-devel] [netcf-devel][PATCH V2] vlan: fix vlan interface misses tag attribute when inactive
Leno Hou
2016-12-02 05:29:55 UTC
Permalink
This patch fixes the problem as shown below.
* virsh dumpxml failed with vlan1292 in inactive status
* virt-manager failed to view vlan1292 interface details.
RedHat Bugzilla:#1398143

Following is steps to reproduce in virsh.
1) setup 802.1q vlan tagging using ifcfg-files
#cat > /etc/sysconfig/network-scripts/ifcfg-vlan1292 < EOF
VLAN=yes
VLAN_NAME_TYPE=VLAN_PLUS_VID_NO_PAD
DEVICE=vlan1292
PHYSDEV=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=10.254.5.254
NETMASK=255.255.255.0
TYPE=Ethernet
NM_CONTROLLED=no
EOF

2) active vlan interface and dumpxml
#ifup vlan1292
#virsh iface-dumpxml vlan1292
<interface type='vlan' name='vlan1292'>
<protocol family='ipv4'>
<ip address='10.254.5.254' prefix='24'/>
</protocol>
<protocol family='ipv6'>
<ip address='fe80::4:21ff:fe00:b300' prefix='64'/>
</protocol>
<link speed='1000' state='up'/>
<vlan tag='1292'>
<interface name='eth0'/>
</vlan>
</interface>

3) deactive vlan interface and dumpxml
#ifdown vlan1292
#virsh iface-dumpxml vlan1292
error: XML error: vlan interface misses the tag attribute

Once applied this patch, it's will be successfully returned the results:
#virsh iface-dumpxml vlan1292
<interface type='vlan' name='vlan1292'>
<start mode='onboot'/>
<protocol family='ipv4'>
<ip address='10.254.5.254' prefix='24'/>
</protocol>
<vlan tag='1292'>
<interface name='eth0'/>
</vlan>
</interface>

4) And netcf would turn above iface-dumpxml to the file
/etc/sysconfig/network-scripts/ifcfg-vlan192
#virsh iface-define vlan1292.xml

Signed-off-by: Leno Hou <***@gmail.com>
---
data/xml/redhat-get.xsl | 20 ++++++++++++++++----
data/xml/redhat-put.xsl | 21 ++++++++++++++++-----
2 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/data/xml/redhat-get.xsl b/data/xml/redhat-get.xsl
index ec56f01..9e18c62 100644
--- a/data/xml/redhat-get.xsl
+++ b/data/xml/redhat-get.xsl
@@ -46,11 +46,23 @@
</xsl:template>

<xsl:template name="vlan-interface-common">
- <xsl:variable name="iface" select="pathcomponent:escape(concat(vlan/interface/@name, '.', vlan/@tag))"/>
+ <xsl:variable name="vlan-name" select="/interface/@name"/>
+ <xsl:choose>
+ <xsl:when test="contains($vlan-name, '.')">
+ <xsl:variable name="iface" select="pathcomponent:escape(concat(vlan/interface/@name, '.', vlan/@tag))"/>
+ <xsl:attribute name="path">/files/etc/sysconfig/network-scripts/ifcfg-<xsl:value-of select="$iface"/></xsl:attribute>
+ <node label="DEVICE" value="{$iface}"/>
+ <node label="VLAN" value="yes"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:variable name="iface" select="/interface/@name"/>
+ <xsl:attribute name="path">/files/etc/sysconfig/network-scripts/ifcfg-<xsl:value-of select="$iface"/></xsl:attribute>
+ <node label="DEVICE" value="{$iface}"/>
+ <node label="PHYSDEV" value="{vlan/interface/@name}"/>
+ <node label="VLAN" value="yes"/>
+ </xsl:otherwise>
+ </xsl:choose>

- <xsl:attribute name="path">/files/etc/sysconfig/network-scripts/ifcfg-<xsl:value-of select="$iface"/></xsl:attribute>
- <node label="DEVICE" value="{$iface}"/>
- <node label="VLAN" value="yes"/>
</xsl:template>

<xsl:template name='bare-vlan-interface'>
diff --git a/data/xml/redhat-put.xsl b/data/xml/redhat-put.xsl
index 89145e5..c6f9f65 100644
--- a/data/xml/redhat-put.xsl
+++ b/data/xml/redhat-put.xsl
@@ -56,11 +56,22 @@

<xsl:template name="vlan-device">
<xsl:variable name="name" select="node[@label = 'DEVICE']/@value"/>
- <xsl:variable name="device" select="substring-before($name, '.')"/>
- <xsl:variable name="tag" select="substring-after($name, '.')"/>
- <vlan tag="{$tag}">
- <interface name="{$device}"/>
- </vlan>
+ <xsl:choose>
+ <xsl:when test="contains($name, '.')">
+ <xsl:variable name="device" select="substring-before($name, '.')"/>
+ <xsl:variable name="tag" select="substring-after($name, '.')"/>
+ <vlan tag="{$tag}">
+ <interface name="{$device}"/>
+ </vlan>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:variable name="device" select="node[@label = 'PHYSDEV']/@value"/>
+ <xsl:variable name="tag" select="translate($name, translate($name, '0123456789', ''), '')"/>
+ <vlan tag="{$tag}">
+ <interface name="{$device}"/>
+ </vlan>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:template>

<!--
--
2.7.4
_______________________________________________
netcf-devel mailing list -- netcf-***@lists.fedorahosted.org
To unsubscribe send an email to netcf-devel-***@lis
Leno Hou
2016-12-07 02:55:58 UTC
Permalink
Hi all,

Any feedback for this patch?

*Leno Hou*
Post by Leno Hou
This patch fixes the problem as shown below.
* virsh dumpxml failed with vlan1292 in inactive status
* virt-manager failed to view vlan1292 interface details.
RedHat Bugzilla:#1398143
Following is steps to reproduce in virsh.
1) setup 802.1q vlan tagging using ifcfg-files
#cat > /etc/sysconfig/network-scripts/ifcfg-vlan1292 < EOF
VLAN=yes
VLAN_NAME_TYPE=VLAN_PLUS_VID_NO_PAD
DEVICE=vlan1292
PHYSDEV=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=10.254.5.254
NETMASK=255.255.255.0
TYPE=Ethernet
NM_CONTROLLED=no
EOF
2) active vlan interface and dumpxml
#ifup vlan1292
#virsh iface-dumpxml vlan1292
<interface type='vlan' name='vlan1292'>
<protocol family='ipv4'>
<ip address='10.254.5.254' prefix='24'/>
</protocol>
<protocol family='ipv6'>
<ip address='fe80::4:21ff:fe00:b300' prefix='64'/>
</protocol>
<link speed='1000' state='up'/>
<vlan tag='1292'>
<interface name='eth0'/>
</vlan>
</interface>
3) deactive vlan interface and dumpxml
#ifdown vlan1292
#virsh iface-dumpxml vlan1292
error: XML error: vlan interface misses the tag attribute
#virsh iface-dumpxml vlan1292
<interface type='vlan' name='vlan1292'>
<start mode='onboot'/>
<protocol family='ipv4'>
<ip address='10.254.5.254' prefix='24'/>
</protocol>
<vlan tag='1292'>
<interface name='eth0'/>
</vlan>
</interface>
4) And netcf would turn above iface-dumpxml to the file
/etc/sysconfig/network-scripts/ifcfg-vlan192
#virsh iface-define vlan1292.xml
---
data/xml/redhat-get.xsl | 20 ++++++++++++++++----
data/xml/redhat-put.xsl | 21 ++++++++++++++++-----
2 files changed, 32 insertions(+), 9 deletions(-)
diff --git a/data/xml/redhat-get.xsl b/data/xml/redhat-get.xsl
index ec56f01..9e18c62 100644
--- a/data/xml/redhat-get.xsl
+++ b/data/xml/redhat-get.xsl
@@ -46,11 +46,23 @@
</xsl:template>
<xsl:template name="vlan-interface-common">
+ <xsl:choose>
+ <xsl:when test="contains($vlan-name, '.')">
+ <xsl:attribute name="path">/files/etc/
attribute>
+ <node label="DEVICE" value="{$iface}"/>
+ <node label="VLAN" value="yes"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:attribute name="path">/files/etc/
attribute>
+ <node label="DEVICE" value="{$iface}"/>
+ <node label="VLAN" value="yes"/>
+ </xsl:otherwise>
+ </xsl:choose>
- <xsl:attribute name="path">/files/etc/sysconfig/network-scripts/ifcfg-<xsl:value-of
select="$iface"/></xsl:attribute>
- <node label="DEVICE" value="{$iface}"/>
- <node label="VLAN" value="yes"/>
</xsl:template>
<xsl:template name='bare-vlan-interface'>
diff --git a/data/xml/redhat-put.xsl b/data/xml/redhat-put.xsl
index 89145e5..c6f9f65 100644
--- a/data/xml/redhat-put.xsl
+++ b/data/xml/redhat-put.xsl
@@ -56,11 +56,22 @@
<xsl:template name="vlan-device">
- <xsl:variable name="device" select="substring-before($name, '.')"/>
- <xsl:variable name="tag" select="substring-after($name, '.')"/>
- <vlan tag="{$tag}">
- <interface name="{$device}"/>
- </vlan>
+ <xsl:choose>
+ <xsl:when test="contains($name, '.')">
+ <xsl:variable name="device" select="substring-before($name, '.')"/>
+ <xsl:variable name="tag" select="substring-after($name, '.')"/>
+ <vlan tag="{$tag}">
+ <interface name="{$device}"/>
+ </vlan>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:variable name="tag" select="translate($name,
translate($name, '0123456789', ''), '')"/>
+ <vlan tag="{$tag}">
+ <interface name="{$device}"/>
+ </vlan>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:template>
<!--
--
2.7.4
Laine Stump
2016-12-07 20:20:48 UTC
Permalink
Post by Leno Hou
This patch fixes the problem as shown below.
* virsh dumpxml failed with vlan1292 in inactive status
* virt-manager failed to view vlan1292 interface details.
RedHat Bugzilla:#1398143
Applying the patch causes test-redhat to fail (run "make check", then
look in the file tests/test-redhat.log). The specific test that fails is
one that creates a bridge that has a vlan interface attached to it

<interface type="bridge" name="br0">
<start mode="onboot"/>
<protocol family="ipv4">
<dhcp/>
</protocol>
<bridge stp="off">
<interface type="vlan" name="eth0.42">
<vlan tag="42">
<interface name="eth0"/>
</vlan>
</interface>
</bridge>
</interface>

Instead of creating the files ifcfg-br0 and ifcfg-eth0.42, it thinks it
has to create 2 files named ifcfg-br0, and messes up the contents of the
2nd (misnamed) file as well.

Even before that's fixed, I'll try to send more comments about the
contents of the patches, but probably won't be able to do that today
(unless I have some time tonight). In the meantime, if the fix to the
above problem is obvious to you (I doubt that it will be obvious to me,
because I am truly bad at navigating xsl transforms!) and you can post a
revised patch with a quick fix, that would be helpful.

Thanks for your patience (and for tackling a problem that needs xsl fu!)
_______________________________________________
netcf-devel mailing list -- netcf-***@lists.fedorahosted.org
To unsubscribe se
Leno Hou
2016-12-08 09:32:40 UTC
Permalink
Sure. I'll spend sometime to fix the testcases.

=======================================
netcf 0.2.8: tests/test-suite.log
=======================================

# TOTAL: 1
# PASS: 0
# SKIP: 0
# XFAIL: 0
# FAIL: 1
# XPASS: 0
# ERROR: 0

.. contents:: :depth: 2

FAIL: test-redhat
=================

.....F.

There was 1 failure:
1) testTransforms:
tutil.c:166: redhat/schema/bridge-vlan.xml: Different values for attribute
tree/@path: /files/etc/sysconfig/network-scripts/ifcfg-eth0.42 !=
/files/etc/sysconfig/network-scripts/ifcfg-br0 (lines 10 and 10)
Expected XML:
<?xml version="1.0"?>
<forest>
<tree path="/files/etc/sysconfig/network-scripts/ifcfg-br0">
<node label="DEVICE" value="br0"/>
<node label="ONBOOT" value="yes"/>
<node label="TYPE" value="Bridge"/>
<node label="BOOTPROTO" value="dhcp"/>
<node label="STP" value="off"/>
</tree>
<tree path="/files/etc/sysconfig/network-scripts/ifcfg-eth0.42">
<node label="DEVICE" value="eth0.42"/>
<node label="VLAN" value="yes"/>
<node label="ONBOOT" value="yes"/>
<node label="BRIDGE" value="br0"/>
</tree>
</forest>

Actual XML:
<?xml version="1.0"?>
<forest>
<tree path="/files/etc/sysconfig/network-scripts/ifcfg-br0">
<node label="DEVICE" value="br0"/>
<node label="ONBOOT" value="yes"/>
<node label="TYPE" value="Bridge"/>
<node label="BOOTPROTO" value="dhcp"/>
<node label="STP" value="off"/>
</tree>
<tree path="/files/etc/sysconfig/network-scripts/ifcfg-br0">
<node label="DEVICE" value="br0"/>
<node label="PHYSDEV" value="eth0"/>
<node label="VLAN" value="yes"/>
<node label="ONBOOT" value="yes"/>
<node label="BRIDGE" value="br0"/>
</tree>
</forest>



!!!FAILURES!!!
Runs: 7 Passes: 6 Fails: 1


*Leno Hou*
Post by Leno Hou
This patch fixes the problem as shown below.
* virsh dumpxml failed with vlan1292 in inactive status
* virt-manager failed to view vlan1292 interface details.
RedHat Bugzilla:#1398143
Applying the patch causes test-redhat to fail (run "make check", then look
in the file tests/test-redhat.log). The specific test that fails is one
that creates a bridge that has a vlan interface attached to it
<interface type="bridge" name="br0">
<start mode="onboot"/>
<protocol family="ipv4">
<dhcp/>
</protocol>
<bridge stp="off">
<interface type="vlan" name="eth0.42">
<vlan tag="42">
<interface name="eth0"/>
</vlan>
</interface>
</bridge>
</interface>
Instead of creating the files ifcfg-br0 and ifcfg-eth0.42, it thinks it
has to create 2 files named ifcfg-br0, and messes up the contents of the
2nd (misnamed) file as well.
Even before that's fixed, I'll try to send more comments about the
contents of the patches, but probably won't be able to do that today
(unless I have some time tonight). In the meantime, if the fix to the above
problem is obvious to you (I doubt that it will be obvious to me, because I
am truly bad at navigating xsl transforms!) and you can post a revised
patch with a quick fix, that would be helpful.
Thanks for your patience (and for tackling a problem that needs xsl fu!)
Leno Hou
2016-12-09 03:46:20 UTC
Permalink
Post by Leno Hou
This patch fixes the problem as shown below.
* virsh dumpxml failed with vlan1292 in inactive status
* virt-manager failed to view vlan1292 interface details.
RedHat Bugzilla:#1398143
Applying the patch causes test-redhat to fail (run "make check", then look
in the file tests/test-redhat.log). The specific test that fails is one
that creates a bridge that has a vlan interface attached to it
<interface type="bridge" name="br0">
<start mode="onboot"/>
<protocol family="ipv4">
<dhcp/>
</protocol>
<bridge stp="off">
<interface type="vlan" name="eth0.42">
<vlan tag="42">
<interface name="eth0"/>
</vlan>
</interface>
</bridge>
</interface>
Instead of creating the files ifcfg-br0 and ifcfg-eth0.42, it thinks it
has to create 2 files named ifcfg-br0, and messes up the contents of the
2nd (misnamed) file as well.
Even before that's fixed, I'll try to send more comments about the
contents of the patches, but probably won't be able to do that today
(unless I have some time tonight). In the meantime, if the fix to the above
problem is obvious to you (I doubt that it will be obvious to me, because I
am truly bad at navigating xsl transforms!) and you can post a revised
patch with a quick fix, that would be helpful.
Thanks for your patience (and for tackling a problem that needs xsl fu!)
Hi Laine,

Patch v3 fixed above issue that you reported. Could you test it again ?

-Leno Hou
Laine Stump
2016-12-15 19:45:58 UTC
Permalink
Post by Leno Hou
This patch fixes the problem as shown below.
* virsh dumpxml failed with vlan1292 in inactive status
* virt-manager failed to view vlan1292 interface details.
RedHat Bugzilla:#1398143
I shortened the commit log considerably, and changed it to describe the
changed behavior, rather than how to reproduce the bug.
Post by Leno Hou
Following is steps to reproduce in virsh.
1) setup 802.1q vlan tagging using ifcfg-files
#cat > /etc/sysconfig/network-scripts/ifcfg-vlan1292 < EOF
VLAN=yes
VLAN_NAME_TYPE=VLAN_PLUS_VID_NO_PAD
DEVICE=vlan1292
PHYSDEV=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=10.254.5.254
NETMASK=255.255.255.0
TYPE=Ethernet
NM_CONTROLLED=no
EOF
2) active vlan interface and dumpxml
#ifup vlan1292
#virsh iface-dumpxml vlan1292
<interface type='vlan' name='vlan1292'>
<protocol family='ipv4'>
<ip address='10.254.5.254' prefix='24'/>
</protocol>
<protocol family='ipv6'>
<ip address='fe80::4:21ff:fe00:b300' prefix='64'/>
</protocol>
<link speed='1000' state='up'/>
<vlan tag='1292'>
<interface name='eth0'/>
</vlan>
</interface>
3) deactive vlan interface and dumpxml
#ifdown vlan1292
#virsh iface-dumpxml vlan1292
error: XML error: vlan interface misses the tag attribute
#virsh iface-dumpxml vlan1292
<interface type='vlan' name='vlan1292'>
<start mode='onboot'/>
<protocol family='ipv4'>
<ip address='10.254.5.254' prefix='24'/>
</protocol>
<vlan tag='1292'>
<interface name='eth0'/>
</vlan>
</interface>
4) And netcf would turn above iface-dumpxml to the file
/etc/sysconfig/network-scripts/ifcfg-vlan192
#virsh iface-define vlan1292.xml
---
data/xml/redhat-get.xsl | 20 ++++++++++++++++----
data/xml/redhat-put.xsl | 21 ++++++++++++++++-----
2 files changed, 32 insertions(+), 9 deletions(-)
diff --git a/data/xml/redhat-get.xsl b/data/xml/redhat-get.xsl
index ec56f01..9e18c62 100644
--- a/data/xml/redhat-get.xsl
+++ b/data/xml/redhat-get.xsl
@@ -46,11 +46,23 @@
</xsl:template>
<xsl:template name="vlan-interface-common">
+ <xsl:choose>
+ <xsl:when test="contains($vlan-name, '.')">
+ <xsl:attribute name="path">/files/etc/sysconfig/network-scripts/ifcfg-<xsl:value-of select="$iface"/></xsl:attribute>
+ <node label="DEVICE" value="{$iface}"/>
+ <node label="VLAN" value="yes"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:attribute name="path">/files/etc/sysconfig/network-scripts/ifcfg-<xsl:value-of select="$iface"/></xsl:attribute>
+ <node label="DEVICE" value="{$iface}"/>
+ <node label="VLAN" value="yes"/>
+ </xsl:otherwise>
It would be nice to eliminate the duplication between the two choices
(the setting of DEVICE and VLAN), but I know only enough about xsl to
realize that variables like $iface must be local to the <xsl:blah> block
they're defined in, so I left it as you wrote it. Since you seem to be
pretty handy with xsl transforms, I would appreciate a followup patch to
eliminate the redundandancy (and if you're good enough to understand how
to translate <route> elements in the XML to/from a file called
"route-$DEVNAME", please let me know and I'll send you a full spec for
adding static routes to an interface's config :-)

In the meantime, ACK, and I pushed it. Thanks for the contribution!
(I've added your name to the AUTHORS file).
Post by Leno Hou
+ </xsl:choose>
- <xsl:attribute name="path">/files/etc/sysconfig/network-scripts/ifcfg-<xsl:value-of select="$iface"/></xsl:attribute>
- <node label="DEVICE" value="{$iface}"/>
- <node label="VLAN" value="yes"/>
</xsl:template>
<xsl:template name='bare-vlan-interface'>
diff --git a/data/xml/redhat-put.xsl b/data/xml/redhat-put.xsl
index 89145e5..c6f9f65 100644
--- a/data/xml/redhat-put.xsl
+++ b/data/xml/redhat-put.xsl
@@ -56,11 +56,22 @@
<xsl:template name="vlan-device">
- <xsl:variable name="device" select="substring-before($name, '.')"/>
- <xsl:variable name="tag" select="substring-after($name, '.')"/>
- <vlan tag="{$tag}">
- <interface name="{$device}"/>
- </vlan>
+ <xsl:choose>
+ <xsl:when test="contains($name, '.')">
+ <xsl:variable name="device" select="substring-before($name, '.')"/>
+ <xsl:variable name="tag" select="substring-after($name, '.')"/>
+ <vlan tag="{$tag}">
+ <interface name="{$device}"/>
+ </vlan>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:variable name="tag" select="translate($name, translate($name, '0123456789', ''), '')"/>
+ <vlan tag="{$tag}">
+ <interface name="{$device}"/>
+ </vlan>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:template>
<!--
_______________________________________________
netcf-devel mailing list -- netcf-***@lists.fedorahosted.org
To unsubscribe send an email to netcf-devel-le
Leno Hou
2016-12-19 09:28:17 UTC
Permalink
Post by Laine Stump
Post by Leno Hou
This patch fixes the problem as shown below.
* virsh dumpxml failed with vlan1292 in inactive status
* virt-manager failed to view vlan1292 interface details.
RedHat Bugzilla:#1398143
I shortened the commit log considerably, and changed it to describe the
changed behavior, rather than how to reproduce the bug.
Yes, that's great!
It would be nice to eliminate the duplication between the two choices (the
Post by Laine Stump
setting of DEVICE and VLAN), but I know only enough about xsl to realize
that variables like $iface must be local to the <xsl:blah> block they're
defined in, so I left it as you wrote it. Since you seem to be pretty handy
with xsl transforms, I would appreciate a followup patch to eliminate the
redundandancy (and if you're good enough to understand how to translate
<route> elements in the XML to/from a file called "route-$DEVNAME", please
let me know and I'll send you a full spec for adding static routes to an
interface's config :-)
Welcome~
Post by Laine Stump
In the meantime, ACK, and I pushed it. Thanks for the contribution! (I've
added your name to the AUTHORS file).
Loading...