Skip to content

Commit

Permalink
Skip mac2iface test when multiple interfaces have the same MAC
Browse files Browse the repository at this point in the history
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.

 $ ip link add link eth0 name eth0.222 type vlan id 222
 $ ip -j addr show dev eth0 | jq '.[]["address"]'
    "00:16:3e:36:b5:0e"
 $ ip -j addr show dev eth0.222 | jq '.[]["address"]'
    "00:16:3e:36:b5:0e"

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
  • Loading branch information
ogayot committed Dec 5, 2023
1 parent 544b438 commit 148e081
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test/test-iputil.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ def test_mac2iface(self):
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):
Expand Down

0 comments on commit 148e081

Please sign in to comment.