Skip to content

Commit

Permalink
networkd: set MTUBytes= in .network files as well (#111)
Browse files Browse the repository at this point in the history
This will account for virtual devices or cases where running in containers.

Signed-off-by: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>
  • Loading branch information
Mathieu Trudel-Lapierre committed Nov 27, 2019
1 parent c40f70e commit 77fcd4d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/networkd.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,9 @@ write_network_file(net_definition* def, const char* rootdir, const char* path)
}
}

if (def->mtubytes) {
g_string_append_printf(link, "MTUBytes=%d\n", def->mtubytes);
}

if (def->dhcp4 && def->dhcp6)
g_string_append(network, "DHCP=yes\n");
Expand Down
15 changes: 14 additions & 1 deletion tests/generator/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,26 @@ def test_mtu_all(self):
'bond0.network': '''[Match]
Name=bond0
[Link]
MTUBytes=9000
[Network]
LinkLocalAddressing=ipv6
ConfigureWithoutCarrier=yes
VLAN=bond0.108
''',
'eth1.link': '[Match]\nOriginalName=eth1\n\n[Link]\nWakeOnLan=off\nMTUBytes=9000\n',
'eth1.network': '[Match]\nName=eth1\n\n[Network]\nLinkLocalAddressing=no\nIPv6MTUBytes=2000\nBond=bond0\n'
'eth1.network': '''[Match]
Name=eth1
[Link]
MTUBytes=9000
[Network]
LinkLocalAddressing=no
IPv6MTUBytes=2000
Bond=bond0
'''
})
self.assert_networkd_udev(None)

Expand Down
3 changes: 3 additions & 0 deletions tests/generator/test_ethernets.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ def test_eth_mtu(self):
'eth1.network': '''[Match]
Name=eth1
[Link]
MTUBytes=1280
[Network]
LinkLocalAddressing=ipv6
'''})
Expand Down

0 comments on commit 77fcd4d

Please sign in to comment.