Merge ~raharper/netplan:fix-mtu into ~netplan-developers/netplan/+git/netplan-lp:master

Proposed by Ryan Harper
Status: Approved
Approved by: Mathieu Trudel-Lapierre
Approved revision: e491050e7c965ead96efdc16642f61c0687c70a8
Proposed branch: ~raharper/netplan:fix-mtu
Merge into: ~netplan-developers/netplan/+git/netplan-lp:master
Diff against target: 274 lines (+103/-28)
6 files modified
src/netplan (+8/-0)
src/networkd.c (+5/-6)
src/parse.c (+26/-21)
src/parse.h (+3/-0)
tests/generate.py (+38/-1)
tests/integration.py (+23/-0)
Reviewer Review Type Date Requested Status
Mathieu Trudel-Lapierre (community) Approve
Review via email: mp+318545@code.launchpad.net

Description of the change

Add support for MTU setting in all network devices

Any interface, physical or netdev can have a .link file to configure the MTU
of a device (eth, bond, bridge, etc).

(LP: #1668693)

To post a comment you must log in.
Revision history for this message
Ryan Harper (raharper) wrote :

There is a superfluous sorting of the mapping keys which makes the diff harder to read; however, it's easier to see if the a mapping key is implemented when scanning the code.

Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

I wasn't able to successfully verify that this works on both NM and networkd. Could you add integration tests too?

review: Needs Fixing
Revision history for this message
Ryan Harper (raharper) wrote :

On Mon, Mar 6, 2017 at 11:13 AM, Mathieu Trudel-Lapierre <
<email address hidden>> wrote:

> Review: Needs Fixing
>
> I wasn't able to successfully verify that this works on both NM and
> networkd. Could you add integration tests too?
>

I tested networkd only; I'll look at the integration tests.

> --
> https://code.launchpad.net/~raharper/netplan/+git/netplan/+merge/318545
> You are the owner of ~raharper/netplan:fix-mtu.
>

Revision history for this message
Ryan Harper (raharper) wrote :

On Mon, Mar 6, 2017 at 11:18 AM, Ryan Harper <email address hidden>
wrote:

> On Mon, Mar 6, 2017 at 11:13 AM, Mathieu Trudel-Lapierre <
> <email address hidden>> wrote:
>
> > Review: Needs Fixing
> >
> > I wasn't able to successfully verify that this works on both NM and
> > networkd. Could you add integration tests too?
> >
>
> I tested networkd only; I'll look at the integration tests.
>

I'm struggling with getting the tests to work reliably; If anyone of the
tests fails,
the system ends up in a bad state (modules previously loaded fail to a load
a second time); veth devices stick around, and data is written into /run but
not cleaned up between test-case runs. The tests don't run with via nose;
but
rather calling python directly and only from within the tests directory.
Finally the test invokes 'netplan' which references whatever netplan is
installed
on the system rather than the netplan from the source tree.

I didn't verify NM side as I didn't add any changes for NM side;

>
> > --
> > https://code.launchpad.net/~raharper/netplan/+git/netplan/+merge/318545
> > You are the owner of ~raharper/netplan:fix-mtu.
> >
>
> --
> https://code.launchpad.net/~raharper/netplan/+git/netplan/+merge/318545
> You are the owner of ~raharper/netplan:fix-mtu.
>

Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

These tests should be run from within autopkgtest:

(from the netplan source tree root)
autopkgtest -U --apt-pocket=proposed -s --test-name integration.py . -- qemu ~/adt-zesty-amd64.img

You can build the necessary zesty qemu image for autpkgtests with:

adt-buildvm-ubuntu-cloud -r zesty -a amd64

This is important, my initial manual testing showed that neither networkd nor NM devices ended up having their MTU set; so we should still test both NM and networkd renderers to make sure that the MTU is set properly on the underlying devices when this runs, and to properly automate testing this behavior (given that it's reportedly playing with udev, so there are possibly other steps to take before the changes will really be applied).

review: Needs Fixing
Revision history for this message
Martin Pitt (pitti) wrote :

Wrt. autopkgtest invocation there's a slight optimization: If you don't want autopkgtest to waste time on building the binary packages first but you already built them (in schroot or whereever), you can add them to the command line. Also, I'd suggest to not test against -proposed locally -- it's not what happens in production CI either and only slows down local iterations:

$ autopkgtest -s --test-name integration.py . /tmp/build-area/*.deb -- qemu ~/adt-zesty-amd64.img

Revision history for this message
Ryan Harper (raharper) wrote :

On Mon, Mar 6, 2017 at 7:04 PM, Mathieu Trudel-Lapierre <
<email address hidden>> wrote:

> Review: Needs Fixing
>
> These tests should be run from within autopkgtest:
>
> (from the netplan source tree root)
> autopkgtest -U --apt-pocket=proposed -s --test-name integration.py . --
> qemu ~/adt-zesty-amd64.img
>
> You can build the necessary zesty qemu image for autpkgtests with:
>
> adt-buildvm-ubuntu-cloud -r zesty -a amd64
>

Ah, thanks for that.

>
> This is important, my initial manual testing showed that neither networkd
> nor NM devices ended up having their MTU set; so we should still test both
> NM and networkd renderers to make sure that the MTU is set properly on the
> underlying devices when this runs, and to properly automate testing this
> behavior (given that it's reportedly playing with udev, so there are
> possibly other steps to take before the changes will really be applied).
>

.link properties are handled by udev, not networkd. I'm not sure if NM has
separate MTU handling; that may be problematic if we're delegating this to
.link files for both networkd and NM.

Currently 'netplan apply' does guarantee .link files are re-run. I've a
separate bug opened to understand why re-triggering the net subsystem
doesn't always ensure .link files are processed

https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1669564

In the mean time, we could look at calling "udevadm test-builtin
setup_net_link /sys/class/net/<iface>" will indeed run the rules including
.link files to verify MTU is applied.

> --
> https://code.launchpad.net/~raharper/netplan/+git/netplan/+merge/318545
> You are the owner of ~raharper/netplan:fix-mtu.
>

~raharper/netplan:fix-mtu updated
86e348f... by Ryan Harper

Add mtu integration test, have netplan apply re-run .link files

5078731... by Ryan Harper

Add mtu integration test, have netplan apply re-run .link files

c8374f8... by Ryan Harper

fix typo on test-builtin command

d234129... by Ryan Harper

fix typo on test-builtin command

eb6bb11... by Ryan Harper

dont be noisy when triggering link rules

f7b6a26... by Ryan Harper

dont be noisy when triggering link rules

208f5f5... by Ryan Harper

integration: fix second interface ip address, add message for mtu test

4d07a39... by Ryan Harper

integration: fix second interface ip address, add message for mtu test

87927c0... by Ryan Harper

check_output returns string, not bytes

09cb443... by Ryan Harper

check_output returns string, not bytes

48b5427... by Ryan Harper

Add ipv6 mtu support

8f44c32... by Ryan Harper

Revert "Add ipv6 mtu support"

This reverts commit 48b542756ca555d48278ef13ebd19e338f689cc1.

226c0d6... by Ryan Harper

Sort mapping entries

e491050... by Ryan Harper

Merge branch 'fix-mtu' of ssh://git.launchpad.net/~raharper/netplan into fix-mtu

Revision history for this message
Ryan Harper (raharper) wrote :

OK,

Rebased on master (0.19)

I've added an integration test as well as fix for netplan apply to ensure we re-process .link files.

I've run this branch under adt and the mtu integration tests are passing in both (a property of having udev handle setting the MTU.

Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

Looks good to me now.

review: Approve

Unmerged commits

e491050... by Ryan Harper

Merge branch 'fix-mtu' of ssh://git.launchpad.net/~raharper/netplan into fix-mtu

09cb443... by Ryan Harper

check_output returns string, not bytes

4d07a39... by Ryan Harper

integration: fix second interface ip address, add message for mtu test

f7b6a26... by Ryan Harper

dont be noisy when triggering link rules

d234129... by Ryan Harper

fix typo on test-builtin command

5078731... by Ryan Harper

Add mtu integration test, have netplan apply re-run .link files

892c160... by Ryan Harper

Expand MTU to all device types

- Add MTU to all device types
- Always write link files, comment indicates that udev reads .link files not
  networkd
- Update test-cases to handle newly written link files for WakeOnLan setting

(LP: #1668693)

226c0d6... by Ryan Harper

Sort mapping entries

21a9c99... by Ryan Harper

Add support for setting MTU on ethernets

Allow setting MTU on ethernets, rendering in .link files for systemd

(LP: #1668693)

8f44c32... by Ryan Harper

Revert "Add ipv6 mtu support"

This reverts commit 48b542756ca555d48278ef13ebd19e338f689cc1.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/src/netplan b/src/netplan
index 900f227..7875517 100755
--- a/src/netplan
+++ b/src/netplan
@@ -276,6 +276,14 @@ def command_apply(): # pragma: nocover (covered in autopkgtest)
276 continue276 continue
277 if replug(device):277 if replug(device):
278 any_replug = True278 any_replug = True
279 else:
280 # if the interface is up, we can still apply .link file changes
281 logging.debug('netplan triggering .link rules for %s', device)
282 with open(os.devnull, 'w') as fd:
283 subprocess.check_call(['udevadm', 'test-builtin',
284 'net_setup_link',
285 '/sys/class/net/' + device],
286 stdout=fd, stderr=fd)
279 if any_replug:287 if any_replug:
280 subprocess.check_call(['udevadm', 'settle'])288 subprocess.check_call(['udevadm', 'settle'])
281289
diff --git a/src/networkd.c b/src/networkd.c
index 6a72370..04c7c37 100644
--- a/src/networkd.c
+++ b/src/networkd.c
@@ -87,10 +87,8 @@ write_link_file(net_definition* def, const char* rootdir, const char* path)
87{87{
88 GString* s = NULL;88 GString* s = NULL;
8989
90 g_assert(def->type < ND_VIRTUAL);
91
92 /* do we need to write a .link file? */90 /* do we need to write a .link file? */
93 if (!def->set_name && !def->wake_on_lan)91 if (!def->set_name && !def->wake_on_lan && !def->mtubytes)
94 return;92 return;
9593
96 /* build file contents */94 /* build file contents */
@@ -102,6 +100,9 @@ write_link_file(net_definition* def, const char* rootdir, const char* path)
102 g_string_append_printf(s, "Name=%s\n", def->set_name);100 g_string_append_printf(s, "Name=%s\n", def->set_name);
103 /* FIXME: Should this be turned from bool to str and support multiple values? */101 /* FIXME: Should this be turned from bool to str and support multiple values? */
104 g_string_append_printf(s, "WakeOnLan=%s\n", def->wake_on_lan ? "magic" : "off");102 g_string_append_printf(s, "WakeOnLan=%s\n", def->wake_on_lan ? "magic" : "off");
103 if (def->mtubytes)
104 g_string_append_printf(s, "MTUBytes=%u\n", def->mtubytes);
105
105106
106 g_string_free_to_file(s, rootdir, path, ".link");107 g_string_free_to_file(s, rootdir, path, ".link");
107}108}
@@ -328,9 +329,7 @@ write_networkd_conf(net_definition* def, const char* rootdir)
328329
329 /* We want this for all backends when renaming, as *.link files are330 /* We want this for all backends when renaming, as *.link files are
330 * evaluated by udev, not networkd itself or NetworkManager. */331 * evaluated by udev, not networkd itself or NetworkManager. */
331 if (def->type < ND_VIRTUAL &&332 write_link_file(def, rootdir, path_base);
332 (def->backend == BACKEND_NETWORKD || def->set_name))
333 write_link_file(def, rootdir, path_base);
334333
335 if (def->backend != BACKEND_NETWORKD) {334 if (def->backend != BACKEND_NETWORKD) {
336 g_debug("networkd: definition %s is not for us (backend %i)", def->id, def->backend);335 g_debug("networkd: definition %s is not for us (backend %i)", def->id, def->backend);
diff --git a/src/parse.c b/src/parse.c
index 2dbec4d..4312112 100644
--- a/src/parse.c
+++ b/src/parse.c
@@ -898,75 +898,80 @@ const mapping_entry_handler nameservers_handlers[] = {
898};898};
899899
900const mapping_entry_handler ethernet_def_handlers[] = {900const mapping_entry_handler ethernet_def_handlers[] = {
901 {"set-name", YAML_SCALAR_NODE, handle_netdef_str, NULL, netdef_offset(set_name)},901 {"addresses", YAML_SEQUENCE_NODE, handle_addresses},
902 {"match", YAML_MAPPING_NODE, handle_match},
903 {"renderer", YAML_SCALAR_NODE, handle_netdef_renderer},
904 {"wakeonlan", YAML_SCALAR_NODE, handle_netdef_bool, NULL, netdef_offset(wake_on_lan)},
905 {"dhcp4", YAML_SCALAR_NODE, handle_netdef_bool, NULL, netdef_offset(dhcp4)},902 {"dhcp4", YAML_SCALAR_NODE, handle_netdef_bool, NULL, netdef_offset(dhcp4)},
906 {"dhcp6", YAML_SCALAR_NODE, handle_netdef_bool, NULL, netdef_offset(dhcp6)},903 {"dhcp6", YAML_SCALAR_NODE, handle_netdef_bool, NULL, netdef_offset(dhcp6)},
907 {"addresses", YAML_SEQUENCE_NODE, handle_addresses},
908 {"gateway4", YAML_SCALAR_NODE, handle_gateway4},904 {"gateway4", YAML_SCALAR_NODE, handle_gateway4},
909 {"gateway6", YAML_SCALAR_NODE, handle_gateway6},905 {"gateway6", YAML_SCALAR_NODE, handle_gateway6},
906 {"match", YAML_MAPPING_NODE, handle_match},
907 {"mtu", YAML_SCALAR_NODE, handle_netdef_guint, NULL, netdef_offset(mtubytes)},
910 {"nameservers", YAML_MAPPING_NODE, NULL, nameservers_handlers},908 {"nameservers", YAML_MAPPING_NODE, NULL, nameservers_handlers},
909 {"renderer", YAML_SCALAR_NODE, handle_netdef_renderer},
911 {"routes", YAML_SEQUENCE_NODE, handle_routes},910 {"routes", YAML_SEQUENCE_NODE, handle_routes},
911 {"set-name", YAML_SCALAR_NODE, handle_netdef_str, NULL, netdef_offset(set_name)},
912 {"wakeonlan", YAML_SCALAR_NODE, handle_netdef_bool, NULL, netdef_offset(wake_on_lan)},
912 {NULL}913 {NULL}
913};914};
914915
915const mapping_entry_handler wifi_def_handlers[] = {916const mapping_entry_handler wifi_def_handlers[] = {
916 {"set-name", YAML_SCALAR_NODE, handle_netdef_str, NULL, netdef_offset(set_name)},917 {"access-points", YAML_MAPPING_NODE, handle_wifi_access_points},
917 {"match", YAML_MAPPING_NODE, handle_match},918 {"addresses", YAML_SEQUENCE_NODE, handle_addresses},
918 {"renderer", YAML_SCALAR_NODE, handle_netdef_renderer},
919 {"wakeonlan", YAML_SCALAR_NODE, handle_netdef_bool, NULL, netdef_offset(wake_on_lan)},
920 {"dhcp4", YAML_SCALAR_NODE, handle_netdef_bool, NULL, netdef_offset(dhcp4)},919 {"dhcp4", YAML_SCALAR_NODE, handle_netdef_bool, NULL, netdef_offset(dhcp4)},
921 {"dhcp6", YAML_SCALAR_NODE, handle_netdef_bool, NULL, netdef_offset(dhcp6)},920 {"dhcp6", YAML_SCALAR_NODE, handle_netdef_bool, NULL, netdef_offset(dhcp6)},
922 {"addresses", YAML_SEQUENCE_NODE, handle_addresses},
923 {"gateway4", YAML_SCALAR_NODE, handle_gateway4},921 {"gateway4", YAML_SCALAR_NODE, handle_gateway4},
924 {"gateway6", YAML_SCALAR_NODE, handle_gateway6},922 {"gateway6", YAML_SCALAR_NODE, handle_gateway6},
923 {"match", YAML_MAPPING_NODE, handle_match},
924 {"mtu", YAML_SCALAR_NODE, handle_netdef_guint, NULL, netdef_offset(mtubytes)},
925 {"nameservers", YAML_MAPPING_NODE, NULL, nameservers_handlers},925 {"nameservers", YAML_MAPPING_NODE, NULL, nameservers_handlers},
926 {"access-points", YAML_MAPPING_NODE, handle_wifi_access_points},926 {"renderer", YAML_SCALAR_NODE, handle_netdef_renderer},
927 {"routes", YAML_SEQUENCE_NODE, handle_routes},927 {"routes", YAML_SEQUENCE_NODE, handle_routes},
928 {"set-name", YAML_SCALAR_NODE, handle_netdef_str, NULL, netdef_offset(set_name)},
929 {"wakeonlan", YAML_SCALAR_NODE, handle_netdef_bool, NULL, netdef_offset(wake_on_lan)},
928 {NULL}930 {NULL}
929};931};
930932
931const mapping_entry_handler bridge_def_handlers[] = {933const mapping_entry_handler bridge_def_handlers[] = {
932 {"renderer", YAML_SCALAR_NODE, handle_netdef_renderer},934 {"addresses", YAML_SEQUENCE_NODE, handle_addresses},
933 {"dhcp4", YAML_SCALAR_NODE, handle_netdef_bool, NULL, netdef_offset(dhcp4)},935 {"dhcp4", YAML_SCALAR_NODE, handle_netdef_bool, NULL, netdef_offset(dhcp4)},
934 {"dhcp6", YAML_SCALAR_NODE, handle_netdef_bool, NULL, netdef_offset(dhcp6)},936 {"dhcp6", YAML_SCALAR_NODE, handle_netdef_bool, NULL, netdef_offset(dhcp6)},
935 {"addresses", YAML_SEQUENCE_NODE, handle_addresses},
936 {"gateway4", YAML_SCALAR_NODE, handle_gateway4},937 {"gateway4", YAML_SCALAR_NODE, handle_gateway4},
937 {"gateway6", YAML_SCALAR_NODE, handle_gateway6},938 {"gateway6", YAML_SCALAR_NODE, handle_gateway6},
938 {"nameservers", YAML_MAPPING_NODE, NULL, nameservers_handlers},
939 {"interfaces", YAML_SEQUENCE_NODE, handle_interfaces, NULL, netdef_offset(bridge)},939 {"interfaces", YAML_SEQUENCE_NODE, handle_interfaces, NULL, netdef_offset(bridge)},
940 {"mtu", YAML_SCALAR_NODE, handle_netdef_guint, NULL, netdef_offset(mtubytes)},
941 {"nameservers", YAML_MAPPING_NODE, NULL, nameservers_handlers},
940 {"parameters", YAML_MAPPING_NODE, handle_bridge},942 {"parameters", YAML_MAPPING_NODE, handle_bridge},
943 {"renderer", YAML_SCALAR_NODE, handle_netdef_renderer},
941 {"routes", YAML_SEQUENCE_NODE, handle_routes},944 {"routes", YAML_SEQUENCE_NODE, handle_routes},
942 {NULL}945 {NULL}
943};946};
944947
945const mapping_entry_handler bond_def_handlers[] = {948const mapping_entry_handler bond_def_handlers[] = {
946 {"renderer", YAML_SCALAR_NODE, handle_netdef_renderer},949 {"addresses", YAML_SEQUENCE_NODE, handle_addresses},
947 {"dhcp4", YAML_SCALAR_NODE, handle_netdef_bool, NULL, netdef_offset(dhcp4)},950 {"dhcp4", YAML_SCALAR_NODE, handle_netdef_bool, NULL, netdef_offset(dhcp4)},
948 {"dhcp6", YAML_SCALAR_NODE, handle_netdef_bool, NULL, netdef_offset(dhcp6)},951 {"dhcp6", YAML_SCALAR_NODE, handle_netdef_bool, NULL, netdef_offset(dhcp6)},
949 {"addresses", YAML_SEQUENCE_NODE, handle_addresses},
950 {"gateway4", YAML_SCALAR_NODE, handle_gateway4},952 {"gateway4", YAML_SCALAR_NODE, handle_gateway4},
951 {"gateway6", YAML_SCALAR_NODE, handle_gateway6},953 {"gateway6", YAML_SCALAR_NODE, handle_gateway6},
952 {"nameservers", YAML_MAPPING_NODE, NULL, nameservers_handlers},
953 {"interfaces", YAML_SEQUENCE_NODE, handle_interfaces, NULL, netdef_offset(bond)},954 {"interfaces", YAML_SEQUENCE_NODE, handle_interfaces, NULL, netdef_offset(bond)},
954 {"macaddress", YAML_SCALAR_NODE, handle_netdef_mac, NULL, netdef_offset(set_mac)},955 {"macaddress", YAML_SCALAR_NODE, handle_netdef_mac, NULL, netdef_offset(set_mac)},
955 {"routes", YAML_SEQUENCE_NODE, handle_routes},956 {"mtu", YAML_SCALAR_NODE, handle_netdef_guint, NULL, netdef_offset(mtubytes)},
957 {"nameservers", YAML_MAPPING_NODE, NULL, nameservers_handlers},
956 {"parameters", YAML_MAPPING_NODE, handle_bonding},958 {"parameters", YAML_MAPPING_NODE, handle_bonding},
959 {"renderer", YAML_SCALAR_NODE, handle_netdef_renderer},
960 {"routes", YAML_SEQUENCE_NODE, handle_routes},
957 {NULL}961 {NULL}
958};962};
959963
960const mapping_entry_handler vlan_def_handlers[] = {964const mapping_entry_handler vlan_def_handlers[] = {
961 {"renderer", YAML_SCALAR_NODE, handle_netdef_renderer},965 {"addresses", YAML_SEQUENCE_NODE, handle_addresses},
962 {"dhcp4", YAML_SCALAR_NODE, handle_netdef_bool, NULL, netdef_offset(dhcp4)},966 {"dhcp4", YAML_SCALAR_NODE, handle_netdef_bool, NULL, netdef_offset(dhcp4)},
963 {"dhcp6", YAML_SCALAR_NODE, handle_netdef_bool, NULL, netdef_offset(dhcp6)},967 {"dhcp6", YAML_SCALAR_NODE, handle_netdef_bool, NULL, netdef_offset(dhcp6)},
964 {"addresses", YAML_SEQUENCE_NODE, handle_addresses},
965 {"gateway4", YAML_SCALAR_NODE, handle_gateway4},968 {"gateway4", YAML_SCALAR_NODE, handle_gateway4},
966 {"gateway6", YAML_SCALAR_NODE, handle_gateway6},969 {"gateway6", YAML_SCALAR_NODE, handle_gateway6},
967 {"nameservers", YAML_MAPPING_NODE, NULL, nameservers_handlers},
968 {"id", YAML_SCALAR_NODE, handle_netdef_guint, NULL, netdef_offset(vlan_id)},970 {"id", YAML_SCALAR_NODE, handle_netdef_guint, NULL, netdef_offset(vlan_id)},
969 {"link", YAML_SCALAR_NODE, handle_netdef_id_ref, NULL, netdef_offset(vlan_link)},971 {"link", YAML_SCALAR_NODE, handle_netdef_id_ref, NULL, netdef_offset(vlan_link)},
972 {"nameservers", YAML_MAPPING_NODE, NULL, nameservers_handlers},
973 {"mtu", YAML_SCALAR_NODE, handle_netdef_guint, NULL, netdef_offset(mtubytes)},
974 {"renderer", YAML_SCALAR_NODE, handle_netdef_renderer},
970 {"routes", YAML_SEQUENCE_NODE, handle_routes},975 {"routes", YAML_SEQUENCE_NODE, handle_routes},
971 {NULL}976 {NULL}
972};977};
diff --git a/src/parse.h b/src/parse.h
index 23c597f..5f5d28d 100644
--- a/src/parse.h
+++ b/src/parse.h
@@ -81,6 +81,9 @@ typedef struct net_definition {
81 /* Configured custom MAC address */81 /* Configured custom MAC address */
82 char* set_mac;82 char* set_mac;
8383
84 /* interface mtu */
85 guint mtubytes;
86
84 /* these properties are only valid for physical interfaces (type < ND_VIRTUAL) */87 /* these properties are only valid for physical interfaces (type < ND_VIRTUAL) */
85 char* set_name;88 char* set_name;
86 struct {89 struct {
diff --git a/tests/generate.py b/tests/generate.py
index 2d69d02..542ad2f 100755
--- a/tests/generate.py
+++ b/tests/generate.py
@@ -23,6 +23,7 @@ import re
23import sys23import sys
24import stat24import stat
25import tempfile25import tempfile
26import textwrap
26import subprocess27import subprocess
27import unittest28import unittest
2829
@@ -275,6 +276,42 @@ unmanaged-devices+=interface-name:eth0,''')
275 # should not allow NM to manage everything276 # should not allow NM to manage everything
276 self.assertFalse(os.path.exists(self.nm_enable_all_conf))277 self.assertFalse(os.path.exists(self.nm_enable_all_conf))
277278
279 def test_eth_mtu(self):
280 self.generate('''network:
281 version: 2
282 ethernets:
283 eth1:
284 mtu: 1280
285 dhcp4: n''')
286
287 self.assert_networkd({'eth1.link': '[Match]\nOriginalName=eth1\n\n[Link]\nWakeOnLan=off\nMTUBytes=1280\n'})
288
289 def test_mtu_all(self):
290 self.generate(textwrap.dedent("""
291 network:
292 version: 2
293 ethernets:
294 eth1:
295 mtu: 1280
296 dhcp4: n
297 bonds:
298 bond0:
299 interfaces:
300 - eth1
301 mtu: 9000
302 vlans:
303 bond0.108:
304 link: bond0
305 id: 108"""))
306 self.assert_networkd({
307 'bond0.108.netdev': '[NetDev]\nName=bond0.108\nKind=vlan\n\n[VLAN]\nId=108\n',
308 'bond0.link': '[Match]\n\n[Link]\nWakeOnLan=off\nMTUBytes=9000\n',
309 'bond0.netdev': '[NetDev]\nName=bond0\nKind=bond\n',
310 'bond0.network': '[Match]\nName=bond0\n\n[Network]\nVLAN=bond0.108\n',
311 'eth1.link': '[Match]\nOriginalName=eth1\n\n[Link]\nWakeOnLan=off\nMTUBytes=1280\n',
312 'eth1.network': '[Match]\nName=eth1\n\n[Network]\nBond=bond0\nLinkLocalAddressing=no\nIPv6AcceptRA=no\n'
313 })
314
278 def test_eth_match_by_driver_rename(self):315 def test_eth_match_by_driver_rename(self):
279 self.generate('''network:316 self.generate('''network:
280 version: 2317 version: 2
@@ -1066,7 +1103,7 @@ method=link-local
1066'''})1103'''})
1067 # should allow NM to manage everything else1104 # should allow NM to manage everything else
1068 self.assertTrue(os.path.exists(self.nm_enable_all_conf))1105 self.assertTrue(os.path.exists(self.nm_enable_all_conf))
1069 self.assert_networkd({})1106 self.assert_networkd({'eth0.link': '[Match]\nOriginalName=eth0\n\n[Link]\nWakeOnLan=magic\n'})
1070 self.assert_udev(None)1107 self.assert_udev(None)
10711108
1072 def test_eth_match_by_driver(self):1109 def test_eth_match_by_driver(self):
diff --git a/tests/integration.py b/tests/integration.py
index 446d70b..074ba59 100755
--- a/tests/integration.py
+++ b/tests/integration.py
@@ -391,6 +391,29 @@ class _CommonTests:
391 for i in [self.dev_e_client, self.dev_e2_client, 'mybr']:391 for i in [self.dev_e_client, self.dev_e2_client, 'mybr']:
392 self.assertRegex(out, '%s\s+(ethernet|bridge)\s+%s' % (i, expected_state))392 self.assertRegex(out, '%s\s+(ethernet|bridge)\s+%s' % (i, expected_state))
393393
394 def test_eth_mtu(self):
395 self.setup_eth(None)
396 self.start_dnsmasq(None, self.dev_e2_ap)
397 with open(self.config, 'w') as f:
398 f.write('''network:
399 renderer: %(r)s
400 ethernets:
401 %(ec)s:
402 dhcp4: yes
403 enmtus:
404 match: {name: %(e2c)s}
405 mtu: 1492
406 dhcp4: yes''' % {'r': self.backend, 'ec': self.dev_e_client, 'e2c': self.dev_e2_client})
407 self.generate_and_settle()
408 self.assert_iface_up(self.dev_e_client,
409 ['inet 192.168.5.[0-9]+/24'],
410 ['master'])
411 self.assert_iface_up(self.dev_e2_client,
412 ['inet 192.168.6.[0-9]+/24'])
413 out = subprocess.check_output(['ip', 'a', 'show', self.dev_e2_client],
414 universal_newlines=True)
415 self.assertTrue('mtu 1492' in out, "checking MTU, should be 1492")
416
394 def test_bridge_path_cost(self):417 def test_bridge_path_cost(self):
395 self.setup_eth(None)418 self.setup_eth(None)
396 self.start_dnsmasq(None, self.dev_e2_ap)419 self.start_dnsmasq(None, self.dev_e2_ap)

Subscribers

People subscribed via source and target branches