mac address parsing fails on specific mac addressess

Bug #1920732 reported by Qarion
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Netplan
Triaged
Medium
Unassigned

Bug Description

config snippet:
        ens8:
            addresses: [10.3.59.3/24]
            match:
                macaddress: 52:54:00:26:30:21
            set-name: ens8

when trying netplan try with this specific mac address I get an error(see bellow)
fortunately I was able to get a different mac address for the vm which did work with everything else in the config the same, but it seems mac address containing only numbers are parsed as a number instead of a string?

root@ubuntu:~# netplan try
Warning: Stopping systemd-networkd.service, but it can still be activated by:
  systemd-networkd.socket

An error occurred: 'int' object has no attribute 'lower'

Reverting.
Warning: Stopping systemd-networkd.service, but it can still be activated by:
  systemd-networkd.socket
Traceback (most recent call last):
  File "/usr/share/netplan/netplan/cli/commands/try_command.py", line 84, in command_try
    NetplanApply().command_apply(run_generate=True, sync=True, exit_on_error=False)
  File "/usr/share/netplan/netplan/cli/commands/apply.py", line 187, in command_apply
    changes = NetplanApply.process_link_changes(devices, config_manager)
  File "/usr/share/netplan/netplan/cli/commands/apply.py", line 283, in process_link_changes
    current_iface_name = utils.find_matching_iface(interfaces, match)
  File "/usr/share/netplan/netplan/cli/utils.py", line 199, in find_matching_iface
    matches = list(filter(lambda iface: is_interface_matching_macaddress(iface, match.get('macaddress')), matches))
  File "/usr/share/netplan/netplan/cli/utils.py", line 199, in <lambda>
    matches = list(filter(lambda iface: is_interface_matching_macaddress(iface, match.get('macaddress')), matches))
  File "/usr/share/netplan/netplan/cli/utils.py", line 187, in is_interface_matching_macaddress
    return match_mac.lower() == macaddress.lower()
AttributeError: 'int' object has no attribute 'lower'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/sbin/netplan", line 23, in <module>
    netplan.main()
  File "/usr/share/netplan/netplan/cli/core.py", line 50, in main
    self.run_command()
  File "/usr/share/netplan/netplan/cli/utils.py", line 257, in run_command
    self.func()
  File "/usr/share/netplan/netplan/cli/commands/try_command.py", line 66, in run
    self.run_command()
  File "/usr/share/netplan/netplan/cli/utils.py", line 257, in run_command
    self.func()
  File "/usr/share/netplan/netplan/cli/commands/try_command.py", line 95, in command_try
    self.revert()
  File "/usr/share/netplan/netplan/cli/commands/try_command.py", line 118, in revert
    NetplanApply().command_apply(run_generate=False, sync=True, exit_on_error=False)
  File "/usr/share/netplan/netplan/cli/commands/apply.py", line 187, in command_apply
    changes = NetplanApply.process_link_changes(devices, config_manager)
  File "/usr/share/netplan/netplan/cli/commands/apply.py", line 283, in process_link_changes
    current_iface_name = utils.find_matching_iface(interfaces, match)
  File "/usr/share/netplan/netplan/cli/utils.py", line 199, in find_matching_iface
    matches = list(filter(lambda iface: is_interface_matching_macaddress(iface, match.get('macaddress')), matches))
  File "/usr/share/netplan/netplan/cli/utils.py", line 199, in <lambda>
    matches = list(filter(lambda iface: is_interface_matching_macaddress(iface, match.get('macaddress')), matches))
  File "/usr/share/netplan/netplan/cli/utils.py", line 187, in is_interface_matching_macaddress
    return match_mac.lower() == macaddress.lower()
AttributeError: 'int' object has no attribute 'lower'

Lukas Märdian (slyon)
Changed in netplan:
status: New → Confirmed
status: Confirmed → Triaged
Revision history for this message
Lukas Märdian (slyon) wrote :

Netplan's configmanager.py uses a python YAML parser, which interpret MAC addresses, consisting of numbers only as integer, e.g.:

>>> import yaml
>>> yaml.safe_load('52:54:00:26:30:21')
41135135421

Please make sure to quote your value (i.e. macaddress: '52:54:00:26:30:21') to have it interpreted as a string.
The netplan CLI will eventually transition to another YAML parser (from libnetplan), which will do more specific input validation and will better handle situations like this.

Changed in netplan:
importance: Undecided → Medium
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.