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

[MirageOS-devel] More troubles with tcp on ARM



My attempts to get tcp working in a VM on ARM continue.

Now I've dropped cohttp and moved down to straight tcp/udp instead.
The following is the code of a simple server:

~~~
open V1_LWT
open Lwt
open Printf

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

    module T = S.TCPV4

    let rec tcp_echo console flow =
        T.read flow
        >>= function
            | `Eof -> T.close flow
            | `Error _ -> T.close flow
            | `Ok b -> C.log_s console (sprintf " %d - %s" (Cstruct.len b) 
(Cstruct.to_string b))
                >>= fun () -> T.write flow b
                >>= function
                    | `Eof -> T.close flow
                    | `Error _ -> T.close flow
                    | `Ok () -> tcp_echo console flow

    let start console stack =
        S.listen_udpv4 stack 18081 (
            fun ~src ~dst ~src_port b ->
                C.log_s console (sprintf "udp: %s:%d" (Ipaddr.V4.to_string src) 
src_port)
                >>= fun () -> C.log_s console (sprintf " udp: %d - %s" 
(Cstruct.len b) (Cstruct.to_string b))
        );

        S.listen_tcpv4 stack 18080 (
            fun flow ->
                let dst, dst_port = T.get_dest flow in
                C.log_s console (sprintf "tcp: %s:%d" (Ipaddr.V4.to_string dst) 
dst_port)
                >>= fun () -> tcp_echo console flow
        );

        S.listen stack
end
~~~

It works fine in Unix mode, both on x86 and on my cubietruck board.
When built in Xen mode though it doesn't work as well.

When run in Unix mode I see the expected behaviour:

  shell                                         my server console
  -----                                         -----------------
  % echo hello | ncat -4 -u localhost 18081 ->  udp: 127.0.0.1:46507
                                                 udp: 6 - hello

  % echo hello | ncat -4 localhost 18080    ->  tcp: 127.0.0.1:59888
  hello                                          6 - hello

  % echo foobar | ncat -4 localhost 18080   ->  tcp: 127.0.0.1:59888
  foobar                                         6 - foobar

When running the server in a VM on ARM I see the same behaviour for
UDP, but for TCP it changes.

  shell                                         my server console
  -----                                         -----------------
  % echo hello | ncat -4 -u localhost 18081 ->  udp: 127.0.0.1:46507
                                                 udp: 6 - hello

  % echo hello | ncat -4 localhost 18080    ->  tcp: 127.0.0.1:59888
                                                 6 -
                                                 6 -

Yupp, the string is printed twice, it has a length, but it's missing
actual data!

Any pointers as to where to start looking would be much appreciated,
as well as confirmation that this really is an issue and not just a
user error ;)

/M

-- 
Magnus Therning                      OpenPGP: 0xAB4DFBA4 
email: magnus@xxxxxxxxxxxx   jabber: magnus@xxxxxxxxxxxx
twitter: magthe               http://therning.org/magnus

For a successful technology, reality must take precedence over public
relations, for nature cannot be fooled.
     -- R.P. Feynman

Attachment: pgpL9Ky1RUUnx.pgp
Description: PGP signature

_______________________________________________
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®.