[PATCH] Allow IPv4 static addresses simultaneous with DHCP
by Laine Stump
Because initscripts network startup ends up ignoring static IPv4
addresses when dhcp is enabled (BOOTPROTO=dhcp in the ifcfg file) and
because at least some of the frontends to Network Manager disable
configuring a static address if dhcp is enabled (and likely due to
other indications, but this all happened far in the past...) netcf has
always made DHCP and static IP addresses for IPv4 mutually exclusive
in the config - an interface either had one or it had the other.
A recent BZ filed against libvirt:
https://bugzilla.redhat.com/show_bug.cgi?id=1113983
suggested that we should also forbid simultaneous DHCP and static IPs
for IPv6, but investigation shows the following:
1) there is nothing inherent in the DHCP protocol that precludes
having both a single DHCP address and one or more static IP addresses
from each protocol (as well as an IPv6 address learned via IPv6
autoconf). Even the lead NetworkManager developer says this in an
email response to a question posed on the dnsmasq mailing list:
http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/2015q1/009346.html
2) Different networking backends currently properly support different
combinations of these address types for the two platforms (for
example, NetworkManager 0.9.10.2 on Fedora 21 will properly acquire a
DHCPv4 address to live alongside multiple static IPv4 addresses while
initscripts 9.56.7 will discard the static IPs, and initscripts will
support multiple static IPv6 addresses together with an autoconf
address, while NetworkManager apparently won't (although this could be
a configuration error on my part).
In the end, any time that all three address types for IPv6 (autoconf,
dhcp, static) or two address types for IPv4 (dhcp, static) cannot work
simultaneously on the same interface, that is a bug in the networking
backend (e.g. initscripts, NetworkManager), *not* a reason to disallow
such configurations via netcf.
For that reason, this patch opens up the RNG for the IPv4 protocol,
allowing <dhcp/> to be specified simultaneously with any number of
static <ip> elements for IPv4, just as we already did for IPv6. Any
future failures of such configurations to work properly should result
in bugs filed against the network backend in use at the time (or
possibly the dhcp server, or some other piece of infrastructure).
---
data/xml/interface.rng | 28 ++++++-------
data/xml/redhat-get.xsl | 48 +++++++++++-----------
data/xml/redhat-put.xsl | 14 +++----
tests/interface/bridge-multi-all.xml | 23 +++++++++++
.../fsroot/etc/sysconfig/network-scripts/ifcfg-br2 | 25 +++++++++++
tests/redhat/schema/bridge-multi-all.xml | 30 ++++++++++++++
tests/test-redhat.c | 3 +-
7 files changed, 123 insertions(+), 48 deletions(-)
create mode 100644 tests/interface/bridge-multi-all.xml
create mode 100644 tests/redhat/fsroot/etc/sysconfig/network-scripts/ifcfg-br2
create mode 100644 tests/redhat/schema/bridge-multi-all.xml
diff --git a/data/xml/interface.rng b/data/xml/interface.rng
index a794084..8d70e8b 100644
--- a/data/xml/interface.rng
+++ b/data/xml/interface.rng
@@ -322,24 +322,22 @@
<value>ipv4</value>
</attribute>
<interleave>
- <choice>
+ <optional>
<ref name="dhcp-element"/>
- <group>
- <oneOrMore>
- <element name="ip">
- <attribute name="address"><ref name="ipv4-addr"/></attribute>
- <optional>
- <attribute name="prefix"><ref name="ipv4-prefix"/></attribute>
- </optional>
- </element>
- </oneOrMore>
+ </optional>
+ <zeroOrMore>
+ <element name="ip">
+ <attribute name="address"><ref name="ipv4-addr"/></attribute>
<optional>
- <element name="route">
- <attribute name="gateway"><ref name="ipv4-addr"/></attribute>
- </element>
+ <attribute name="prefix"><ref name="ipv4-prefix"/></attribute>
</optional>
- </group>
- </choice>
+ </element>
+ </zeroOrMore>
+ <optional>
+ <element name="route">
+ <attribute name="gateway"><ref name="ipv4-addr"/></attribute>
+ </element>
+ </optional>
</interleave>
</element>
</define>
diff --git a/data/xml/redhat-get.xsl b/data/xml/redhat-get.xsl
index 96518ee..ec56f01 100644
--- a/data/xml/redhat-get.xsl
+++ b/data/xml/redhat-get.xsl
@@ -183,32 +183,32 @@
</xsl:template>
<xsl:template name="protocol-ipv4">
- <xsl:choose>
- <xsl:when test="dhcp">
- <node label="BOOTPROTO" value="dhcp"/>
- <xsl:if test="dhcp/@peerdns">
- <node label="PEERDNS" value="{dhcp/@peerdns}"/>
+ <xsl:if test="count(dhcp) > 0">
+ <node label="BOOTPROTO" value="dhcp"/>
+ <xsl:if test="dhcp/@peerdns">
+ <node label="PEERDNS" value="{dhcp/@peerdns}"/>
+ </xsl:if>
+ </xsl:if>
+ <xsl:if test="count(dhcp) = 0">
+ <node label="BOOTPROTO" value="none"/>
+ </xsl:if>
+ <xsl:if test="count(ip) > 0">
+ <xsl:for-each select="ip">
+ <xsl:if test="position() = 1">
+ <xsl:call-template name="ipv4-address">
+ <xsl:with-param name="index"/>
+ </xsl:call-template>
</xsl:if>
- </xsl:when>
- <xsl:when test="ip">
- <node label="BOOTPROTO" value="none"/>
- <xsl:for-each select="ip">
- <xsl:if test="position() = 1">
- <xsl:call-template name="ipv4-address">
- <xsl:with-param name="index"/>
- </xsl:call-template>
- </xsl:if>
- <xsl:if test="position() > 1 and position() < 101">
- <xsl:call-template name="ipv4-address">
- <xsl:with-param name="index" select="position() - 1"/>
- </xsl:call-template>
- </xsl:if>
- </xsl:for-each>
- <xsl:if test="route">
- <node label="GATEWAY" value="{route/@gateway}"/>
+ <xsl:if test="position() > 1 and position() < 101">
+ <xsl:call-template name="ipv4-address">
+ <xsl:with-param name="index" select="position() - 1"/>
+ </xsl:call-template>
</xsl:if>
- </xsl:when>
- </xsl:choose>
+ </xsl:for-each>
+ <xsl:if test="route">
+ <node label="GATEWAY" value="{route/@gateway}"/>
+ </xsl:if>
+ </xsl:if>
</xsl:template>
<xsl:template name="ipv4-address">
diff --git a/data/xml/redhat-put.xsl b/data/xml/redhat-put.xsl
index a89cc2d..ed56c66 100644
--- a/data/xml/redhat-put.xsl
+++ b/data/xml/redhat-put.xsl
@@ -186,16 +186,15 @@
select="count(node[substring(@label,1,6) = 'IPADDR']) > 0"/>
<xsl:variable name="uses_ipv4" select="$uses_dhcp or $uses_static"/>
<xsl:if test="$uses_ipv4">
- <protocol family="ipv4">
- <xsl:choose>
- <xsl:when test="$uses_dhcp">
+ <protocol family="ipv4">
+ <xsl:if test="$uses_dhcp">
<dhcp>
<xsl:if test="node[@label = 'PEERDNS']">
<xsl:attribute name="peerdns"><xsl:value-of select="node[@label = 'PEERDNS']/@value"></xsl:value-of></xsl:attribute>
</xsl:if>
</dhcp>
- </xsl:when>
- <xsl:when test="$uses_static">
+ </xsl:if>
+ <xsl:if test="$uses_static">
<!-- IPADDR and IPADDR0 must be treated differently from IPADDR1 - IPADDR99 -->
<xsl:choose>
<xsl:when test="node[@label = 'IPADDR']">
@@ -236,9 +235,8 @@
</ip>
</xsl:if>
</xsl:for-each>
- </xsl:when>
- </xsl:choose>
- </protocol>
+ </xsl:if>
+ </protocol>
</xsl:if>
</xsl:template>
diff --git a/tests/interface/bridge-multi-all.xml b/tests/interface/bridge-multi-all.xml
new file mode 100644
index 0000000..0cdf484
--- /dev/null
+++ b/tests/interface/bridge-multi-all.xml
@@ -0,0 +1,23 @@
+<interface type="bridge" name="br2">
+ <start mode="onboot"/>
+ <protocol family="ipv4">
+ <dhcp peerdns="yes"/>
+ <ip address="10.0.0.1" prefix="24"/>
+ <ip address="192.168.125.4" prefix="24"/>
+ <ip address="192.168.125.5" prefix="31"/>
+ <ip address="192.168.125.6"/>
+ <ip address="192.168.125.7"/>
+ <ip address="192.168.125.8"/>
+ <ip address="192.168.125.9"/>
+ <ip address="192.168.125.10"/>
+ <ip address="172.16.20.32" prefix="12"/>
+ </protocol>
+ <protocol family="ipv6">
+ <autoconf/>
+ <dhcp/>
+ <ip address="3ffe:ffff:0:5::1" prefix="128"/>
+ <ip address="3ffe:ffff:0:5::3" prefix="128"/>
+ <ip address="3ffe:ffff:0:5::5" prefix="128"/>
+ </protocol>
+ <bridge stp="on" delay="0"/>
+</interface>
diff --git a/tests/redhat/fsroot/etc/sysconfig/network-scripts/ifcfg-br2 b/tests/redhat/fsroot/etc/sysconfig/network-scripts/ifcfg-br2
new file mode 100644
index 0000000..3d45d9e
--- /dev/null
+++ b/tests/redhat/fsroot/etc/sysconfig/network-scripts/ifcfg-br2
@@ -0,0 +1,25 @@
+DEVICE="br2"
+ONBOOT='yes'
+TYPE="Bridge"
+BOOTPROTO="dhcp"
+PEERDNS="yes"
+IPADDR="10.0.0.1"
+NETMASK=255.255.255.0
+IPADDR1="192.168.125.4"
+NETMASK1="255.255.255.0"
+IPADDR2="192.168.125.5"
+NETMASK2="255.255.255.254"
+IPADDR3="192.168.125.6"
+IPADDR4="192.168.125.7"
+IPADDR5="192.168.125.8"
+IPADDR6="192.168.125.9"
+IPADDR7="192.168.125.10"
+IPADDR8="172.16.20.32"
+NETMASK8="255.240.0.0"
+IPV6INIT="yes"
+IPV6_AUTOCONF="yes"
+DHCPV6C="yes"
+IPV6ADDR="3ffe:ffff:0:5::1/128"
+IPV6ADDR_SECONDARIES="3ffe:ffff:0:5::3/128 3ffe:ffff:0:5::5/128"
+STP=on
+DELAY=0
diff --git a/tests/redhat/schema/bridge-multi-all.xml b/tests/redhat/schema/bridge-multi-all.xml
new file mode 100644
index 0000000..4b67a5c
--- /dev/null
+++ b/tests/redhat/schema/bridge-multi-all.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+<forest>
+ <tree path="/files/etc/sysconfig/network-scripts/ifcfg-br2">
+ <node label="DEVICE" value="br2"/>
+ <node label="ONBOOT" value="yes"/>
+ <node label="TYPE" value="Bridge"/>
+ <node label="BOOTPROTO" value="dhcp"/>
+ <node label="PEERDNS" value="yes"/>
+ <node label="IPADDR" value="10.0.0.1"/>
+ <node label="NETMASK" value="255.255.255.0"/>
+ <node label="IPADDR1" value="192.168.125.4"/>
+ <node label="NETMASK1" value="255.255.255.0"/>
+ <node label="IPADDR2" value="192.168.125.5"/>
+ <node label="NETMASK2" value="255.255.255.254"/>
+ <node label="IPADDR3" value="192.168.125.6"/>
+ <node label="IPADDR4" value="192.168.125.7"/>
+ <node label="IPADDR5" value="192.168.125.8"/>
+ <node label="IPADDR6" value="192.168.125.9"/>
+ <node label="IPADDR7" value="192.168.125.10"/>
+ <node label="IPADDR8" value="172.16.20.32"/>
+ <node label="NETMASK8" value="255.240.0.0"/>
+ <node label="IPV6INIT" value="yes"/>
+ <node label="IPV6_AUTOCONF" value="yes"/>
+ <node label="DHCPV6C" value="yes"/>
+ <node label="IPV6ADDR" value="3ffe:ffff:0:5::1/128"/>
+ <node label="IPV6ADDR_SECONDARIES" value="3ffe:ffff:0:5::3/128 3ffe:ffff:0:5::5/128"/>
+ <node label="STP" value="on"/>
+ <node label="DELAY" value="0"/>
+ </tree>
+</forest>
diff --git a/tests/test-redhat.c b/tests/test-redhat.c
index a08bc23..404f375 100644
--- a/tests/test-redhat.c
+++ b/tests/test-redhat.c
@@ -43,7 +43,7 @@ static void testListInterfaces(CuTest *tc) {
int nint;
char **names;
static const char *const exp_names[] =
- { "br0", "br1", "bond0", "lo", "eth3", "eth4" };
+ { "br0", "br1", "br2", "bond0", "lo", "eth3", "eth4" };
static const int exp_nint = ARRAY_CARDINALITY(exp_names);
nint = ncf_num_of_interfaces(ncf, NETCF_IFACE_ACTIVE|NETCF_IFACE_INACTIVE);
@@ -181,6 +181,7 @@ static void testTransforms(CuTest *tc) {
assert_transforms(tc, "bridge-empty");
assert_transforms(tc, "bridge-bond");
assert_transforms(tc, "bridge-multi");
+ assert_transforms(tc, "bridge-multi-all");
assert_transforms(tc, "ethernet-static");
assert_transforms(tc, "ethernet-static-no-prefix");
assert_transforms(tc, "ethernet-dhcp");
--
2.1.0
9 years
[PATCH] support multiple IPv4 addresses in redhat driver
by Laine Stump
netcf has always supported multiple IPv6 addresses, but only a single
IPv4 address. This patch remedies that, at least for the redhat driver
(also used for Fedora and CentOS).
I can't claim that the xsl transforms in redhat-(get|put).xsl are the
optimum code, but they do get the job done (no mean feat, since this
is the first time I've ever made anything beyond a cosmetic change to
an xsl script).
Similar to what NetworkManager does, the first IPv4 address is stored
in the ifcfg file as
IPADDR=b.l.a.h
NETMASK=b.l.a.h
while subsequent ip addresses are stored as:
IPADDRn=b.l.a.h
NETMASKn=b.l.a.h
where "n" is 1 - 99 (since that is what initscripts (and probably
NetworkManager) support).
A new test case with multiple IPv4 addresses has also been added -
bridge-multi.
---
data/xml/interface.rng | 14 ++++++------
data/xml/redhat-get.xsl | 25 ++++++++++++++++++----
data/xml/redhat-put.xsl | 23 ++++++++++++++++++--
tests/interface/bridge-multi.xml | 15 +++++++++++++
.../fsroot/etc/sysconfig/network-scripts/ifcfg-br1 | 20 +++++++++++++++++
tests/redhat/schema/bridge-multi.xml | 24 +++++++++++++++++++++
tests/test-redhat.c | 5 +++--
7 files changed, 112 insertions(+), 14 deletions(-)
create mode 100644 tests/interface/bridge-multi.xml
create mode 100644 tests/redhat/fsroot/etc/sysconfig/network-scripts/ifcfg-br1
create mode 100644 tests/redhat/schema/bridge-multi.xml
diff --git a/data/xml/interface.rng b/data/xml/interface.rng
index 7810a7a..c587da8 100644
--- a/data/xml/interface.rng
+++ b/data/xml/interface.rng
@@ -325,12 +325,14 @@
<choice>
<ref name="dhcp-element"/>
<group>
- <element name="ip">
- <attribute name="address"><ref name="ipv4-addr"/></attribute>
- <optional>
- <attribute name="prefix"><ref name="ipv4-prefix"/></attribute>
- </optional>
- </element>
+ <zeroOrMore>
+ <element name="ip">
+ <attribute name="address"><ref name="ipv4-addr"/></attribute>
+ <optional>
+ <attribute name="prefix"><ref name="ipv4-prefix"/></attribute>
+ </optional>
+ </element>
+ </zeroOrMore>
<optional>
<element name="route">
<attribute name="gateway"><ref name="ipv4-addr"/></attribute>
diff --git a/data/xml/redhat-get.xsl b/data/xml/redhat-get.xsl
index 81dc718..5970c67 100644
--- a/data/xml/redhat-get.xsl
+++ b/data/xml/redhat-get.xsl
@@ -192,10 +192,18 @@
</xsl:when>
<xsl:when test="ip">
<node label="BOOTPROTO" value="none"/>
- <node label="IPADDR" value="{ip/@address}"/>
- <xsl:if test="ip/@prefix">
- <node label="NETMASK" value="{ipcalc:netmask(ip/@prefix)}"/>
- </xsl:if>
+ <xsl:for-each select="ip">
+ <xsl:if test="position() = 1">
+ <xsl:call-template name="ipv4-address">
+ <xsl:with-param name="index"/>
+ </xsl:call-template>
+ </xsl:if>
+ <xsl:if test="position() > 1 and position() < 100">
+ <xsl:call-template name="ipv4-address">
+ <xsl:with-param name="index" select="position() - 1"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:for-each>
<xsl:if test="route">
<node label="GATEWAY" value="{route/@gateway}"/>
</xsl:if>
@@ -203,6 +211,15 @@
</xsl:choose>
</xsl:template>
+ <xsl:template name="ipv4-address">
+ <xsl:param name="index"/>
+ <node label="IPADDR{$index}" value="{@address}"/>
+ <xsl:if test="@prefix">
+ <node label="NETMASK{$index}" value="{ipcalc:netmask(@prefix)}"/>
+ </xsl:if>
+ </xsl:template>
+
+
<xsl:template name="protocol-ipv6">
<node label="IPV6INIT" value="yes"/>
<xsl:if test="count(autoconf) > 0">
diff --git a/data/xml/redhat-put.xsl b/data/xml/redhat-put.xsl
index ed800d6..7a3e482 100644
--- a/data/xml/redhat-put.xsl
+++ b/data/xml/redhat-put.xsl
@@ -183,8 +183,7 @@
<xsl:variable name="uses_dhcp"
select="node[@label = 'BOOTPROTO']/@value = 'dhcp'"/>
<xsl:variable name="uses_static"
- select="count(node[@label = 'IPADDR']) +
- count(node[@label = 'IPADDR0']) > 0"/>
+ select="count(node[substring(@label,1,6) = 'IPADDR']) > 0"/>
<xsl:variable name="uses_ipv4" select="$uses_dhcp or $uses_static"/>
<xsl:if test="$uses_ipv4">
<protocol family="ipv4">
@@ -197,6 +196,7 @@
</dhcp>
</xsl:when>
<xsl:when test="$uses_static">
+ <!-- IPADDR and IPADDR0 must be treated differently from IPADDR1 - IPADDR99 -->
<xsl:choose>
<xsl:when test="node[@label = 'IPADDR']">
<ip address="{node[@label = 'IPADDR']/@value}">
@@ -217,6 +217,25 @@
<route gateway="{node[@label = 'GATEWAY0']/@value}"/>
</xsl:when>
</xsl:choose>
+ <xsl:for-each select="node[substring(@label, 1, 6) = 'IPADDR']">
+ <xsl:variable name="index" select="substring(@label, 7, 3)"/>
+ <xsl:if test="number($index) > 0 and number($index) < 100">
+ <ip address="{@value}">
+ <xsl:choose>
+ <xsl:when test="../node[@label = concat('PREFIX', $index)]">
+ <xsl:attribute name="prefix">
+ <xsl:value-of select="../node[@label = concat('PREFIX', $index)]/@value"/>
+ </xsl:attribute>
+ </xsl:when>
+ <xsl:when test="../node[@label = concat('NETMASK', $index)]">
+ <xsl:attribute name="prefix">
+ <xsl:value-of select="ipcalc:prefix(../node[@label = concat('NETMASK', $index)]/@value)"/>
+ </xsl:attribute>
+ </xsl:when>
+ </xsl:choose>
+ </ip>
+ </xsl:if>
+ </xsl:for-each>
</xsl:when>
</xsl:choose>
</protocol>
diff --git a/tests/interface/bridge-multi.xml b/tests/interface/bridge-multi.xml
new file mode 100644
index 0000000..d476c5b
--- /dev/null
+++ b/tests/interface/bridge-multi.xml
@@ -0,0 +1,15 @@
+<interface type="bridge" name="br1">
+ <start mode="onboot"/>
+ <protocol family="ipv4">
+ <ip address="10.0.0.1" prefix="24"/>
+ <ip address="192.168.125.4" prefix="24"/>
+ <ip address="192.168.125.5" prefix="31"/>
+ <ip address="192.168.125.6"/>
+ <ip address="192.168.125.7"/>
+ <ip address="192.168.125.8"/>
+ <ip address="192.168.125.9"/>
+ <ip address="192.168.125.10"/>
+ <ip address="172.16.20.32" prefix="12"/>
+ </protocol>
+ <bridge stp="on" delay="0"/>
+</interface>
diff --git a/tests/redhat/fsroot/etc/sysconfig/network-scripts/ifcfg-br1 b/tests/redhat/fsroot/etc/sysconfig/network-scripts/ifcfg-br1
new file mode 100644
index 0000000..5247f7b
--- /dev/null
+++ b/tests/redhat/fsroot/etc/sysconfig/network-scripts/ifcfg-br1
@@ -0,0 +1,20 @@
+# Enclosing the values in useless quotes is intentional
+DEVICE="br1"
+ONBOOT='yes'
+BOOTPROTO="none"
+TYPE="Bridge"
+DELAY=0
+STP=on
+IPADDR="10.0.0.1"
+NETMASK=255.255.255.0
+IPADDR1="192.168.125.4"
+PREFIX1=24
+IPADDR2="192.168.125.5"
+NETMASK2="255.255.255.254"
+IPADDR3="192.168.125.6"
+IPADDR4="192.168.125.7"
+IPADDR5="192.168.125.8"
+IPADDR6="192.168.125.9"
+IPADDR7="192.168.125.10"
+IPADDR8="172.16.20.32"
+PREFIX8=12
diff --git a/tests/redhat/schema/bridge-multi.xml b/tests/redhat/schema/bridge-multi.xml
new file mode 100644
index 0000000..24c6f9d
--- /dev/null
+++ b/tests/redhat/schema/bridge-multi.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<forest>
+ <tree path="/files/etc/sysconfig/network-scripts/ifcfg-br1">
+ <node label="DEVICE" value="br1"/>
+ <node label="ONBOOT" value="yes"/>
+ <node label="TYPE" value="Bridge"/>
+ <node label="BOOTPROTO" value="none"/>
+ <node label="IPADDR" value="10.0.0.1"/>
+ <node label="NETMASK" value="255.255.255.0"/>
+ <node label="IPADDR1" value="192.168.125.4"/>
+ <node label="NETMASK1" value="255.255.255.0"/>
+ <node label="IPADDR2" value="192.168.125.5"/>
+ <node label="NETMASK2" value="255.255.255.254"/>
+ <node label="IPADDR3" value="192.168.125.6"/>
+ <node label="IPADDR4" value="192.168.125.7"/>
+ <node label="IPADDR5" value="192.168.125.8"/>
+ <node label="IPADDR6" value="192.168.125.9"/>
+ <node label="IPADDR7" value="192.168.125.10"/>
+ <node label="IPADDR8" value="172.16.20.32"/>
+ <node label="NETMASK8" value="255.240.0.0"/>
+ <node label="STP" value="on"/>
+ <node label="DELAY" value="0"/>
+ </tree>
+</forest>
diff --git a/tests/test-redhat.c b/tests/test-redhat.c
index ab22a6a..a08bc23 100644
--- a/tests/test-redhat.c
+++ b/tests/test-redhat.c
@@ -1,7 +1,7 @@
/*
* test-redhat.c:
*
- * Copyright (C) 2009 Red Hat Inc.
+ * Copyright (C) 2009, 2011, 2015 Red Hat Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -43,7 +43,7 @@ static void testListInterfaces(CuTest *tc) {
int nint;
char **names;
static const char *const exp_names[] =
- { "br0", "bond0", "lo", "eth3", "eth4" };
+ { "br0", "br1", "bond0", "lo", "eth3", "eth4" };
static const int exp_nint = ARRAY_CARDINALITY(exp_names);
nint = ncf_num_of_interfaces(ncf, NETCF_IFACE_ACTIVE|NETCF_IFACE_INACTIVE);
@@ -180,6 +180,7 @@ static void testTransforms(CuTest *tc) {
assert_transforms(tc, "bridge-vlan");
assert_transforms(tc, "bridge-empty");
assert_transforms(tc, "bridge-bond");
+ assert_transforms(tc, "bridge-multi");
assert_transforms(tc, "ethernet-static");
assert_transforms(tc, "ethernet-static-no-prefix");
assert_transforms(tc, "ethernet-dhcp");
--
2.1.0
9 years
[PATCH] remove unused data file and make rule adding it to packages
by Laine Stump
Way back in 2010, commit 210b78b3 removed code that would add this
rule to iptables:
-I FORWARD -m physdev --physdev-is-bridged -j ACCEPT
but for some reason I neglected to remove the data file, which was
still being put into packages and installed to every system. This
patch fixes that omission.
---
Makefile.am | 1 -
data/iptables-forward-bridged | 1 -
tests/redhat/fsroot/etc/sysconfig/system-config-firewall | 5 -----
3 files changed, 7 deletions(-)
delete mode 100644 data/iptables-forward-bridged
delete mode 100644 tests/redhat/fsroot/etc/sysconfig/system-config-firewall
diff --git a/Makefile.am b/Makefile.am
index d380ec8..ed6de65 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -16,7 +16,6 @@ dist_xml_DATA=data/xml/augeas.rng data/xml/interface.rng \
data/xml/debian-get.xsl data/xml/debian-put.xsl \
data/xml/redhat-get.xsl data/xml/redhat-put.xsl \
data/xml/suse-get.xsl data/xml/suse-put.xsl
-dist_netcf_DATA=data/iptables-forward-bridged
dist_lens_DATA= \
data/lenses/netcf.aug \
data/lenses/persist_net_rules.aug \
diff --git a/data/iptables-forward-bridged b/data/iptables-forward-bridged
deleted file mode 100644
index 133e87b..0000000
--- a/data/iptables-forward-bridged
+++ /dev/null
@@ -1 +0,0 @@
--I FORWARD -m physdev --physdev-is-bridged -j ACCEPT
diff --git a/tests/redhat/fsroot/etc/sysconfig/system-config-firewall b/tests/redhat/fsroot/etc/sysconfig/system-config-firewall
deleted file mode 100644
index 0ea3c39..0000000
--- a/tests/redhat/fsroot/etc/sysconfig/system-config-firewall
+++ /dev/null
@@ -1,5 +0,0 @@
-# Configuration file for system-config-firewall
-
---enabled
---service=ssh
---custom-rules=ipv4:filter:/data/share/share/netcf/iptables-forward-bridged
--
2.1.0
9 years, 1 month
[PATCH 0/5] Various small tweaks/fixes.
by Laine Stump
I made these changes while working on something slightly more
significant, and wanted to get them out of the way.
Laine Stump (5):
don't redefine DATADIR
use augeas typedef instead of "struct augeas"
remove unnecessary calls to get_augeas()
Update gnulib
Update STR*() macros to match those in libvirt
.gnulib | 2 +-
bootstrap.conf | 3 ++-
src/drv_debian.c | 8 ++++----
src/drv_redhat.c | 30 +++++++++---------------------
src/drv_suse.c | 24 ++++++++++++------------
src/dutil_linux.c | 24 ++++++++++++------------
src/dutil_linux.h | 4 ++--
src/internal.h | 28 +++++++++++++++++-----------
8 files changed, 59 insertions(+), 64 deletions(-)
--
2.1.0
9 years, 1 month
[PATCH] Remove extraneous single quotes from IPV6ADDR_SECONDARIES
by jiahu
The IPV6ADDR_SECONDARIES setting in ifcfg files was being set
with an extra set of single quotes.
For example:
After defining a interface with multi-ipv6 addresses
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-enp2s0
DEVICE=enp2s0
ONBOOT=yes
IPV6INIT=yes
IPV6_AUTOCONF=no
DHCPV6C=no
IPV6ADDR=2002::200/64
IPV6ADDR_SECONDARIES="'2002::201/64 2002::202/64'"
Should like below:
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-enp2s0
DEVICE=enp2s0
ONBOOT=yes
IPV6INIT=yes
IPV6_AUTOCONF=no
DHCPV6C=no
IPV6ADDR=2002::200/64
IPV6ADDR_SECONDARIES="2002::201/64 2002::202/64"
Since the extra quotes are added in all cases, this patch just
unconditionally removes them.
---
data/xml/redhat-get.xsl | 2 --
data/xml/suse-get.xsl | 2 --
tests/redhat/schema/ipv6-static-multi.xml | 2 +-
tests/suse/schema/ipv6-static-multi.xml | 2 +-
4 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/data/xml/redhat-get.xsl b/data/xml/redhat-get.xsl
index 923dde0..a3970de 100644
--- a/data/xml/redhat-get.xsl
+++ b/data/xml/redhat-get.xsl
@@ -226,14 +226,12 @@
<xsl:if test="count(ip) > 1">
<node label="IPV6ADDR_SECONDARIES">
<xsl:attribute name="value">
- <xsl:text>'</xsl:text>
<xsl:for-each select="ip[1]/following-sibling::ip[following-sibling::ip]">
<xsl:value-of select="@address"/><xsl:if test="@prefix">/<xsl:value-of select="@prefix"/></xsl:if><xsl:value-of select="string(' ')"/>
</xsl:for-each>
<xsl:for-each select="ip[last()]">
<xsl:value-of select="@address"/><xsl:if test="@prefix">/<xsl:value-of select="@prefix"/></xsl:if>
</xsl:for-each>
- <xsl:text>'</xsl:text>
</xsl:attribute>
</node>
</xsl:if>
diff --git a/data/xml/suse-get.xsl b/data/xml/suse-get.xsl
index 182d292..bc5eb72 100644
--- a/data/xml/suse-get.xsl
+++ b/data/xml/suse-get.xsl
@@ -243,14 +243,12 @@
<xsl:if test="count(ip) > 1">
<node label="IPV6ADDR_SECONDARIES">
<xsl:attribute name="value">
- <xsl:text>'</xsl:text>
<xsl:for-each select="ip[1]/following-sibling::ip[following-sibling::ip]">
<xsl:value-of select="@address"/><xsl:if test="@prefix">/<xsl:value-of select="@prefix"/></xsl:if><xsl:value-of select="string(' ')"/>
</xsl:for-each>
<xsl:for-each select="ip[last()]">
<xsl:value-of select="@address"/><xsl:if test="@prefix">/<xsl:value-of select="@prefix"/></xsl:if>
</xsl:for-each>
- <xsl:text>'</xsl:text>
</xsl:attribute>
</node>
</xsl:if>
diff --git a/tests/redhat/schema/ipv6-static-multi.xml b/tests/redhat/schema/ipv6-static-multi.xml
index d865a05..f1f82cd 100644
--- a/tests/redhat/schema/ipv6-static-multi.xml
+++ b/tests/redhat/schema/ipv6-static-multi.xml
@@ -7,6 +7,6 @@
<node label="IPV6_AUTOCONF" value="no"/>
<node label="DHCPV6C" value="no"/>
<node label="IPV6ADDR" value="3ffe:ffff:0:5::1/128"/>
- <node label="IPV6ADDR_SECONDARIES" value="'3ffe:ffff:0:5::3/128 3ffe:ffff:0:5::5/128'"/>
+ <node label="IPV6ADDR_SECONDARIES" value="3ffe:ffff:0:5::3/128 3ffe:ffff:0:5::5/128"/>
</tree>
</forest>
diff --git a/tests/suse/schema/ipv6-static-multi.xml b/tests/suse/schema/ipv6-static-multi.xml
index d865a05..f1f82cd 100644
--- a/tests/suse/schema/ipv6-static-multi.xml
+++ b/tests/suse/schema/ipv6-static-multi.xml
@@ -7,6 +7,6 @@
<node label="IPV6_AUTOCONF" value="no"/>
<node label="DHCPV6C" value="no"/>
<node label="IPV6ADDR" value="3ffe:ffff:0:5::1/128"/>
- <node label="IPV6ADDR_SECONDARIES" value="'3ffe:ffff:0:5::3/128 3ffe:ffff:0:5::5/128'"/>
+ <node label="IPV6ADDR_SECONDARIES" value="3ffe:ffff:0:5::3/128 3ffe:ffff:0:5::5/128"/>
</tree>
</forest>
--
1.8.1.4
9 years, 1 month
[PATCH] eliminate netcf-specific sysconfig.aug lense
by Laine Stump
Back in 2010 when netcf needed a separate augeas lense for files in
sysconfig/network-scripts (e.g. the ifcfg-* files), augeas itself had
no special purpose sysconfig.aug lense, so netcf has its own
sysconfig.aug lens based on the shellvars.aug lense from augeas at the
time. Sometime soon after that augeas got its own sysconfig.aug lense,
but netcf never rid itself of its own copy.
The sysconfig.aug in netcf is now severely out of date compared to the
one in augeas, and is missing many bugfixes. This patch just removes
the netcf version from /usr/share/netcf/lenses, so that augeas will
use its own lense when it's called by netcf. Among other things, this
updated lense properly ignores semicolons and "#"-initiated partial
line comments at the ends of lines that contain valid variable
settings at the beginning.
This resolves:
https://bugzilla.redhat.com/show_bug.cgi?id=761246
---
Makefile.am | 1 -
data/lenses/sysconfig.aug | 60 -----------------------------------------------
2 files changed, 61 deletions(-)
delete mode 100644 data/lenses/sysconfig.aug
diff --git a/Makefile.am b/Makefile.am
index d35fd18..d380ec8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,7 +19,6 @@ dist_xml_DATA=data/xml/augeas.rng data/xml/interface.rng \
dist_netcf_DATA=data/iptables-forward-bridged
dist_lens_DATA= \
data/lenses/netcf.aug \
- data/lenses/sysconfig.aug \
data/lenses/persist_net_rules.aug \
data/lenses/routes.aug
diff --git a/data/lenses/sysconfig.aug b/data/lenses/sysconfig.aug
deleted file mode 100644
index 9ee668e..0000000
--- a/data/lenses/sysconfig.aug
+++ /dev/null
@@ -1,60 +0,0 @@
-(* Variation of the Shellvars lens *)
-(* Supports only what's needed to handle sysconfig files *)
-(* Modified to strip quotes. In the put direction, add double quotes *)
-(* around values that need them *)
-(* To keep things simple, we also do not support shell variable arrays *)
-module Sysconfig =
- let eol = Util.eol
-
- let key_re = /[A-Za-z0-9_]+(\[[0-9]+\])?/ - "unset" - "export"
- let eq = Util.del_str "="
- let comment = Util.comment
- let empty = Util.empty
- let xchgs = Build.xchgs
- let dels = Util.del_str
-
- let nothing = del /(""|'')?/ "" . value ""
-
- (* Chars allowed in a bare string *)
- let bchar = /[^ \t\n\"'\\]|\\\\./
- let qchar = /["']/ (* " *)
-
- (* We split the handling of right hand sides into a few cases:
- * bare - strings that contain no spaces, optionally enclosed in
- * single or double quotes
- * dquot - strings that contain at least one space or apostrophe,
- * which must be enclosed in double quotes
- * squot - strings that contain an unescaped double quote
- *)
- let bare = del qchar? "" . store (bchar+) . del qchar? ""
- let dquot =
- del qchar "\"" . store (bchar* . /[ \t']/ . bchar*)+ . del qchar "\""
- let squot =
- dels "'" . store ((bchar|/[ \t]/)* . "\"" . (bchar|/[ \t]/)*)+ . dels "'"
-
- let export = [ key "export" . Util.del_ws_spc ]
- let kv (value:lens) = [ export? . key key_re . eq . value . eol ]
- let assign = kv nothing | kv bare | kv dquot | kv squot
-
- let var_action (name:string) =
- [ xchgs name ("@" . name) . Util.del_ws_spc . store key_re . eol ]
-
- let unset = var_action "unset"
- let bare_export = var_action "export"
-
- let source =
- [
- del /\.|source/ "." . label ".source" .
- Util.del_ws_spc . store /[^= \t\n]+/ . eol
- ]
-
- let lns = (comment | empty | source | assign | unset | bare_export) *
-
-(*
- Examples:
-
- abc -> abc -> abc
- "abc" -> abc -> abc
- "a b" -> a b -> "a b"
- 'a"b' -> a"b -> 'a"b'
-*)
--
2.1.0
9 years, 1 month