Skip to content
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

use mirage-crypto-rng directly, no need for mirage-random-test #514

Merged
merged 2 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tcpip.opam
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ depends: [
"cstruct-lwt"
"mirage-net" {>= "3.0.0"}
"mirage-clock" {>= "3.0.0"}
"mirage-random" {>= "2.0.0"}
"mirage-random" {>= "2.0.0" & < "4.0.0"}
"mirage-time" {>= "2.0.0"}
"ipaddr" {>= "5.0.0"}
"macaddr" {>="4.0.0"}
Expand All @@ -48,7 +48,7 @@ depends: [
"alcotest" {with-test & >="1.5.0"}
"pcap-format" {with-test}
"mirage-clock-unix" {with-test & >= "3.0.0"}
"mirage-random-test" {with-test & >= "0.1.0"}
"mirage-crypto-rng" {with-test & >= "0.11.0"}
"ipaddr-cstruct"
"macaddr-cstruct"
"lru" {>= "0.3.0"}
Expand Down
2 changes: 1 addition & 1 deletion test/dune
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(test
(name test)
(libraries alcotest mirage-random-test lwt.unix logs logs.fmt
(libraries alcotest mirage-crypto-rng mirage-crypto-rng.unix lwt.unix logs logs.fmt
mirage-flow mirage-vnetif mirage-clock-unix pcap-format duration
mirage-random arp arp.mirage ethernet tcpip.ipv4 tcpip.tcp tcpip.udp
tcpip.stack-direct tcpip.icmpv4 tcpip.udpv4v6-socket tcpip.tcpv4v6-socket
Expand Down
2 changes: 1 addition & 1 deletion test/low_level.ml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module Time = Vnetif_common.Time
module V = Vnetif.Make(Vnetif_backends.Basic)
module E = Ethernet.Make(V)
module A = Arp.Make(E)(Time)
module I = Static_ipv4.Make(Mirage_random_test)(Vnetif_common.Clock)(E)(A)
module I = Static_ipv4.Make(Mirage_crypto_rng)(Vnetif_common.Clock)(E)(A)
module Wire = Tcp.Wire
module WIRE = Wire.Make(I)
module Tcp_wire = Tcp.Tcp_wire
Expand Down
3 changes: 1 addition & 2 deletions test/test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ let run test () =

let () =
Printexc.record_backtrace true;
(* someone has to call Mirage_random_test.initialize () *)
Mirage_random_test.initialize ();
Mirage_crypto_rng_unix.initialize (module Mirage_crypto_rng.Fortuna);
(* enable logging to stdout for all modules *)
Logs.set_reporter (Logs_fmt.reporter ());
Logs.set_level ~all:true (Some Logs.Debug);
Expand Down
4 changes: 2 additions & 2 deletions test/test_deadlock.ml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Client_log = (val Logs.src_log client_log : Logs.LOG)

module TCPIP =
struct
module RANDOM = Mirage_random_test
module RANDOM = Mirage_crypto_rng

module TIME =
struct
Expand Down Expand Up @@ -80,7 +80,7 @@ let test_digest netif1 netif2 =
TCPIP.make `Server netif2 >>= fun server_stack ->

let send_data () =
let data = Mirage_random_test.generate 100_000_000 |> Cstruct.to_string in
let data = Mirage_crypto_rng.generate 100_000_000 |> Cstruct.to_string in
let t0 = Unix.gettimeofday () in
TCPIP.TCP.create_connection
TCPIP.(tcp @@ tcpip server_stack) (Ipaddr.V4 TCPIP.client_ip, port) >>= function
Expand Down
4 changes: 2 additions & 2 deletions test/test_icmpv4.ml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ type decomposed = {
ethernet_header : Ethernet.Packet.t;
}

module Ip = Static_ipv4.Make(Mirage_random_test)(Mclock)(E)(Static_arp)
module Ip = Static_ipv4.Make(Mirage_crypto_rng)(Mclock)(E)(Static_arp)
module Icmp = Icmpv4.Make(Ip)

module Udp = Udp.Make(Ip)(Mirage_random_test)
module Udp = Udp.Make(Ip)(Mirage_crypto_rng)

type stack = {
backend : B.t;
Expand Down
4 changes: 2 additions & 2 deletions test/test_ipv6.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ module B = Vnetif_backends.Basic
module V = Vnetif.Make(B)
module E = Ethernet.Make(V)

module Ipv6 = Ipv6.Make(V)(E)(Mirage_random_test)(Time)(Mclock)
module Udp = Udp.Make(Ipv6)(Mirage_random_test)
module Ipv6 = Ipv6.Make(V)(E)(Mirage_crypto_rng)(Time)(Mclock)
module Udp = Udp.Make(Ipv6)(Mirage_crypto_rng)
open Lwt.Infix

let ip =
Expand Down
4 changes: 2 additions & 2 deletions test/test_udp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ module B = Basic_backend.Make
module V = Vnetif.Make(B)
module E = Ethernet.Make(V)
module Static_arp = Static_arp.Make(E)(Time)
module Ip = Static_ipv4.Make(Mirage_random_test)(Mclock)(E)(Static_arp)
module Udp = Udp.Make(Ip)(Mirage_random_test)
module Ip = Static_ipv4.Make(Mirage_crypto_rng)(Mclock)(E)(Static_arp)
module Udp = Udp.Make(Ip)(Mirage_crypto_rng)

type stack = {
backend : B.t;
Expand Down
13 changes: 4 additions & 9 deletions test/vnetif_backends.ml
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,8 @@ module Uniform_packet_loss : Backend = struct

let write t id ~size fill =
if Random.float 1.0 < drop_p then
begin
MProf.Trace.label "pkt_drop";
Lwt.return (Ok ()) (* drop packet *)
end else
Lwt.return (Ok ()) (* drop packet *)
else
X.write t id ~size fill (* pass to real write *)

let create () =
Expand All @@ -125,10 +123,8 @@ module Uniform_no_payload_packet_loss : Backend = struct

let write t id ~size fill =
if size <= no_payload_len && Random.float 1.0 < drop_p then
begin
MProf.Trace.label "pkt_drop";
Lwt.return (Ok ()) (* drop packet *)
end else
Lwt.return (Ok ()) (* drop packet *)
else
X.write t id ~size fill (* pass to real write *)

let create () =
Expand Down Expand Up @@ -216,7 +212,6 @@ module On_off_switch = struct
if not !send_packets then
begin
Logs.info (fun f -> f "write dropping 1 packet");
MProf.Trace.label "pkt_drop";
Lwt.return (Ok ()) (* drop packet *)
end else
X.write t id ~size fill (* pass to real write *)
Expand Down
10 changes: 5 additions & 5 deletions test/vnetif_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ end
module E = Ethernet.Make(V)

module A = Arp.Make(E)(Time)
module Ip4 = Static_ipv4.Make(Mirage_random_test)(Clock)(E)(A)
module Ip4 = Static_ipv4.Make(Mirage_crypto_rng)(Clock)(E)(A)
module Icmp4 = Icmpv4.Make(Ip4)
module Ip6 = Ipv6.Make(V)(E)(Mirage_random_test)(Time)(Clock)
module Ip6 = Ipv6.Make(V)(E)(Mirage_crypto_rng)(Time)(Clock)
module Ip46 = Tcpip_stack_direct.IPV4V6(Ip4)(Ip6)
module U = Udp.Make(Ip46)(Mirage_random_test)
module T = Tcp.Flow.Make(Ip46)(Time)(Clock)(Mirage_random_test)
module U = Udp.Make(Ip46)(Mirage_crypto_rng)
module T = Tcp.Flow.Make(Ip46)(Time)(Clock)(Mirage_crypto_rng)

module Stack =
Tcpip_stack_direct.MakeV4V6(Time)(Mirage_random_test)(V)(E)(A)(Ip46)(Icmp4)(U)(T)
Tcpip_stack_direct.MakeV4V6(Time)(Mirage_crypto_rng)(V)(E)(A)(Ip46)(Icmp4)(U)(T)

let create_backend () =
B.create ()
Expand Down
Loading