Skip to content

Commit

Permalink
Merge pull request mirage#55 from avsm/yomimono-dhcp-without-listen
Browse files Browse the repository at this point in the history
Further tidyups to mirage#53 fix
  • Loading branch information
avsm committed Jun 18, 2014
2 parents 103706d + e4cbd51 commit d333843
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 30 deletions.
5 changes: 5 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
1.1.5 (18-June-2014)
* Ensure that DHCP completes before the application is started, so that
unikernels that establish outgoing connections can do so without a race.
(fix from Mindy Preston in #53, followup in #55)

1.1.4 (03-June-2014):
* [tcp] Fully process the last `ACK` in a 3-way handshake for server connections.
This ensures that a `FIN` is correctly transmitted upon application-initiated
Expand Down
2 changes: 1 addition & 1 deletion _oasis
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
OASISFormat: 0.3
Name: tcpip
Version: 1.1.4
Version: 1.1.5
Synopsis: Ethernet, TCP/IPv4 and DHCPv4 library
Authors: Anil Madhavapeddy, Balraj Singh, Richard Mortier
License: ISC
Expand Down
34 changes: 17 additions & 17 deletions lib/META
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# OASIS_START
# DO NOT EDIT (digest: ad7ce68613bd14bc1d9b5d0283b8fd16)
version = "1.1.4"
# DO NOT EDIT (digest: 915fb48a64872696b047d8ca9ceb5f60)
version = "1.1.5"
description = "Ethernet, TCP/IPv4 and DHCPv4 library"
requires = "io-page mirage-types ipaddr cstruct"
archive(byte) = "tcpip.cma"
Expand All @@ -9,7 +9,7 @@ archive(native) = "tcpip.cmxa"
archive(native, plugin) = "tcpip.cmxs"
exists_if = "tcpip.cma"
package "udpv4-unix" (
version = "1.1.4"
version = "1.1.5"
description = "Ethernet, TCP/IPv4 and DHCPv4 library"
requires =
"tcpip.udpv4 tcpip.ipv4-unix lwt lwt.unix ipaddr.unix cstruct.lwt io-page.unix"
Expand All @@ -21,7 +21,7 @@ package "udpv4-unix" (
)

package "udpv4-socket" (
version = "1.1.4"
version = "1.1.5"
description = "Ethernet, TCP/IPv4 and DHCPv4 library"
requires = "tcpip.udpv4 lwt lwt.unix ipaddr.unix cstruct.lwt io-page.unix"
archive(byte) = "udpv4-socket.cma"
Expand All @@ -32,7 +32,7 @@ package "udpv4-socket" (
)

package "udpv4" (
version = "1.1.4"
version = "1.1.5"
description = "Ethernet, TCP/IPv4 and DHCPv4 library"
requires =
"io-page mirage-types ipaddr cstruct cstruct.syntax lwt.syntax lwt tcpip"
Expand All @@ -44,7 +44,7 @@ package "udpv4" (
)

package "tcpv4-unix" (
version = "1.1.4"
version = "1.1.5"
description = "Ethernet, TCP/IPv4 and DHCPv4 library"
requires =
"tcpip.tcpv4 tcpip.ipv4-unix tcpip.channel lwt lwt.unix mirage-unix mirage-clock-unix ipaddr.unix cstruct.lwt io-page.unix"
Expand All @@ -56,7 +56,7 @@ package "tcpv4-unix" (
)

package "tcpv4-socket" (
version = "1.1.4"
version = "1.1.5"
description = "Ethernet, TCP/IPv4 and DHCPv4 library"
requires = "lwt lwt.unix ipaddr.unix cstruct.lwt io-page.unix"
archive(byte) = "tcpv4-socket.cma"
Expand All @@ -67,7 +67,7 @@ package "tcpv4-socket" (
)

package "tcpv4" (
version = "1.1.4"
version = "1.1.5"
description = "Ethernet, TCP/IPv4 and DHCPv4 library"
requires =
"io-page mirage-types ipaddr cstruct cstruct.syntax lwt.syntax lwt tcpip tcpip.ipv4"
Expand All @@ -79,7 +79,7 @@ package "tcpv4" (
)

package "stack-unix" (
version = "1.1.4"
version = "1.1.5"
description = "Ethernet, TCP/IPv4 and DHCPv4 library"
requires =
"tcpip.udpv4-unix tcpip.tcpv4-unix tcpip.stack-direct lwt lwt.unix ipaddr.unix mirage-unix mirage-clock-unix mirage-console-unix mirage-types.lwt io-page.unix"
Expand All @@ -91,7 +91,7 @@ package "stack-unix" (
)

package "stack-socket" (
version = "1.1.4"
version = "1.1.5"
description = "Ethernet, TCP/IPv4 and DHCPv4 library"
requires =
"tcpip.udpv4-socket tcpip.tcpv4-socket lwt lwt.unix ipaddr.unix io-page.unix"
Expand All @@ -103,7 +103,7 @@ package "stack-socket" (
)

package "stack-direct" (
version = "1.1.4"
version = "1.1.5"
description = "Ethernet, TCP/IPv4 and DHCPv4 library"
requires =
"io-page mirage-types ipaddr cstruct cstruct.syntax lwt.syntax lwt tcpip.ethif tcpip.udpv4 tcpip.tcpv4 tcpip.dhcpv4"
Expand All @@ -115,7 +115,7 @@ package "stack-direct" (
)

package "ipv4-unix" (
version = "1.1.4"
version = "1.1.5"
description = "Ethernet, TCP/IPv4 and DHCPv4 library"
requires = "tcpip.ethif-unix tcpip.ipv4 lwt lwt.unix"
archive(byte) = "ipv4-unix.cma"
Expand All @@ -126,7 +126,7 @@ package "ipv4-unix" (
)

package "ipv4" (
version = "1.1.4"
version = "1.1.5"
description = "Ethernet, TCP/IPv4 and DHCPv4 library"
requires =
"io-page mirage-types ipaddr cstruct cstruct.syntax lwt.syntax lwt tcpip"
Expand All @@ -138,7 +138,7 @@ package "ipv4" (
)

package "ethif-unix" (
version = "1.1.4"
version = "1.1.5"
description = "Ethernet, TCP/IPv4 and DHCPv4 library"
requires = "tcpip.ethif mirage-net-unix lwt lwt.unix"
archive(byte) = "ethif-unix.cma"
Expand All @@ -149,7 +149,7 @@ package "ethif-unix" (
)

package "ethif" (
version = "1.1.4"
version = "1.1.5"
description = "Ethernet, TCP/IPv4 and DHCPv4 library"
requires =
"tcpip io-page mirage-types ipaddr cstruct cstruct.syntax lwt.syntax lwt"
Expand All @@ -161,7 +161,7 @@ package "ethif" (
)

package "dhcpv4" (
version = "1.1.4"
version = "1.1.5"
description = "Ethernet, TCP/IPv4 and DHCPv4 library"
requires =
"io-page mirage-types ipaddr cstruct cstruct.syntax lwt.syntax lwt tcpip.udpv4"
Expand All @@ -173,7 +173,7 @@ package "dhcpv4" (
)

package "channel" (
version = "1.1.4"
version = "1.1.5"
description = "Ethernet, TCP/IPv4 and DHCPv4 library"
requires = "io-page mirage-types ipaddr cstruct lwt.syntax lwt"
archive(byte) = "channel.cma"
Expand Down
27 changes: 19 additions & 8 deletions lib/tcpip_stack_direct.ml
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,11 @@ module Make
let configure t config =
match config with
| `DHCP -> begin
(* TODO: spawn a background thread to reconfigure the interface
when future offers are received. *)
let dhcp, offers = Dhcp.create t.c t.ipv4 t.udpv4 in
listen_udpv4 t 68 (Dhcp.input dhcp);
(* TODO: stop listening to this port when done with DHCP. *)
Lwt_stream.get offers
>>= function
| None -> fail (Failure "No DHCP offer received")
Expand All @@ -109,7 +112,7 @@ module Make
with Not_found -> None

let listen t =
let t1 = Netif.listen t.netif (
Netif.listen t.netif (
Ethif.input
~ipv4:(
Ipv4.input
Expand All @@ -120,12 +123,6 @@ module Make
~default:(fun ~proto ~src ~dst buf -> return ())
t.ipv4)
~ipv6:(fun b -> Console.log_s t.c ("Dropping ipv6")) t.ethif)
in
let t2 =
Console.log_s t.c "Manager: configuring"
>>= fun () ->
configure t t.mode
in t1 <&> t2

let connect id =
let {V1_LWT.console = c; interface = netif; mode; name } = id in
Expand All @@ -149,8 +146,22 @@ module Make
let tcpv4_listeners = Hashtbl.create 7 in
let t = { id; c; mode; netif; ethif; ipv4; tcpv4; udpv4;
udpv4_listeners; tcpv4_listeners } in
Console.log_s t.c "Manager: configuring"
>>= fun () ->
let _ = listen t in
configure t t.mode
>>= fun () ->
(* TODO: this is fine for now, because the DHCP state machine isn't fully
implemented and its thread will terminate after one successful lease
transaction. For a DHCP thread that runs forever, `configure` will need
to spawn a background thread, but we need to consider how to inform the
application stack that the IP address has changed (perhaps via a control
Lwt_stream that the application can ignore if it doesn't care). *)
Console.log_s t.c "Manager: configuration done"
>>= fun () ->
return (`Ok t)

let disconnect t =
return ()
(* TODO: kill the listening thread *)
Console.log_s t.c "Manager: disconnect"
end
9 changes: 5 additions & 4 deletions setup.ml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(* setup.ml generated for the first time by OASIS v0.4.4 *)

(* OASIS_START *)
(* DO NOT EDIT (digest: b66a7a96f0a247c441492dedb1d808fa) *)
(* DO NOT EDIT (digest: 9a43bdb68f572d76b1e9c848b19d69dd) *)
(*
Regenerated by OASIS v0.4.4
Visit http://oasis.forge.ocamlcore.org for more information and
Expand Down Expand Up @@ -6638,7 +6638,7 @@ let setup_t =
alpha_features = [];
beta_features = [];
name = "tcpip";
version = "1.1.4";
version = "1.1.5";
license =
OASISLicense.DEP5License
(OASISLicense.DEP5Unit
Expand Down Expand Up @@ -7341,14 +7341,15 @@ let setup_t =
};
oasis_fn = Some "_oasis";
oasis_version = "0.4.4";
oasis_digest = Some "ëè\152\159\t\003-ãý©ÑÓÎdÀÜ";
oasis_digest =
Some "\159\179\"\025\151\254<\208\193\014\147|\239\201\162\228";
oasis_exec = None;
oasis_setup_args = [];
setup_update = false
};;

let setup () = BaseSetup.setup setup_t;;

# 7353 "setup.ml"
# 7354 "setup.ml"
(* OASIS_STOP *)
let () = setup ();;

0 comments on commit d333843

Please sign in to comment.