netplan generates duplicate dns

Bug #2007682 reported by Tommy
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Netplan
Fix Released
Low
Unassigned

Bug Description

Hello,
I have a server with Ubuntu 22.04LTS
Netplan version: netplan.io 0.104-0ubuntu2

When bonds section upper than ethernets section I see duplicate bonds.ifname.nameservers.addresses and bonds.ifname.nameservers.search:

# netplan get
network:
  version: 2
  renderer: networkd
  ethernets:
    ens3f0:
      match:
        macaddress: "some-mac"
      dhcp4: false
      set-name: "ens3f0"
    ens2f0:
      match:
        macaddress: "some-mac"
      dhcp4: false
      set-name: "ens2f0"
  bonds:
    aggi:
      addresses:
      - "10.17.0.73/26"
      nameservers:
        addresses:
        - 8.8.8.8
        - 8.8.4.4
        - 8.8.8.8
        - 8.8.4.4
        search:
        - example.com
        - example.com
      dhcp4: false
      interfaces:
      - ens2f0
      - ens3f0
      parameters:
        mode: "802.3ad"
        mii-monitor-interval: "100"
        up-delay: "200"
        down-delay: "200"
        lacp-rate: "slow"
        transmit-hash-policy: "layer3+4"
      routes:
      - to: "default"
        via: "10.17.0.67"

But when I swap sections everything is fine:
# netplan get
network:
  version: 2
  renderer: networkd
  ethernets:
    ens3f0:
      match:
        macaddress: "some-mac"
      dhcp4: false
      set-name: "ens3f0"
    ens2f0:
      match:
        macaddress: "some-mac"
      dhcp4: false
      set-name: "ens2f0"
  bonds:
    aggi:
      addresses:
      - "10.17.0.73/26"
      nameservers:
        addresses:
        - 8.8.8.8
        - 8.8.4.4
        search:
        - example.com
      dhcp4: false
      interfaces:
      - ens2f0
      - ens3f0
      parameters:
        mode: "802.3ad"
        mii-monitor-interval: "100"
        up-delay: "200"
        down-delay: "200"
        lacp-rate: "slow"
        transmit-hash-policy: "layer3+4"
      routes:
      - to: "default"
        via: "10.17.0.67"

Tags: fr-3537
Revision history for this message
Danilo Egea Gondolfo (danilogondolfo) wrote (last edit ):

Hi, thanks for your bug report.

I can confirm that the problem still exists on netplan.io 0.106.

Here is a simpler reproducer:

$ cat /tmp/fakeroot/etc/netplan/90-configs.yaml
network:
  bonds:
    aggi:
      nameservers:
        addresses:
        - 8.8.8.8
        search:
        - example.com
      interfaces:
      - ens3f0
  ethernets:
    ens3f0: {}

$ netplan get --root-dir /tmp/fakeroot/
network:
  version: 2
  ethernets:
    ens3f0: {}
  bonds:
    aggi:
      nameservers:
        addresses:
        - 8.8.8.8
        - 8.8.8.8
        search:
        - example.com
        - example.com
      interfaces:
      - ens3f0

And indeed the duplication doesn't happen if "ethernets" is defined before "bonds".

Lukas Märdian (slyon)
Changed in netplan:
status: New → Triaged
importance: Undecided → Low
Revision history for this message
Danilo Egea Gondolfo (danilogondolfo) wrote :

It also generates duplicated entries so the problem is not only with the "netplan get" command:

$ cat /tmp/fakeroot/etc/netplan/90-config.yaml
network:
  bonds:
    aggi:
      nameservers:
        addresses:
        - 8.8.8.8
        search:
        - example.com
      interfaces:
      - ens3f0
  ethernets:
    ens3f0: {}

$ cat /tmp/fakeroot/run/systemd/network/10-netplan-aggi.network
[Match]
Name=aggi

[Network]
LinkLocalAddressing=ipv6
DNS=8.8.8.8
DNS=8.8.8.8
Domains=example.com example.com
ConfigureWithoutCarrier=yes

Revision history for this message
Danilo Egea Gondolfo (danilogondolfo) wrote :

The problem happens when the parser needs a second pass to find all the interfaces. It doesn't check if the values are already in their lists.

The problem is not limited to the DNS entries.

Here is another example:

network:
  bonds:
    aggi:
      routing-policy:
        - table: 1
          from: 1.2.3.4
      nameservers:
        addresses:
        - 8.8.8.8
        search:
        - example.com
      interfaces:
      - ens3f0
  ethernets:
    ens3f0: {}

The .netdev file will look like this:

[Match]
Name=aggi

[Network]
LinkLocalAddressing=ipv6
DNS=8.8.8.8
DNS=8.8.8.8
Domains=example.com example.com
ConfigureWithoutCarrier=yes

[RoutingPolicyRule]
From=1.2.3.4
Table=1

[RoutingPolicyRule]
From=1.2.3.4
Table=1

tags: added: fr-3537
Revision history for this message
Danilo Egea Gondolfo (danilogondolfo) wrote :

Another instance of duplication:

network:
  bridges:
    br0:
      openvswitch:
        protocols:
          - OpenFlow10
          - OpenFlow11
          - OpenFlow12
        controller:
          addresses:
            - tcp:127.0.0.1:6653
            - tcp:127.0.0.2:6653
      interfaces:
        - nic1
  ethernets:
    nic1: {}

$ tail -n 4 /tmp/fakeroot/run/systemd/system/netplan-ovs-br0.service
ExecStart=/usr/bin/ovs-vsctl set Bridge br0 protocols=OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow10,OpenFlow11,OpenFlow12
ExecStart=/usr/bin/ovs-vsctl set Bridge br0 external-ids:netplan/protocols=OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow10,OpenFlow11,OpenFlow12
ExecStart=/usr/bin/ovs-vsctl set-controller br0 tcp:127.0.0.1:6653 tcp:127.0.0.2:6653 tcp:127.0.0.1:6653 tcp:127.0.0.2:6653
ExecStart=/usr/bin/ovs-vsctl set Bridge br0 external-ids:netplan/global/set-controller=tcp:127.0.0.1:6653,tcp:127.0.0.2:6653,tcp:127.0.0.1:6653,tcp:127.0.0.2:6653

Revision history for this message
Danilo Egea Gondolfo (danilogondolfo) wrote :
Lukas Märdian (slyon)
Changed in netplan:
status: Triaged → In Progress
Revision history for this message
Lukas Märdian (slyon) wrote :
Changed in netplan:
status: In Progress → Fix Released
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.