Example:
<network>
...
<bridge name='virbr2' mtu='9000'/>
...
If mtu is unset, it's assumed that we want the default for whatever is
the underlying transport (usually this is 1500).
This setting isn't yet wired in, so it will have no effect.
This partially resolves:
https://bugzilla.redhat.com/1224348
---
docs/formatnetwork.html.in | 8 +++++++-
docs/news.xml | 6 +++++-
docs/schemas/network.rng | 6 ++++++
src/conf/network_conf.c | 20 ++++++++++++++++++--
src/conf/network_conf.h | 1 +
tests/networkxml2xmlin/set-mtu.xml | 11 +++++++++++
tests/networkxml2xmlout/set-mtu.xml | 11 +++++++++++
tests/networkxml2xmltest.c | 1 +
8 files changed, 60 insertions(+), 4 deletions(-)
create mode 100644 tests/networkxml2xmlin/set-mtu.xml
create mode 100644 tests/networkxml2xmlout/set-mtu.xml
diff --git a/docs/formatnetwork.html.in b/docs/formatnetwork.html.in
index 291dcea..19245cf 100644
--- a/docs/formatnetwork.html.in
+++ b/docs/formatnetwork.html.in
@@ -92,7 +92,7 @@
<pre>
...
-<bridge name="virbr0" stp="on" delay="5"
macTableManager="libvirt"/>
+<bridge name="virbr0" stp="on" delay="5"
mtu='9000' macTableManager="libvirt"/>
<domain name="example.com" localOnly="no"/>
<forward mode="nat" dev="eth0"/>
...</pre>
@@ -121,6 +121,12 @@
delay value in seconds (default is 0).
<span class="since">Since 0.3.0</span>
+ The optional attribute. <code>mtu</code> specifies the Maximum
+ Transmission Unit (MTU) for the
+ bridge. <span class="since">Since 3.1.0</span>. If mtu is
+ unspecified, the default setting for the type of bridge being
+ used is assumed (usually 1500).
+
<p>
The <code>macTableManager</code> attribute of the bridge
element is used to tell libvirt how the bridge's MAC address
diff --git a/docs/news.xml b/docs/news.xml
index ef7e2db..ca2546a 100644
--- a/docs/news.xml
+++ b/docs/news.xml
@@ -12,7 +12,11 @@
<libvirt>
<release version="v3.1.0" date="unreleased">
<section title="New features">
- <change/>
+ <change>
+ <summary>
+ Support specifying MTU in a network's <bridge> element
+ </summary>
+ </change>
</section>
<section title="Improvements">
<change>
diff --git a/docs/schemas/network.rng b/docs/schemas/network.rng
index 8f0a61b..4f52fdb 100644
--- a/docs/schemas/network.rng
+++ b/docs/schemas/network.rng
@@ -71,6 +71,12 @@
</optional>
<optional>
+ <attribute name="mtu">
+ <data type="unsignedInt"/>
+ </attribute>
+ </optional>
+
+ <optional>
<attribute name="macTableManager">
<ref name="macTableManager"/>
</attribute>
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 86ce311..681dffb 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -2212,6 +2212,17 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
}
VIR_FREE(tmp);
+ tmp = virXPathString("string(./bridge[1]/@mtu)", ctxt);
+ if (tmp) {
+ if (virStrToLong_ui(tmp, NULL, 10, &def->mtu) < 0) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("Invalid mtu value '%s' in network
'%s'"),
+ tmp, def->name);
+ goto error;
+ }
+ }
+ VIR_FREE(tmp);
+
tmp = virXPathString("string(./bridge[1]/@macTableManager)", ctxt);
if (tmp) {
if ((def->macTableManager
@@ -2433,9 +2444,11 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
}
/* fall through to next case */
case VIR_NETWORK_FORWARD_BRIDGE:
- if (def->delay || stp) {
+ if (def->delay || stp || def->mtu) {
virReportError(VIR_ERR_XML_ERROR,
- _("bridge delay/stp options only allowed in route, nat,
and isolated mode, not in %s (network '%s')"),
+ _("bridge delay/stp/mtu options only allowed in "
+ "route, nat, and isolated mode, not in %s "
+ "(network '%s')"),
virNetworkForwardTypeToString(def->forward.type),
def->name);
goto error;
@@ -2957,6 +2970,9 @@ virNetworkDefFormatBuf(virBufferPtr buf,
virBufferAsprintf(buf, " stp='%s' delay='%ld'",
def->stp ? "on" : "off",
def->delay);
}
+ if (def->mtu)
+ virBufferAsprintf(buf, " mtu='%u'", def->mtu);
+
if (def->macTableManager) {
virBufferAsprintf(buf, " macTableManager='%s'",
virNetworkBridgeMACTableManagerTypeToString(def->macTableManager));
diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h
index b5c9ea2..9e4ae71 100644
--- a/src/conf/network_conf.h
+++ b/src/conf/network_conf.h
@@ -240,6 +240,7 @@ struct _virNetworkDef {
int domainLocalOnly; /* enum virTristateBool: yes disables dns forwarding */
unsigned long delay; /* Bridge forward delay (ms) */
bool stp; /* Spanning tree protocol */
+ unsigned int mtu; /* MTU for bridge, 0 means "default" i.e. unset in config
*/
virMacAddr mac; /* mac address of bridge device */
bool mac_specified;
diff --git a/tests/networkxml2xmlin/set-mtu.xml b/tests/networkxml2xmlin/set-mtu.xml
new file mode 100644
index 0000000..86c1729
--- /dev/null
+++ b/tests/networkxml2xmlin/set-mtu.xml
@@ -0,0 +1,11 @@
+<network ipv6='no'>
+ <name>private</name>
+ <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
+ <bridge name='virbr2' mtu='9000'/>
+ <mac address='52:54:00:17:3F:37'/>
+ <ip address="192.168.152.1" netmask="255.255.255.0">
+ <dhcp>
+ <range start="192.168.152.2" end="192.168.152.254"/>
+ </dhcp>
+ </ip>
+</network>
diff --git a/tests/networkxml2xmlout/set-mtu.xml b/tests/networkxml2xmlout/set-mtu.xml
new file mode 100644
index 0000000..df038ae
--- /dev/null
+++ b/tests/networkxml2xmlout/set-mtu.xml
@@ -0,0 +1,11 @@
+<network>
+ <name>private</name>
+ <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
+ <bridge name='virbr2' stp='on' delay='0'
mtu='9000'/>
+ <mac address='52:54:00:17:3f:37'/>
+ <ip address='192.168.152.1' netmask='255.255.255.0'>
+ <dhcp>
+ <range start='192.168.152.2' end='192.168.152.254'/>
+ </dhcp>
+ </ip>
+</network>
diff --git a/tests/networkxml2xmltest.c b/tests/networkxml2xmltest.c
index 01cd6f7..cfaf718 100644
--- a/tests/networkxml2xmltest.c
+++ b/tests/networkxml2xmltest.c
@@ -158,6 +158,7 @@ mymain(void)
DO_TEST_PARSE_ERROR("hostdev-duplicate");
DO_TEST_PARSE_ERROR("passthrough-duplicate");
DO_TEST("metadata");
+ DO_TEST("set-mtu");
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
--
2.9.3