Reject invalid static-route nexthops#760
Open
MorganaFuture wants to merge 1 commit into
Open
Conversation
Static route requests accepted any nexthop, including 127.0.0.1. Add a RouterIpAddr newtype in rdb that validates an IpAddr as a forwarding address (rejecting unspecified, loopback, multicast, IPv4 broadcast, and IPv4-mapped IPv6; link-local is allowed since the lower half resolves it to an interface) and validate nexthops in the static route add handlers, returning HTTP 400 on failure. RouterIpAddr is modeled on omicron's RouterPeerIpAddr and is a candidate to lift into oxnet for cross-repo reuse. Closes oxidecomputer#738
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
mgdstatic routing API accepted any nexthop, including127.0.0.1(as a property test found). This adds aRouterIpAddrnewtype inrdbthat validates anIpAddras a forwarding address - rejecting the unspecified, loopback, multicast, and IPv4 broadcast addresses and IPv4-mapped IPv6 addresses - and validates nexthops in the static-route add handlers, returning HTTP 400 on a bad one. IPv6 link-local is allowed, since the lower half resolves it to an egress interface.RouterIpAddris modeled on omicron'sRouterPeerIpAddr. Sinceoxnetis an external crate it lives in maghemite for now, but it's structured (serde + schemars) to be lifted intooxnetand shared, as the issue suggests.Tested with unit tests for the newtype and the handler validation; ran the rdb and mgd suites. Didn't exercise it against a live switch.
Closes #738