Longest prefix match
Sort the route table in descending sort order based on the prefix length. This way finding the route in the route table will result in longest prefix match, as is expected.
Fixes #1769
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.
ℹ️ Googlers: Go here for more info.
@googlebot I fixed it.
I'm having problem understanding why subnet masks which aren't in the canonical form (i.e they don't represent a CIDR prefix) are allowed in the tcpip package. I don't think it makes sense to add routes to such subnets/prefixes to the route table.
My proposition is to require that subnet masks must be in canonical form, and I have added a verification to tcpip.NewSubnet in a separate commit together with updated test cases.
I updated the branch with a new version which doesn't change NewSubnet, but instead validates the routes in SetRouteTable, and AddRoute.
A friendly reminder that this PR had no activity for 120 days.
This PR has been closed due to lack of activity.