]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
network: set mtu as a DHCP option when specified
authorCasey Callendrello <cdc@redhat.com>
Tue, 11 Dec 2018 16:05:43 +0000 (17:05 +0100)
committerJán Tomko <jtomko@redhat.com>
Thu, 31 Jan 2019 16:45:41 +0000 (17:45 +0100)
This adds an additional directive to the dnsmasq configuration file that
notifies clients via dhcp about the link's MTU. Guests can then choose
adjust their link accordingly.

Signed-off-by: Casey Callendrello <cdc@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
src/network/bridge_driver.c
tests/networkxml2confdata/nat-network-mtu.conf [new file with mode: 0644]
tests/networkxml2confdata/nat-network-mtu.xml [new file with mode: 0644]
tests/networkxml2conftest.c
tests/networkxml2xmlin/nat-network-mtu.xml [new file with mode: 0644]
tests/networkxml2xmlout/nat-network-mtu.xml [new file with mode: 0644]
tests/networkxml2xmltest.c

index 20a0f65e65cc85c252fcb01fb4e2410291d27dab..a9674ef6c2c640a5c689118b546fca4747debf04 100644 (file)
@@ -1410,6 +1410,10 @@ networkDnsmasqConfContents(virNetworkObjPtr obj,
                           dctx->addnhostsfile->path);
     }
 
