diff --git a/internal/app/machined/pkg/runtime/v1alpha1/platform/azure/azure.go b/internal/app/machined/pkg/runtime/v1alpha1/platform/azure/azure.go index 01cd9b05b4..ae5c6d0553 100644 --- a/internal/app/machined/pkg/runtime/v1alpha1/platform/azure/azure.go +++ b/internal/app/machined/pkg/runtime/v1alpha1/platform/azure/azure.go @@ -28,6 +28,7 @@ import ( "github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform/internal/netutils" "github.com/siderolabs/talos/pkg/download" "github.com/siderolabs/talos/pkg/machinery/constants" + "github.com/siderolabs/talos/pkg/machinery/nethelpers" "github.com/siderolabs/talos/pkg/machinery/resources/network" runtimeres "github.com/siderolabs/talos/pkg/machinery/resources/runtime" ) @@ -113,14 +114,32 @@ func (a *Azure) ParseMetadata(metadata *ComputeMetadata, interfaceAddresses []Ne } if ipv6 { + ifname := fmt.Sprintf("eth%d", idx) + networkConfig.Operators = append(networkConfig.Operators, network.OperatorSpecSpec{ Operator: network.OperatorDHCP6, - LinkName: fmt.Sprintf("eth%d", idx), + LinkName: ifname, RequireUp: true, DHCP6: network.DHCP6OperatorSpec{ - RouteMetric: 1024, + RouteMetric: 2 * network.DefaultRouteMetric, }, }) + + // If accept_ra is not set, use the default gateway. + route := network.RouteSpecSpec{ + ConfigLayer: network.ConfigPlatform, + Gateway: netip.MustParseAddr("fe80::1234:5678:9abc"), + OutLinkName: ifname, + Table: nethelpers.TableMain, + Protocol: nethelpers.ProtocolStatic, + Type: nethelpers.TypeUnicast, + Family: nethelpers.FamilyInet6, + Priority: 4 * network.DefaultRouteMetric, + } + + route.Normalize() + + networkConfig.Routes = append(networkConfig.Routes, route) } } diff --git a/internal/app/machined/pkg/runtime/v1alpha1/platform/azure/testdata/expected.yaml b/internal/app/machined/pkg/runtime/v1alpha1/platform/azure/testdata/expected.yaml index fff77a4b0e..a899b09e34 100644 --- a/internal/app/machined/pkg/runtime/v1alpha1/platform/azure/testdata/expected.yaml +++ b/internal/app/machined/pkg/runtime/v1alpha1/platform/azure/testdata/expected.yaml @@ -1,6 +1,18 @@ addresses: [] links: [] -routes: [] +routes: + - family: inet6 + dst: "" + src: "" + gateway: fe80::1234:5678:9abc + outLinkName: eth0 + table: main + priority: 4096 + scope: global + type: unicast + flags: "" + protocol: static + layer: platform hostnames: - hostname: some domainname: fqdn @@ -12,7 +24,7 @@ operators: linkName: eth0 requireUp: true dhcp6: - routeMetric: 1024 + routeMetric: 2048 layer: default externalIPs: - 1.2.3.4 diff --git a/internal/app/machined/pkg/runtime/v1alpha1/platform/digitalocean/digitalocean.go b/internal/app/machined/pkg/runtime/v1alpha1/platform/digitalocean/digitalocean.go index dda1a56976..869ea02551 100644 --- a/internal/app/machined/pkg/runtime/v1alpha1/platform/digitalocean/digitalocean.go +++ b/internal/app/machined/pkg/runtime/v1alpha1/platform/digitalocean/digitalocean.go @@ -109,7 +109,7 @@ func (d *DigitalOcean) ParseMetadata(metadata *MetadataConfig) (*runtime.Platfor Protocol: nethelpers.ProtocolStatic, Type: nethelpers.TypeUnicast, Family: nethelpers.FamilyInet4, - Priority: 1024, + Priority: network.DefaultRouteMetric, } route.Normalize() @@ -164,7 +164,7 @@ func (d *DigitalOcean) ParseMetadata(metadata *MetadataConfig) (*runtime.Platfor Protocol: nethelpers.ProtocolStatic, Type: nethelpers.TypeUnicast, Family: nethelpers.FamilyInet6, - Priority: 1024, + Priority: 2 * network.DefaultRouteMetric, } route.Normalize() diff --git a/internal/app/machined/pkg/runtime/v1alpha1/platform/digitalocean/testdata/expected.yaml b/internal/app/machined/pkg/runtime/v1alpha1/platform/digitalocean/testdata/expected.yaml index 3a0dde1b49..d40e6cb454 100644 --- a/internal/app/machined/pkg/runtime/v1alpha1/platform/digitalocean/testdata/expected.yaml +++ b/internal/app/machined/pkg/runtime/v1alpha1/platform/digitalocean/testdata/expected.yaml @@ -69,7 +69,7 @@ routes: gateway: 2a03:b0c0:2:d0::1 outLinkName: eth0 table: main - priority: 1024 + priority: 2048 scope: global type: unicast flags: "" diff --git a/internal/app/machined/pkg/runtime/v1alpha1/platform/gcp/gcp.go b/internal/app/machined/pkg/runtime/v1alpha1/platform/gcp/gcp.go index 2bb6579530..c0d21b15e6 100644 --- a/internal/app/machined/pkg/runtime/v1alpha1/platform/gcp/gcp.go +++ b/internal/app/machined/pkg/runtime/v1alpha1/platform/gcp/gcp.go @@ -85,7 +85,7 @@ func (g *GCP) ParseMetadata(metadata *MetadataConfig, interfaces []NetworkInterf Operator: network.OperatorDHCP4, LinkName: ifname, DHCP4: network.DHCP4OperatorSpec{ - RouteMetric: 1024, + RouteMetric: network.DefaultRouteMetric, }, RequireUp: true, ConfigLayer: network.ConfigPlatform, @@ -125,6 +125,7 @@ func (g *GCP) ParseMetadata(metadata *MetadataConfig, interfaces []NetworkInterf Protocol: nethelpers.ProtocolStatic, Type: nethelpers.TypeUnicast, Family: nethelpers.FamilyInet6, + Priority: 2 * network.DefaultRouteMetric, } route.Normalize() diff --git a/internal/app/machined/pkg/runtime/v1alpha1/platform/gcp/testdata/expected.yaml b/internal/app/machined/pkg/runtime/v1alpha1/platform/gcp/testdata/expected.yaml index e111b1e258..c5b2f91a3e 100644 --- a/internal/app/machined/pkg/runtime/v1alpha1/platform/gcp/testdata/expected.yaml +++ b/internal/app/machined/pkg/runtime/v1alpha1/platform/gcp/testdata/expected.yaml @@ -20,6 +20,7 @@ routes: gateway: fe80::4001:acff:fe10:1 outLinkName: eth0 table: main + priority: 2048 scope: global type: unicast flags: "" diff --git a/internal/app/machined/pkg/runtime/v1alpha1/platform/nocloud/metadata.go b/internal/app/machined/pkg/runtime/v1alpha1/platform/nocloud/metadata.go index 65947c60e2..ac18db71d4 100644 --- a/internal/app/machined/pkg/runtime/v1alpha1/platform/nocloud/metadata.go +++ b/internal/app/machined/pkg/runtime/v1alpha1/platform/nocloud/metadata.go @@ -335,7 +335,7 @@ func (n *Nocloud) applyNetworkConfigV1(config *NetworkConfig, st state.State, ne LinkName: name, RequireUp: true, DHCP4: network.DHCP4OperatorSpec{ - RouteMetric: 1024, + RouteMetric: network.DefaultRouteMetric, }, ConfigLayer: network.ConfigPlatform, }) @@ -405,7 +405,7 @@ func (n *Nocloud) applyNetworkConfigV1(config *NetworkConfig, st state.State, ne LinkName: name, RequireUp: true, DHCP6: network.DHCP6OperatorSpec{ - RouteMetric: 1024, + RouteMetric: 2 * network.DefaultRouteMetric, }, ConfigLayer: network.ConfigPlatform, }) @@ -530,11 +530,6 @@ func applyNetworkConfigV2Ethernet(name string, eth Ethernet, networkConfig *runt return fmt.Errorf("failed to parse route destination: %w", err) } - family := nethelpers.FamilyInet4 - if gw.Is6() { - family = nethelpers.FamilyInet6 - } - route := network.RouteSpecSpec{ ConfigLayer: network.ConfigPlatform, Destination: dest, @@ -543,8 +538,13 @@ func applyNetworkConfigV2Ethernet(name string, eth Ethernet, networkConfig *runt Table: nethelpers.RoutingTable(route.Table), Protocol: nethelpers.ProtocolStatic, Type: nethelpers.TypeUnicast, - Family: family, - Priority: 1024, + Family: nethelpers.FamilyInet4, + Priority: network.DefaultRouteMetric, + } + + if gw.Is6() { + route.Family = nethelpers.FamilyInet6 + route.Priority = 2 * network.DefaultRouteMetric } route.Normalize() diff --git a/internal/app/machined/pkg/runtime/v1alpha1/platform/openstack/openstack.go b/internal/app/machined/pkg/runtime/v1alpha1/platform/openstack/openstack.go index 93e4986206..ad6a30e39b 100644 --- a/internal/app/machined/pkg/runtime/v1alpha1/platform/openstack/openstack.go +++ b/internal/app/machined/pkg/runtime/v1alpha1/platform/openstack/openstack.go @@ -200,7 +200,7 @@ func (o *Openstack) ParseMetadata( LinkName: iface, RequireUp: true, DHCP4: network.DHCP4OperatorSpec{ - RouteMetric: 1024, + RouteMetric: network.DefaultRouteMetric, SkipHostnameRequest: true, }, ConfigLayer: network.ConfigPlatform, @@ -211,7 +211,7 @@ func (o *Openstack) ParseMetadata( LinkName: iface, RequireUp: true, DHCP6: network.DHCP6OperatorSpec{ - RouteMetric: 1024, + RouteMetric: 2 * network.DefaultRouteMetric, SkipHostnameRequest: true, }, ConfigLayer: network.ConfigPlatform, @@ -260,7 +260,7 @@ func (o *Openstack) ParseMetadata( Protocol: nethelpers.ProtocolStatic, Type: nethelpers.TypeUnicast, Family: family, - Priority: 1024, + Priority: network.DefaultRouteMetric, } route.Normalize() @@ -294,7 +294,7 @@ func (o *Openstack) ParseMetadata( Protocol: nethelpers.ProtocolStatic, Type: nethelpers.TypeUnicast, Family: family, - Priority: 1024, + Priority: network.DefaultRouteMetric, } route.Normalize() diff --git a/internal/app/machined/pkg/runtime/v1alpha1/platform/openstack/testdata/expected.yaml b/internal/app/machined/pkg/runtime/v1alpha1/platform/openstack/testdata/expected.yaml index 48d87190ec..0b6a4cb717 100644 --- a/internal/app/machined/pkg/runtime/v1alpha1/platform/openstack/testdata/expected.yaml +++ b/internal/app/machined/pkg/runtime/v1alpha1/platform/openstack/testdata/expected.yaml @@ -187,7 +187,7 @@ operators: linkName: eth2 requireUp: true dhcp6: - routeMetric: 1024 + routeMetric: 2048 skipHostnameRequest: true layer: platform externalIPs: diff --git a/internal/app/machined/pkg/runtime/v1alpha1/platform/scaleway/scaleway.go b/internal/app/machined/pkg/runtime/v1alpha1/platform/scaleway/scaleway.go index 65b1f9a2ed..6cdd1bb381 100644 --- a/internal/app/machined/pkg/runtime/v1alpha1/platform/scaleway/scaleway.go +++ b/internal/app/machined/pkg/runtime/v1alpha1/platform/scaleway/scaleway.go @@ -74,7 +74,7 @@ func (s *Scaleway) ParseMetadata(metadata *instance.Metadata) (*runtime.Platform Protocol: nethelpers.ProtocolStatic, Type: nethelpers.TypeUnicast, Family: nethelpers.FamilyInet4, - Priority: 1024, + Priority: network.DefaultRouteMetric, } route.Normalize() @@ -85,7 +85,7 @@ func (s *Scaleway) ParseMetadata(metadata *instance.Metadata) (*runtime.Platform LinkName: "eth0", RequireUp: true, DHCP4: network.DHCP4OperatorSpec{ - RouteMetric: 1024, + RouteMetric: network.DefaultRouteMetric, }, ConfigLayer: network.ConfigPlatform, }) @@ -128,7 +128,7 @@ func (s *Scaleway) ParseMetadata(metadata *instance.Metadata) (*runtime.Platform Protocol: nethelpers.ProtocolStatic, Type: nethelpers.TypeUnicast, Family: nethelpers.FamilyInet6, - Priority: 1024, + Priority: 2 * network.DefaultRouteMetric, } route.Normalize() diff --git a/internal/app/machined/pkg/runtime/v1alpha1/platform/scaleway/testdata/expected.yaml b/internal/app/machined/pkg/runtime/v1alpha1/platform/scaleway/testdata/expected.yaml index 31201ed793..61def78c01 100644 --- a/internal/app/machined/pkg/runtime/v1alpha1/platform/scaleway/testdata/expected.yaml +++ b/internal/app/machined/pkg/runtime/v1alpha1/platform/scaleway/testdata/expected.yaml @@ -32,7 +32,7 @@ routes: gateway: '2001:111:222:3333::' outLinkName: eth0 table: main - priority: 1024 + priority: 2048 scope: global type: unicast flags: "" diff --git a/internal/app/machined/pkg/runtime/v1alpha1/platform/upcloud/upcloud.go b/internal/app/machined/pkg/runtime/v1alpha1/platform/upcloud/upcloud.go index 71bd836b7f..82be5155c8 100644 --- a/internal/app/machined/pkg/runtime/v1alpha1/platform/upcloud/upcloud.go +++ b/internal/app/machined/pkg/runtime/v1alpha1/platform/upcloud/upcloud.go @@ -89,7 +89,7 @@ func (u *UpCloud) ParseMetadata(metadata *MetadataConfig) (*runtime.PlatformNetw LinkName: iface, RequireUp: true, DHCP4: network.DHCP4OperatorSpec{ - RouteMetric: 1024, + RouteMetric: network.DefaultRouteMetric, }, ConfigLayer: network.ConfigPlatform, }) @@ -141,7 +141,7 @@ func (u *UpCloud) ParseMetadata(metadata *MetadataConfig) (*runtime.PlatformNetw Protocol: nethelpers.ProtocolStatic, Type: nethelpers.TypeUnicast, Family: family, - Priority: 1024, + Priority: network.DefaultRouteMetric, } route.Normalize() diff --git a/internal/app/machined/pkg/runtime/v1alpha1/platform/vultr/vultr.go b/internal/app/machined/pkg/runtime/v1alpha1/platform/vultr/vultr.go index bb3aa4d279..18fba67e50 100644 --- a/internal/app/machined/pkg/runtime/v1alpha1/platform/vultr/vultr.go +++ b/internal/app/machined/pkg/runtime/v1alpha1/platform/vultr/vultr.go @@ -125,7 +125,7 @@ func (v *Vultr) ParseMetadata(metadata *metadata.MetaData) (*runtime.PlatformNet LinkName: iface, RequireUp: true, DHCP4: network.DHCP4OperatorSpec{ - RouteMetric: 1024, + RouteMetric: network.DefaultRouteMetric, }, ConfigLayer: network.ConfigPlatform, })