43fe83
From 9e8eabdfdefe2d31282b7994d01c28dc8cd818e0 Mon Sep 17 00:00:00 2001
43fe83
Message-Id: <9e8eabdfdefe2d31282b7994d01c28dc8cd818e0.1378475168.git.jdenemar@redhat.com>
43fe83
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
43fe83
Date: Thu, 5 Sep 2013 14:25:28 +0200
43fe83
Subject: [PATCH] Add '<nat>' element to '<forward>' network schemas
43fe83
43fe83
Commits 905629f4 and 1716e7a6 have added support for specifying
43fe83
an IPv4 range and a port range to be used by NAT:
43fe83
<forward mode='nat'>
43fe83
  <nat>
43fe83
    <address start='10.20.30.40' end='10.20.30.44'/>
43fe83
    <port start='60000' end='65432'/>
43fe83
  </nat>
43fe83
</forward>
43fe83
43fe83
https://bugzilla.redhat.com/show_bug.cgi?id=1004364
43fe83
(cherry picked from commit 437b7944a81b648a15c657fef184f3bcd2427dac)
43fe83
43fe83
Conflicts:
43fe83
	tests/networkxml2xmltest.c:
43fe83
        4f595ba not backported (dns forwardPlainNames)
43fe83
43fe83
A few spaces were needed in
43fe83
networkxml2xmlout/nat-network-forward-nat-address.xml
43fe83
because d8bd24a which removed them is not backported either.
43fe83
---
43fe83
 docs/schemas/network.rng                           | 26 +++++++++++++++++++++
43fe83
 docs/schemas/networkcommon.rng                     |  7 ++++++
43fe83
 .../nat-network-forward-nat-address.xml            | 26 +++++++++++++++++++++
43fe83
 .../nat-network-forward-nat-address.xml            | 27 ++++++++++++++++++++++
43fe83
 tests/networkxml2xmltest.c                         |  1 +
43fe83
 5 files changed, 87 insertions(+)
43fe83
 create mode 100644 tests/networkxml2xmlin/nat-network-forward-nat-address.xml
43fe83
 create mode 100644 tests/networkxml2xmlout/nat-network-forward-nat-address.xml
43fe83
43fe83
diff --git a/docs/schemas/network.rng b/docs/schemas/network.rng
43fe83
index ded8580..11adbac 100644
43fe83
--- a/docs/schemas/network.rng
43fe83
+++ b/docs/schemas/network.rng
43fe83
@@ -160,6 +160,32 @@
43fe83
                   <empty/>
43fe83
                 </element>
43fe83
               </optional>
43fe83
+              <optional>
43fe83
+                <element name='nat'>
43fe83
+                  <interleave>
43fe83
+                    <optional>
43fe83
+                      <element name='address'>
43fe83
+                        <attribute name='start'>
43fe83
+                          <ref name='ipv4Addr'/>
43fe83
+                        </attribute>
43fe83
+                        <attribute name='end'>
43fe83
+                          <ref name='ipv4Addr'/>
43fe83
+                        </attribute>
43fe83
+                      </element>
43fe83
+                    </optional>
43fe83
+                    <optional>
43fe83
+                      <element name='port'>
43fe83
+                        <attribute name='start'>
43fe83
+                          <ref name='port'/>
43fe83
+                        </attribute>
43fe83
+                        <attribute name='end'>
43fe83
+                          <ref name='port'/>
43fe83
+                        </attribute>
43fe83
+                      </element>
43fe83
+                    </optional>
43fe83
+                  </interleave>
43fe83
+                </element>
43fe83
+              </optional>
43fe83
             </interleave>
43fe83
           </element>
43fe83
         </optional>
43fe83
diff --git a/docs/schemas/networkcommon.rng b/docs/schemas/networkcommon.rng
43fe83
index e60f1fc..e26b7f3 100644
43fe83
--- a/docs/schemas/networkcommon.rng
43fe83
+++ b/docs/schemas/networkcommon.rng
43fe83
@@ -217,4 +217,11 @@
43fe83
       </oneOrMore>
43fe83
     </element>
43fe83
   </define>
43fe83
+
43fe83
+  <define name='port'>
43fe83
+    <data type='integer'>
43fe83
+      <param name='minInclusive'>1</param>
43fe83
+      <param name='maxInclusive'>65535</param>
43fe83
+    </data>
43fe83
+  </define>
43fe83
 </grammar>
