Hi all, I am continuing debugging the ipv6 guestfwd feature, and I would like to understand the behavior of slirp better.
Progress I've made: Let QEMU take parameter like following: guestfwd=tcp:[fec0::105]:54322-tcp:[::1]:6655 For slirp side, I basically searched for the appearance of gfwd_list and made all code traverse the fwd list compatible with ipv6. With these change, now I can see the packets coming out of the guest OS to the assigned guest server port via tcpdump: ``` 00:38:18.831831 IP6 fdb5:481:10ce:0:8c41:aaff:fea9:f674.52190 > fec0::105.54322: tcp 0 0x0000: 600a 1f94 0028 0640 fdb5 0481 10ce 0000 `....(.@........ 0x0010: 8c41 aaff fea9 f674 fec0 0000 0000 0000 .A.....t........ 0x0020: 0000 0000 0000 0105 cbde d432 df6d 8332 ...........2.m.2 0x0030: 0000 0000 a0*02* fd20 535f 0000 0204 05a0 ........S_...... 0x0040: 0402 080a b87b fd3b 0000 0000 0103 0307 .....{.;........ ``` 02 == SYN so it looks good. But both tcpdump and wireshark (looking into packet dump provided by QEMU invocation) didn't see any response and this packet never reached the host. I added multiple prints inside slirp and confirmed the ipv6 version of [1] was reached. in tcp_output function [2], I got following print: qemu-system-aarch64: info: Slirp: AF_INET6 out dst ip = fdb5:481:10ce:0:8c41:aaff:fea9:f674, port = 52190 qemu-system-aarch64: info: Slirp: AF_INET6 out src ip = fec0::105, port = 54322 It looks like there should be something being sent back to the guest, unless my understanding of tcp_output is wrong. To understand the datapath of guestfwd better, I have the following questions: 1. What's the meaning of tcp_input and tcp_output? My guess is the following graph, but I would like to confirm. tcp_input tcp_output QEMU --------> slirp ----------> host <-------- <---------- tcp_output tcp_input 2. I don't see port 6655 in the above process. How does slirp know 6655 is the port that needs to be visited on the host side? Thanks in advance, Felix [1]. https://gitlab.freedesktop.org/slirp/libslirp/-/blob/master/src/tcp_input.c#L630 [2]. https://gitlab.freedesktop.org/slirp/libslirp/-/blob/master/src/tcp_output.c#L477 On Mon, Jun 26, 2023 at 3:08 AM Samuel Thibault <samuel.thiba...@gnu.org> wrote: > Hello, > > Felix Wu <f...@google.com> wrote: > > 2. I want to understand what ip I should use. Currently I have following > > formats for the QEMU invocation in ipv6: > > ``` > > guestfwd=tcp:[::1]:1234-tcp:[my:host:ip:from:ifconfig]:22 > > ``` > > I know the general form is `guestfwd=tcp:server:port-dev`, where > > server:port is for guest, > > Yes, the address to be used within the guest network. So it needs to be > within the guest network. > > > Is the aforementioned invocation correct? > > No, because ::1 isn't in the guest network. > > > Or in this case [::1] is the local host address and I should put qemu > > address for it instead? > > You can use whatever IP you want, as long as it's in the guest network. > e.g. [fec0::1234] if you're with the default fec0::/64 network. > > > 3. Is there a default ipv6 address for QEMU instance? I think I need it > in > > the invocation. > > By default it's address 2 within the prefix, i.e. fec0::2 with the > default fec0::/64 network. > > Samuel >