Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add /96 suffix to static addresses for IPv6 external forwarding rules #2183

Merged
merged 1 commit into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pkg/loadbalancers/forwarding_rules_ipv6.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (

const (
IPVersionIPv6 = "IPV6"
prefix96range = "/96"
)

func (l4 *L4) ensureIPv6ForwardingRule(bsLink string, options gce.ILBOptions, existingIPv6FwdRule *composite.ForwardingRule, ipv6AddressToUse string) (*composite.ForwardingRule, error) {
Expand Down Expand Up @@ -210,6 +211,14 @@ func (l4netlb *L4NetLB) buildExpectedIPv6ForwardingRule(bsLink, ipv6AddressToUse
return nil, fmt.Errorf("failed to compute description for forwarding rule %s, err: %w", frName, err)
}

// ipv6AddressToUse will be returned from address manager without /96 prefix.
// for creating external IPv6 forwarding rule, address has to be specified with /96 prefix, or API will return error.
// This applies only to IPv6 External Forwarding rules,
// there is no such requirement for internal IPv6 forwarding rules.
if ipv6AddressToUse != "" && !strings.HasSuffix(ipv6AddressToUse, prefix96range) {
ipv6AddressToUse += prefix96range
}

svcPorts := l4netlb.Service.Spec.Ports
portRange, protocol := utils.MinMaxPortRangeAndProtocol(svcPorts)
fr := &composite.ForwardingRule{
Expand Down
4 changes: 2 additions & 2 deletions pkg/loadbalancers/l4netlbipv6.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ func (l4netlb *L4NetLB) ensureIPv6NodesFirewall(ipAddress string, nodeNames []st
portRanges := utils.GetServicePortRanges(svcPorts)
protocol := utils.GetProtocol(svcPorts)

klog.V(2).Infof("Ensuring IPv6 nodes firewall %s for L4 ILB Service %s/%s, ipAddress: %s, protocol: %s, len(nodeNames): %v, portRanges: %v", firewallName, l4netlb.Service.Namespace, l4netlb.Service.Name, ipAddress, protocol, len(nodeNames), portRanges)
klog.V(2).Infof("Ensuring IPv6 nodes firewall %s for L4 NetLB Service %s/%s, ipAddress: %s, protocol: %s, len(nodeNames): %v, portRanges: %v", firewallName, l4netlb.Service.Namespace, l4netlb.Service.Name, ipAddress, protocol, len(nodeNames), portRanges)
defer func() {
klog.V(2).Infof("Finished ensuring IPv6 nodes firewall %s for L4 ILB Service %s/%s, time taken: %v", l4netlb.Service.Namespace, l4netlb.Service.Name, firewallName, time.Since(start))
klog.V(2).Infof("Finished ensuring IPv6 nodes firewall %s for L4 NetLB Service %s/%s, time taken: %v", l4netlb.Service.Namespace, l4netlb.Service.Name, firewallName, time.Since(start))
}()

// ensure firewalls
Expand Down