Comment 2 for bug 1959148

Revision history for this message
Harald Jensås (harald-jensas) wrote :

Adding Nova, since this coming from Openstack Nova Compute network metadata.

See: https://docs.openstack.org/nova/latest/user/metadata.html#openstack-format-metadata
The Schema: https://docs.openstack.org/nova/latest/_downloads/9119ca7ac90aa2990e762c08baea3a36/network_data.json

To quote the network_data.json schema:

    "l3_ipv6_netmask": {
      "$id": "#/definitions/l3_ipv6_netmask",
      "type": "string",
      "pattern": "^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7})|(::))$",
      "title": "L3 IPv6 network mask",
      "examples": [
        "ffff:ffff:ffff:ffff::"
      ]
    },

Openstack Nova is using 'netaddr', and it can do this:

>>> route_addr = netaddr.IPNetwork('2bd0::/63')
>>> route_addr
IPNetwork('2bd0::/63')
>>> route_addr.netmask
IPAddress('ffff:ffff:ffff:fffe::')

Here is the Nova code building the network_metadata, it shared code for IPv4 and IPv6.
https://opendev.org/openstack/nova/src/branch/master/nova/virt/netutils.py#L311-L319

I think, ideally Nova should put the "prefix" in netmask for IPv6, or the schema should be extended to include "prefix" in `l3_ipv6_network`, `l3_ipv6_network_route`. We do not belive using an IPv6 address as netmask is a valid syntax for IPv6, see: https://github.com/canonical/cloud-init/pull/1215#issuecomment-1025068132.