Skip to content

Conversation

@patricoferris
Copy link

A few remarks about this PR:

  • A few functor applications are gone \o/ (thanks @hannesm et al. for their work on defunctorising parts of the Mirage stack in favour of dune virtual libraries).
  • The TCP stack is becoming more agnostic to IPV4 and IPV6, this PR needs a little work in terms of renaming modules and variables to reflect those changes.
  • These changes allow VPNkit to be built with OCaml 5+ compilers :) (the original motivation behind the PR).

This PR will depend on updating hvsock (mirage/ocaml-hvsock#69) and ocaml-9p (mirage/ocaml-9p#146).

I was also struggling to build on nixos, but I'll work on that.

Icmpv4_wire.set_icmpv4_id raw id';
Icmpv4_wire.set_icmpv4_csum raw 0;
Icmpv4_wire.set_icmpv4_csum raw (Tcpip_checksum.ones_complement raw);
Cstruct.BE.set_uint16 raw 5 id'; (* TODO: Upstream *)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch, please upstream the missing bindings (from when I removed ppx_cstruct)

(libraries hostnet cmdliner alcotest logs.fmt protocol-9p mirage_dns
mirage-clock-unix charrua-client.mirage forwarder sha
mirage-random-stdlib arp.mirage)
mirage-random-stdlib arp.mirage tcpip.ipv6 mirage-crypto-rng.unix)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the mirage-random-stdlib is to be avoided (deprecated) and shouldn't be needed. Just use Mirage_crypto_rng directly (and Mirage_crypto_rng_unix.use_default ()).

@djs55
Copy link
Collaborator

djs55 commented Jul 4, 2025

I've pushed a few more patches, now the Dockerfile should build with OCaml 5.3 and opam 2.2

@djs55
Copy link
Collaborator

djs55 commented Jul 5, 2025

I'll rebase against master since there are now some integration tests running in CI

patricoferris and others added 6 commits July 5, 2025 12:57
This also allows VPNkit to be build with OCaml 5+

Signed-off-by: Patrick Ferris <[email protected]>
Signed-off-by: Patrick Ferris <[email protected]>
Signed-off-by: Patrick Ferris <[email protected]>
@djs55 djs55 force-pushed the updating-mirage branch from efda439 to eb52bea Compare July 5, 2025 12:17
djs55 added 4 commits July 5, 2025 14:08
In particular io-page-unix needs recent opam

Signed-off-by: David Scott <[email protected]>
There is some unexpected hidden state somewhere which is causing
with_stack called in test case with the same UUID as a previous case,
to discover the same IP binding ("Reconnecting ...") Perhaps the DHCP
server remembers the MAC?

Signed-off-by: David Scott <[email protected]>
@djs55 djs55 force-pushed the updating-mirage branch from a8a30d4 to 57515b0 Compare July 5, 2025 13:09
Signed-off-by: David Scott <[email protected]>
@djs55
Copy link
Collaborator

djs55 commented Jul 5, 2025

ocaml-ci seems unhappy with:

