Skip to content

Conversation

@rbtr
Copy link
Collaborator

@rbtr rbtr commented Oct 18, 2021

Reason for Change:

Prior to this change, we parsed the subnet string into a byte array as [1].[2].[3].[4], then built the gateway address for our netns by dropping [4] and replacing it with .1, as [1].[2].[3].1. This doesn't work for subnets that begin on a non-zero final octect, such as 10.0.0.128/27, which should have a gateway address of 10.0.0.129.

This change updates the relevant code to calculate the gateway address as the first available IP in the provided subnet, fixing these bugs.

Along the way, it also:

  • fixes the log of the response body to print the actual response string instead of the pointer to the body
  • returns an error if the CIDR does not have capacity to calculate a gateway IP (like if it is a /32)

Issue Fixed:

Requirements:

Notes:

@rbtr rbtr changed the title fix: parse subnet cidr and calculate gateway instead of sticking a .1 on the end fix: parse subnet cidr and calculate gateway Oct 18, 2021
@rbtr rbtr force-pushed the fix/gateway-addr branch from 1a52470 to f1da2e8 Compare October 18, 2021 22:33
@rbtr rbtr force-pushed the fix/gateway-addr branch from f1da2e8 to 5d16e9d Compare October 18, 2021 22:49
@rbtr rbtr merged commit 943c1ae into Azure:master Oct 19, 2021
@rbtr rbtr deleted the fix/gateway-addr branch October 19, 2021 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants