Skip to content

Commit

Permalink
fix: default priority for ipv6
Browse files Browse the repository at this point in the history
We will use the default IPv6 gateway priority as 2048.
The RA default is 1024, which leads to verbose messages such as 'error adding route: netlink receive: file exists.'

Azure uses DHCPv6 and RA for configuring IPv6 on the node.
The platform sets the default gateway as a fallback in case 'accept_ra' is not set to 2.

Signed-off-by: Serge Logvinov <serge.logvinov@sinextra.dev>
Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
  • Loading branch information
sergelogvinov authored and smira committed Dec 29, 2023
1 parent e8758dc commit f6926fa
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 29 deletions.
23 changes: 21 additions & 2 deletions internal/app/machined/pkg/runtime/v1alpha1/platform/azure/azure.go
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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)
}
}

Expand Down
@@ -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
Expand All @@ -12,7 +24,7 @@ operators:
linkName: eth0
requireUp: true
dhcp6:
routeMetric: 1024
routeMetric: 2048
layer: default
externalIPs:
- 1.2.3.4
Expand Down
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
Expand Up @@ -69,7 +69,7 @@ routes:
gateway: 2a03:b0c0:2:d0::1
outLinkName: eth0
table: main
priority: 1024
priority: 2048
scope: global
type: unicast
flags: ""
Expand Down
Expand Up @@ -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,
Expand Down Expand Up @@ -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()
Expand Down
Expand Up @@ -20,6 +20,7 @@ routes:
gateway: fe80::4001:acff:fe10:1
outLinkName: eth0
table: main
priority: 2048
scope: global
type: unicast
flags: ""
Expand Down
Expand Up @@ -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,
})
Expand Down Expand Up @@ -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,
})
Expand Down Expand Up @@ -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,
Expand All @@ -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()
Expand Down
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -260,7 +260,7 @@ func (o *Openstack) ParseMetadata(
Protocol: nethelpers.ProtocolStatic,
Type: nethelpers.TypeUnicast,
Family: family,
Priority: 1024,
Priority: network.DefaultRouteMetric,
}

route.Normalize()
Expand Down Expand Up @@ -294,7 +294,7 @@ func (o *Openstack) ParseMetadata(
Protocol: nethelpers.ProtocolStatic,
Type: nethelpers.TypeUnicast,
Family: family,
Priority: 1024,
Priority: network.DefaultRouteMetric,
}

route.Normalize()
Expand Down
Expand Up @@ -187,7 +187,7 @@ operators:
linkName: eth2
requireUp: true
dhcp6:
routeMetric: 1024
routeMetric: 2048
skipHostnameRequest: true
layer: platform
externalIPs:
Expand Down
Expand Up @@ -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()
Expand All @@ -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,
})
Expand Down Expand Up @@ -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()
Expand Down
Expand Up @@ -32,7 +32,7 @@ routes:
gateway: '2001:111:222:3333::'
outLinkName: eth0
table: main
priority: 1024
priority: 2048
scope: global
type: unicast
flags: ""
Expand Down
Expand Up @@ -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,
})
Expand Down Expand Up @@ -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()
Expand Down
Expand Up @@ -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,
})
Expand Down

0 comments on commit f6926fa

Please sign in to comment.