-
Notifications
You must be signed in to change notification settings - Fork 9
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
remove dependency on cstruct, use string and bytes instead #279
Conversation
dda7db1
to
a0637e1
Compare
The CI failures for the unikernels are due to the fact that our cirrus jobs use the miragevpn#main opam file for discovering dependencies. |
mirage-router: avoid deprecated function get_ip
@@ -95,9 +92,11 @@ let send_ping ({ ip_config; seq_no; mtu = _; ping = _ } as ifconfig) = | |||
~payload_len:(Cstruct.lenv [ icmpv4_hdr; payload ]) | |||
ipv4_hdr | |||
in | |||
(ifconfig, Cstruct.concat [ ipv4_hdr; icmpv4_hdr; payload ]) | |||
( ifconfig, | |||
Cstruct.to_string (Cstruct.concat [ ipv4_hdr; icmpv4_hdr; payload ]) ) |
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 wonder if it would be faster or better to do String.concat "" (List.map Cstruct.to_string [ ... ])
This may very well be premature optimization in unimportant code.
| `SHA512 -> "SHA512" | ||
| _ -> assert false) |
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.
This is a bit annoying, but I didn't find a nicer way.
@@ -1248,7 +1269,7 @@ let outgoing s data = | |||
|
|||
let ping = | |||
(* constant ping_string in OpenVPN: src/openvpn/ping.c *) | |||
Cstruct.of_hex "2a 18 7b f3 64 1e b4 cb 07 ed 2d 0a 98 1f c7 48" | |||
Ohex.decode "2a 18 7b f3 64 1e b4 cb 07 ed 2d 0a 98 1f c7 48" |
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 can make this a string literal now, but I like this.
let out = Cstruct.append out wkc in | ||
Packet.set_protocol out session.protocol; | ||
let out = out ^ wkc in | ||
Packet.set_protocol (Bytes.unsafe_of_string out) session.protocol; |
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.
Not ideal, but ok
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 let out = out ^ wkc in
line above allocates a new string so it's local to us.
Co-authored-by: Reynir Björnsson <[email protected]>
Co-authored-by: Reynir Björnsson <[email protected]>
Co-authored-by: Reynir Björnsson <[email protected]>
Co-authored-by: Reynir Björnsson <[email protected]>
Co-authored-by: Reynir Björnsson <[email protected]>
Co-authored-by: Reynir Björnsson <[email protected]>
Instead of doing unsafe casts to bytes and then calling Lwt_unix.write.
|
Hm, CI failed due to the unikernels pinning the main branch :/ |
Here are some numbers of iperf3 over openvpn with the server running in a local VM. Before this branch was merged
With this branch merged
Download speed is roughly the same while upload speed is 15% faster and now closer to the download speed. |
re done of #223. compiles and test run fine. I'm sure there are potential optimizations, and we should take a look into what we did in #223 (which I tried and failed to rebase).