opam@5da5311c6961:/src$ opam exec -- dune build @check
(cd _build/default && /home/opam/.opam/5.3/bin/ocamlc.opt -w @[email protected]@30..39@[email protected]@[email protected]@67@69-40 -strict-sequence -strict-formats -short-paths -keep-locs -warn-error +A-67-69 -g -bin-annot -bin-annot-occurrences -I src/dns_forward_test/.test.eobjs/byte -I /home/opam/.opam/5.3/lib/alcotest -I /home/opam/.opam/5.3/lib/alcotest/engine -I /home/opam/.opam/5.3/lib/alcotest/stdlib_ext -I /home/opam/.opam/5.3/lib/angstrom -I /home/opam/.opam/5.3/lib/astring -I /home/opam/.opam/5.3/lib/base64 -I /home/opam/.opam/5.3/lib/bigarray-compat -I /home/opam/.opam/5.3/lib/bigstringaf -I /home/opam/.opam/5.3/lib/bytes -I /home/opam/.opam/5.3/lib/cmdliner -I /home/opam/.opam/5.3/lib/cstruct -I /home/opam/.opam/5.3/lib/cstruct-lwt -I /home/opam/.opam/5.3/lib/domain-name -I /home/opam/.opam/5.3/lib/duration -I /home/opam/.opam/5.3/lib/fmt -I /home/opam/.opam/5.3/lib/fmt/cli -I /home/opam/.opam/5.3/lib/fmt/tty -I /home/opam/.opam/5.3/lib/io-page -I /home/opam/.opam/5.3/lib/io-page-unix -I /home/opam/.opam/5.3/lib/ipaddr -I /home/opam/.opam/5.3/lib/logs -I /home/opam/.opam/5.3/lib/logs/fmt -I /home/opam/.opam/5.3/lib/lwt -I /home/opam/.opam/5.3/lib/lwt-dllist -I /home/opam/.opam/5.3/lib/lwt/unix -I /home/opam/.opam/5.3/lib/macaddr -I /home/opam/.opam/5.3/lib/mirage-channel -I /home/opam/.opam/5.3/lib/mirage-flow -I /home/opam/.opam/5.3/lib/mirage-flow-combinators -I /home/opam/.opam/5.3/lib/mirage-mtime/unix -I /home/opam/.opam/5.3/lib/mirage-sleep/unix -I /home/opam/.opam/5.3/lib/mtime -I /home/opam/.opam/5.3/lib/mtime/clock -I /home/opam/.opam/5.3/lib/ocaml/threads -I /home/opam/.opam/5.3/lib/ocaml/unix -I /home/opam/.opam/5.3/lib/ocplib-endian -I /home/opam/.opam/5.3/lib/ocplib-endian/bigstring -I /home/opam/.opam/5.3/lib/parsexp -I /home/opam/.opam/5.3/lib/ppx_sexp_conv/runtime-lib -I /home/opam/.opam/5.3/lib/re -I /home/opam/.opam/5.3/lib/re/str -I /home/opam/.opam/5.3/lib/seq -I /home/opam/.opam/5.3/lib/sexplib -I /home/opam/.opam/5.3/lib/sexplib0 -I /home/opam/.opam/5.3/lib/stdlib-shims -I /home/opam/.opam/5.3/lib/stringext -I /home/opam/.opam/5.3/lib/uri -I /home/opam/.opam/5.3/lib/uri/services -I /home/opam/.opam/5.3/lib/uutf -I src/dns/.dns.objs/byte -I src/dns_forward/.dns_forward.objs/byte -I src/dns_forward_lwt_unix/.dns_forward_lwt_unix.objs/byte -no-alias-deps -opaque -open Dune__exe -o src/dns_forward_test/.test.eobjs/byte/dune__exe__Test_fake.cmo -c -impl src/dns_forward_test/test_fake.ml)
File "src/dns_forward_test/test_fake.ml", line 67, characters 6-29:
67 |       Fake_time_state.advance Duration.(of_sec 1);
           ^^^^^^^^^^^^^^^^^^^^^^^
