From: Casey Callendrello Date: Tue, 11 Dec 2018 16:05:43 +0000 (+0100) Subject: network: set mtu as a DHCP option when specified X-Git-Tag: v5.1.0-rc1~293 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=682be115057f0dffbdd73dac93cb9dc676e279c0;p=thirdparty%2Flibvirt.git network: set mtu as a DHCP option when specified 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 Reviewed-by: Ján Tomko Signed-off-by: Ján Tomko --- diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 20a0f65e65..a9674ef6c2 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -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 index 0000000000..91b574b964 --- /dev/null +++ b/tests/networkxml2confdata/nat-network-mtu.conf @@ -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 index 0000000000..87b214e95c --- /dev/null +++ b/tests/networkxml2confdata/nat-network-mtu.xml @@ -0,0 +1,22 @@ + + default + 81ff0d90-c91e-6742-64da-4a736edb9a9b + + + + + + + + + + + + + + + + + + + diff --git a/tests/networkxml2conftest.c b/tests/networkxml2conftest.c index c362149c29..bf9675838d 100644 --- a/tests/networkxml2conftest.c +++ b/tests/networkxml2conftest.c @@ -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 index 0000000000..07d0d9f22d --- /dev/null +++ b/tests/networkxml2xmlin/nat-network-mtu.xml @@ -0,0 +1,22 @@ + + default + 81ff0d90-c91e-6742-64da-4a736edb9a9b + + + + + + + + + + + + + + + + + + + diff --git a/tests/networkxml2xmlout/nat-network-mtu.xml b/tests/networkxml2xmlout/nat-network-mtu.xml new file mode 100644 index 0000000000..715bc1b505 --- /dev/null +++ b/tests/networkxml2xmlout/nat-network-mtu.xml @@ -0,0 +1,24 @@ + + default + 81ff0d90-c91e-6742-64da-4a736edb9a9b + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/networkxml2xmltest.c b/tests/networkxml2xmltest.c index 4e4c7d20a6..b19a365ff4 100644 --- a/tests/networkxml2xmltest.c +++ b/tests/networkxml2xmltest.c @@ -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");