From a7017961b64e6a4c381141e654220235fd1910cf Mon Sep 17 00:00:00 2001 From: Manuel Buil Date: Fri, 21 Jul 2023 18:54:25 +0200 Subject: [PATCH] Add ipv6-only support for extension backend Signed-off-by: Manuel Buil --- pkg/backend/extension/extension.go | 9 ++++++++- pkg/subnet/kube/kube.go | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/backend/extension/extension.go b/pkg/backend/extension/extension.go index 6804c5dbb8..111a04b5f5 100644 --- a/pkg/backend/extension/extension.go +++ b/pkg/backend/extension/extension.go @@ -97,11 +97,18 @@ func (be *ExtensionBackend) RegisterNetwork(ctx context.Context, wg *sync.WaitGr } attrs := lease.LeaseAttrs{ - PublicIP: ip.FromIP(be.extIface.ExtAddr), BackendType: "extension", BackendData: data, } + if be.extIface.IfaceAddr != nil { + attrs.PublicIP = ip.FromIP(be.extIface.IfaceAddr) + } + + if be.extIface.IfaceV6Addr != nil { + attrs.PublicIPv6 = ip.FromIP6(be.extIface.IfaceV6Addr) + } + lease, err := be.sm.AcquireLease(ctx, &attrs) switch err { case nil: diff --git a/pkg/subnet/kube/kube.go b/pkg/subnet/kube/kube.go index e31f60b50b..4d8dad2374 100644 --- a/pkg/subnet/kube/kube.go +++ b/pkg/subnet/kube/kube.go @@ -393,7 +393,10 @@ func (ksm *kubeSubnetManager) AcquireLease(ctx context.Context, attrs *lease.Lea } } - if (attrs.BackendType == "vxlan" && string(v6Bd) != "null") || (attrs.BackendType == "wireguard" && string(v6Bd) != "null" && attrs.PublicIPv6 != nil) || (attrs.BackendType == "host-gw" && attrs.PublicIPv6 != nil) { + if (attrs.BackendType == "vxlan" && string(v6Bd) != "null") || + (attrs.BackendType == "wireguard" && string(v6Bd) != "null" && attrs.PublicIPv6 != nil) || + (attrs.BackendType == "host-gw" && attrs.PublicIPv6 != nil) || + (attrs.BackendType == "extension" && attrs.PublicIPv6 != nil) { n.Annotations[ksm.annotations.BackendV6Data] = string(v6Bd) if n.Annotations[ksm.annotations.BackendPublicIPv6Overwrite] != "" { if n.Annotations[ksm.annotations.BackendPublicIPv6] != n.Annotations[ksm.annotations.BackendPublicIPv6Overwrite] {