from key in routes generates incorrect networkd configuration

Bug #1767849 reported by djGrrr
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Netplan
Fix Released
Undecided
Daniel Axtens
netplan.io (Ubuntu)
Fix Released
Undecided
Unassigned
Xenial
Fix Released
Undecided
Unassigned
Bionic
Fix Released
Undecided
Unassigned
Cosmic
Fix Released
Undecided
Unassigned

Bug Description

When you use netplan's "from" key under routes, the systemd-networkd .network file generated uses the wrong variable name "From", when it should be using "Source".

And networkd generates a warning and ignores it as a result:
systemd-networkd[585]: /run/systemd/network/10-netplan-eth0.network:16: Unknown lvalue 'From' in section 'Route'

I have attached a very simple patch which should fix the problem.

Tags: patch
Revision history for this message
djGrrr (djgrrr) wrote :
Revision history for this message
Ryan Harper (raharper) wrote :

Hello,

Thank you for reporting this issue and helping make Ubuntu better.

Can you include which Ubuntu release, systemd and netplan package version you were using?

I don't believe there is support in netplan 'routes' for a 'from' field, though I see that it does accept the value

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      addresses:
       - 192.168.3.30/24
      dhcp4: no
      routes:
       - to: 192.168.3.0/24
         via: 192.168.3.1
         table: 101
         from: 10.0.0.1
      routing-policy:
       - from: 192.168.3.0/24
         table: 101

Generates:

root@b1:/run/systemd/network# cat 10-netplan-eth0.network
[Match]
Name=eth0

[Network]
Address=192.168.3.30/24

[Route]
Destination=192.168.3.0/24
Gateway=192.168.3.1
From=10.0.0.1
Table=101

[RoutingPolicyRule]
From=192.168.3.0/24
Table=101

Which then systemd-networkd does complain about a From= in a [Routes] section which isn't supported.

However, I believe you want to use the 'routing-policy' to set the From value for a particular route.

Please confirm if using routing-policy allows you to get the configuration you need. If the configuration can't be achieved with the policy, please include your netplan config as you have it now and an ip route show all to help indicate which route you need to add.

Netplan shouldn't render From= in the [Routes] section for sure.

Changed in netplan:
status: New → Incomplete
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for netplan because there has been no activity for 60 days.]

Changed in netplan:
status: Incomplete → Expired
Revision history for this message
Jari Salo (jari-salo) wrote :

This is still valid if you want to specify the source address for the outgoing traffic. A valid example is to use additional loopback address as the source address for all the outgoing traffic.

man netplan dictates the following:

Routing
       Complex routing is possible with netplan. Standard static routes as well as policy routing using routing tables are supported
       via the networkd backend.

       These options are available for all types of interfaces.

       routes (mapping)
              The routes block defines standard static routes for an interface. At least to and via must be specified.

              For from, to, and via, both IPv4 and IPv6 addresses are recognized, and must be in the form addr/prefixlen or addr.

              from (scalar)
                     Set a source IP address for traffic going through the route.

man systemd.network also has reference to Source= under [ROUTE] section:
Source=
           The source prefix of the route. Possibly followed by a slash and the prefix length. If omitted, a full-length host route
           is assumed.

As the original bug report says netplan is rendering the configuration incorrectly for systemd-networkd backend and should be fixed.

Changed in netplan:
status: Expired → Confirmed
Revision history for this message
Jari Salo (jari-salo) wrote :

Actually the correct systemd.network attribute is PreferredSource= instead of Source= as shown in this comment https://github.com/systemd/systemd/issues/5888#issuecomment-301565544

Source= is only applicable to ipv6 source-based routing

Revision history for this message
Daniel Axtens (daxtens) wrote :

Hi, I also discovered this and can confirm it.

I submitted a patch much like the original patch on this bug but also changing the tests.

It's at https://github.com/CanonicalLtd/netplan/pull/42/commits/3682933b73b552af8984bf0a3f109158219ead89

Regards,
Daniel

Revision history for this message
Daniel Axtens (daxtens) wrote :

Hi,

The fix has now been committed and should be in the next release.

Regards,
Daniel

Changed in netplan:
status: Confirmed → Fix Committed
assignee: nobody → Daniel Axtens (daxtens)
Revision history for this message
Daniel Axtens (daxtens) wrote :

This has been fixed in Cosmic. I have attempted to nominate it for Xenial and Bionic for backporting.

Changed in netplan.io (Ubuntu):
status: New → Fix Committed
Changed in netplan:
status: Fix Committed → Fix Released
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "netplan-networkd-route-source-fix.patch" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

AFAICT this has been released in xenial, bionic, cosmic, and disco, for netplan.io versions 0.40 and above.

Changed in netplan.io (Ubuntu):
status: Fix Committed → Fix Released
Changed in netplan.io (Ubuntu Xenial):
status: New → Fix Released
Changed in netplan.io (Ubuntu Bionic):
status: New → Fix Released
Changed in netplan.io (Ubuntu Cosmic):
status: New → 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.