I wonder if someone could help me with a frustrating problem I'm
having with slirp-based networking in UML?  (I've tried asking
on the slirp-devel mailing list, but didn't get any response.)
I'd be very grateful for any help.

Although this has worked for me successfully in the past, I'm
having trouble getting the "redir" option for slirp to work
properly for connecting to a UML instance.  (Network access from
the UML machine to the outside world works fine, it's just the
incoming connections that fail.)

If I run tcpdump on the UML guest it seems that some packets are
directed to the right port, but there are no replies at all.  To
describe the setup in more detail, I'm starting the server with:

  linux mem=256M ubda=uml-rootfs-test umid=TWFY con=null ssl=null 
con0=fd:0,fd:1 con1=xterm eth0=slirp,,./slirp-wrapper

... where ./slirp-wrapper is a script consisting of:

  #!/bin/sh
  exec slirp-fullbolt -S "redir 8042 80" "redir 2242 22" "$@"

This appears to set up the redirections correctly, since I see the
following output (with some whitespace edited for readability):

   [..]
   Setting up networking....
   Configuring network interfaces...
   Slirp v1.0.17 (BETA) FULL_BOLT
   Copyright (c) 1995,1996 Danny Gasparovski and others.
   All rights reserved.
   This program is copyrighted, free software.
   Please read the file COPYRIGHT that came with the Slirp
   package for the terms and conditions of the copyright.
   Logging statistics
   Redirecting TCP port 8042 to 10.0.2.15:80
   Redirecting TCP port 2242 to 10.0.2.15:22
   IP address of Slirp host: 127.0.1.1
   IP address of your DNS(s): 10.101.0.1
   Your address is 10.0.2.15
   (or anything else you want)

   Type five zeroes (0) to exit.

   [autodetect SLIP/CSLIP, MTU 1500, MRU 1500]

   SLiRP Ready ...
   done.
   INIT: Entering runlevel: 2
   Starting enhanced syslogd: rsyslogd.
   [..]

The UML machine's root filesystem has the following
/etc/network/interfaces:

   auto lo
   iface lo inet loopback

   auto eth0
   iface eth0 inet static
     address 10.0.2.15
     netmask 255.0.0.0
     gateway 10.0.2.15

... and resolv.conf consists of:

   nameserver 10.0.2.3

The output of ifconfig and route -n in the UML instance are as
follows:

   sandbox:~# ifconfig
   eth0      Link encap:Serial Line IP
             inet addr:10.0.2.15  Mask:255.0.0.0
             UP RUNNING NOARP  MTU:1500  Metric:1
             RX packets:3 errors:0 dropped:0 overruns:0 frame:0
             TX packets:3 errors:0 dropped:0 overruns:0 carrier:0
             collisions:0 txqueuelen:256
             RX bytes:384 (384.0 B)  TX bytes:159 (159.0 B)
             Interrupt:5

   lo        Link encap:Local Loopback
             inet addr:127.0.0.1  Mask:255.0.0.0
             UP LOOPBACK RUNNING  MTU:16436  Metric:1
             RX packets:0 errors:0 dropped:0 overruns:0 frame:0
             TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
             collisions:0 txqueuelen:0
             RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

   sandbox:~# route -n
   Kernel IP routing table
   Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
   10.0.0.0        0.0.0.0         255.0.0.0       U     0      0        0 eth0
   0.0.0.0         10.0.2.15       0.0.0.0         UG    0      0        0 eth0

The web server running on the UML machine is listening on all
interfaces:

   sandbox:~# netstat -ap|egrep apach
   tcp        0      0 *:www                   *:*                     LISTEN   
   955/apache2

If I set tcpdump running on the UML machine and make a request
from the host to http://localhost:8042/ then the following is
captured:

   sandbox:~# tcpdump -n -vvv
   tcpdump: listening on eth0, link-type RAW (Raw IP), capture size 96 bytes
   16:17:30.869511 IP (tos 0x0, ttl 64, id 17099, offset 0, flags [none], proto 
TCP (6), length 44) 127.0.1.1.52602 > 10.0.2.15.80: S, cksum 0x96b6 (correct), 
157056001:157056001(0) win 8760 <mss 1460>
   16:17:36.827335 IP (tos 0x0, ttl 64, id 17100, offset 0, flags [none], proto 
TCP (6), length 44) 127.0.1.1.52602 > 10.0.2.15.80: S, cksum 0x96b6 (correct), 
157056001:157056001(0) win 8760 <mss 1460>
   16:17:36.827335 IP (tos 0x0, ttl 64, id 17100, offset 0, flags [none], proto 
TCP (6), length 44) 127.0.1.1.52602 > 10.0.2.15.80: S, cksum 0x96b6 (correct), 
157056001:157056001(0) win 8760 <mss 1460>
   16:17:49.091012 IP (tos 0x0, ttl 64, id 17101, offset 0, flags [none], proto 
TCP (6), length 44) 127.0.1.1.52602 > 10.0.2.15.80: S, cksum 0x96b6 (correct), 
157056001:157056001(0) win 8760 <mss 1460>
   16:18:01.354694 IP (tos 0x0, ttl 64, id 17102, offset 0, flags [none], proto 
TCP (6), length 44) 127.0.1.1.52602 > 10.0.2.15.80: S, cksum 0x96b6 (correct), 
157056001:157056001(0) win 8760 <mss 1460>

I'm using the Ubuntu 9.10 packages of user-mode-linux,
uml-utilities and slirp in the following versions:

  slirp            1:1.0.17-2
  uml-utilities    20070815-1.1ubuntu2
  user-mode-linux  2.6.22-2um-0ubuntu2

In the UML instance, the equivalent works:

   sandbox:~# curl 'http://10.0.2.15/'
   <html><body><h1>It works!</h1></body></html>

The uname -a output of the host machine is:

  Linux cava 2.6.31-20-generic #57-Ubuntu SMP Mon Feb 8 09:05:19 UTC 2010 i686 
GNU/Linux

... and similarly for the UML guest:

  Linux sandbox 2.6.22-rc5 #2 Mon Jul 2 10:14:22 GMT 2007 i686 GNU/Linux

The output in slirp_stats after a run when a couple of requests
to http://localhost:8042/ from the host had failed as described
above is:

   Slirp 1.0.17 - Debugging Started.
   Debugging Started level 15.
 
   IP stats:
          9 total packets received (0 were unaligned)
          0 with incorrect version
          0 with bad header checksum
          0 with length too short (len < sizeof(iphdr))
          0 with length too small (len < ip->len)
          0 with bad header length
          0 with bad packet length
          0 fragments received
          0 fragments dropped
          0 fragments timed out
          0 packets reassembled ok
          0 outgoing packets fragmented
          0 total outgoing fragments
          0 with bad protocol field
          9 total packets delivered
 
   TCP stats:
         14 packets sent
                  0 data packets (0 bytes)
                  0 data packets retransmitted (0 bytes)
                  0 ack-only packets (0 delayed)
                  0 URG only packets
                  0 window probe packets
                  0 window update packets
                 14 control (SYN/FIN/RST) packets
                  0 times tcp_output did nothing
          0 packets received
                  0 acks (for 0 bytes)
                  0 duplicate acks
                  0 acks for unsent data
                  0 packets received in sequence (0 bytes)
                  0 completely duplicate packets (0 bytes)
                  0 packets with some duplicate data (0 bytes duped)
                  0 out-of-order packets (0 bytes)
                  0 packets of data after window (0 bytes)
                  0 window probes
                  0 window update packets
                  0 packets received after close
                  0 discarded for bad checksums
                  0 discarded for bad header offset fields
          2 connection requests
          0 connection accepts
          0 connections established (including accepts)
          2 connections closed (including 0 drop)
          2 embryonic connections dropped
          2 segments we tried to get rtt (0 succeeded)
         12 retransmit timeouts
                  0 connections dropped by rxmt timeout
          0 persist timeouts
          2 keepalive timeouts
                  0 keepalive probes sent
                  2 connections dropped by keepalive
          0 correct ACK header predictions
          0 correct data packet header predictions
          0 TCP cache misses
 
   UDP stats:
          8 datagrams received
          0 with packets shorter than header
          0 with bad checksums
          0 with data length larger than packet
          2 UDP socket cache misses
          4 datagrams sent
 
   ICMP stats:
          1 ICMP packets received
          0 were too short
          0 with bad checksums
          1 with type not supported
          0 with bad type feilds
          0 ICMP packets sent in reply
 
   Mbuf stats:
          2 mbufs allocated (2 max)
          1 mbufs on free list
          1 mbufs on used list
          0 mbufs queued as packets

 
   Proto[state]     Sock     Local Address, Port  Remote Address, Port RecvQ 
SendQ
   tcp[REDIRECT]       4         10.0.2.15    22       127.0.1.1  2242     0    
 0
   tcp[REDIRECT]       3         10.0.2.15    80       127.0.1.1  8042     0    
 0
   udp[232 sec]        6        10.0.2.15 32768         10.0.2.3    53     0    
 0
 
   VJ compression stats:
          0 outbound packets (0 compressed)
          0 searches for connection stats (0 misses)
          0 inbound uncompressed packets
          0 inbound compressed packets
          0 inbound unknown type packets
          0 inbound packets tossed due to error

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
User-mode-linux-user mailing list
User-mode-linux-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-user

Reply via email to