43fe83
diff --git a/tests/networkxml2xmlin/nat-network-forward-nat-address.xml b/tests/networkxml2xmlin/nat-network-forward-nat-address.xml
43fe83
new file mode 100644
43fe83
index 0000000..403d058
43fe83
--- /dev/null
43fe83
+++ b/tests/networkxml2xmlin/nat-network-forward-nat-address.xml
43fe83
@@ -0,0 +1,26 @@
43fe83
+<network>
43fe83
+  <name>default</name>
43fe83
+  <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
43fe83
+  <bridge name="virbr0"/>
43fe83
+  <forward mode="nat" dev="eth1">
43fe83
+    <nat>
43fe83
+      <address start='10.20.30.40' end='10.20.30.44'/>
43fe83
+      <port start='60000' end='65432'/>
43fe83
+    </nat>
43fe83
+  </forward>
43fe83
+  <ip address="192.168.122.1" netmask="255.255.255.0">
43fe83
+    <dhcp>
43fe83
+      <range start="192.168.122.2" end="192.168.122.254"/>
43fe83
+      <host mac="00:16:3e:77:e2:ed" name="a.example.com" ip="192.168.122.10"/>
43fe83
+      <host mac="00:16:3e:3e:a9:1a" name="b.example.com" ip="192.168.122.11"/>
43fe83
+    </dhcp>
43fe83
+  </ip>
43fe83
+  <ip family="ipv4" address="192.168.123.1" netmask="255.255.255.0">
43fe83
+  </ip>
43fe83
+  <ip family="ipv6" address="2001:db8:ac10:fe01::1" prefix="64">
43fe83
+  </ip>
43fe83
+  <ip family="ipv6" address="2001:db8:ac10:fd01::1" prefix="64">
43fe83
+  </ip>
43fe83
+  <ip family="ipv4" address="10.24.10.1">
43fe83
+  </ip>
43fe83
+</network>
43fe83
diff --git a/tests/networkxml2xmlout/nat-network-forward-nat-address.xml b/tests/networkxml2xmlout/nat-network-forward-nat-address.xml
43fe83
new file mode 100644
43fe83
index 0000000..796220d
43fe83
--- /dev/null
43fe83
+++ b/tests/networkxml2xmlout/nat-network-forward-nat-address.xml
43fe83
@@ -0,0 +1,27 @@
43fe83
+<network>
43fe83
+  <name>default</name>
43fe83
+  <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
43fe83
+  <forward dev='eth1' mode='nat'>
43fe83
+    <nat>
43fe83
+      <address start='10.20.30.40' end='10.20.30.44'/>
43fe83
+      <port start='60000' end='65432'/>
43fe83
+    </nat>
43fe83
+    <interface dev='eth1'/>
43fe83
+  </forward>
43fe83
+  <bridge name='virbr0' stp='on' delay='0' />
43fe83
+  <ip address='192.168.122.1' netmask='255.255.255.0'>
43fe83
+    <dhcp>
43fe83
+      <range start='192.168.122.2' end='192.168.122.254' />
43fe83
+      <host mac='00:16:3e:77:e2:ed' name='a.example.com' ip='192.168.122.10' />
43fe83
+      <host mac='00:16:3e:3e:a9:1a' name='b.example.com' ip='192.168.122.11' />
43fe83
+    </dhcp>
43fe83
+  </ip>
43fe83
+  <ip family='ipv4' address='192.168.123.1' netmask='255.255.255.0'>
43fe83
+  </ip>
43fe83
+  <ip family='ipv6' address='2001:db8:ac10:fe01::1' prefix='64'>
43fe83
+  </ip>
43fe83
+  <ip family='ipv6' address='2001:db8:ac10:fd01::1' prefix='64'>
43fe83
+  </ip>
43fe83
+  <ip family='ipv4' address='10.24.10.1'>
43fe83
+  </ip>
43fe83
+</network>
43fe83
diff --git a/tests/networkxml2xmltest.c b/tests/networkxml2xmltest.c
43fe83
index 0dfed16..b48eed2 100644
43fe83
--- a/tests/networkxml2xmltest.c
43fe83
+++ b/tests/networkxml2xmltest.c
43fe83
@@ -104,6 +104,7 @@ mymain(void)
43fe83
     DO_TEST("netboot-proxy-network");
43fe83
     DO_TEST("nat-network-dns-txt-record");
43fe83
     DO_TEST("nat-network-dns-hosts");
43fe83
+    DO_TEST("nat-network-forward-nat-address");
43fe83
     DO_TEST("8021Qbh-net");
43fe83
     DO_TEST("direct-net");
43fe83
     DO_TEST("host-bridge-net");
43fe83
-- 
43fe83
1.8.3.2
43fe83