Skip to content

Commit

Permalink
Only configure IPv6 RAs when ipv6 mode enabled
Browse files Browse the repository at this point in the history
Without this fix, ovn-controller would spam:
2024-10-28T16:58:44.283Z|04438|pinctrl|WARN|Invalid IPv6 prefixes:

Signed-off-by: Tim Rozet <trozet@redhat.com>
  • Loading branch information
trozet committed Oct 29, 2024
1 parent 0bbcaea commit 7ce7e3c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
3 changes: 2 additions & 1 deletion go-controller/pkg/ovn/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
30 changes: 23 additions & 7 deletions go-controller/pkg/ovn/secondary_layer2_network_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 7ce7e3c

Please sign in to comment.