Error: Unbound module Fake_time_state
(cd _build/default && /home/opam/.opam/5.3/bin/ocamlc.opt -w @[email protected]@30..39@[email protected]@[email protected]@67@69-40 -strict-sequence -strict-formats -short-paths -keep-locs -warn-error +A-67-69 -g -bin-annot -bin-annot-occurrences -I src/dns_forward_test/.test_fake.eobjs/byte -I /home/opam/.opam/5.3/lib/alcotest -I /home/opam/.opam/5.3/lib/alcotest/engine -I /home/opam/.opam/5.3/lib/alcotest/stdlib_ext -I /home/opam/.opam/5.3/lib/angstrom -I /home/opam/.opam/5.3/lib/astring -I /home/opam/.opam/5.3/lib/base64 -I /home/opam/.opam/5.3/lib/bigarray-compat -I /home/opam/.opam/5.3/lib/bigstringaf -I /home/opam/.opam/5.3/lib/bytes -I /home/opam/.opam/5.3/lib/cmdliner -I /home/opam/.opam/5.3/lib/cstruct -I /home/opam/.opam/5.3/lib/cstruct-lwt -I /home/opam/.opam/5.3/lib/domain-name -I /home/opam/.opam/5.3/lib/duration -I /home/opam/.opam/5.3/lib/fmt -I /home/opam/.opam/5.3/lib/fmt/cli -I /home/opam/.opam/5.3/lib/fmt/tty -I /home/opam/.opam/5.3/lib/io-page -I /home/opam/.opam/5.3/lib/io-page-unix -I /home/opam/.opam/5.3/lib/ipaddr -I /home/opam/.opam/5.3/lib/logs -I /home/opam/.opam/5.3/lib/logs/fmt -I /home/opam/.opam/5.3/lib/lwt -I /home/opam/.opam/5.3/lib/lwt-dllist -I /home/opam/.opam/5.3/lib/lwt/unix -I /home/opam/.opam/5.3/lib/macaddr -I /home/opam/.opam/5.3/lib/mirage-channel -I /home/opam/.opam/5.3/lib/mirage-flow -I /home/opam/.opam/5.3/lib/mirage-flow-combinators -I /home/opam/.opam/5.3/lib/ocaml/threads -I /home/opam/.opam/5.3/lib/ocaml/unix -I /home/opam/.opam/5.3/lib/ocplib-endian -I /home/opam/.opam/5.3/lib/ocplib-endian/bigstring -I /home/opam/.opam/5.3/lib/parsexp -I /home/opam/.opam/5.3/lib/ppx_sexp_conv/runtime-lib -I /home/opam/.opam/5.3/lib/re -I /home/opam/.opam/5.3/lib/re/str -I /home/opam/.opam/5.3/lib/seq -I /home/opam/.opam/5.3/lib/sexplib -I /home/opam/.opam/5.3/lib/sexplib0 -I /home/opam/.opam/5.3/lib/stdlib-shims -I /home/opam/.opam/5.3/lib/stringext -I /home/opam/.opam/5.3/lib/uri -I /home/opam/.opam/5.3/lib/uri/services -I /home/opam/.opam/5.3/lib/uutf -I src/dns/.dns.objs/byte -I src/dns_forward/.dns_forward.objs/byte -I src/dns_forward_lwt_unix/.dns_forward_lwt_unix.objs/byte -I src/dns_forward_test/fake_sleep/.fake_sleep.objs/byte -I src/dns_forward_test/fake_time/.fake_time.objs/byte -no-alias-deps -opaque -open Dune__exe -o src/dns_forward_test/.test_fake.eobjs/byte/dune__exe__Test.cmo -c -impl src/dns_forward_test/test.ml)
File "src/dns_forward_test/test.ml", line 1:
Error: Could not find the .cmi file for interface
       src/dns_forward_test/test.mli.

@hannesm
Copy link

hannesm commented Jul 5, 2025

Dear @djs55, impressive work. For the mirage-time/fake-time, I don't think dune variants work across packages (they used to, but there was some bad things happening).

But we have a mirage-mtime.mock available (see https://github.com/mirage/mirage-mtime/tree/main/mock), used i. mirage-tcpip tests https://github.com/mirage/mirage-tcpip/tree/main/test/mock-clock

I'm on vacation without my laptop for the next weeks, so please excusive my brevity, and if I'm missing something (hard to grasp big changes on a tiny mobile screen).

src/hostnet/dune Outdated
mirage-vnetif uuidm cohttp-lwt mirage-channel ezjsonm
duration mirage-time mirage-clock
mirage-random tcpip.checksum forwarder cstructs sha)
duration mirage-time
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you can drop mirage-time now here as well.

@hannesm
Copy link

hannesm commented Aug 23, 2025

I couldn't stand this anymore, and prepared patricoferris#1 with more details what is needed. Let me know if this works for you, and the plan to cut the releases resonates with you.

