-
Notifications
You must be signed in to change notification settings - Fork 292
CP-50108: Use Ipaddr instead of string-based CIDR address handling #5794
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
CP-50108: Use Ipaddr instead of string-based CIDR address handling #5794
Conversation
aea39d5
to
575180b
Compare
Addressed the review comments in a fixup commit - will be squashed before merging |
I recommend doing fixups without signing them off, it will make the DCO check to fail and make it obvious the PR shouldn't be merged before the fixups are gone |
575180b
to
84856c8
Compare
84856c8
to
79130a4
Compare
This CI failure is weird: File "ocaml/xapi/nm.ml", line 623, characters 53-80:
623 | Prefix.address ip_t |> Ipaddr_unix.V6.to_inet_addr
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Unbound module Ipaddr_unix I didn't add this in any of the fixups, and it passed before. Did something in xs-opam change in the meantime? |
79130a4
to
24d418b
Compare
Got it, transitive dependencies were turned off on master, had to add the submodule to dune as well. CI passes now. |
32 - List.fold_left length 0 masks | ||
let raise_on_ipaddr_err = function | ||
| `Msg str -> | ||
raise (Scanf.Scan_failure str) |
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 are no longer using Scanf
for parsing - so I think we should not use this exception (I understand the argument for maintaining previous behaviour). I doubt this exception is handled except at the highest level (might want to grep for it). So with could be a failwith
which also would be turned into an internal error at the outermost level. I am fine to merge this as is, though.
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.
Replaced with a failwith
In nm.ml; helpers.ml. Expands test cases, keeps the existent exception behaviour. Signed-off-by: Andrii Sultanov <andrii.sultanov@cloud.com>
24d418b
to
b23a64a
Compare
Refactored several string-based functions that handled CIDR addresses to use the
Ipaddr
module instead.Expanded test cases, kept the existent exception behaviour.
My first time doing this with modules (in
helpers.ml
) - not sure if it's in the right direction at all, please do correct me. The idea was to model the common interface for v4 and v6 to avoid code duplication in the logic part. The common interface the library itself offers (in the top-levelIpaddr.
) does not have the functionality I would need here. In particular I'm wondering if I'm not exposing this interface into the public unnecessarily and how would I fix that?==
These changes passed the BST+BVT test suites.