+    /* Configure DHCP to tell clients about the MTU. */
+    if (def->mtu > 0)
+        virBufferAsprintf(&configbuf, "dhcp-option=option:mtu,%d\n", def->mtu);
+
     /* Are we doing RA instead of radvd? */
     if (DNSMASQ_RA_SUPPORT(caps)) {
         if (ipv6def) {
diff --git a/tests/networkxml2confdata/nat-network-mtu.conf b/tests/networkxml2confdata/nat-network-mtu.conf
new file mode 100644 (file)
index 0000000..91b574b
--- /dev/null
@@ -0,0 +1,19 @@
+##WARNING:  THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
+##OVERWRITTEN AND LOST.  Changes to this configuration should be made using:
+##    virsh net-edit default
+## or other application using the libvirt API.
+##
+## dnsmasq conf file created by libvirt
+strict-order
+except-interface=lo
+bind-dynamic
+interface=virbr0
+dhcp-range=192.168.122.2,192.168.122.254
+dhcp-no-override
+dhcp-authoritative
+dhcp-lease-max=253
+dhcp-hostsfile=/var/lib/libvirt/dnsmasq/default.hostsfile
+addn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts
+dhcp-option=option:mtu,7000
+dhcp-range=2001:db8:ac10:fe01::1,ra-only
+dhcp-range=2001:db8:ac10:fd01::1,ra-only
diff --git a/tests/networkxml2confdata/nat-network-mtu.xml b/tests/networkxml2confdata/nat-network-mtu.xml
new file mode 100644 (file)
index 0000000..87b214e
--- /dev/null
@@ -0,0 +1,22 @@
+<network>
+  <name>default</name>
+  <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
+  <forward dev='eth1' mode='nat'/>
+  <bridge name='virbr0' stp='on' delay='0'/>
+  <mtu size='7000'/>
+  <ip address='192.168.122.1' netmask='255.255.255.0'>
+    <dhcp>
+      <range start='192.168.122.2' end='192.168.122.254'/>
+      <host mac='00:16:3e:77:e2:ed' name='a.example.com' ip='192.168.122.10'/>
+      <host mac='00:16:3e:3e:a9:1a' name='b.example.com' ip='192.168.122.11'/>
+    </dhcp>
+  </ip>
+  <ip family='ipv4' address='192.168.123.1' netmask='255.255.255.0'>
+  </ip>
+  <ip family='ipv6' address='2001:db8:ac10:fe01::1' prefix='64'>
+  </ip>
+  <ip family='ipv6' address='2001:db8:ac10:fd01::1' prefix='64'>
+  </ip>
+  <ip family='ipv4' address='10.24.10.1'>
+  </ip>
+</network>
index c362149c296bedc6af0da6719fbd10958d41b56c..bf9675838d792f32eceb3876a15a200d8220d567 100644 (file)
@@ -136,6 +136,7 @@ mymain(void)
     DO_TEST("nat-network-dns-forwarders", full);
     DO_TEST("nat-network-dns-forwarder-no-resolv", full);
     DO_TEST("nat-network-dns-local-domain", full);
+    DO_TEST("nat-network-mtu", dhcpv6);
     DO_TEST("dhcp6-network", dhcpv6);
     DO_TEST("dhcp6-nat-network", dhcpv6);
     DO_TEST("dhcp6host-routed-network", dhcpv6);
diff --git a/tests/networkxml2xmlin/nat-network-mtu.xml b/tests/networkxml2xmlin/nat-network-mtu.xml
new file mode 100644 (file)
index 0000000..07d0d9f
--- /dev/null
@@ -0,0 +1,22 @@
+<network>
+  <name>default</name>
+  <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
+  <bridge name="virbr0"/>
+  <mtu size='7000'/>
+  <forward mode="nat" dev="eth1"/>
+  <ip address="192.168.122.1" netmask="255.255.255.0">
+    <dhcp>
+      <range start="192.168.122.2" end="192.168.122.254"/>
+      <host mac="00:16:3e:77:e2:ed" name="a.example.com" ip="192.168.122.10"/>
+      <host mac="00:16:3e:3e:a9:1a" name="b.example.com" ip="192.168.122.11"/>
+    </dhcp>
+  </ip>
+  <ip family="ipv4" address="192.168.123.1" netmask="255.255.255.0">
+  </ip>
+  <ip family="ipv6" address="2001:db8:ac10:fe01::1" prefix="64">
+  </ip>
+  <ip family="ipv6" address="2001:db8:ac10:fd01::1" prefix="64">
+  </ip>
+  <ip family="ipv4" address="10.24.10.1">
+  </ip>
+</network>
diff --git a/tests/networkxml2xmlout/nat-network-mtu.xml b/tests/networkxml2xmlout/nat-network-mtu.xml
new file mode 100644 (file)
index 0000000..715bc1b
--- /dev/null
@@ -0,0 +1,24 @@
+<network>
+  <name>default</name>
+  <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
+  <forward dev='eth1' mode='nat'>
+    <interface dev='eth1'/>
+  </forward>
+  <bridge name='virbr0' stp='on' delay='0'/>
+  <mtu size='7000'/>
+  <ip address='192.168.122.1' netmask='255.255.255.0'>
+    <dhcp>
+      <range start='192.168.122.2' end='192.168.122.254'/>
+      <host mac='00:16:3e:77:e2:ed' name='a.example.com' ip='192.168.122.10'/>
+      <host mac='00:16:3e:3e:a9:1a' name='b.example.com' ip='192.168.122.11'/>
+    </dhcp>
+  </ip>
+  <ip family='ipv4' address='192.168.123.1' netmask='255.255.255.0'>
+  </ip>
+  <ip family='ipv6' address='2001:db8:ac10:fe01::1' prefix='64'>
+  </ip>
+  <ip family='ipv6' address='2001:db8:ac10:fd01::1' prefix='64'>
+  </ip>
+  <ip family='ipv4' address='10.24.10.1'>
+  </ip>
+</network>
index 4e4c7d20a67b17c1b4a69bc3fe034e70740a3f5c..b19a365ff48e50bb2fdf15901dfa65b9342366f7 100644 (file)
@@ -141,6 +141,7 @@ mymain(void)
     DO_TEST("nat-network-dns-forwarder-no-resolv");
     DO_TEST("nat-network-forward-nat-address");
     DO_TEST("nat-network-forward-nat-no-address");
+    DO_TEST("nat-network-mtu");
     DO_TEST("8021Qbh-net");
     DO_TEST("direct-net");
     DO_TEST("host-bridge-net");