mirror of
https://github.com/floci-io/floci.git
synced 2026-11-30 17:05:21 -05:00
fix(ec2): write Amazon-provided VPC IPv6 blocks in canonical form (#6692)
CreateVpc and AssociateVpcCidrBlock with AmazonProvidedIpv6CidrBlock built the /56 by concatenating random hex digits, so a group that drew a leading zero kept it: about one block in eight came back as, for example, 2600:1f18:21c4:0200::/56 instead of 2600:1f18:21c4:200::/56, and one in 256 wrote out an all-zero fourth group instead of folding it into the "::". The block now goes through CidrCanonicalizer, which writes RFC 5952 text. VPCs already held in a persistent store keep the text they were created with. The endpoint test that derives /64 subnets from the VPC block now works from the address bytes, because canonical text drops a zero fourth group. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
This commit is contained in:
1 parent
f24cab1622
commit
c6927cca96
3 files changed
+64
-7
No files matched your search
@@ -6599,10 +6599,13 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
|
||||
* Allocates a /56 the way an Amazon-provided association looks on the wire. AWS hands out a
|
||||
* block from its own pool with no say from the caller, so the exact prefix is not something a
|
||||
* client can predict or assert on, what matters is that one is returned at all, that it is a
|
||||
* well-formed /56, and that it comes back unchanged on every later read.
|
||||
* well-formed /56 in canonical text, and that it comes back unchanged on every later read.
|
||||
* A random group can start with a zero digit, which canonical text drops, and an all-zero
|
||||
* fourth group folds into the "::".
|
||||
*/
|
||||
private VpcIpv6CidrBlockAssociation amazonProvidedIpv6Association(String region) {
|
||||
String block = "2600:1f18:" + randomHex(4) + ":" + randomHex(2) + "00::/56";
|
||||
String block = CidrCanonicalizer.canonicalize(
|
||||
"2600:1f18:" + randomHex(4) + ":" + randomHex(2) + "00::/56").orElseThrow();
|
||||
return new VpcIpv6CidrBlockAssociation("vpc-cidr-assoc-" + randomHex(8), block, region);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user