* some minor tweak, reuse the mirage-mtime.mock implementation
* opam: update bounds (requires opam releases being merged)
@hannesm
Copy link

hannesm commented Aug 28, 2025

There are two ocaml-ci errors:

(cd _build/default && /home/opam/.opam/4.14/bin/ocamlc.opt -w @[email protected]@30..39@[email protected]@[email protected]@67@69-40 -strict-sequence -strict-formats -short-paths -keep-locs -warn-error +A-67-69 -g -bin-annot -I src/dns_forward_test/.test.eobjs/byte -I /home/opam/.opam/4.14/lib/alcotest -I /home/opam/.opam/4.14/lib/alcotest/engine -I /home/opam/.opam/4.14/lib/alcotest/stdlib_ext -I /home/opam/.opam/4.14/lib/angstrom -I /home/opam/.opam/4.14/lib/astring -I /home/opam/.opam/4.14/lib/base64 -I /home/opam/.opam/4.14/lib/bigstringaf -I /home/opam/.opam/4.14/lib/bytes -I /home/opam/.opam/4.14/lib/cmdliner -I /home/opam/.opam/4.14/lib/cstruct -I /home/opam/.opam/4.14/lib/cstruct-lwt -I /home/opam/.opam/4.14/lib/domain-name -I /home/opam/.opam/4.14/lib/duration -I /home/opam/.opam/4.14/lib/fmt -I /home/opam/.opam/4.14/lib/fmt/cli -I /home/opam/.opam/4.14/lib/fmt/tty -I /home/opam/.opam/4.14/lib/ipaddr -I /home/opam/.opam/4.14/lib/logs -I /home/opam/.opam/4.14/lib/logs/fmt -I /home/opam/.opam/4.14/lib/lwt -I /home/opam/.opam/4.14/lib/lwt-dllist -I /home/opam/.opam/4.14/lib/lwt/unix -I /home/opam/.opam/4.14/lib/macaddr -I /home/opam/.opam/4.14/lib/mirage-channel -I /home/opam/.opam/4.14/lib/mirage-flow -I /home/opam/.opam/4.14/lib/mirage-flow-combinators -I /home/opam/.opam/4.14/lib/mirage-mtime/unix -I /home/opam/.opam/4.14/lib/mirage-sleep/unix -I /home/opam/.opam/4.14/lib/mtime -I /home/opam/.opam/4.14/lib/mtime/clock -I /home/opam/.opam/4.14/lib/ocaml/threads -I /home/opam/.opam/4.14/lib/ocplib-endian -I /home/opam/.opam/4.14/lib/ocplib-endian/bigstring -I /home/opam/.opam/4.14/lib/parsexp -I /home/opam/.opam/4.14/lib/ppx_sexp_conv/runtime-lib -I /home/opam/.opam/4.14/lib/re -I /home/opam/.opam/4.14/lib/re/str -I /home/opam/.opam/4.14/lib/seq -I /home/opam/.opam/4.14/lib/sexplib -I /home/opam/.opam/4.14/lib/sexplib0 -I /home/opam/.opam/4.14/lib/stdlib-shims -I /home/opam/.opam/4.14/lib/stringext -I /home/opam/.opam/4.14/lib/uri -I /home/opam/.opam/4.14/lib/uri/services -I /home/opam/.opam/4.14/lib/uutf -I src/dns/.dns.objs/byte -I src/dns_forward/.dns_forward.objs/byte -I src/dns_forward_lwt_unix/.dns_forward_lwt_unix.objs/byte -no-alias-deps -opaque -open Dune__exe -o src/dns_forward_test/.test.eobjs/byte/dune__exe__Test_fake.cmo -c -impl src/dns_forward_test/test_fake.ml)
File "src/dns_forward_test/test_fake.ml", line 67, characters 6-31:
67 |       Mirage_mtime_set.tick_for Duration.(of_sec 1);
^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Unbound module Mirage_mtime_set

and

