-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Publish NI routes in a deterministic and easy-to-read order #4298
Publish NI routes in a deterministic and easy-to-read order #4298
Conversation
79ef9bb
to
2ee6e8f
Compare
case generic.IPv4RouteTypename: | ||
ipVer = types.AddressTypeIPV4 | ||
case generic.IPv6RouteTypename: | ||
ipVer = types.AddressTypeIPV6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the Type()
function may also return generic items.UnsupportedRouteTypename
. Shouldn't we add it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will leave the zero value types.AddressTypeNone
in that case which is OK I think.
// first for clarity, followed by other routes ordered by prefix length, | ||
// with more specific routes (longer prefixes) listed before broader ones. | ||
// This is at least how Linux lists the routes of a routing table. | ||
sort.Slice(routes, func(i, j int) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The entire function is a good candidate for a Unit test, if you have time for that)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Working on it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will you add it to this PR? Or we should not wait for it and it comes later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Run Eden tests
76de04f
to
6ed060b
Compare
First IPv4 routes will be listed, then IPv6 routes. Inside the set of routes of the same IP version, default routes appear first for clarity, followed by other routes ordered by prefix length, with more specific routes (longer prefixes) listed before broader ones. This is at least how Linux lists the routes of a routing table. We also want to avoid returning <nil> as destination network for default routes, and instead show destination as 0.0.0.0/0 or ::/0 Signed-off-by: Milan Lenco <[email protected]>
6ed060b
to
4f7635f
Compare
First IPv4 routes will be listed, then IPv6 routes. Inside the set of routes of the same IP version, default routes appear first for clarity, followed by other routes ordered by prefix length, with more specific routes (longer prefixes) listed before broader ones. This is at least how Linux lists the routes of a routing table.
We also want to avoid returning
<nil>
as destination network for default routes, and instead show destination as0.0.0.0/0
or::/0