Skip to content

Commit bdfaf5a

Browse files
committed
securitygroup: ensure icmpv6 is supported
CAPA handles icmpv6 as a protocol number 58. AWS accepts protocol number when creating rules. However, describing a rule from AWS API returns the protocol name, thus causing CAPA to not recognize it and fail.
1 parent b1e9bd8 commit bdfaf5a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

pkg/cloud/services/securitygroup/securitygroups.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const (
5353
IPProtocolICMP = "icmp"
5454

5555
// IPProtocolICMPv6 is how EC2 represents the ICMPv6 protocol in ingress rules.
56-
IPProtocolICMPv6 = "58"
56+
IPProtocolICMPv6 = "icmpv6"
5757
)
5858

5959
// ReconcileSecurityGroups will reconcile security groups against the Service object.
@@ -921,8 +921,14 @@ func ingressRuleFromSDKProtocol(v types.IpPermission) infrav1.IngressRule {
921921
IPProtocolUDP,
922922
IPProtocolICMP,
923923
IPProtocolICMPv6:
924+
// The API returns IpProtocol values as protocol names.
925+
// But icmpv6 is handled as its protocol number in CAPA.
926+
protocol := *v.IpProtocol
927+
if protocol == IPProtocolICMPv6 {
928+
protocol = string(infrav1.SecurityGroupProtocolICMPv6)
929+
}
924930
return infrav1.IngressRule{
925-
Protocol: infrav1.SecurityGroupProtocol(*v.IpProtocol),
931+
Protocol: infrav1.SecurityGroupProtocol(protocol),
926932
FromPort: utils.ToInt64Value(v.FromPort),
927933
ToPort: utils.ToInt64Value(v.ToPort),
928934
}

0 commit comments

Comments
 (0)