Only one route is generated from multiple files with different tables and same vlan

Bug #2003061 reported by Iku Iwasa
24
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Netplan
Triaged
Medium
Danilo Egea Gondolfo

Bug Description

Suppose the following 3 files exist in /etc/netplan.

# 01-netcfg.yaml
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: false
      dhcp6: false
      addresses: [172.17.17.151/20]
      routes:
        - to: default
          via: 172.17.17.1
      nameservers:
        addresses: [4.2.2.1, 4.2.2.2, 208.67.220.220]
  vlans:
    vlan100:
      id: 100
      link: eth0
      addresses: [10.0.0.1/24,10.0.0.2/24]

# 10-table1.yaml
network:
  version: 2
  vlans:
    vlan100:
      routing-policy:
        - from: 10.0.0.1
          table: 1001
      routes:
        - to: 0.0.0.0/0
          via: 10.0.0.100
          table: 1001

# 10-table2.yaml
network:
  version: 2
  vlans:
    vlan100:
      routing-policy:
        - from: 10.0.0.2
          table: 1002
      routes:
        - to: 0.0.0.0/0
          via: 10.0.0.200
          table: 1002

Then, `netplan apply` generates a route for table 1001 only.

# output of netplan apply
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      addresses:
      - "172.17.17.151/20"
      nameservers:
        addresses:
        - 4.2.2.1
        - 4.2.2.2
        - 208.67.220.220
      dhcp4: false
      dhcp6: false
      routes:
      - to: "default"
        via: "172.17.17.1"
  vlans:
    vlan100:
      addresses:
      - "10.0.0.1/24"
      - "10.0.0.2/24"
      routes:
      - table: 1001
        to: "0.0.0.0/0"
        via: "10.0.0.100"
      routing-policy:
      - table: 1001
        from: "10.0.0.1"
      - table: 1002
        from: "10.0.0.2"
      id: 100
      link: "eth0"

Expected `network.vlans.vlan100.routes` node is as follows.
# part of expected output
      routes:
      - table: 1001
        to: "0.0.0.0/0"
        via: "10.0.0.100"
      - table: 1002
        to: "0.0.0.0/0"
        via: "10.0.0.200"

If 10-table1.yaml and 10-table2.yaml are merged to one file like below, `network.vlans.vlan100.routes` node is generated as expected.

# 20-merged.yaml
network:
  version: 2
  vlans:
    vlan100:
      routing-policy:
        - from: 10.0.0.1
          table: 1001
        - from: 10.0.0.2
          table: 1002
      routes:
        - to: 0.0.0.0/0
          via: 10.0.0.100
          table: 1001
        - to: 0.0.0.0/0
          via: 10.0.0.200
          table: 1002

Same contents in Gist for readability.
https://gist.github.com/iquiw/373a139e4ab773574983293061d979bb

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

Indeed, I think something might be wrong with netplan's additive route merging logic.

Changed in netplan:
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
Danilo Egea Gondolfo (danilogondolfo) wrote :

I can confirm the issue. For the example above, the generated configuration will have only one route:

$ cat systemd/network/10-netplan-vlan100.network
[Match]
Name=vlan100

[Network]
LinkLocalAddressing=ipv6
Address=10.0.0.1/24
Address=10.0.0.2/24
ConfigureWithoutCarrier=yes

[Route]
Destination=0.0.0.0/0
Gateway=10.0.0.100
Table=1001

[RoutingPolicyRule]
From=10.0.0.1
Table=1001

[RoutingPolicyRule]
From=10.0.0.2
Table=1002

I'm investigating the issue and working on a fix.

Thanks for reporting the problem.

Changed in netplan:
assignee: nobody → Danilo Egea Gondolfo (danilogondolfo)
Revision history for this message
Danilo Egea Gondolfo (danilogondolfo) wrote :

I've created a patch with a possible solution for this issue: 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.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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