Package: nvme-stas
Severity: normal
Tags: patch
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu noble ubuntu-patch

Dear Maintainer,

When an autopkgtest runner has esoteric network interfaces configured,
the test-suite (i.e., test-udev.py and/or test-iputil.py) is likely to
fail.

The following types of interfaces are known to cause failures on
autopkgtest runners in Ubuntu:

 * vlan
 * gre
 * dummy
 * veth

I am not sure if Debian autopkgtest runners would be affected but the
test suite is a bit fragile at the moment, so I think the patches would
make sense.

NOTE: Ubuntu is ahead of Debian by two patches, so the autopkgtest
failures might not unravel until the following are addressed:

 * https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1054533
 * https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1057031

In Ubuntu, the attached patch was applied to achieve the following:

  * Skip mac2iface test for esoteric network interfaces (LP: #2045690)
  * Add upstream patch to fix udev test for esoteric network interfaces


Thanks for considering the patch.


-- System Information:
Debian Release: trixie/sid
  APT prefers mantic-updates
  APT policy: (500, 'mantic-updates'), (500, 'mantic-security'), (500, 'mantic')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 6.1.0-16-generic (SMP w/8 CPU threads; PREEMPT)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
diff -Nru 
nvme-stas-2.3/debian/patches/fix-test-udev-with-dummy-interfaces.patch 
nvme-stas-2.3/debian/patches/fix-test-udev-with-dummy-interfaces.patch
--- nvme-stas-2.3/debian/patches/fix-test-udev-with-dummy-interfaces.patch      
1970-01-01 01:00:00.000000000 +0100
+++ nvme-stas-2.3/debian/patches/fix-test-udev-with-dummy-interfaces.patch      
2023-12-05 21:04:32.000000000 +0100
@@ -0,0 +1,26 @@
+Description: Fix test-udev with dummy interfaces
+Author: Martin Belanger <martin.belan...@dell.com>
+Origin: upstream, 
https://github.com/linux-nvme/nvme-stas/commit/371c1e875a9a660adca241265e4cd460ee7e5e5c
+Bug: https://github.com/linux-nvme/nvme-stas/issues/407
+Last-Update: 2023-12-05
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+diff --git a/test/test-udev.py b/test/test-udev.py
+index ba484e0..9621edc 100755
+--- a/test/test-udev.py
++++ b/test/test-udev.py
+@@ -295,6 +295,11 @@ class Test(unittest.TestCase):
+     def test__cid_matches_tid(self):
+         ifaces = iputil.net_if_addrs()
+         for ifname, addrs in self.ifaces.items():
++            # <ifaces> contains a subset of the interfaces found in 
<self.ifaces>.
++            # So, let's make sure that we only test with the interfaces found 
in both.
++            if ifname not in ifaces:
++                continue
++
+             ##############################################
+             # IPV4
+ 
+-- 
+2.40.1
+
diff -Nru nvme-stas-2.3/debian/patches/series 
nvme-stas-2.3/debian/patches/series
--- nvme-stas-2.3/debian/patches/series 2023-11-28 11:01:46.000000000 +0100
+++ nvme-stas-2.3/debian/patches/series 2023-12-05 21:04:32.000000000 +0100
@@ -1,3 +1,5 @@
 fix-test-libnvme-version.patch
 fix-test-udev-failing-multiple-IPv6.patch
 fix-iputil-endianness-issue.patch
+skip-mac2iface-test-for-esoteric-interfaces.patch
+fix-test-udev-with-dummy-interfaces.patch
diff -Nru 
nvme-stas-2.3/debian/patches/skip-mac2iface-test-for-esoteric-interfaces.patch 
nvme-stas-2.3/debian/patches/skip-mac2iface-test-for-esoteric-interfaces.patch
--- 
nvme-stas-2.3/debian/patches/skip-mac2iface-test-for-esoteric-interfaces.patch  
    1970-01-01 01:00:00.000000000 +0100
+++ 
nvme-stas-2.3/debian/patches/skip-mac2iface-test-for-esoteric-interfaces.patch  
    2023-12-05 21:04:32.000000000 +0100
@@ -0,0 +1,70 @@
+Description: Skip mac2iface test for esoteric interfaces
+ mac2iface takes a MAC address as argument and returns the corresponding
+ interface (if any).
+ The mac2iface tests will however invoke mac2iface with invalid MAC addresses
+ when esoteric network interfaces are present on the system. As an example,
+ armhf autopkgtest runners in Ubuntu have gre interfaces configured so the
+ test-suite fails.
+ .
+ We now ensure that the test-suite calls mac2iface with only valid MAC
+ addresses.
+ .
+ Furthermore, sometimes the same MAC address is assigned to more than one
+ interface on the system (this is true for VLAN interfaces for instance). This
+ confuses mac2iface, which returns only the first match. This scenario is
+ possibly more of a nvme-stas bug than a test-suite bug, but for now we will
+ just skip the interfaces that have a duplicate MAC address.
+Author: Olivier Gayot <olivier.ga...@canonical.com>
+Bug-Ubuntu: https://launchpad.net/bugs/2045690
+Forwarded: https://github.com/linux-nvme/nvme-stas/pull/411
+Last-Update: 2023-12-05
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+--- a/test/test-iputil.py
++++ b/test/test-iputil.py
+@@ -43,11 +43,41 @@
+         self.assertEqual('', iputil.get_interface(ifaces, ''))
+         self.assertEqual('', iputil.get_interface(ifaces, None))
+ 
++    @staticmethod
++    def _is_ok_for_mac2iface(iface) -> bool:
++        ''' mac2iface can only work with interfaces that have a proper MAC
++        address. One can use this function to filter out other interfaces
++        configured on the system. '''
++        if iface['link_type'] != 'ether':
++            # Some esoteric interface types (e.g., gre) use the address
++            # field to store something that is not a MAC address. Skip
++            # them.
++            return False
++        if 'address' not in iface:
++            return False
++        if iface['address'] == '00:00:00:00:00:00':
++            # All 0's is an invalid MAC address so do not bother.
++            # In practice, it often appears as the address of the loopback
++            # interface but it can also appear for other things like a gretap
++            # or erspan interface.
++            return False
++        return True
++
+     def test_mac2iface(self):
+-        for iface in self.ifaces:
+-            address = iface.get('address', None)
+-            if address:
+-                self.assertEqual(iface['ifname'], iputil.mac2iface(address))
++        # We only test the interfaces that have a MAC address, and a valid 
one.
++        candidate_ifaces = [iface for iface in self.ifaces if 
self._is_ok_for_mac2iface(iface)]
++
++        for iface in candidate_ifaces:
++            if len([x for x in candidate_ifaces if x['address'] == 
iface['address']]) >= 2:
++                # We need to be careful, sometimes we can have the same MAC 
address
++                # on multiple interfaces. This happens with VLAN interfaces 
for
++                # instance. mac2iface will obviously be confused when dealing 
with
++                # those so let's skip the interfaces that have duplicate MAC.
++                logging.warning('[%s] is not the only interface with address 
[%s]',
++                                iface['ifname'], iface['address'])
++                continue
++
++            self.assertEqual(iface['ifname'], 
iputil.mac2iface(iface['address']))
+ 
+     def test_remove_invalid_addresses(self):
+         good_tcp = trid.TID({'transport': 'tcp', 'traddr': '1.1.1.1', 
'subsysnqn': '', 'trsvcid': '8009'})

Reply via email to