Merge ~rodsmith/maas-cert-server:set-mtu-in-start-iperf3 into maas-cert-server:master

Proposed by Rod Smith
Status: Merged
Approved by: Rod Smith
Approved revision: 77f7d6dd7b419515a2340dedea1db0cd7db15403
Merged at revision: 70f73dc02e5c9c7cdd5e0370b9134e0075377f71
Proposed branch: ~rodsmith/maas-cert-server:set-mtu-in-start-iperf3
Merge into: maas-cert-server:master
Diff against target: 59 lines (+26/-1)
2 files modified
debian/changelog (+7/-0)
usr/sbin/start-iperf3 (+19/-1)
Reviewer Review Type Date Requested Status
Jeff Lane  Approve
Review via email: mp+380157@code.launchpad.net

Commit message

Update start-iperf3 to have it set an MTU of 9000 on any NIC with an over-10Gbps speed on which iperf3 is launched.

Description of the change

Update start-iperf3 to have it set an MTU of 9000 on any NIC with an over-10Gbps speed on which iperf3 is launched.

To post a comment you must log in.
Revision history for this message
Jeff Lane  (bladernr) wrote :

LGTM, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index b2fdba6..346c710 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,10 @@
6+maas-cert-server (0.4.8-0ppa1) bionic; urgency=medium
7+
8+ * Updated start-iperf3 script to ensure an MTU of 9000 is set on
9+ any NIC with a speed of over 10 Gbps.
10+
11+ -- Rod Smith <rod.smith@canonical.com> Tue, 03 Mar 2020 10:10:51 -0500
12+
13 maas-cert-server (0.4.7-0ppa1) bionic; urgency=medium
14
15 * Update maniacs-setup.sh to replace deprecated maas-region-admin call
16diff --git a/usr/sbin/start-iperf3 b/usr/sbin/start-iperf3
17index 419fa88..c3f819c 100755
18--- a/usr/sbin/start-iperf3
19+++ b/usr/sbin/start-iperf3
20@@ -1,6 +1,6 @@
21 #!/usr/bin/env python3
22
23-# Copyright (c) 2018 Canonical, Ltd.
24+# Copyright (c) 2018-2020 Canonical, Ltd.
25 #
26 # Authors
27 # Rod Smith <rod.smith@canonical.com>
28@@ -128,6 +128,23 @@ def launch_all_iperf3(core_list, ip_address, num_instances):
29 print("Failed running iperf: {}".format(iperf_exception.output))
30
31
32+def set_mtu(device):
33+ speed = psutil.net_if_stats()[device].speed
34+ mtu = psutil.net_if_stats()[device].mtu
35+ if (speed > 10000) and (mtu < 9000):
36+ print("Trying to set MTU on {} to 9000".format(device))
37+ cmd = "sudo ip link set {} mtu 9000".format(device)
38+ try:
39+ check_output(shlex.split(cmd), universal_newlines=True)
40+ except CalledProcessError as mtu_exception:
41+ print("Failed setting MTU: {}".format(mtu_exception.output))
42+ if (speed > 10000):
43+ mtu = psutil.net_if_stats()[device].mtu
44+ print("MTU on {} is now {}".format(device, mtu))
45+ if (mtu < 9000):
46+ print("*** INADEQUATE MTU ON {}! ***".format(device))
47+
48+
49 def main(args):
50 gopts = ArgumentParser()
51 gopts.add_argument('-a', '--address', type=str,
52@@ -143,6 +160,7 @@ def main(args):
53 if device is not None:
54 node = find_numa(device)
55 core_list = find_cores(node)
56+ set_mtu(device)
57 launch_all_iperf3(core_list, args.address, args.num_instances)
58 else:
59 print("Could not find a network device associated with {}!\n".

Subscribers

People subscribed via source and target branches