From 7ce7e3c10c6e651622127175d9dbd97e26bc907f Mon Sep 17 00:00:00 2001 From: Tim Rozet Date: Mon, 28 Oct 2024 16:24:06 -0400 Subject: [PATCH] Only configure IPv6 RAs when ipv6 mode enabled Without this fix, ovn-controller would spam: 2024-10-28T16:58:44.283Z|04438|pinctrl|WARN|Invalid IPv6 prefixes: Signed-off-by: Tim Rozet --- go-controller/pkg/ovn/gateway.go | 3 +- ...econdary_layer2_network_controller_test.go | 30 ++++++++++++++----- ...econdary_layer3_network_controller_test.go | 6 ++++ 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/go-controller/pkg/ovn/gateway.go b/go-controller/pkg/ovn/gateway.go index ea244082d1..651e3d4140 100644 --- a/go-controller/pkg/ovn/gateway.go +++ b/go-controller/pkg/ovn/gateway.go @@ -403,7 +403,8 @@ func (gw *GatewayManager) GatewayInit( types.NetworkExternalID: gw.netInfo.GetNetworkName(), types.TopologyExternalID: gw.netInfo.TopologyType(), } - if gw.netInfo.IsPrimaryNetwork() && gw.netInfo.TopologyType() == types.Layer2Topology { + _, isNetIPv6 := gw.netInfo.IPMode() + if gw.netInfo.IsPrimaryNetwork() && gw.netInfo.TopologyType() == types.Layer2Topology && isNetIPv6 && config.IPv6Mode { logicalRouterPort.Ipv6RaConfigs = map[string]string{ "address_mode": "dhcpv6_stateful", "send_periodic": "true", diff --git a/go-controller/pkg/ovn/secondary_layer2_network_controller_test.go b/go-controller/pkg/ovn/secondary_layer2_network_controller_test.go index cd328b5de0..c0d2f66d08 100644 --- a/go-controller/pkg/ovn/secondary_layer2_network_controller_test.go +++ b/go-controller/pkg/ovn/secondary_layer2_network_controller_test.go @@ -15,6 +15,7 @@ import ( nadapi "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + knet "k8s.io/utils/net" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/config" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/nbdb" @@ -64,6 +65,11 @@ var _ = Describe("OVN Multi-Homed pod operations for layer2 network", func() { } } config.Gateway.Mode = gatewayMode + if knet.IsIPv6CIDRString(netInfo.clustersubnets) { + config.IPv6Mode = true + // tests dont support dualstack yet + config.IPv4Mode = false + } app.Action = func(ctx *cli.Context) error { By(fmt.Sprintf("creating a network attachment definition for network: %s", netInfo.netName)) nad, err := newNetworkAttachmentDefinition( @@ -206,6 +212,13 @@ var _ = Describe("OVN Multi-Homed pod operations for layer2 network", func() { icClusterWithDisableSNATTestConfiguration(), config.GatewayModeShared, ), + /** FIXME: tests do not support ipv6 yet + Entry("pod on a IPv6 user defined primary network on an IC cluster with per-pod SNATs enabled", + dummyPrimaryLayer2UserDefinedNetwork("2001:db8:abcd:0012::/64"), + icClusterWithDisableSNATTestConfiguration(), + config.GatewayModeShared, + ), + */ ) DescribeTable( @@ -478,13 +491,16 @@ func expectedLayer2EgressEntities(netInfo util.NetInfo, gwConfig util.L3GatewayC func expectedGWToNetworkSwitchRouterPort(name string, netInfo util.NetInfo, networks ...*net.IPNet) *nbdb.LogicalRouterPort { options := map[string]string{"gateway_mtu": fmt.Sprintf("%d", 1400)} lrp := expectedLogicalRouterPort(name, netInfo, options, networks...) - lrp.Ipv6RaConfigs = map[string]string{ - "address_mode": "dhcpv6_stateful", - "mtu": "1400", - "send_periodic": "true", - "max_interval": "900", - "min_interval": "300", - "router_preference": "LOW", + + if config.IPv6Mode { + lrp.Ipv6RaConfigs = map[string]string{ + "address_mode": "dhcpv6_stateful", + "mtu": "1400", + "send_periodic": "true", + "max_interval": "900", + "min_interval": "300", + "router_preference": "LOW", + } } return lrp } diff --git a/go-controller/pkg/ovn/secondary_layer3_network_controller_test.go b/go-controller/pkg/ovn/secondary_layer3_network_controller_test.go index 49aa22d396..f658326a38 100644 --- a/go-controller/pkg/ovn/secondary_layer3_network_controller_test.go +++ b/go-controller/pkg/ovn/secondary_layer3_network_controller_test.go @@ -16,6 +16,7 @@ import ( v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + knet "k8s.io/utils/net" "k8s.io/utils/ptr" nadapi "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1" @@ -97,6 +98,11 @@ var _ = Describe("OVN Multi-Homed pod operations", func() { } } config.Gateway.Mode = gwMode + if knet.IsIPv6CIDRString(netInfo.clustersubnets) { + config.IPv6Mode = true + // tests dont support dualstack yet + config.IPv4Mode = false + } app.Action = func(ctx *cli.Context) error { nad, err := newNetworkAttachmentDefinition( ns,