cloud-init should officially support routes with source ip

Bug #1909138 reported by Richard Schwab
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init
Fix Released
Wishlist
Unassigned

Bug Description

cloud-init supports routes with source IPs on netplan systems (because it passes the configuration through to netplan). It does not support this on non-netplan systems, because renderer support has not been written.

[Original Report]

https://cloudinit.readthedocs.io/en/latest/topics/network-config-format-v2.html does not currently mention supporting setting the source ip on a route.

the following example currently works but it's not documented at this time.

version: 2
renderer: networkd
ethernets:
  ens18:
    addresses:
      - 10.0.0.1/24
      - 10.0.0.2/24
    routes:
      - to: 10.0.1.0/24
        via: 10.0.0.3
        from: 10.0.0.1
      - to: 10.0.2.0/24
        via: 10.0.0.4
        from: 10.0.0.2

Revision history for this message
Dan Watkins (oddbloke) wrote :

Hi Richard,

Thanks for using cloud-init and for the bug report!

cloud-init passes through the v2 format to netplan (when present, i.e. on Ubuntu), or else it converts it to the appropriate format for the current system (sysconfig, ENI or *BSD). Those backends (or our renderers for them) do not necessarily have support for everything that netplan supports, which is why that doc says:

> Cloud-init’s support for Version 2 network config is a subset of the version 2 format defined for the netplan tool.

So it's possible that you could see this working on a netplan-enabled system because of the passthrough, but that doesn't necessarily mean that it should be listed in our documentation.

I believe the relevant lines of code are https://github.com/canonical/cloud-init/blob/5d017ab6d1368271f4a522a24e16e57fbbd6e53a/cloudinit/net/network_state.py#L808-L810, in `_v2_to_v1_ipcfg`:

  for route in cfg.get('routes', []):
      routes.append(_normalize_route(
          {'destination': route.get('to'), 'gateway': route.get('via')}))

Here we can see that `from` is not pulled out of the route definition; I believe this implies that it won't be available to the non-passthrough renderers, and so can't possibly be supported by them.

So: I agree that it would be good for cloud-init to support routes with source IPs but, unfortunately, that's a feature request and not merely a documentation bug. (Though perhaps we could clarify the language at the top of that doc to make it clearer why this does work on Ubuntu?)

(If you're seeing this work on a non-netplan system then I've evidently got the wrong end of the stick: let me know and I'll take another look. :)

Thanks!

Dan

Changed in cloud-init:
status: New → Triaged
importance: Undecided → Wishlist
description: updated
Revision history for this message
Richard Schwab (nothing4you) wrote :

Hi Dan,

I am indeed seeing this on a netplan system.
The main reason I created this issue is that it was recommended to me on IRC to ensure that this functionality is not getting lost at some point due to it not being officially supported.
As cloud-init is a subset of netplan v2 config ideally what I'd be looking for would be to officially have support for passing the config to netplan even for parameters not supported by cloud-init at my own risk.

Revision history for this message
Richard Schwab (nothing4you) wrote :

My risk being that it being up to me that netplan accepts the config, not my risk being that a cloud-init update didn't break something.

Revision history for this message
Dan Watkins (oddbloke) wrote :

Aha, right, understood. We have no plans to disable netplan passthrough; even if we were to do so at some unspecified point in the future, we certainly wouldn't do so in stable Ubuntu releases. I've opened https://github.com/canonical/cloud-init/pull/750 to clarify our current support in our docs; if you have a second to review that, I'd appreciate it!

(I'll leave this bug as-is to represent the feature request. :)

Revision history for this message
Richard Schwab (nothing4you) wrote :

looks good, thanks!

Revision history for this message
Dan Watkins (oddbloke) wrote : Re: [Bug 1909138] Re: cloud-init should officially support routes with source ip

On Tue, Jan 05, 2021 at 06:23:16PM -0000, Richard Schwab wrote:
> looks good, thanks!

Thanks for the review!

Changed in cloud-init:
status: Triaged → Fix Released
Revision history for this message
James Falcon (falcojr) wrote :
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.