summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>2017-07-11 22:44:01 (GMT)
committerMathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>2017-07-11 22:44:01 (GMT)
commitdfe290e6013386c1fa30adad7e6440067bb35283 (patch)
tree312e58f5c135cb5aaa7c22f6df43ffda6c05213b
parentab9d85ffaf198c40d9790785bec319da0c3106aa (diff)
src/nm.c: set the MTU even though we also specify it in systemd-networkd for consumption by udev. NetworkManager will try to set it and might otherwise default to the wrong value.
-rw-r--r--debian/changelog3
-rw-r--r--src/nm.c21
-rwxr-xr-xtests/generate.py85
3 files changed, 107 insertions, 2 deletions
diff --git a/debian/changelog b/debian/changelog
index bbaae8c..e1dbcd2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,9 @@ nplan (0.25) UNRELEASED; urgency=medium
* tests/integration.py: clean up after br0 in networkd's test_bridge_mac; as
the remaining interface and udev configuration can confuse NetworkManager
now that it seems to manage random devices it did not create again.
+ * src/nm.c: set the MTU even though we also specify it in systemd-networkd
+ for consumption by udev. NetworkManager will try to set it and might
+ otherwise default to the wrong value.
-- Mathieu Trudel-Lapierre <cyphermox@ubuntu.com> Tue, 11 Jul 2017 13:43:21 -0400
diff --git a/src/nm.c b/src/nm.c
index 6921fee..d8db582 100644
--- a/src/nm.c
+++ b/src/nm.c
@@ -305,6 +305,9 @@ write_nm_conf_access_point(net_definition* def, const char* rootdir, const wifi_
if (def->set_mac) {
g_string_append_printf(link_str, "cloned-mac-address=%s\n", def->set_mac);
}
+ if (def->mtubytes) {
+ g_string_append_printf(link_str, "mtu=%d\n", def->mtubytes);
+ }
if (link_str->len > 0) {
switch (def->type) {
@@ -317,8 +320,22 @@ write_nm_conf_access_point(net_definition* def, const char* rootdir, const wifi_
g_string_free(link_str, TRUE);
} else {
- if (def->set_mac)
- g_string_append_printf(s, "\n[802-3-ethernet]\ncloned-mac-address=%s\n", def->set_mac);
+ GString *link_str = NULL;
+
+ link_str = g_string_new(NULL);
+
+ if (def->set_mac) {
+ g_string_append_printf(link_str, "cloned-mac-address=%s\n", def->set_mac);
+ }
+ if (def->mtubytes) {
+ g_string_append_printf(link_str, "mtu=%d\n", def->mtubytes);
+ }
+
+ if (link_str->len > 0) {
+ g_string_append_printf(s, "\n[802-3-ethernet]\n%s", link_str->str);
+ }
+
+ g_string_free(link_str, TRUE);
}
if (def->type == ND_VLAN) {
diff --git a/tests/generate.py b/tests/generate.py
index af0e0fc..f448d5c 100755
--- a/tests/generate.py
+++ b/tests/generate.py
@@ -1151,6 +1151,91 @@ method=link-local
self.assert_networkd({'eth0.link': '[Match]\nOriginalName=eth0\n\n[Link]\nWakeOnLan=magic\n'})
self.assert_udev(None)
+ def test_eth_mtu(self):
+ self.generate('''network:
+ version: 2
+ renderer: NetworkManager
+ ethernets:
+ eth1:
+ mtu: 1280
+ dhcp4: n''')
+
+ self.assert_networkd({'eth1.link': '[Match]\nOriginalName=eth1\n\n[Link]\nWakeOnLan=off\nMTUBytes=1280\n'})
+ self.assert_nm({'eth1': '''[connection]
+id=netplan-eth1
+type=ethernet
+interface-name=eth1
+
+[ethernet]
+wake-on-lan=0
+
+[802-3-ethernet]
+mtu=1280
+
+[ipv4]
+method=link-local
+'''})
+
+ def test_mtu_all(self):
+ self.generate(textwrap.dedent("""
+ network:
+ version: 2
+ renderer: NetworkManager
+ ethernets:
+ eth1:
+ mtu: 1280
+ dhcp4: n
+ bonds:
+ bond0:
+ interfaces:
+ - eth1
+ mtu: 9000
+ vlans:
+ bond0.108:
+ link: bond0
+ id: 108"""))
+ self.assert_nm({
+ 'bond0.108': '''[connection]
+id=netplan-bond0.108
+type=vlan
+interface-name=bond0.108
+
+[vlan]
+id=108
+parent=bond0
+
+[ipv4]
+method=link-local
+''',
+ 'bond0': '''[connection]
+id=netplan-bond0
+type=bond
+interface-name=bond0
+
+[802-3-ethernet]
+mtu=9000
+
+[ipv4]
+method=link-local
+''',
+ 'eth1': '''[connection]
+id=netplan-eth1
+type=ethernet
+interface-name=eth1
+slave-type=bond
+master=bond0
+
+[ethernet]
+wake-on-lan=0
+
+[802-3-ethernet]
+mtu=1280
+
+[ipv4]
+method=link-local
+''',
+ })
+
def test_eth_set_mac(self):
self.generate('''network:
version: 2