-
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
Static pre-shared key mode (for client only so far), add a mirage-router unikernel #37
Conversation
this is getting better:
I used the previous version (morally cea472f) for ~48 hours without an issue (on my laptop, connected via wlan and a DSL uplink which is flaky -- it worked throughout disconnects and new IP address very fine), and am now running 1de4cb2 since ~1 hour without issues. I plan to deploy 1de4cb2 on my server. so, feedback (with the above described limitations in mind) would be great on this PR @cfcs :) while working on this, I discovered our |
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.
Looks good to me, left feedback.
Re: Replays: I think we should definitely support out-of-order receiving for UDP. For TCP I'm not so sure, but I could imagine a multi-core implementation might send out-of-order on TCP.
As for how how to do replay detection, Maybe a sliding window of where we keep track of the last n
messages could work?
Here's an (untested) attempt at a space-efficient sliding window algorithm to recognize repeated packet ids. The window size is module Sliding_window : sig
type t
val make : int -> t
val add : int -> t -> (t, string) result
val mem : t -> int -> bool
val pp : Format.formatter -> t -> unit
end = struct
type t = { window: int; counter: int; }
let make counter = { window = 1; counter }
let add n {window; counter} =
if n <= counter then begin
let diff = counter -n in
if diff >= Sys.int_size
then Error "n not in sliding window"
else Ok {window = window lor (1 lsl diff); counter}
end else begin (* counter > n; always succeeds *)
let diff = n - counter in
if diff >= Sys.int_size
then Ok (make n) (* new window *)
else Ok {window = (window lsl diff) lor 1; counter = n}
end
let pp ppf {window;counter} =
Fmt.pf ppf "{ window = %d; counter = %d }" window counter
let mem {window;counter} n =
let diff = counter - n in
if counter < n || diff > Sys.int_size
then false
else 0 <> window land (1 lsl diff)
end |
Co-Authored-By: C For C's Sake <[email protected]>
Co-Authored-By: C For C's Sake <[email protected]>
Co-Authored-By: C For C's Sake <[email protected]>
Co-Authored-By: C For C's Sake <[email protected]>
Co-Authored-By: C For C's Sake <[email protected]>
Co-Authored-By: C For C's Sake <[email protected]>
about the replay protection:
The underlying question is still: how large should the window be? 3? 5? And given the above |
…block_size to not hardcode 16 all over
…e errors: ttl exceeded and don't fragment but fragmentation needed
remaining is implementing the replay protection -- and further testing there's a bit of asymmetry: the anyways, good to be squashed and merged IMHO, the replay protection is important, but can be a separate PR (I feel this is already large enough) |
Minor suggestions, mostly about documentation and API clarity, otherwise looks good to go for me. |
Co-Authored-By: C For C's Sake <[email protected]>
…tes timestamp header is included)
…ge-crypto is in place
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.
LGTM!
this fixes #11
it is atm only the client that is implemented, and only udp mode so far. there's as well some code duplication between
handle_client
andhandle_static_client
(in respect to resolving and connecting state machine) which should be cleaned up before merge. Thecompression
is set totrue
(should be looked up in the config). It may be worth to support OCC (as mentioned in #11), though openvpn seems to deal fine without (ilkely makes a difference if configuration mismatches or for MTU adjustments).I tested with a openvpn server running on my laptop, and a
mirage-client
unikernel running as virtual machine. I can successfully ping (ICMP echo request & reply) from my laptop the unikernel on its openvpn-tunneled IP address. The unikernel replies with ICMP echo reply.