Skip the default route when an interface has no gateway - #831
Open
adityasingh2400 wants to merge 1 commit into
Open
Skip the default route when an interface has no gateway#831adityasingh2400 wants to merge 1 commit into
adityasingh2400 wants to merge 1 commit into
Conversation
The Interface protocol documents ipv4Gateway and ipv6Gateway as the address for the default route, or nil for no default route. setupInterface logged the nil-gateway case and then called routeAddDefault anyway, so the guest received an on-link default route that made every external destination look directly reachable on the link. Return early instead when both gateways are nil, and cover the routing decisions with a recording VirtualMachineAgent test double so the v4-only, v6-only, and no-gateway cases are all asserted.
Contributor
Author
|
One thing worth flagging for review: Happy to move the check into the guest instead, or to gate it behind an explicit opt-in on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
Interfaceprotocol documentsipv4Gatewayandipv6Gatewayas the address for the default route, or nil for no default route, butsetupInterfacelogged the nil-gateway case and then calledrouteAddDefaultanyway. The guest ended up withdefault dev eth0 scope link, so route lookup treated arbitrary external destinations as directly reachable on the link and started neighbor resolution for them. This also left callers with no way to build a first interface that has no default route.This returns early when both gateways are nil and leaves every other path untouched, so a v4-only gateway, a v6-only gateway, or a gateway outside the subnet all still install the same routes as before.
The new tests drive
setupInterfacethrough a recordingVirtualMachineAgentdouble, which covers the routing decisions without booting a sandbox.noDefaultRouteWhenBothGatewaysAreNilfails on main and passes here, anddefaultRouteInstalledForIPv6OnlyGatewaypins the v6-only behavior that the existing integration testtestIPv6OnlyDefaultRouteexercises against a real VM.Fixes #825