Skip to content

Commit

Permalink
nits
Browse files Browse the repository at this point in the history
  • Loading branch information
hannesm committed Nov 27, 2020
1 parent 8666c83 commit 7e45588
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/ipv4/static_ipv4.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/ipv6/ipv6.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/stack-direct/tcpip_stack_direct.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/stack-unix/ipv4_socket.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/stack-unix/ipv4v6_socket.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/stack-unix/ipv6_socket.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/tcp/flow.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
7 changes: 2 additions & 5 deletions tcpip.opam
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand All @@ -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"}
]
Expand All @@ -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" ]
]
2 changes: 1 addition & 1 deletion test/dune
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7e45588

Please sign in to comment.