Skip to content

Commit

Permalink
Fix issue mirage#53 by configuring the stack in connect rather than in
Browse files Browse the repository at this point in the history
`listen`.
  • Loading branch information
yomimono committed Jun 17, 2014
1 parent ba751a0 commit 433f706
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lib/tcpip_stack_direct.ml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ module Make
match config with
| `DHCP -> begin
let dhcp, offers = Dhcp.create t.c t.ipv4 t.udpv4 in
listen_udpv4 t 68 (Dhcp.input dhcp);
listen_udpv4 t 68 (Dhcp.input dhcp);
Lwt_stream.get offers
>>= function
| None -> fail (Failure "No DHCP offer received")
Expand All @@ -109,7 +109,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 +120,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,6 +143,14 @@ 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" >>
choose [ listen t;
configure t t.mode ] >> (* 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 not terminate, and the client application will
never run. *)
Console.log_s t.c "Manager: configuration done") >>
return (`Ok t)

let disconnect t =
Expand Down

0 comments on commit 433f706

Please sign in to comment.