(cd _build/default && /home/opam/.opam/4.14/bin/ocamlc.opt -w @[email protected]@30..39@[email protected]@[email protected]@67@69-40 -strict-sequence -strict-formats -short-paths -keep-locs -warn-error +A-67-69 -g -bin-annot -I src/dns_forward_test/.test_fake.eobjs/byte -I /home/opam/.opam/4.14/lib/alcotest -I /home/opam/.opam/4.14/lib/alcotest/engine -I /home/opam/.opam/4.14/lib/alcotest/stdlib_ext -I /home/opam/.opam/4.14/lib/angstrom -I /home/opam/.opam/4.14/lib/astring -I /home/opam/.opam/4.14/lib/base64 -I /home/opam/.opam/4.14/lib/bigstringaf -I /home/opam/.opam/4.14/lib/bytes -I /home/opam/.opam/4.14/lib/cmdliner -I /home/opam/.opam/4.14/lib/cstruct -I /home/opam/.opam/4.14/lib/cstruct-lwt -I /home/opam/.opam/4.14/lib/domain-name -I /home/opam/.opam/4.14/lib/duration -I /home/opam/.opam/4.14/lib/fmt -I /home/opam/.opam/4.14/lib/fmt/cli -I /home/opam/.opam/4.14/lib/fmt/tty -I /home/opam/.opam/4.14/lib/ipaddr -I /home/opam/.opam/4.14/lib/logs -I /home/opam/.opam/4.14/lib/logs/fmt -I /home/opam/.opam/4.14/lib/lwt -I /home/opam/.opam/4.14/lib/lwt-dllist -I /home/opam/.opam/4.14/lib/lwt/unix -I /home/opam/.opam/4.14/lib/macaddr -I /home/opam/.opam/4.14/lib/mirage-channel -I /home/opam/.opam/4.14/lib/mirage-flow -I /home/opam/.opam/4.14/lib/mirage-flow-combinators -I /home/opam/.opam/4.14/lib/mirage-mtime/mock -I /home/opam/.opam/4.14/lib/mirage-mtime/set -I /home/opam/.opam/4.14/lib/mirage-sleep/unix -I /home/opam/.opam/4.14/lib/ocaml/threads -I /home/opam/.opam/4.14/lib/ocplib-endian -I /home/opam/.opam/4.14/lib/ocplib-endian/bigstring -I /home/opam/.opam/4.14/lib/parsexp -I /home/opam/.opam/4.14/lib/ppx_sexp_conv/runtime-lib -I /home/opam/.opam/4.14/lib/re -I /home/opam/.opam/4.14/lib/re/str -I /home/opam/.opam/4.14/lib/seq -I /home/opam/.opam/4.14/lib/sexplib -I /home/opam/.opam/4.14/lib/sexplib0 -I /home/opam/.opam/4.14/lib/stdlib-shims -I /home/opam/.opam/4.14/lib/stringext -I /home/opam/.opam/4.14/lib/uri -I /home/opam/.opam/4.14/lib/uri/services -I /home/opam/.opam/4.14/lib/uutf -I src/dns/.dns.objs/byte -I src/dns_forward/.dns_forward.objs/byte -I src/dns_forward_lwt_unix/.dns_forward_lwt_unix.objs/byte -no-alias-deps -opaque -open Dune__exe -o src/dns_forward_test/.test_fake.eobjs/byte/dune__exe__Test.cmo -c -impl src/dns_forward_test/test.ml)
File "src/dns_forward_test/test.ml", line 1:
Error: Could not find the .cmi file for interface
src/dns_forward_test/test.mli.

I've no clue why this fails -- the first there's a dependency on mirage-mtime.mock in the dune file, where Mirage_mtime_set is part of; and the second error I don't understand why there's an attempt to find an interface file for test.ml. But I'm sure some build systems / dune person can solve these easily within seconds. It btw works fine on my local clone.

@hannesm
Copy link

hannesm commented Aug 28, 2025

see patricoferris#2 which makes dune build @install @check @runtest work locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants