netplan does not match multiple driver specifications

Bug #1918421 reported by Dave Jones
This bug affects 4 people
Affects Status Importance Assigned to Milestone (Ubuntu)
Fix Released
Fix Released

Bug Description

The current network-config configuration for cloud-init on the Ubuntu Raspberry Pi images includes the following section for matching the built-in Ethernet port on all supported models of Pi:

    # Rename the built-in ethernet device to "eth0"
      driver: bcmgenet smsc95xx lan78xx
    set-name: eth0
    dhcp4: true
    optional: true

The space-separated list of driver names (actually globs) is the format supported by networkd; from

    A whitespace-separated list of shell-style globs matching the driver currently bound to the
    device, as exposed by the udev property ID_NET_DRIVER of its parent device, or if that is
    not set, the driver as exposed by ethtool -i of the device itself. If the list is prefixed
    with a "!", the test is inverted.

Given that netplan only supports driver matching when the back-end is networkd, it would be logical to assume that it also permits multiple specifications here (although the format is somewhat incongruous given it's not a YAML list), and this had *appeared* to work historically (netplan happily copied the specification to /run/systemd/network/ However, while testing netplan under hirsute a recent change (specifically in 0.101-1) makes it clear that it is in fact failing to match the interface:

  $ sudo netplan apply
  Cannot find unique matching interface for 'eth0': {'driver': 'bcmgenet smsc95xx lan78xx'}

A work-around I'm implementing for now is to use three separate sections (each with a different name) to split out the driver components but I get the impression netplan probably ought to support this a bit more elegantly given the underlying networkd back-end does.

It would be trivial to tweak "is_interface_matching_driver_name" in netplan/cli/ to support the space separated format (and I'm happy to provide a PR implementing that if requested) but for the sake of consistency I suspect the schema ought to be extended to support the option of a YAML list instead of a string for that value?

Tags: fr-1742
Lukas Märdian (slyon)
Changed in (Ubuntu):
status: New → Triaged
Revision history for this message
Dave Jones (waveform) wrote :
tags: added: rls-ii-incoming
tags: added: fr-1742
tags: added: rls-jj-incoming
removed: rls-ii-incoming
tags: removed: rls-jj-incoming
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package - 0.104-0ubuntu1

--------------- (0.104-0ubuntu1) jammy; urgency=medium

  * New upstream release: 0.104
    - Enable 'embedded-switch-mode' setting on SmartNICs
    - Permit multiple patterns for the driver globs in match (LP: #1918421)
    - Improve routing capabilities (LP: #1892272, LP: #1805038)
    - Support additional link offload options for networkd (LP: #1771740)
    - Handle differing 'ip6-privacy' default value for NetworkManager
    - YAML state tracking for DBus API and 'netplan try' (LP: #1943120)
    - Support ConfigureWithoutCarrier ('ignore-carrier') for networkd
    - Cleanup Makefile, install only public headers
    - Netplan 'get' to use the libnetplan parser
    - libnetplan:
      + introduce the notion of NetplanState
      + use an explicit parser context
      + expose coherent generator APIs
      + improve overall error handling
      + consolidation of YAML parsing into the library
    - Restrict the symbol export to a determined public API
      + We dropped some internal symbols from the API that we know have no
        external consumers, see upstream changelog for list of dropped symbols
    Bug fixes:
    - Fix removal of defunct OVS vlan interfaces (LP: #1959147)
    - Make ConfigManager cleanup on destruction (LP: #1959729)
    - Do not write unvalidated YAML from keyfile (LP: #1952967)
    - Disable tmp address generation for real with NetworkManager (LP: #1948027)
    - Ignore empty YAML hints, delete files on 'set network=null' (LP: #1946957)
    - Wait for 'netplan try' to be ready in DBus API (LP: #1949893)
    - Initialize self.state in 'apply' (LP: #1949104)
    - Driver fallback to nl80211 and/or wext for wpa_supplicant (LP: #1814012)
    - Handle missing 'gateway' in keyfile routes, keep 'dns-search' fallback
    - Make it possible to unset a whole devtype subtree (LP: #1942930)
    - Fix memory leaks, dangling pointers & overall cleanup of API data
  * d/t/control: Add explicit wpasupplicant test Depends
  * d/control: Improved glib (v2.70+-) compat
  * d/control: Strict version dependency on libnetplan
  * d/control: Bump standards version to 4.6.0, improve sections
  * Mute false positive lintian warning
  * d/patches/: Drop patches, applied upstream
  * d/p/autopkgtest-fixes: Refresh
  * d/libnetplan0.symbols: Add new symbols for 0.104
  * d/libnetplan0.symbols: Drop (internal) legacy symbols

 -- Lukas Märdian <email address hidden> Thu, 17 Feb 2022 12:46:23 +0100

Changed in (Ubuntu Jammy):
status: Triaged → Fix Released
Revision history for this message
Matthew Lloyd (matthewlloyd) wrote :

Unfortunately the patch to in PR 202 has not quite fixed the original issue and actually breaks existing Jammy Pi installs when the package is upgraded. The version of /etc/netplan/10-rpi-ethernet-eth0.yaml shipped in the image uses the whitespace-separated driver line which the maintainers decided to disallow:

      # Rename the built-in ethernet device to "eth0"
        driver: bcmgenet smsc95xx lan78xx
      set-name: eth0
      dhcp4: true
      optional: true

This style was accepted by versions prior to 0.104-0ubuntu1 (although it didn't actually match the driver correctly), but the new version rejects the existing configuration file entirely, failing with the error "A 'driver' glob cannot contain whitespace". After upgrading packages on my Jammy Pi installation with sudo apt upgrade, the network did not come up automatically on the next reboot, and I could only recover the install by connecting HDMI / USB to debug.

The fix was to simply replace the driver line with:

        driver: ["bcmgenet", "smsc95xx", "lan78xx"]

Either needs to accept whitespace-separated driver lists after all, or the 10-rpi-ethernet-eth0.yaml file shipped with the Ubuntu Pi image needs to be updated to use a YAML-conforming list (and if possible this file should be automatically patched when upgrading existing installs).

Revision history for this message
Dave Jones (waveform) wrote :

@matthewlloyd thanks for the heads-up -- I'd actually noticed this while testing something unrelated. There's currently a patch pending on ubuntu-settings (which produces ubuntu-raspi-settings which should remove the netplan eth0 hack in favour of a straight systemd link file which works nicely); LP: #1961618 has the details.

Probably better to clean up cruft like this rather than having netplan accept broken old syntax. If you want to work-around the situation before that lands you can simply rm /etc/netplan/10-rpi-ethernet-eth0.yaml and it *should* still work (because the ubuntu-raspi-settings package in jammy already had /lib/systemd/network/ to deal with the renaming.

Revision history for this message
Matthew Lloyd (matthewlloyd) wrote :

Thanks for the information and glad to hear this has already been addressed. I'm all for cleaning up cruft.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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