[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MirageOS-devel] TCP client problems



On 28 Feb 2014, at 17:30, Hannes Mehnert <hannes@xxxxxxxxxxx> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA384
> 
> Dear hackers,
> 
> I have a slight problem when trying to open a tcp connection as client
> - - the mirage application is at
> https://github.com/mirleft/ocaml-tls/tree/master/mirage-client (using
> a tap interface on my FreeBSD laptop). The only packet I can see on
> tap0 is
> 17:22:49.859718 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has
> 10.0.0.1 (ff:ff:ff:ff:ff:ff) tell 0.0.0.0, length 28
>        0x0000:  0001 0800 0604 0001 c29d 5619 d72c 0000
>        0x0010:  0000 ffff ffff ffff 0a00 0001
> 
> console output being:
> [17:22 hannes@aterscientia:mirage-client] sudo ./mir-mirage-tls-client
> assembled CLIENT_HELLO into a buf of size 41
> 
> 01 00 00 29 03 01 00 00 00 00 00 00 00 00 00 00
> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> 00 00 00 00 00 00 00 00 02 00 0a 01 00
> plugging into tap0 with mac c2:9d:56:19:d7:2c..
> Netif: connect tap0
> Manager: connect
> connecting to host
> ARP: transmitting probe -> 10.0.0.1

The problem here is that the tap0 bridge probably doesn't have an
IP address configured yet, since you are initiating the connection
immediately as soon as the unikernel starts.  If you add a short
pause at the beginning of start, and then configure tap0 with a
10.0.0.1 IP address, it should work.  I just tried it with this to
a localhost `cohttp-server` and it responded fine with an HTTP
response:

open Lwt
open V1_LWT
open Printf

let red fmt    = sprintf ("\027[31m"^^fmt^^"\027[m")
let green fmt  = sprintf ("\027[32m"^^fmt^^"\027[m")
let yellow fmt = sprintf ("\027[33m"^^fmt^^"\027[m")
let blue fmt   = sprintf ("\027[36m"^^fmt^^"\027[m")

module Main (C:CONSOLE) (S:STACKV4) = struct

  module T  = S.TCPV4

  let start c s =
    OS.Time.sleep 5.0 >>= fun () ->
    let ip = Ipaddr.V4.make 127 0 0 1 in
    C.log_s c (green "connecting to host") >>= fun () ->
    T.create_connection (S.tcpv4 s) (ip, 8080) >>= function
     | `Ok flow ->
        C.log_s c (green "established connection") >>= fun () ->
        let wr = Cstruct.of_string "GET / HTTP/1.1\nHost: localhost\n\n" in
        T.write flow wr >>= fun () ->
        T.read flow >>= begin function
          | `Ok b -> C.log_s c (Cstruct.copyv [b])
          | _ -> C.log_s c "Error"
        end

     | `Error e ->
        C.log_s c (red "received an error while connecting")

end


Let me know if that doesn't work.  It would be nice to tackle bridge
configuration directly within the unikernel config.ml, but it's not
currently supported (and it's a can of worms due to all the possible
network topologies).

-anil

_______________________________________________
MirageOS-devel mailing list
MirageOS-devel@xxxxxxxxxxxxxxxxxxxx
http://lists.xenproject.org/cgi-bin/mailman/listinfo/mirageos-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.