netplan: adding routes via CLI can silently fail

Bug #1988444 reported by Simon Chopin
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Netplan
New
Medium
Unassigned

Bug Description

If you already have one route defined on your interface, adding a second one via `netplan set` will silently fail:

❯ netplan get
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      addresses:
      - "192.168.46.7/24"
      routes:
      - to: "default"
        via: "192.168.46.1"
❯ netplan set ethernets.eth0.routes='[{"to":"10.10.10.0/24", "via": "192.168.46.2"}]'

❯ echo $?
0

 ❯ netplan get
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      addresses:
      - "192.168.46.7/24"
      routes:
      - to: "default"
        via: "192.168.46.1"

The issue is caused by the parsing code using invalid heuristics when avoid to add duplicate entries caused by multiple parsing of the same input file: currently, it assumes that if the input array has the same number of entries as the current routes array, it must be the same file. That is obviously not true, and will not only discard valid new input, but will only prevent duplicate entries in the simple cases.

Revision history for this message
Lukas Märdian (slyon) wrote :

I think this should be fixed in 0.106 via https://github.com/canonical/netplan/pull/320

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.