[lxc-devel] [lxd/master] Fixes MTU tests for VLAN support in latest LXC

tomponline on Github lxc-bot at linuxcontainers.org
Fri May 10 10:19:10 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190510/35fa4e7d/attachment-0001.bin>
-------------- next part --------------
From 540ff2956013083f947a832c81a8bed860b3fc54 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Thu, 9 May 2019 17:51:36 +0100
Subject: [PATCH 1/2] test: Updates physical tests to detect MTU support in LXC

Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
 test/suites/container_devices_nic_physical.sh | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/test/suites/container_devices_nic_physical.sh b/test/suites/container_devices_nic_physical.sh
index eae925645c..8a5ce2cd3e 100644
--- a/test/suites/container_devices_nic_physical.sh
+++ b/test/suites/container_devices_nic_physical.sh
@@ -21,10 +21,12 @@ test_container_devices_nic_physical() {
   # Lauch container and check it has nic applied correctly.
   lxc start "${ct_name}"
 
-  # Check custom MTU is applied.
-  if ! lxc exec "${ct_name}" -- ip link show eth0 | grep "mtu 1400" ; then
-    echo "mtu invalid"
-    true #We expect this to not apply currently as LXC won't apply it to physical devices.
+  # Check custom MTU is applied if feature available in LXD.
+  if lxc info | grep 'network_phys_macvlan_mtu: "true"' ; then
+    if ! lxc exec "${ct_name}" -- ip link show eth0 | grep "mtu 1400" ; then
+      echo "mtu invalid"
+      false
+    fi
   fi
 
   lxc config device remove "${ct_name}" eth0
@@ -36,10 +38,10 @@ test_container_devices_nic_physical() {
     parent="${ct_name}" \
     name=eth0 \
     vlan=10 \
-    mtu=1401
+    mtu=1399 #This must be less than or equal to the MTU of the parent device (which is not being reset)
 
   # Check custom MTU is applied.
-  if ! lxc exec "${ct_name}" -- ip link show eth0 | grep "mtu 1401" ; then
+  if ! lxc exec "${ct_name}" -- ip link show eth0 | grep "mtu 1399" ; then
     echo "mtu invalid"
     false
   fi

From bb3cf4e3932f137693eff46dbb0650bb8fd0c3e9 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Thu, 9 May 2019 17:50:48 +0100
Subject: [PATCH 2/2] test: Updates macvlan tests to detect MTU support in LXC

Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
 test/suites/container_devices_nic_macvlan.sh | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/test/suites/container_devices_nic_macvlan.sh b/test/suites/container_devices_nic_macvlan.sh
index 934cd6345d..e436eeb4c0 100644
--- a/test/suites/container_devices_nic_macvlan.sh
+++ b/test/suites/container_devices_nic_macvlan.sh
@@ -19,10 +19,12 @@ test_container_devices_nic_macvlan() {
   lxc exec "${ct_name}" -- ip addr add "192.0.2.1${ipRand}/24" dev eth0
   lxc exec "${ct_name}" -- ip addr add "2001:db8::1${ipRand}/64" dev eth0
 
-  # Check custom MTU is applied on boot.
-  if ! lxc exec "${ct_name}" -- ip link show eth0 | grep "mtu 1400" ; then
-    echo "mtu invalid"
-    true #We expect this to not apply currently as LXC won't apply it to macvlan devices.
+  # Check custom MTU is applied if feature available in LXD.
+  if lxc info | grep 'network_phys_macvlan_mtu: "true"' ; then
+    if ! lxc exec "${ct_name}" -- ip link show eth0 | grep "mtu 1400" ; then
+      echo "mtu invalid"
+      false
+    fi
   fi
 
   #Spin up another container with multiple IPs.


More information about the lxc-devel mailing list