diff --git a/src/ipv4/static_ipv4.ml b/src/ipv4/static_ipv4.ml index 8f7f6a65e..761353b9a 100644 --- a/src/ipv4/static_ipv4.ml +++ b/src/ipv4/static_ipv4.ml @@ -176,6 +176,6 @@ module Make (R: Mirage_random.S) (C: Mirage_clock.MCLOCK) (Ethernet: Mirage_prot let src t ~dst:_ = Ipaddr.V4.Prefix.address t.cidr - let mtu t = Ethernet.mtu t.ethif - Ipv4_wire.sizeof_ipv4 + let mtu t ~dst:_ = Ethernet.mtu t.ethif - Ipv4_wire.sizeof_ipv4 end diff --git a/src/ipv6/ipv6.ml b/src/ipv6/ipv6.ml index 40c16a65e..83292a660 100644 --- a/src/ipv6/ipv6.ml +++ b/src/ipv6/ipv6.ml @@ -61,7 +61,7 @@ module Make (N : Mirage_net.S) in loop (Some u) - let mtu t = E.mtu t.ethif - Ipv6_wire.sizeof_ipv6 + let mtu t ~dst:_ = E.mtu t.ethif - Ipv6_wire.sizeof_ipv6 let write t ?fragment:_ ?ttl:_ ?src dst proto ?(size = 0) headerf bufs = let now = C.elapsed_ns () in diff --git a/src/stack-direct/tcpip_stack_direct.ml b/src/stack-direct/tcpip_stack_direct.ml index dfbc0340c..b7f528942 100644 --- a/src/stack-direct/tcpip_stack_direct.ml +++ b/src/stack-direct/tcpip_stack_direct.ml @@ -376,9 +376,9 @@ module IPV4V6 (Ipv4 : Mirage_protocols.IPV4) (Ipv6 : Mirage_protocols.IPV6) = st List.map (fun ip -> Ipaddr.V4 ip) (Ipv4.get_ip t.ipv4) @ List.map (fun ip -> Ipaddr.V6 ip) (Ipv6.get_ip t.ipv6) - let mtu t = - (* TODO incorrect for IPv4 *) - Ipv6.mtu t.ipv6 + let mtu t ~dst = match dst with + | Ipaddr.V4 dst -> Ipv4.mtu t.ipv4 ~dst + | Ipaddr.V6 dst -> Ipv6.mtu t.ipv6 ~dst end module MakeV4V6 diff --git a/src/stack-unix/ipv4_socket.ml b/src/stack-unix/ipv4_socket.ml index 790a6bccf..ecd2fae70 100644 --- a/src/stack-unix/ipv4_socket.ml +++ b/src/stack-unix/ipv4_socket.ml @@ -22,7 +22,7 @@ type callback = src:ipaddr -> dst:ipaddr -> Cstruct.t -> unit Lwt.t let pp_error = Mirage_protocols.Ip.pp_error let pp_ipaddr = Ipaddr.V4.pp -let mtu _ = 1500 - Ipv4_wire.sizeof_ipv4 +let mtu _ ~dst:_ = 1500 - Ipv4_wire.sizeof_ipv4 let disconnect _ = Lwt.return_unit let connect _ = Lwt.return_unit diff --git a/src/stack-unix/ipv4v6_socket.ml b/src/stack-unix/ipv4v6_socket.ml index f8c49910c..3f31ebbf1 100644 --- a/src/stack-unix/ipv4v6_socket.ml +++ b/src/stack-unix/ipv4v6_socket.ml @@ -22,7 +22,9 @@ type callback = src:ipaddr -> dst:ipaddr -> Cstruct.t -> unit Lwt.t let pp_error = Mirage_protocols.Ip.pp_error let pp_ipaddr = Ipaddr.pp -let mtu _ = 1500 - Ipv6_wire.sizeof_ipv6 +let mtu _ ~dst = match dst with + | Ipaddr.V4 _ -> 1500 - Ipv4_wire.sizeof_ipv4 + | Ipaddr.V6 _ -> 1500 - Ipv6_wire.sizeof_ipv6 let disconnect _ = Lwt.return_unit let connect _ = Lwt.return_unit diff --git a/src/stack-unix/ipv6_socket.ml b/src/stack-unix/ipv6_socket.ml index 9507ec7b6..b9811e82c 100644 --- a/src/stack-unix/ipv6_socket.ml +++ b/src/stack-unix/ipv6_socket.ml @@ -23,7 +23,7 @@ type callback = src:ipaddr -> dst:ipaddr -> Cstruct.t -> unit Lwt.t let pp_error = Mirage_protocols.Ip.pp_error let pp_ipaddr = Ipaddr.V6.pp -let mtu _ = 1500 - Ipv6_wire.sizeof_ipv6 +let mtu _ ~dst:_ = 1500 - Ipv6_wire.sizeof_ipv6 let disconnect () = Lwt.return_unit let connect () = Lwt.return_unit diff --git a/src/tcp/flow.ml b/src/tcp/flow.ml index f74fbe21d..f4a80fc55 100644 --- a/src/tcp/flow.ml +++ b/src/tcp/flow.ml @@ -316,7 +316,7 @@ struct let emitted_keepalive_warning = ref false let new_pcb t params id keepalive = - let mtu_mss = Ip.mtu t.ip - Tcp_wire.sizeof_tcp in + let mtu_mss = Ip.mtu t.ip ~dst:(WIRE.dst id) - Tcp_wire.sizeof_tcp in let { tx_wnd; sequence; options; tx_isn; rx_wnd; rx_wnd_scaleoffer } = params in @@ -413,7 +413,7 @@ struct Hashtbl.add t.listens id (params.tx_isn, (pushf, (pcb, th))); Stats.incr_listen (); (* Queue a SYN ACK for transmission *) - let options = Options.MSS (Ip.mtu t.ip - Tcp_wire.sizeof_tcp) :: opts in + let options = Options.MSS (Ip.mtu t.ip ~dst:(WIRE.dst id) - Tcp_wire.sizeof_tcp) :: opts in TXS.output ~flags:Segment.Syn ~options pcb.txq (Cstruct.create 0) >>= fun () -> Lwt.return (pcb, th) @@ -685,7 +685,7 @@ struct (* TODO: This is hardcoded for now - make it configurable *) let rx_wnd_scaleoffer = wscale_default in let options = - Options.MSS (Ip.mtu t.ip - Tcp_wire.sizeof_tcp) :: Options.Window_size_shift rx_wnd_scaleoffer :: [] + Options.MSS (Ip.mtu t.ip ~dst - Tcp_wire.sizeof_tcp) :: Options.Window_size_shift rx_wnd_scaleoffer :: [] in let window = 5840 in let th, wakener = MProf.Trace.named_task "TCP connect" in diff --git a/tcpip.opam b/tcpip.opam index 8e6814ddc..950fa30fd 100644 --- a/tcpip.opam +++ b/tcpip.opam @@ -29,7 +29,7 @@ depends: [ "mirage-clock" {>= "3.0.0"} "mirage-random" {>= "2.0.0"} "mirage-stack" {>= "2.2.0"} - "mirage-protocols" {>= "4.0.0"} + "mirage-protocols" {>= "5.0.0"} "mirage-time" {>= "2.0.0"} "ipaddr" {>= "5.0.0"} "macaddr" {>="4.0.0"} @@ -48,7 +48,7 @@ depends: [ "pcap-format" {with-test} "mirage-clock-unix" {with-test & >= "3.0.0"} "mirage-random-test" {with-test & >= "0.1.0"} - "arp-mirage" {with-test & >= "2.0.0"} + "arp" {with-test & >= "2.3.0"} "ipaddr-cstruct" {with-test} "lru" {>= "0.3.0"} ] @@ -63,6 +63,3 @@ system](https://mirage.io). It provides implementations for the following module * UDP * TCP """ -pin-depends: [ - [ "mirage-protocols.5.0.0" "git+https://github.com/hannesm/mirage-protocols.git#208f364329a6b3f6026fa361d89db66dbac4e37a" ] -] diff --git a/test/dune b/test/dune index f288e3c75..31b26afac 100644 --- a/test/dune +++ b/test/dune @@ -2,7 +2,7 @@ (name test) (libraries alcotest mirage-random-test lwt.unix logs logs.fmt mirage-profile mirage-flow mirage-vnetif mirage-clock-unix pcap-format duration - mirage-random rresult mirage-protocols mirage-stack arp arp-mirage + mirage-random rresult mirage-protocols mirage-stack arp arp.mirage ethernet tcpip.ipv4 tcpip.tcp tcpip.udp tcpip.stack-direct tcpip.icmpv4 tcpip.udpv4-socket tcpip.tcpv4-socket tcpip.icmpv4-socket tcpip.stack-socket tcpip.ipv6 ipaddr-cstruct macaddr-cstruct tcpip.unix)