From 094cf78f6c927d2143ed5aad97e6efe2bfd4c9a8 Mon Sep 17 00:00:00 2001 From: slonka Date: Tue, 19 Jul 2022 12:00:46 +0200 Subject: [PATCH] fix(cni): check to enable ipv6 flag on transparent proxy engine Signed-off-by: slonka --- app/cni/pkg/cni/injector_linux.go | 8 ++++++++ pkg/transparentproxy/transparentproxy_experimental.go | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/cni/pkg/cni/injector_linux.go b/app/cni/pkg/cni/injector_linux.go index a64d453f79c2..188da9b18d0a 100644 --- a/app/cni/pkg/cni/injector_linux.go +++ b/app/cni/pkg/cni/injector_linux.go @@ -11,6 +11,8 @@ import ( "github.com/kumahq/kuma-net/iptables/builder" "github.com/kumahq/kuma-net/iptables/config" + + "github.com/kumahq/kuma/pkg/transparentproxy" ) func convertToUint16(field string, value string) (uint16, error) { @@ -93,6 +95,12 @@ func mapToConfig(intermediateConfig *IntermediateConfig) (*config.Config, error) if err != nil { return nil, err } + enableIpV6, err := transparentproxy.ShouldEnableIPv6() + if err != nil { + return nil, err + } + cfg.IPv6 = enableIpV6 + inboundPortV6, err := convertToUint16("inbound port ipv6", intermediateConfig.inboundPortV6) if err != nil { return nil, err diff --git a/pkg/transparentproxy/transparentproxy_experimental.go b/pkg/transparentproxy/transparentproxy_experimental.go index cdbf83851502..537b4d6b665a 100644 --- a/pkg/transparentproxy/transparentproxy_experimental.go +++ b/pkg/transparentproxy/transparentproxy_experimental.go @@ -51,7 +51,7 @@ func hasLocalIPv6() (bool, error) { return false, nil } -func shouldEnableIPv6() (bool, error) { +func ShouldEnableIPv6() (bool, error) { hasIPv6Address, err := hasLocalIPv6() if !hasIPv6Address || err != nil { return false, err @@ -124,7 +124,7 @@ func (tp *ExperimentalTransparentProxy) Setup(tpConfig *config.TransparentProxyC } } - ipv6, err := shouldEnableIPv6() + ipv6, err := ShouldEnableIPv6() if err != nil { return "", errors.Wrap(err, "cannot verify if IPv6 should be enabled") }